-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.js
1 lines (1 loc) · 123 KB
/
bot.js
1
const _0x11db1f=_0xbddb;(function(_0x1557c6,_0x37226d){const _0x323600=_0xbddb,_0x308a6c=_0x1557c6();while(!![]){try{const _0x19c51e=-parseInt(_0x323600(0x2ef))/0x1+-parseInt(_0x323600(0x31f))/0x2*(-parseInt(_0x323600(0x20b))/0x3)+-parseInt(_0x323600(0x34a))/0x4+parseInt(_0x323600(0x2f9))/0x5*(-parseInt(_0x323600(0x26c))/0x6)+-parseInt(_0x323600(0x296))/0x7+-parseInt(_0x323600(0x29f))/0x8*(-parseInt(_0x323600(0x1c3))/0x9)+parseInt(_0x323600(0x1e9))/0xa;if(_0x19c51e===_0x37226d)break;else _0x308a6c['push'](_0x308a6c['shift']());}catch(_0x577a64){_0x308a6c['push'](_0x308a6c['shift']());}}}(_0x75d6,0x94321));const _0x241fd4=function(){let _0x385813=!![];return function(_0x5ae3f4,_0x23c31c){const _0x505b31=_0x385813?function(){const _0x7d85ae=_0xbddb;if(_0x23c31c){const _0x2ba920=_0x23c31c[_0x7d85ae(0x2db)](_0x5ae3f4,arguments);return _0x23c31c=null,_0x2ba920;}}:function(){};return _0x385813=![],_0x505b31;};}(),_0x2ffc52=_0x241fd4(this,function(){const _0x6f8640=_0xbddb;return _0x2ffc52[_0x6f8640(0x361)]()['search'](_0x6f8640(0x2ac))[_0x6f8640(0x361)]()['constructor'](_0x2ffc52)[_0x6f8640(0x1f0)](_0x6f8640(0x2ac));});function _0xbddb(_0x2928f3,_0x4a8e35){const _0x2c39b3=_0x75d6();return _0xbddb=function(_0x2ffc52,_0x241fd4){_0x2ffc52=_0x2ffc52-0x198;let _0x75d6dd=_0x2c39b3[_0x2ffc52];return _0x75d6dd;},_0xbddb(_0x2928f3,_0x4a8e35);}_0x2ffc52();'use strict';const ccxt=require('ccxt'),low=require(_0x11db1f(0x2f0)),FileSync=require(_0x11db1f(0x25e)),fs=require('fs'),fns=require(_0x11db1f(0x234)),forge=require(_0x11db1f(0x364)),util=require(_0x11db1f(0x2aa)),argv=require('yargs/yargs')(process['argv']['slice'](0x2))[_0x11db1f(0x19e)],path=require(_0x11db1f(0x24e)),axios=require('axios');let exchange,gTicker={},gChange={};const usdBasecoins=[_0x11db1f(0x359),_0x11db1f(0x324),'TUSD',_0x11db1f(0x27a),'USDC',_0x11db1f(0x20a)],excludedExchanges=['bitmex'],debugging=argv['d']||![];function _0x75d6(){const _0x58c331=['apiPassword','\x20has\x20a\x2024h\x20drop\x20of\x20','\x20due\x20to\x20offset','timestamp-issue','secret','Order\x20filled','\x0aSymbol(s):\x20','split','22372140MBzBWk','Balance\x20Bot\x20does\x20not\x20support\x20the\x20','\x20API\x20key\x20or\x20API\x20secret\x20invalid\x20-\x20also\x20make\x20sure\x20your\x20machine\x27s\x20IP\x20address\x20is\x20whitelisted\x20for\x20this\x20API\x20key\x20on\x20the\x20exchange','setSandboxMode','detectLiquidityChange()','Portfolio\x20change\x20-\x20performance\x20and\x20starting\x20balance\x20updated','PermissionDenied','search','stack','\x20|\x20exchange:\x20','\x20orders\x20in\x20less\x20than\x20','parse','Unknown\x20error:\x20','findIndex','fetchOpenOrders','\x20closed\x20the\x20connection\x20(see:\x20hodlerhacks.com/fix/5)','Net\x20','<b>','configuration','recreate','.json','password','distribution','create','token\x20is\x20expired','kill',')\x20|\x20exchange:\x20','toLowerCase','<pre>','get','PnL\x20','starting-balance-','\x20-\x20liquidity\x20settings\x20updated\x20accordingly','USDP','1658289ZbcWkF','debug','spot','Bybit','orderstatus','max','slider','\x20blocked\x20API\x20(RateLimitExceeded)\x20-\x20check\x20if\x20API\x20key\x20is\x20enabled\x20for\x20spot\x20trading','***','2\x20-\x20handling\x20FILLED\x20order:\x20','\x20>\x20[DEBUG]\x20','/EUR','2.6.22','pnl-basecoin','Stopping\x20bot\x20-\x20resolve\x20the\x20issue\x20and\x20restart\x20bot\x20(see:\x20hodlerhacks.com/fix/1)','find','Order\x20filled:\x20','getMonth','BTC','storeHeadless','balances','warning','openOrders','initTickers()','getTime','net','testApi','starting-balances','Invalid\x20symbol:\x20','\x20metrics:</b>\x20\x0a\x0a','UNLOCKED','addDays','getHours','test','API-key\x20format\x20invalid','market_cap','\x20-\x20bot\x20already\x20running\x20in\x20manual\x20mode','Network\x20error\x20details:','Ordering\x20not\x20possible\x20while\x20waiting\x20for\x20previous\x20order(s)\x20to\x20be\x20filled','1\x20-\x20partially\x20FILLED\x20(','\x20minutes\x20-\x20starting\x20cooldown\x20period\x20of\x20','date-fns','ordertype','RSA-OAEP','error','sells','Error:\x20Invalid\x20argument\x20','apiSecret','coin','cancelLoading','\x20>\x20details:','order','entries','marketcapsqrt','1\x20-\x20FILLED\x20unknown\x20order:\x20','************','limit-high','net-basecoin','Loading\x20completed','startprice','Invalid\x20API\x20details,\x20please\x20try\x20again\x20-\x20also\x20make\x20sure\x20your\x20machine\x27s\x20IP\x20address\x20is\x20whitelisted\x20for\x20this\x20API\x20key\x20on\x20the\x20exchange','\x20API\x20key\x20is\x20invalid\x20-\x20update\x20the\x20API\x20key\x20in\x20the\x20configuration\x20(see:\x20hodlerhacks.com/fix/1)','symbol','configstate','MIN_NOTIONAL','Insufficient\x20funds\x20to\x20execute\x20order:\x20','getMinutes','path','string','update-liquidity','watchTrades()','\x20|\x20highest\x20fee:\x20','cancelOrder','deleteHistoryAlerts','threshold','pnl','\x20-\x20','watchTrades','initclient','bot-','placeOrder()','length','Limit\x20(high-margin)','lowdb/adapters/FileSync','Exchange','bot','abs','sandbox','pnl-fiat','pop','secure','\x20Permission\x20denied\x20-\x20make\x20sure\x20your\x20exhange\x20API\x20key\x20has\x20the\x20required\x20permissions\x20and\x20your\x20machine\x27s\x20IP\x20address\x20is\x20whitelisted\x20for\x20this\x20API\x20key\x20on\x20the\x20exchange','1\x20-\x20Validate\x20orders:\x20','valid','function','Order\x20is\x20invalid:\x20','initial','67926jyYUiK','bb-secure.json','no\x20open\x20orders','bots',')\x20unknown\x20order:\x20','full','Cryptocom',',\x20must\x20be\x20a\x203\x20digit\x20number','apiKey','average','./logs/','substring','Order(s)\x20not\x20validated\x20after\x20','change24h','USDT','pro','min','Initializing\x20coin\x20results','enabled','\x20-\x20go\x20back\x20and\x20try\x20again','balancing\x20resumed','getDate','/output-000.log','startnumber','UNLOCKING','pki','loadSymbols()','1\x20-\x20Handle\x20open\x20orders','EUR','Test\x20new\x20API','amountToPrecision','restart','Block\x20transaction\x20detection:\x20','AuthenticationError','watchTradesForSymbols()','enableFiatToggle','\x20exchange','Failed\x20to\x20load\x20coin\x20data\x20for\x20','sha256','bid','\x20hour','\x20API\x20key,\x20secret\x20or\x20password\x20invalid\x20-\x20also\x20make\x20sure\x20your\x20machine\x27s\x20IP\x20address\x20is\x20whitelisted\x20for\x20this\x20API\x20key\x20on\x20the\x20exchange','5262544oBuirx','\x20exchange\x20error:\x20','date','<b>Bot\x20','Resuming\x20(','includes','Limit\x20(low-margin)','OrderNotFound','Set\x20lock\x20orders\x20to:\x20','2028560KvlJWY','Unfilled\x20order(s)\x20canceled\x20after\x20','map','-performance.json','ExchangeNotAvailable','isEqual','Liquidity\x20change\x20|\x20basecoin\x20value:\x20','\x20|\x20','%)\x0a','match','Error\x20occurred:\x20','util','recovery','(((.+)+)+)+$','Huobipro','random','Will\x20continue\x20to\x20wait\x20for\x20order(s)\x20to\x20be\x20filled\x20and\x20try\x20to\x20cancel\x20again\x20later','resetHistory','unlinkSync','watchOrders()','currency','marketcapEnabled','./version.json','value','\x20API\x20key\x20is\x20invalid','sendMetricsTelegram','remove','\x20|\x20Custom\x20ID:\x20','reverse','1\x20-\x20FILLED\x20known\x20order:\x20','sort','\x20uses\x20','\x20not\x20responding\x20(see:\x20hodlerhacks.com/fix/5)','NetworkError','decrypt','marketcapApi','toUpperCase','final','remainingSymbols','Reset\x20|\x20','Value\x20','timestamp','settings','\x20order:\x20','-------------------------------\x0a','Switching\x20bot\x20to\x20manual\x20mode\x20to\x20prevent\x20major\x20losses','Bot\x20has\x20not\x20loaded\x20yet\x20-\x20try\x20again\x20in\x20a\x20minute','exchanges','basecoinvalue','exchange','trade','has','added','price','Exception\x20thrown\x20in\x20','placeOrder','limit-low',':\x20Bot\x20',':\x20timer\x20>','success','apply','portfolio1','none','performance','recent20','orderId','shift','filter','splice','prevnumber','%\x20(','emojibuy','code','no\x20exchange\x20reloaded','logs','botname','set','cancel','No\x20more\x20open\x20orders\x20-\x20','001','452477OuWcLe','lowdb','environment','format','Placing\x20order\x20for:\x20','fetchTickers()','loadMarkets','\x20-\x20bot\x20not\x20started','\x20API\x20secret\x20is\x20invalid','fetchTickers','505wcMwED','removed','indexOf','\x20rejected\x20your\x20API\x20request\x20(see:\x20hodlerhacks.com/fix/4)','defaults','Ordering\x20not\x20possible\x20while\x20in\x20cooldown\x20mode','RETRY\x20-\x20Problem\x20resolved\x20after\x20','portfolio2','0\x20-\x20EXECUTION:\x20','headless','2.6.0','offset','showname','fee','LOCKED','status','Avoiding\x20continuous\x20order\x20attempts',')\x20known\x20order:\x20','watchOrders','exchange\x20reload','staging','CoinMarketCap\x20data\x20could\x20not\x20be\x20retrieved\x20for\x20','excluded','\x20sec\x20for\x20order\x20info\x20to\x20be\x20completed','side','closed','write','market','\x20attempts','breakeven','Bot\x20','usd','\x20API\x20key\x20or\x20API\x20secret\x20invalid\x20-\x20also\x20make\x20sure\x20your\x20machine\x27s\x20IP\x20address\x20is\x20whitelisted\x20for\x20this\x20API\x20key\x20on\x20the\x20exchange\x20(see:\x20hodlerhacks.com/fix/1)','changes','getPortfolio','add','yyyy/MM/dd','\x20minutes','2XZVpdR','data','ongoing','quote','startdate','BUSD','time','Generated\x20PnL\x20data','getOpenOrders()','round','onepagemode','2.6.23','uncaughtException','differenceInSeconds','storeFiat','Failed\x20to\x20connect\x20to\x20the\x20exchange\x20-\x20bot\x20not\x20started','botID','isBefore','InvalidOrder','percentage','\x20blocked\x20API\x20(DDoSProtection)\x20-\x20check\x20if\x20API\x20key\x20is\x20enabled\x20for\x20spot\x20trading','padEnd','Resetting\x20coin\x20results:\x20','message','version','Error\x20details:','\x20-\x20exclude\x20coin\x20in\x20the\x20configuration','customId','target','Trigger:\x20','cooldown','type','/USD','amount','stringify','bb-settings.json','filled','last','\x20>\x20','sendPortfolioTelegram','send','storeConfiguration','testAPI()','2383952sEAQSy','</pre>','portfolio','realizedPnL','timeout','fromCodePoint','push','2.3.5','Portfolio\x20change\x20detected:\x20','heapUsed','slice','sell','active','\x20(see:\x20hodlerhacks.com/fix/1)','number','USD','padStart','cost','basecoin','Market','ETH','freeze','sortBy','toString','red_yellow_blue','Updating\x20API\x20key\x20(not\x20saved\x20in\x20config\x20file\x20yet)','node-forge','Your\x20machine\x27s\x20internal\x20clock\x20may\x20be\x20out\x20of\x20sync\x20(see:\x20hodlerhacks.com/fix/3)','createOrder','InvalidNonce','timeshift','\x20Permission\x20denied\x20-\x20make\x20sure\x20your\x20exhange\x20API\x20key\x20has\x20the\x20required\x20permissions\x20and\x20your\x20machine\x27s\x20IP\x20address\x20is\x20whitelisted\x20for\x20this\x20API\x20key\x20on\x20the\x20exchange\x20(see:\x20hodlerhacks.com/fix/1)','Waited\x20','configuration-stored','limits','net-fiat','Insufficient\x20funds\x20to\x20place\x20order\x20for\x20','autoliquidity','memoryUsage','buy','loading-canceled','getFullYear','progress','switch-manual','emitHistory','delta','Unfilled\x20order(s)\x20could\x20not\x20be\x20canceled\x20after\x20','\x20|\x20lock\x20orders:\x20','Order\x20amount\x20is\x20invalid:\x20','argv','change','PAXG','must\x20be\x20greater\x20than\x20minimum\x20amount','eur','toFixed','event-history','ExchangeError','\x20not\x20available\x20(see:\x20hodlerhacks.com/fix/5)','CoinMarketCap\x20data\x20could\x20not\x20be\x20updated\x20-\x20will\x20try\x20again\x20in\x201\x20hour','coins','emojisell','\x20portfolio:</b>\x20\x0a\x0a','open','status\x20code\x20401','total','fetchBalance()','OnMaintenance','Executed\x20','limit','/backup/','event','netoffset','Order\x20amount\x20is\x20too\x20small\x20to\x20trade:\x20','privateKey','fetchTicker','fetchBalance','colorscheme','keys','Ordering\x20not\x20possible\x20while\x20waiting\x20for\x20previous\x20order(s)\x20to\x20be\x20validated','join','\x20minutes,\x20then\x20restarting\x20bot\x20to\x20try\x20again','existsSync','mkdirSync','ask','assign','highest','27diZVNW','Pausing\x20for\x20','canceled','request-time','liquidity','sqrt','getSeconds','args','Invalid\x20balance\x20for\x20','-results.json','Carefully\x20evaluate\x20the\x20situation\x20before\x20you\x20decide\x20to\x20switch\x20to\x20automatic\x20mode\x20again','createWriteStream','getStartingBalances','fiat','marketcap','log','\x20>\x20stopping\x20bot\x20-\x20resolve\x20the\x20issue\x20and\x20restart\x20bot','Binance','RequestTimeout','\x20API\x20secret\x20is\x20invalid\x20-\x20update\x20the\x20API\x20secret\x20in\x20the\x20configuration\x20(see:\x20hodlerhacks.com/fix/1)','forEach','./config/','\x20minutes\x20-\x20','2\x20-\x20Handled\x20open\x20orders','-events.json','replace','RETRY\x20-\x20Error\x20in\x20','running','quick','\x20-\x20bot\x20switched\x20to\x20manual\x20mode'];_0x75d6=function(){return _0x58c331;};return _0x75d6();}let pnlGenerationNeeded=argv['r']||![],config,markets,allSymbols,currentCoins=[],currentCoinsAll=[],watchedSymbols=[],lastBalances,lastPerformanceEmitted,lastPerformanceStored,startingBalances;const ORDERS=Object[_0x11db1f(0x35f)]({'LOCKED':0x0,'UNLOCKING':0x1,'UNLOCKED':0x2});let lockOrders=ORDERS['UNLOCKED'],validateOrdersState,blockTransactionDetection=![],allOpenOrders,lastOrders=[],lastFees={'recent20':[],'highest':0x0},allOrdersPlaced=!![],cooldownTracker=[],coolingDown=![];const cooldownPeriod=0xe10*0x3e8,cooldownInterval=0x5*0x3c,getBalancesInterval=0xa*0x3e8,pauseBotIntervalShort=0xa*0x3e8,pauseBotInterval=0x5*0x3c*0x3e8,pauseBotMsg='\x20>\x20pausing\x20bot\x20for\x20'+pauseBotInterval/0xea60+'\x20minutes',maxPauseRetries=0x6,loadCoinsRetryInterval=0x3c*0x3c*0x3e8,validateOrderInterval=0xa*0x3e8,validateOrderTimeout=0x3c,watchTransactionsInterval=0x3c*0x3e8,schedulerInterval=0x3c*0x3c*0x3e8,retryInterval=0x3e8,maxRetries=0x5,logPageSize=0x14,defaultFee=0.003;let initialPerformanceStored,wsEventsSet=![],coinsLoaded=![],pidBalances,pidOrdersInitialTimeout,pidOrdersTimeout,botPaused=![],transactionDetectionOngoing=![],lastCoinsToBalance='',insufficientFundsWarningSent=[],exchangeStopped=![],loadingCanceled=![],loadingProgress;const maxLoadingProgress=0x2;let loading={'progress':-0x1,'remainingSymbols':[],'timeout':![],'cancel':![],'error':![]},lasttime,bots=[],initCycle=0x0;const balanceUpdateDelay=0x5dc,balanceUpdateRetries=0x5;let enableFiatToggle;const serverversion=require(_0x11db1f(0x2b5))[_0x11db1f(0x337)],environment=require(_0x11db1f(0x2b5))[_0x11db1f(0x2f1)]||'production',botID=process[_0x11db1f(0x19e)][0x2]||_0x11db1f(0x2ee),pattern=/^[0-9]{3}$/;!pattern[_0x11db1f(0x22c)](botID)&&(console[_0x11db1f(0x1d2)](_0x11db1f(0x239)+botID+_0x11db1f(0x273)),killBot());const userID=process[_0x11db1f(0x19e)][0x3]||'',configpath=userID?_0x11db1f(0x1d8)+userID+'/':_0x11db1f(0x1d8),logspath=userID?_0x11db1f(0x276)+userID+'/':_0x11db1f(0x276),loggerfile=fs[_0x11db1f(0x1ce)](logspath+_0x11db1f(0x282),{'flags':'a'});!fs[_0x11db1f(0x1be)](configpath)&&fs[_0x11db1f(0x1bf)](configpath);!fs['existsSync'](logspath)&&fs[_0x11db1f(0x1bf)](logspath);const configfile=configpath+_0x11db1f(0x25a)+botID+'-config.json',logfile=configpath+_0x11db1f(0x25a)+botID+_0x11db1f(0x1db),performancefile=configpath+_0x11db1f(0x25a)+botID+_0x11db1f(0x2a2),coinresultsfile=configpath+_0x11db1f(0x25a)+botID+_0x11db1f(0x1cc),settingsfile=configpath+_0x11db1f(0x342),securefile=configpath+_0x11db1f(0x26d),configbackuppath=configpath+_0x11db1f(0x1b2),adapter=new FileSync(logfile),dbLogs=low(adapter);dbLogs['defaults']({'logs':[],'version':serverversion})[_0x11db1f(0x313)]();const adapter2=new FileSync(performancefile),dbPerformance=low(adapter2);dbPerformance[_0x11db1f(0x2fd)]({'data':[],'version':serverversion})[_0x11db1f(0x313)]();const adapter3=new FileSync(configfile),dbConfig=low(adapter3);dbConfig[_0x11db1f(0x2fd)]({'bot':[],'version':serverversion})['write']();const adapter4=new FileSync(coinresultsfile),dbCoinResults=low(adapter4);dbCoinResults[_0x11db1f(0x2fd)]({'coins':{},'version':serverversion})[_0x11db1f(0x313)]();const adapter5=new FileSync(settingsfile),dbSettings=low(adapter5),adapter6=new FileSync(securefile),dbSecure=low(adapter6);let stablecoins,lastErrorShown,lastBotPause=![],consecutivePauses=0x0,settings=getSettings(),secure=getSecure();oneTimeMigration(),config=getConfiguration(botID);const logger={'screen':_0x3436af=>{const _0xc7b442=_0x11db1f;console[_0xc7b442(0x1d2)](_0x3436af);},'simple':_0x2507a8=>{const _0x2e9edb=_0x11db1f;console[_0x2e9edb(0x1d2)](_0x2507a8),loggerfile[_0x2e9edb(0x313)](util[_0x2e9edb(0x2f2)](_0x2507a8)+'\x0a');},'full':async(_0x5c11a4,_0x25ad9c='')=>{const _0x3ea4e1=_0x11db1f;let _0x5f1ab6;if(config[_0x3ea4e1(0x305)])_0x5f1ab6=getTimeStamp()+':\x20'+config[_0x3ea4e1(0x2ea)]+_0x3ea4e1(0x345)+_0x5c11a4;else _0x5f1ab6=getTimeStamp()+':\x20Bot\x20'+botID+_0x3ea4e1(0x345)+_0x5c11a4;console[_0x3ea4e1(0x1d2)](_0x5f1ab6),loggerfile[_0x3ea4e1(0x313)](util[_0x3ea4e1(0x2f2)](_0x5f1ab6)+'\x0a'),_0x25ad9c&&(console['log'](_0x25ad9c),loggerfile['write'](util[_0x3ea4e1(0x2f2)](_0x25ad9c)+'\x0a'));},'debug':async(_0x442340,_0x56840b='')=>{const _0x1cd463=_0x11db1f;let _0x15b928;if(config[_0x1cd463(0x305)])_0x15b928=getTimeStamp()+':\x20'+config[_0x1cd463(0x2ea)]+_0x1cd463(0x215)+_0x442340;else _0x15b928=getTimeStamp()+_0x1cd463(0x2d8)+botID+'\x20>\x20[DEBUG]\x20'+_0x442340;if(debugging)console['log'](_0x15b928);loggerfile[_0x1cd463(0x313)](util['format'](_0x15b928)+'\x0a');if(_0x56840b){if(debugging)console['log'](_0x56840b);loggerfile[_0x1cd463(0x313)](util[_0x1cd463(0x2f2)](_0x56840b)+'\x0a');}}};process['on']('uncaughtException',function(_0x489b3e){const _0x2666e1=_0x11db1f;handleError(_0x489b3e[_0x2666e1(0x1f1)],_0x2666e1(0x32b));});settings[_0x11db1f(0x368)]!=config['timeshift']&&updateTimeshift(settings[_0x11db1f(0x368)]);settings['onepagemode']!=config[_0x11db1f(0x329)]&&updateOnepagemode(settings[_0x11db1f(0x329)]);(settings[_0x11db1f(0x2c2)]&&!config[_0x11db1f(0x2c2)]||!settings[_0x11db1f(0x2c2)]&&config[_0x11db1f(0x2c2)])&&updateMarketcapApi(settings[_0x11db1f(0x2c2)]);process['send']({'started':_0x11db1f(0x1de)},_0xa96221=>{}),initializeProcessListeners();function proxyEmit(_0x21b2cb,_0x539318=null){const _0x12e480=_0x11db1f;process[_0x12e480(0x347)]({'function':_0x21b2cb,'args':_0x539318},_0xe91b52=>{});}function initializeProcessListeners(){const _0x1c4511=_0x11db1f;process['on'](_0x1c4511(0x336),_0x290309=>{const _0x227807=_0x1c4511;switch(Object[_0x227807(0x1ba)](_0x290309)[0x0]){case _0x227807(0x368):_0x290309['timeshift']!=undefined&&(settings[_0x227807(0x368)]=_0x290309[_0x227807(0x368)],updateTimeshift(settings[_0x227807(0x368)]));break;case _0x227807(0x329):_0x290309['onepagemode']!=undefined&&(settings['onepagemode']=_0x290309['onepagemode'],updateOnepagemode(settings[_0x227807(0x329)]));break;case _0x227807(0x2c2):_0x290309[_0x227807(0x2c2)]!=undefined&&(settings['marketcapApi']=_0x290309[_0x227807(0x2c2)],updateMarketcapApi(settings[_0x227807(0x2c2)]));break;case _0x227807(0x26f):_0x290309['bots']!=undefined&&(bots=JSON[_0x227807(0x1f4)](_0x290309['bots']),proxyEmit(_0x227807(0x26f),bots));break;case'function':switch(_0x290309[_0x227807(0x269)]){case _0x227807(0x259):initclient();break;case'toggleBotMode':toggleBotMode();break;case _0x227807(0x199):emitHistory(_0x290309[_0x227807(0x1ca)]);break;case _0x227807(0x254):deleteHistoryAlerts(_0x290309['args']);break;case _0x227807(0x31b):getPortfolio(_0x290309[_0x227807(0x1ca)]);break;case _0x227807(0x348):storeConfiguration(_0x290309['args']);break;case _0x227807(0x21e):storeHeadless(_0x290309['args']);break;case _0x227807(0x32d):storeFiat(_0x290309[_0x227807(0x1ca)]);break;case _0x227807(0x2b0):resetHistory();break;case _0x227807(0x1cf):getStartingBalances(getNormalizedPerformance());break;case _0x227807(0x2d6):placeOrder(_0x290309[_0x227807(0x1ca)]);break;case _0x227807(0x23c):cancelLoading();break;case'showConfig':showConfig();break;case _0x227807(0x2b8):sendMetricsTelegram();break;case _0x227807(0x346):sendPortfolioTelegram();break;}}});}reset(!![]);async function reset(_0x133c67=![]){const _0x2f45cd=_0x11db1f;logger['debug'](_0x2f45cd(0x2c6)+(_0x133c67?_0x2f45cd(0x30c):_0x2f45cd(0x2e8))+_0x2f45cd(0x1f2)+config['exchange']);if(pidBalances)clearTimeout(pidBalances);lastCoinsToBalance='',insufficientFundsWarningSent=[],coinsLoaded=![];if(config[_0x2f45cd(0x274)]!=''&&config[_0x2f45cd(0x274)]!=_0x2f45cd(0x213)){loadingProgress=0x0;if(_0x133c67){await initExchange();const _0x2dcbbc=await testAPI();if(!_0x2dcbbc)return;await loadSymbols(),loadingProgress=0x1,setStableCoins(),proxyEmit(_0x2f45cd(0x1fb),emittedConfiguration()),initialPerformanceStored=![];}const _0x112d70=await getCoins();[currentCoins,currentCoinsAll]=_0x112d70,setBlockTransactionDetection(![]),startScheduler(),loadingProgress=maxLoadingProgress,await initwsCcxt(),exchangeStopped=![];while(!coinsLoaded){await sleep(0x64);}logger['debug'](_0x2f45cd(0x245)),getBalances(![]),await updateOpenOrders();if(lastOrders[_0x2f45cd(0x25c)]==0x0&&allOpenOrders['length']!=0x0)restoreOrders();persistOpenOrders(lastOrders),getBalances();if(pnlGenerationNeeded)await generatePnL();}}async function resumeBot(_0x3e0478=![]){const _0x344142=_0x11db1f;logger['debug'](_0x344142(0x29a)+(_0x3e0478?_0x344142(0x1df):'complete')+_0x344142(0x203)+config[_0x344142(0x2d0)]);if(pidBalances)clearTimeout(pidBalances);if(_0x3e0478){getBalances();return;}coinsLoaded=![];if(config[_0x344142(0x274)]!=''&&config[_0x344142(0x274)]!=_0x344142(0x213)){loadingProgress=0x1;const _0x339672=await getCoins();[currentCoins,currentCoinsAll]=_0x339672,setBlockTransactionDetection(![]),loadingProgress=maxLoadingProgress,await initwsCcxt(),exchangeStopped=![];while(!coinsLoaded){await sleep(0x64);}logger[_0x344142(0x20c)]('Loading\x20completed'),getBalances(![]),await updateOpenOrders();if(lastOrders['length']==0x0&&allOpenOrders[_0x344142(0x25c)]!=0x0)restoreOrders();persistOpenOrders(lastOrders),getBalances();}}async function getMarketCap(_0x52acd8){const _0xdf248f=_0x11db1f;let _0x40df07=![];if(_0x52acd8)_0x40df07=!![];const _0x3751df=_0x40df07?_0x52acd8:currentCoins,_0x5b52c2=_0x3751df['map'](_0x27c81e=>_0x27c81e[_0xdf248f(0x23b)]);if(!config[_0xdf248f(0x2c2)]||!_0x40df07&&!config['marketcapEnabled']||_0x5b52c2[_0xdf248f(0x25c)]==0x0)return;let _0x73f3e3=null;try{_0x73f3e3=await axios[_0xdf248f(0x206)]('https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest',{'headers':{'X-CMC_PRO_API_KEY':settings[_0xdf248f(0x2c2)]},'params':{'symbol':_0x5b52c2['toString']()}});}catch(_0x5ab909){_0x73f3e3=null,_0x5ab909[_0xdf248f(0x361)]()[_0xdf248f(0x29b)](_0xdf248f(0x1ac))?(config['marketcapApi']=![],updateConfig(),proxyEmit(_0xdf248f(0x1fb),emittedConfiguration()),logHistory('error','CoinMarketCap\x20API\x20key\x20is\x20invalid\x20-\x20enter\x20your\x20API\x20key\x20in\x20the\x20Bot\x20Manager')):(logHistory(_0xdf248f(0x237),'CoinMarketCap\x20data\x20could\x20not\x20be\x20retrieved\x20-\x20trying\x20again\x20in\x20'+schedulerInterval/(0x3c*0x3e8)+_0xdf248f(0x31e)),logger[_0xdf248f(0x20c)](_0xdf248f(0x338),_0x5ab909['toString']()+_0xdf248f(0x257)+_0x5ab909[_0xdf248f(0x2e7)]));}let _0x158fc2=!![];if(_0x73f3e3){let _0x33eb65=0x0;const _0xd4a76e=_0x73f3e3[_0xdf248f(0x320)];_0x5b52c2[_0xdf248f(0x1d7)](_0x38b563=>{const _0x58bae7=_0xdf248f;if(_0xd4a76e[_0x58bae7(0x320)][_0x38b563][0x0]&&_0xd4a76e[_0x58bae7(0x320)][_0x38b563][0x0][_0x58bae7(0x322)][_0x58bae7(0x359)][_0x58bae7(0x22e)])_0x33eb65+=_0xd4a76e['data'][_0x38b563][0x0][_0x58bae7(0x322)]['USD']['market_cap'];else{if(!['EUR',_0x58bae7(0x359)][_0x58bae7(0x29b)](_0x38b563)){if(_0x40df07)logHistory('error',_0x58bae7(0x30e)+_0x38b563+_0x58bae7(0x27f));else{const _0x45631f=config['portfolio']['find'](_0x1fce52=>_0x1fce52['coin']==_0x38b563);_0x45631f&&!_0x45631f[_0x58bae7(0x30f)]&&_0x45631f[_0x58bae7(0x211)]==-0x1&&(_0x158fc2=![],logHistory(_0x58bae7(0x237),_0x58bae7(0x1a7)),logger[_0x58bae7(0x20c)]('CoinMarketCap\x20data\x20could\x20not\x20be\x20retrieved\x20for\x20'+_0x38b563));}}}});if(!_0x158fc2)return;_0x5b52c2[_0xdf248f(0x1d7)](_0x4e715e=>{const _0x4f8320=_0xdf248f,_0x503868=_0xd4a76e[_0x4f8320(0x320)][_0x4e715e][0x0]?_0xd4a76e[_0x4f8320(0x320)][_0x4e715e][0x0][_0x4f8320(0x322)]['USD'][_0x4f8320(0x22e)]:0x0;if(_0x40df07){const _0x3b8ff7=_0x52acd8['find'](_0x300712=>_0x300712[_0x4f8320(0x23b)]==_0x4e715e);_0x3b8ff7&&(_0x3b8ff7[_0x4f8320(0x1d1)]=_0x503868);}else{const _0x59e06d=currentCoins[_0x4f8320(0x21a)](_0x4a0bb4=>_0x4a0bb4[_0x4f8320(0x23b)]==_0x4e715e);_0x59e06d&&(_0x59e06d[_0x4f8320(0x1d1)]=_0x503868);const _0x313f05=currentCoinsAll[_0x4f8320(0x21a)](_0x3f9e65=>_0x3f9e65[_0x4f8320(0x23b)]==_0x4e715e);_0x313f05&&(_0x313f05[_0x4f8320(0x1d1)]=_0x503868);}}),!_0x40df07&&updateTargetDistribution();}}function updateTargetDistribution(){const _0x431e36=_0x11db1f,_0x10a177=0x2;let _0x5d63b7=0x0,_0x39b4e9=0x0,_0x2f6384=0x0,_0x4f5815=0x0,_0x9c61b1=0x0;config[_0x431e36(0x34c)][_0x431e36(0x1d7)](_0x59b300=>{const _0x1d7b61=_0x431e36;if(!_0x59b300[_0x1d7b61(0x30f)]){_0x2f6384++,_0x5d63b7+=_0x59b300['slider'];if(_0x59b300['slider']===-0x1){_0x5d63b7++;const _0x140b0e=currentCoinsAll[_0x1d7b61(0x21a)](_0x463d8d=>_0x463d8d[_0x1d7b61(0x23b)]==_0x59b300['coin']);_0x140b0e&&(_0x4f5815+=_0x140b0e[_0x1d7b61(0x1d1)],_0x9c61b1+=Math['sqrt'](_0x140b0e[_0x1d7b61(0x1d1)]));}if(_0x59b300['slider']!==-0x1)_0x39b4e9++;}});let _0x363d04;const _0x20326c=0x64-_0x5d63b7,_0x55eec9=_0x2f6384-_0x39b4e9;_0x363d04=_0x55eec9===0x0?_0x5d63b7:Math[_0x431e36(0x210)](0x64,_0x5d63b7),config['portfolio'][_0x431e36(0x1d7)](_0x299c35=>{const _0x419de8=_0x431e36,_0x26ce1a=currentCoinsAll[_0x419de8(0x21a)](_0x177066=>_0x177066[_0x419de8(0x23b)]==_0x299c35[_0x419de8(0x23b)]);_0x26ce1a&&(_0x299c35[_0x419de8(0x1d1)]=_0x26ce1a[_0x419de8(0x1d1)]);if(!_0x299c35['excluded']){if(_0x363d04<=0x64){if(_0x299c35[_0x419de8(0x211)]===-0x1){if(_0x4f5815!==0x0&&config[_0x419de8(0x2b4)]){if(_0x26ce1a){if(config[_0x419de8(0x2b4)]==_0x419de8(0x1d1))_0x299c35['distribution']=(_0x20326c/(_0x4f5815/_0x26ce1a[_0x419de8(0x1d1)]))[_0x419de8(0x1a3)](_0x10a177);else config[_0x419de8(0x2b4)]==_0x419de8(0x240)&&(_0x299c35[_0x419de8(0x1ff)]=(_0x20326c/(_0x9c61b1/Math[_0x419de8(0x1c8)](_0x26ce1a[_0x419de8(0x1d1)])))['toFixed'](_0x10a177));}}}}}}),updateConfig();}function updateConfig(){const _0x249ad3=_0x11db1f;let _0x3fd494=dbConfig[_0x249ad3(0x206)]('bot')[_0x249ad3(0x21a)]({'botID':botID})[_0x249ad3(0x2b6)]();_0x3fd494&&dbConfig[_0x249ad3(0x206)](_0x249ad3(0x260))[_0x249ad3(0x21a)]({'botID':botID})[_0x249ad3(0x1c1)](config)[_0x249ad3(0x313)]();}function logMemory(){const _0x1bba3c=_0x11db1f;if(environment!=_0x1bba3c(0x30d))return;const _0x1d4654=process[_0x1bba3c(0x370)]()[_0x1bba3c(0x353)]/0x400/0x400;logger['debug']('process\x20'+process['pid']+_0x1bba3c(0x2be)+formatResult(_0x1d4654,0x1)+'\x20MB');}async function startScheduler(){const _0x46eb9b=_0x11db1f,_0x1f8797=shiftedTime()[_0x46eb9b(0x22b)]();getMarketCap(),loadSymbols(),_0x1f8797==0x1&&logMemory(),await sleep(schedulerInterval),startScheduler();}async function restartBot(_0x4c91a9=![]){const _0x5b3be6=_0x11db1f;logger[_0x5b3be6(0x20c)]('Initiating\x20bot\x20restart');if(!_0x4c91a9)while(lockOrders!=ORDERS['UNLOCKED']||coolingDown){await sleep(0x3e8);}process[_0x5b3be6(0x347)]({'stop':_0x5b3be6(0x28b)},_0x42a42f=>{});}async function initExchange(_0x3c19b1=config[_0x11db1f(0x2d0)],_0x5835a7=config[_0x11db1f(0x274)],_0x8adb5c=config['apiSecret'],_0x39fc49=config['apiPassword'],_0x485850=config['sandbox']){const _0x555ffb=_0x11db1f;if(exchange){logger[_0x555ffb(0x20c)]('Initializing\x20exchange:\x20already\x20done');return;}logger[_0x555ffb(0x20c)]('Initializing\x20exchange');!supportedExchanges()[_0x555ffb(0x29b)](_0x3c19b1)&&(logHistory(_0x555ffb(0x237),_0x555ffb(0x1ea)+_0x3c19b1+_0x555ffb(0x290)),killBot());const _0x3d3e6a=ccxt[_0x555ffb(0x27b)][_0x3c19b1[_0x555ffb(0x204)]()];exchange=new _0x3d3e6a({'apiKey':_0x5835a7,'secret':_0x8adb5c,'options':{'defaultType':_0x555ffb(0x20d)}});if(_0x39fc49)exchange[_0x555ffb(0x1fe)]=_0x39fc49;if(exchange[_0x555ffb(0x2d2)][_0x555ffb(0x262)])exchange[_0x555ffb(0x1ec)](_0x485850);}function updateExchange(_0x3d895a,_0x3b867d,_0x1771c0=null){const _0x718106=_0x11db1f;exchange[_0x718106(0x274)]=_0x3d895a,exchange[_0x718106(0x1e5)]=_0x3b867d,exchange['password']=_0x1771c0,logger[_0x718106(0x20c)](_0x718106(0x363));}function setStableCoins(){const _0x512e0c=_0x11db1f;let _0x2b79c6=config[_0x512e0c(0x35c)]==_0x512e0c(0x35e)?_0x512e0c(0x35e):config[_0x512e0c(0x35c)]=='PAXG'?_0x512e0c(0x1a0):_0x512e0c(0x21d),_0x2c1ead=allSymbols[_0x512e0c(0x29b)](_0x2b79c6+_0x512e0c(0x33f))?_0x512e0c(0x359):allSymbols[_0x512e0c(0x29b)](_0x2b79c6+'/USDT')?_0x512e0c(0x27a):_0x512e0c(0x288),_0x7c731b=allSymbols[_0x512e0c(0x29b)](_0x2b79c6+_0x512e0c(0x216))?_0x512e0c(0x288):_0x2c1ead;enableFiatToggle=!![],_0x2c1ead==_0x512e0c(0x288)&&(enableFiatToggle=![],storeFiat(_0x512e0c(0x288))),_0x7c731b!=_0x512e0c(0x288)&&(enableFiatToggle=![],storeFiat(_0x512e0c(0x359))),stablecoins={'eur':{'coin':''+_0x2b79c6+_0x7c731b,'symbol':_0x2b79c6+'/'+_0x7c731b},'usd':{'coin':''+_0x2b79c6+_0x2c1ead,'symbol':_0x2b79c6+'/'+_0x2c1ead}};}async function initwsCcxt(){const _0x412d06=_0x11db1f;initCycle++;const _0x211496=initCycle;let _0x439304=[];config[_0x412d06(0x34c)][_0x412d06(0x1d7)](_0x2c614d=>{const _0x1261ca=_0x412d06;if(!_0x2c614d[_0x1261ca(0x30f)]&&_0x2c614d[_0x1261ca(0x23b)]!=config['basecoin'])_0x439304[_0x1261ca(0x350)](_0x2c614d[_0x1261ca(0x249)]);});if(!_0x439304[_0x412d06(0x29b)](stablecoins['eur']['symbol']))_0x439304[_0x412d06(0x350)](stablecoins[_0x412d06(0x1a2)][_0x412d06(0x249)]);if(!_0x439304[_0x412d06(0x29b)](stablecoins[_0x412d06(0x318)]['symbol']))_0x439304['push'](stablecoins[_0x412d06(0x318)][_0x412d06(0x249)]);loadCoins(_0x439304),_0x439304=validateSymbols(_0x439304);const _0x4e67f1=async _0x514450=>{const _0x4129e9=_0x412d06;let _0x442771;try{const _0x411b05=await getTickers(_0x514450);Object['entries'](_0x411b05)['forEach'](_0x59f52b=>{const _0x3ca03a=_0xbddb;_0x442771=_0x59f52b[0x1][_0x3ca03a(0x249)],gTicker[noslash(_0x442771)]=_0x59f52b[0x1][_0x3ca03a(0x344)],gChange[_0x442771]=_0x59f52b[0x1][_0x3ca03a(0x332)];});}catch(_0xdd935d){await handleError(_0xdd935d,_0x4129e9(0x222),_0x442771);}},_0x8e4012=async _0x1d04f0=>{const _0x40b71c=_0x412d06;while(initCycle==_0x211496){if(!botPaused)try{const _0x36e2b2=await exchange[_0x40b71c(0x258)](_0x1d04f0);gTicker[noslash(_0x36e2b2[0x0][_0x40b71c(0x249)])]=_0x36e2b2[0x0][_0x40b71c(0x2d4)];}catch(_0xece8de){if(!exchangeStopped)await handleError(_0xece8de,_0x40b71c(0x251),_0x1d04f0);}else await sleep(0x64);}},_0x434b0f=async _0x17e33a=>{const _0x286175=_0x412d06;while(initCycle==_0x211496){if(!botPaused)try{const _0x41355d=await exchange['watchTradesForSymbols'](_0x17e33a),_0x4daa4e=_0x41355d[_0x286175(0x264)]();gTicker[noslash(_0x4daa4e[_0x286175(0x249)])]=_0x4daa4e[_0x286175(0x2d4)];}catch(_0x47ae43){if(!exchangeStopped)await handleError(_0x47ae43,_0x286175(0x28e),_0x17e33a[_0x286175(0x361)]());}else await sleep(0x64);}},_0x24e36f=async _0x45fc7e=>{const _0x582446=_0x412d06;while(initCycle==_0x211496){if(!botPaused){let _0x310d19;try{await sleep(0x3c*0x3e8);const _0x453fbe=await getTickers(_0x45fc7e);Object[_0x582446(0x23f)](_0x453fbe)[_0x582446(0x1d7)](_0x13d148=>{const _0x3a011c=_0x582446;_0x310d19=_0x13d148[0x1][_0x3a011c(0x249)],gChange[_0x310d19]=_0x13d148[0x1][_0x3a011c(0x332)];});}catch(_0x1edfe6){if(!exchangeStopped)await handleError(_0x1edfe6,_0x582446(0x2f4),_0x310d19);}}else await sleep(0x64);}},_0x3efb37=async _0x2513f7=>{const _0x20b9c0=_0x412d06;while(initCycle==_0x211496){if(!botPaused)try{const _0x146091=await exchange[_0x20b9c0(0x30b)](_0x2513f7);initCycle==_0x211496&&_0x146091['forEach'](_0x358a99=>{updateNumberCoinsCcxt(_0x358a99);});}catch(_0x7eba5d){if(!exchangeStopped)await handleError(_0x7eba5d,_0x20b9c0(0x2b2));}else await sleep(0x64);}};_0x4e67f1(_0x439304),_0x24e36f(_0x439304),exchange['has']['watchTradesForSymbols']&&!(config['exchange']=='Bybit'&&_0x439304[_0x412d06(0x25c)]>0xa)?_0x434b0f(_0x439304):_0x439304[_0x412d06(0x1d7)](_0x383d84=>{_0x8e4012(_0x383d84);}),_0x439304['forEach'](_0x1f0303=>{_0x3efb37(_0x1f0303);}),!wsEventsSet&&(wsEventsSet=!![],watchTransactions());}async function getTickers(_0x23b7ec){const _0x4e26b9=_0x11db1f;let _0x2ef055={};try{if(config['exchange']!=_0x4e26b9(0x272))_0x2ef055=await exchange['fetchTickers'](_0x23b7ec);else for(const _0x451a8a of _0x23b7ec){const _0x55c04a=await exchange[_0x4e26b9(0x1b7)](_0x451a8a);_0x2ef055[_0x451a8a]=_0x55c04a;}return _0x2ef055;}catch(_0x50ae3a){throw _0x50ae3a;}}function setBlockTransactionDetection(_0x417129){const _0x313c6e=_0x11db1f;blockTransactionDetection=_0x417129,logger[_0x313c6e(0x20c)](_0x313c6e(0x28c)+blockTransactionDetection);}async function detectLiquidityChange(_0x1c8404=0x0){const _0xf251a0=_0x11db1f;transactionDetectionOngoing=!![];try{const _0xa89ba2=await getCoins(_0x1c8404),[_0x2a7483,_0x18a5c9]=_0xa89ba2;let _0x48c62d=[];currentCoins[_0xf251a0(0x1d7)](_0xd92460=>{const _0x24a86c=_0xf251a0,_0x27ec84=_0x2a7483[_0x24a86c(0x21a)](_0x27adf4=>_0x27adf4['coin']==_0xd92460[_0x24a86c(0x23b)]);if(_0x27ec84){if(_0xd92460['number']!=_0x27ec84[_0x24a86c(0x358)]){let _0x2433ec;if(_0xd92460[_0x24a86c(0x23b)]!=config[_0x24a86c(0x35c)]){const _0x204142=gTicker[noslash(_0xd92460['symbol'])];_0x2433ec=_0xd92460[_0x24a86c(0x2bb)]?0x1/_0x204142:_0x204142;}else _0x2433ec=0x1;_0x48c62d[_0x24a86c(0x350)]({'coin':_0xd92460[_0x24a86c(0x23b)],'symbol':_0xd92460[_0x24a86c(0x249)],'price':_0x2433ec,'number':Number(formatResult(_0x27ec84['number']-_0xd92460[_0x24a86c(0x358)],0x8)),'basecoinvalue':_0x2433ec*(_0x27ec84[_0x24a86c(0x358)]-_0xd92460[_0x24a86c(0x358)])});}}});if(_0x48c62d['length']>0x0&&!blockTransactionDetection){for(const _0x5d93e5 of _0x48c62d){if(config[_0xf251a0(0x36f)]){logger['debug'](_0xf251a0(0x2a5)+_0x5d93e5[_0xf251a0(0x2cf)]+_0xf251a0(0x252)+lastFees['highest']);if(lastFees[_0xf251a0(0x1c2)]==0x0||Math['abs'](_0x5d93e5[_0xf251a0(0x2cf)])>lastFees[_0xf251a0(0x1c2)]*0x3){if(config['autoliquidity']==_0xf251a0(0x250)){delete _0x5d93e5[_0xf251a0(0x249)],delete _0x5d93e5['basecoinvalue'];let _0x20151c=[],_0x4336b1=[...config[_0xf251a0(0x1c7)]]||[],_0x340de8=config[_0xf251a0(0x1c7)];_0x4336b1[_0xf251a0(0x2bd)]((_0x395863,_0x33fe97)=>_0x395863[_0xf251a0(0x298)]>_0x33fe97[_0xf251a0(0x298)]?-0x1:_0x33fe97['date']>_0x395863[_0xf251a0(0x298)]?0x1:0x0);const _0xddeed2=getDate();if(_0x4336b1[0x0]){const _0x4dcd7c=fns['parse'](_0x4336b1[0x0][_0xf251a0(0x298)],'yyyy/MM/dd',new Date()),_0x38a814=fns[_0xf251a0(0x1f4)](_0xddeed2,_0xf251a0(0x31d),new Date());if(fns['isEqual'](_0x4dcd7c,_0x38a814)){_0x20151c=_0x4336b1[0x0]['changes'];const _0x449f3d=_0x20151c[_0xf251a0(0x21a)](_0x3de13f=>_0x3de13f[_0xf251a0(0x23b)]==_0x5d93e5[_0xf251a0(0x23b)]);_0x449f3d?(_0x449f3d[_0xf251a0(0x358)]+=_0x5d93e5['number'],_0x449f3d[_0xf251a0(0x358)]==0x0&&(_0x20151c=_0x20151c[_0xf251a0(0x2e2)](_0x2e7178=>{return _0x2e7178['coin']!=_0x5d93e5['coin'];}))):_0x20151c[_0xf251a0(0x350)](_0x5d93e5);const _0xf82b5e=_0x340de8[_0xf251a0(0x21a)](_0x193cfa=>_0x193cfa['date']==_0xddeed2);_0xf82b5e[_0xf251a0(0x31a)]=_0x20151c;}else _0x340de8[_0xf251a0(0x350)]({'date':_0xddeed2,'changes':[_0x5d93e5]});}const _0x4244fd=_0x340de8[_0xf251a0(0x21a)](_0x20e743=>_0x20e743[_0xf251a0(0x298)]==_0xddeed2);if(_0x4244fd){let _0x5b4f64=!![];_0x4244fd[_0xf251a0(0x31a)][_0xf251a0(0x1d7)](_0x2aea5e=>{if(_0x2aea5e['number']!=0x0)_0x5b4f64=![];}),_0x5b4f64&&(_0x340de8=_0x340de8['filter'](_0x3d328a=>{const _0x25ebeb=_0xf251a0;return _0x3d328a[_0x25ebeb(0x298)]!=_0xddeed2;}));}let _0x6a013b=dbConfig[_0xf251a0(0x206)]('bot')[_0xf251a0(0x21a)]({'botID':botID})[_0xf251a0(0x2b6)]();_0x6a013b&&(dbConfig[_0xf251a0(0x206)](_0xf251a0(0x260))[_0xf251a0(0x21a)]({'botID':botID})['assign']({'liquidity':_0x340de8})[_0xf251a0(0x313)](),config[_0xf251a0(0x1c7)]=_0x340de8);logHistory('success','Portfolio\x20change\x20detected:\x20'+Math[_0xf251a0(0x261)](_0x5d93e5['number'])+'\x20'+_0x5d93e5[_0xf251a0(0x23b)]+'\x20'+(_0x5d93e5[_0xf251a0(0x358)]>0x0?_0xf251a0(0x2d3):_0xf251a0(0x2fa))+_0xf251a0(0x209)),proxyEmit(_0xf251a0(0x1fb),emittedConfiguration());const _0x2ef41f=getNormalizedPerformance();emitPerformance(_0x2ef41f),getStartingBalances(_0x2ef41f),logger[_0xf251a0(0x20c)](_0xf251a0(0x1ee));}else config['autoliquidity']==_0xf251a0(0x198)&&(config['headless']?(await storeHeadless({'headless':![]}),logHistory('success','Portfolio\x20change\x20detected:\x20'+Math[_0xf251a0(0x261)](_0x5d93e5[_0xf251a0(0x358)])+'\x20'+_0x5d93e5['coin']+'\x20'+(_0x5d93e5[_0xf251a0(0x358)]>0x0?_0xf251a0(0x2d3):_0xf251a0(0x2fa))+_0xf251a0(0x1e0))):logger[_0xf251a0(0x20c)](_0xf251a0(0x352)+Math[_0xf251a0(0x261)](_0x5d93e5[_0xf251a0(0x358)])+'\x20'+_0x5d93e5['coin']+'\x20'+(_0x5d93e5[_0xf251a0(0x358)]>0x0?'added':_0xf251a0(0x2fa))+_0xf251a0(0x22f)));}else logger[_0xf251a0(0x20c)]('Fee\x20discount\x20refund\x20detected:\x20'+Math[_0xf251a0(0x261)](_0x5d93e5['number'])+'\x20'+_0x5d93e5[_0xf251a0(0x23b)]+'\x20'+(_0x5d93e5['number']>0x0?_0xf251a0(0x2d3):'removed'));}else logger[_0xf251a0(0x20c)](_0xf251a0(0x352)+Math['abs'](_0x5d93e5[_0xf251a0(0x358)])+'\x20'+_0x5d93e5[_0xf251a0(0x23b)]+'\x20'+(_0x5d93e5['number']>0x0?'added':_0xf251a0(0x2fa))+'\x20-\x20auto\x20adjusting\x20liquidity\x20is\x20disabled');}currentCoins=_0x2a7483,currentCoinsAll=_0x18a5c9;}}catch(_0x441bf3){if(!exchangeStopped)await handleError(_0x441bf3,_0xf251a0(0x1ed));}transactionDetectionOngoing=![];}async function watchTransactions(){await sleep(0x14*0x3e8);while(!![]){!botPaused&&!blockTransactionDetection&&coinsLoaded?(detectLiquidityChange(),await sleep(watchTransactionsInterval)):await sleep(0x3e8);}}async function loadSymbols(){const _0x523b66=_0x11db1f;try{markets=await exchange[_0x523b66(0x2f5)](!![]),allSymbols=[],Object[_0x523b66(0x23f)](markets)[_0x523b66(0x1d7)](_0x2dcb56=>{const _0x57920e=_0x523b66;_0x2dcb56[0x1][_0x57920e(0x356)]&&_0x2dcb56[0x1][_0x57920e(0x20d)]&&allSymbols[_0x57920e(0x350)](_0x2dcb56[0x0]);});}catch(_0x117564){markets?logger[_0x523b66(0x20c)]('Error\x20in\x20loadSymbols():\x20'+_0x117564[_0x523b66(0x361)]()):(loading['cancel']=!![],_0x117564['toString']()[_0x523b66(0x204)]()[_0x523b66(0x29b)](_0x523b66(0x2c8))||_0x117564['toString']()[_0x523b66(0x204)]()[_0x523b66(0x29b)]('request-time')?(logHistory('error',_0x523b66(0x365)),loading[_0x523b66(0x237)]='timestamp-issue'):handleErrorNoStop(_0x117564,_0x523b66(0x286),!![]),logHistory(_0x523b66(0x237),'Failed\x20to\x20load\x20market\x20data\x20-\x20bot\x20not\x20started'),logHistory(_0x523b66(0x237),_0x523b66(0x1c4)+loadCoinsRetryInterval/0xea60+_0x523b66(0x1bd)),logger[_0x523b66(0x20c)](_0x523b66(0x338),_0x117564),emitLoadingProgress(),botPaused=!![],await sleep(loadCoinsRetryInterval),restartBot());}}function validateSymbols(_0x278e9e){const _0x1bebe2=_0x11db1f;let _0x322d88=[];return _0x278e9e[_0x1bebe2(0x1d7)](_0x4b51ed=>{const _0x288696=_0x1bebe2;!allSymbols['includes'](_0x4b51ed)?(logHistory(_0x288696(0x237),_0x288696(0x227)+_0x4b51ed+_0x288696(0x339)),loading['timeout']=!![],emitLoadingProgress()):_0x322d88[_0x288696(0x350)](_0x4b51ed);}),_0x322d88;}async function initclient(){const _0x530fd1=_0x11db1f;proxyEmit(_0x530fd1(0x1fb),emittedConfiguration()),proxyEmit(_0x530fd1(0x2ce),supportedExchanges()),emitLoadingProgress();while(!coinsLoaded){await sleep(0xc8);}if(lastBalances)proxyEmit('balances',{'serverversion':serverversion,'balances':lastBalances});emitHistory();const _0x4b8133=getNormalizedPerformance();emitPerformance(_0x4b8133),getStartingBalances(_0x4b8133);}async function toggleBotMode(){const _0x20afe7=_0x11db1f;let _0x3bdb9d=dbConfig['get']('bot')['find']({'botID':botID})[_0x20afe7(0x2b6)]();if(_0x3bdb9d){const _0x3542c7=!_0x3bdb9d[_0x20afe7(0x302)];dbConfig[_0x20afe7(0x206)](_0x20afe7(0x260))[_0x20afe7(0x21a)]({'botID':botID})[_0x20afe7(0x1c1)]({'headless':_0x3542c7})['write'](),config[_0x20afe7(0x302)]=_0x3542c7,proxyEmit(_0x20afe7(0x1fb),emittedConfiguration()),updateBotManager();}}function updateBotManager(){const _0xc4646a=_0x11db1f;process[_0xc4646a(0x347)]({'updatebotmanager':!![]},_0x3389f1=>{}),logger[_0xc4646a(0x20c)]('Headless:\x20'+config['headless']);}async function loadCoins(_0x3c2fbc){const _0x310a9f=_0x11db1f;loading={'progress':0x0,'remainingSymbols':[],'timeout':![],'cancel':![],'error':![]},emitLoadingProgress();let _0x425a14,_0x230263=0x0,_0x1da1e4=0x0;_0x3c2fbc[_0x310a9f(0x1d7)](_0x33c69e=>{const _0x346f13=_0x310a9f;loading['remainingSymbols'][_0x346f13(0x350)](_0x33c69e);}),loadingCanceled=![];let _0x11c33a=![];while(_0x425a14!=_0x3c2fbc[_0x310a9f(0x25c)]+maxLoadingProgress){_0x425a14=loadingProgress,_0x3c2fbc['forEach'](_0x463c5f=>{const _0x3242f4=_0x310a9f;if(gTicker[noslash(_0x463c5f)]){loading['remainingSymbols']=loading['remainingSymbols'][_0x3242f4(0x2e2)](_0x19e9b6=>_0x19e9b6!=_0x463c5f);if(!watchedSymbols[_0x3242f4(0x29b)](_0x463c5f))watchedSymbols[_0x3242f4(0x350)](_0x463c5f);_0x425a14++;}}),loading[_0x310a9f(0x374)]=Math[_0x310a9f(0x328)](_0x425a14/(_0x3c2fbc[_0x310a9f(0x25c)]+maxLoadingProgress)*0x64);loading[_0x310a9f(0x374)]!=0x64&&(_0x1da1e4>0x1e*0x5&&(loading['timeout']=!![],emitLoadingProgress()),_0x1da1e4>0x78*0x5&&!_0x11c33a&&(_0x11c33a=!![],logHistory(_0x310a9f(0x237),_0x310a9f(0x291)+loading[_0x310a9f(0x2c5)][_0x310a9f(0x1bc)](',\x20')+_0x310a9f(0x2f6)),logHistory('error',_0x310a9f(0x1c4)+loadCoinsRetryInterval/0xea60+'\x20minutes,\x20then\x20restarting\x20bot\x20to\x20try\x20again'),loadingCanceled=!![],await sleep(loadCoinsRetryInterval),restartBot()));if(loadingCanceled){loading[_0x310a9f(0x2ec)]=!![],emitLoadingProgress();break;}else _0x230263!=loading['progress']&&(_0x230263=loading[_0x310a9f(0x374)],emitLoadingProgress()),_0x1da1e4++,await sleep(0xc8);}_0x425a14==_0x3c2fbc[_0x310a9f(0x25c)]+maxLoadingProgress&&(coinsLoaded=!![],process[_0x310a9f(0x347)]({'status':_0x310a9f(0x27e),'live':_0x310a9f(0x1de)},_0x4d1675=>{}),_0x11c33a&&logHistory('success','All\x20coin\x20data\x20loaded\x20-\x20bot\x20started'));}function cancelLoading(){loadingCanceled=!![];}function showConfig(){const _0x13820f=_0x11db1f;proxyEmit(_0x13820f(0x1fb),{...emittedConfiguration(),'configstate':_0x13820f(0x372)});}function emitLoadingProgress(){proxyEmit('coin-loading-progress',loading);}async function getFiat(){const _0x5da91b=_0x11db1f;let _0x3cc27d=gTicker[stablecoins[_0x5da91b(0x1a2)][_0x5da91b(0x23b)]],_0x320221=gTicker[stablecoins[_0x5da91b(0x318)][_0x5da91b(0x23b)]];return{'eur':Number(_0x3cc27d),'usd':Number(_0x320221)};}function capitalize(_0x2aef5c){const _0x4d76c0=_0x11db1f;return _0x2aef5c[_0x4d76c0(0x277)](0x0,0x1)[_0x4d76c0(0x2c3)]()+_0x2aef5c['substring'](0x1);}function supportedExchanges(){const _0x254a4b=_0x11db1f,_0x45b4cb=['ws',_0x254a4b(0x2f8),_0x254a4b(0x1b7),'watchTrades',_0x254a4b(0x30b),_0x254a4b(0x253),_0x254a4b(0x366),'fetchOpenOrders',_0x254a4b(0x1b8)];let _0x4979aa=[],_0x3e6cfb=[],_0x1663bf=ccxt['pro'][_0x254a4b(0x2ce)];_0x1663bf[_0x254a4b(0x1d7)](_0xfecfd3=>{const _0x31e13c=_0x254a4b;try{const _0x43ef19=new ccxt[(_0x31e13c(0x27b))][_0xfecfd3]();_0x3e6cfb['push'](_0x43ef19);}catch(_0xa2aa78){}}),_0x3e6cfb[_0x254a4b(0x1d7)](_0x2537dd=>{const _0x3a2ccd=_0x254a4b;let _0x44d24c=0x0;_0x45b4cb[_0x3a2ccd(0x1d7)](_0x65f645=>{const _0x4c78af=_0x3a2ccd;_0x65f645 in _0x2537dd['has']&&_0x2537dd[_0x4c78af(0x2d2)][_0x65f645]&&_0x44d24c++;}),_0x44d24c==_0x45b4cb[_0x3a2ccd(0x25c)]&&(!excludedExchanges[_0x3a2ccd(0x29b)](_0x2537dd['id'])&&_0x4979aa[_0x3a2ccd(0x350)](capitalize(_0x2537dd['id'])));});let _0x4f8bde=[];return _0x1663bf[_0x254a4b(0x1d7)](_0x57c211=>{const _0x9998c8=_0x254a4b;_0x57c211=capitalize(_0x57c211);if(!_0x4979aa[_0x9998c8(0x29b)](_0x57c211))_0x4f8bde[_0x9998c8(0x350)](_0x57c211);}),_0x4979aa;}function setStartDatePerformance(){const _0x38c10=_0x11db1f;if(config&&config['liquidity'][0x0][_0x38c10(0x31a)][_0x38c10(0x25c)]!=0x0){const _0x553770=config['liquidity'][0x0][_0x38c10(0x31a)];dbPerformance['get'](_0x38c10(0x320))['find']({'date':config[_0x38c10(0x323)]})[_0x38c10(0x1c1)]({'coins':_0x553770})['write']();}}function calculatePnL(_0x23d557,_0x42adf2,_0x1dbfbc,_0x18f5db,_0x3eddac,_0x26b3cc){const _0x3e3828=_0x11db1f;!_0x23d557['includes']('/'+config[_0x3e3828(0x35c)])&&(_0x1dbfbc=_0x1dbfbc==_0x3e3828(0x371)?_0x3e3828(0x355):_0x3e3828(0x371));!_0x26b3cc[_0x42adf2]&&(_0x26b3cc[_0x42adf2]={'number':0x0,'sells':0x0,'buys':0x0,'breakeven':0x0,'realizedPnL':0x0});let _0x178eee=0x0,_0x3718be,_0xd71104;if(_0x1dbfbc==_0x3e3828(0x371))_0xd71104=_0x26b3cc[_0x42adf2][_0x3e3828(0x358)]*_0x26b3cc[_0x42adf2][_0x3e3828(0x316)]+_0x3eddac*_0x18f5db,_0x26b3cc[_0x42adf2][_0x3e3828(0x358)]+=_0x18f5db,_0x26b3cc[_0x42adf2][_0x3e3828(0x316)]=_0x26b3cc[_0x42adf2]['number']!=0x0?_0xd71104/_0x26b3cc[_0x42adf2][_0x3e3828(0x358)]:0x0,_0x26b3cc[_0x42adf2]['buys']++;else _0x1dbfbc==_0x3e3828(0x355)&&(_0x3718be=Math['min'](_0x26b3cc[_0x42adf2]['number'],_0x18f5db),_0x178eee=(_0x3eddac-_0x26b3cc[_0x42adf2][_0x3e3828(0x316)])*_0x3718be,_0xd71104=Math[_0x3e3828(0x210)](_0x26b3cc[_0x42adf2][_0x3e3828(0x358)]*_0x26b3cc[_0x42adf2][_0x3e3828(0x316)]-_0x3718be*_0x26b3cc[_0x42adf2][_0x3e3828(0x316)],0x0),_0x26b3cc[_0x42adf2]['number']-=_0x3718be,_0x26b3cc[_0x42adf2][_0x3e3828(0x316)]=_0x26b3cc[_0x42adf2][_0x3e3828(0x358)]!=0x0?_0xd71104/_0x26b3cc[_0x42adf2][_0x3e3828(0x358)]:0x0,_0x26b3cc[_0x42adf2]['realizedPnL']+=_0x178eee,_0x26b3cc[_0x42adf2][_0x3e3828(0x238)]++);return _0x178eee;}async function generatePnL(){const _0x2c0813=_0x11db1f;pnlGenerationNeeded=![],logger['debug']('Generating\x20PnL\x20data');const _0x18809a=dbLogs[_0x2c0813(0x206)](_0x2c0813(0x2e9))[_0x2c0813(0x2b6)]();let _0x3b2883={},_0x4be8c5=0x0,_0x2cbb24=0x0,_0x14678b=config[_0x2c0813(0x323)];const _0x1499bc=fns[_0x2c0813(0x1f4)](_0x14678b,_0x2c0813(0x31d),new Date()),_0x21b14f=new Date();let _0x361f8a=0x0;for(let _0x1a8fc5=_0x1499bc;!fns[_0x2c0813(0x330)](_0x21b14f,_0x1a8fc5);_0x1a8fc5=fns[_0x2c0813(0x22a)](_0x1a8fc5,0x1)){const _0x4b8f76=fns[_0x2c0813(0x2f2)](_0x1a8fc5,_0x2c0813(0x31d));while(_0x4be8c5<_0x18809a[_0x2c0813(0x25c)]){const _0x90d99d=new Date(_0x18809a[_0x4be8c5][_0x2c0813(0x325)]);if(fns[_0x2c0813(0x330)](_0x90d99d,_0x1a8fc5))_0x4be8c5++;else{if(_0x18809a[_0x4be8c5][_0x2c0813(0x325)][_0x2c0813(0x29b)](_0x4b8f76)){const _0x2bb215=_0x18809a[_0x4be8c5];if(_0x2bb215[_0x2c0813(0x33e)]===_0x2c0813(0x23e)&&(_0x2bb215[_0x2c0813(0x1b3)][_0x2c0813(0x29b)](_0x2c0813(0x1e6))||_0x2bb215[_0x2c0813(0x1b3)][_0x2c0813(0x29b)]('Market\x20order'))){const _0x21dd87=_0x2bb215[_0x2c0813(0x1b3)][_0x2c0813(0x2a8)](/([A-Z]+\/[A-Z]+) (sell|buy) #([\d.]+) @([\d.]+)/);if(_0x21dd87){const [,_0x34ad53,_0x33c11f,_0x38192c,_0x37a039]=_0x21dd87,_0x1b7227=_0x34ad53['includes']('/'+config[_0x2c0813(0x35c)])?_0x34ad53['split']('/')[0x0]:_0x34ad53[_0x2c0813(0x1e8)]('/')[0x1],_0x5d438d=calculatePnL(_0x34ad53,_0x1b7227,_0x33c11f,parseFloat(_0x38192c),parseFloat(_0x37a039),_0x3b2883);_0x2cbb24+=_0x5d438d;}}_0x4be8c5++;}else break;}}dbPerformance[_0x2c0813(0x206)](_0x2c0813(0x320))[_0x2c0813(0x21a)]({'date':_0x4b8f76})[_0x2c0813(0x1c1)]({'pnl':_0x2cbb24})['write']();}dbCoinResults[_0x2c0813(0x2eb)](_0x2c0813(0x1a8),_0x3b2883)[_0x2c0813(0x313)](),logger['debug'](_0x2c0813(0x326));const _0x3194a9=getNormalizedPerformance();emitPerformance(_0x3194a9);}async function updatePnL(_0x3bee66){const _0x108ae6=_0x11db1f,{symbol:_0x1abbac,coin:_0x62e4a9,amount:_0x3b3c6e,price:_0x32949e,side:_0x47e02e,reverse:_0x484a00}=_0x3bee66;let _0x31d831=dbCoinResults[_0x108ae6(0x206)](_0x108ae6(0x1a8))['value']();const _0x4015a5=calculatePnL(_0x1abbac,_0x62e4a9,_0x47e02e,_0x3b3c6e,_0x32949e,_0x31d831);dbCoinResults[_0x108ae6(0x2eb)](_0x108ae6(0x1a8),_0x31d831)[_0x108ae6(0x313)]();const _0x3304ae=getTimeStamp()[_0x108ae6(0x1e8)]('\x20')[0x0];let _0x4131be=dbPerformance[_0x108ae6(0x206)](_0x108ae6(0x320))['find']({'date':_0x3304ae})[_0x108ae6(0x2b6)]();_0x4131be?(_0x4131be[_0x108ae6(0x256)]+=_0x4015a5,dbPerformance[_0x108ae6(0x206)](_0x108ae6(0x320))[_0x108ae6(0x21a)]({'date':_0x3304ae})[_0x108ae6(0x1c1)](_0x4131be)[_0x108ae6(0x313)]()):await storePerformance();const _0x14e661=getNormalizedPerformance();emitPerformance(_0x14e661);}async function validate24hChanges(){const _0x18559d=_0x11db1f;for(const _0x28d061 of currentCoins){if(_0x28d061['coin']!=config['basecoin']){let _0x4e4923;_0x28d061[_0x18559d(0x2bb)]?_0x4e4923=formatResult((0x1/(gChange[_0x28d061['symbol']]/0x64+0x1)-0x1)*0x64,0x3):_0x4e4923=gChange[_0x28d061[_0x18559d(0x249)]],_0x4e4923<config[_0x18559d(0x279)]&&(logHistory(_0x18559d(0x237),_0x28d061[_0x18559d(0x23b)]+_0x18559d(0x1e2)+_0x4e4923+'%'),logHistory(_0x18559d(0x237),_0x18559d(0x2cc)),logHistory(_0x18559d(0x237),_0x18559d(0x1cd)),await storeHeadless({'headless':![]}));}}}function isOlderVersion(_0x47444e,_0x581fe7){const _0x26fdd6=_0x11db1f;if(!_0x47444e)return!![];const _0x3e8d61=_0x581fe7['split']('.'),_0x1666ca=_0x47444e['split']('.');for(var _0x3f93b9=0x0;_0x3f93b9<_0x1666ca[_0x26fdd6(0x25c)];_0x3f93b9++){const _0xd613f0=~~_0x1666ca[_0x3f93b9],_0x24f073=~~_0x3e8d61[_0x3f93b9];if(_0xd613f0<_0x24f073)return!![];if(_0xd613f0>_0x24f073)return![];}return![];}async function oneTimeMigration(){const _0x26ebdb=_0x11db1f;let _0x52f2c1=dbLogs[_0x26ebdb(0x206)](_0x26ebdb(0x337))[_0x26ebdb(0x2b6)]();if(isOlderVersion(_0x52f2c1,_0x26ebdb(0x351))){let _0x37a0a9=[];const _0x37eb80=dbLogs['get'](_0x26ebdb(0x2e9))[_0x26ebdb(0x2b6)]();_0x37eb80[_0x26ebdb(0x1d7)](_0x18618e=>{const _0x1c1553=_0x26ebdb;_0x37a0a9[_0x1c1553(0x350)]({'time':_0x18618e[_0x1c1553(0x325)],'type':_0x18618e['type'],'event':_0x18618e['event']});}),dbLogs[_0x26ebdb(0x206)](_0x26ebdb(0x2e9))[_0x26ebdb(0x1c1)](_0x37a0a9)[_0x26ebdb(0x313)]();}let _0x2b44e2=dbConfig[_0x26ebdb(0x206)](_0x26ebdb(0x337))[_0x26ebdb(0x2b6)]();if(isOlderVersion(_0x2b44e2,_0x26ebdb(0x351))){let _0x39efad=dbConfig[_0x26ebdb(0x206)](_0x26ebdb(0x260))['find']({'botID':botID})[_0x26ebdb(0x2b6)]();if(_0x39efad){let _0x30d9df=[];_0x39efad[_0x26ebdb(0x34c)][_0x26ebdb(0x1d7)](_0x553646=>{const _0x46a300=_0x26ebdb;_0x30d9df['push']({'coin':_0x553646[_0x46a300(0x23b)],'number':_0x553646[_0x46a300(0x283)],'price':_0x553646[_0x46a300(0x246)]}),delete _0x553646[_0x46a300(0x283)],delete _0x553646[_0x46a300(0x246)];});if(_0x30d9df[_0x26ebdb(0x25c)]!==0x0)fs['writeFile'](configbackuppath+(_0x26ebdb(0x208)+botID+_0x26ebdb(0x1fd)),JSON[_0x26ebdb(0x341)](_0x30d9df,null,0x4),function(_0x36c234){if(_0x36c234){}});const _0x238b19=(_0x5a64cb,_0x2ef83e)=>{const _0xa80af=_0x26ebdb;let _0x2325c9=[];_0x2ef83e[_0xa80af(0x1d7)](_0x53ebae=>{const _0x348366=_0xa80af,_0x43e757=_0x5a64cb['find'](_0x11faba=>_0x11faba[_0x348366(0x23b)]==_0x53ebae[_0x348366(0x23b)]);if(!_0x43e757)_0x2325c9[_0x348366(0x350)](_0x53ebae);});let _0x1ff99c=[];return _0x5a64cb['forEach'](_0x37a583=>{const _0x2e00d8=_0xa80af,_0x440c6e=_0x2ef83e['find'](_0xd6f0c4=>_0xd6f0c4[_0x2e00d8(0x23b)]==_0x37a583[_0x2e00d8(0x23b)]);if(!_0x440c6e||_0x440c6e[_0x2e00d8(0x358)]==0x0&&_0x37a583[_0x2e00d8(0x358)]!=0x0)_0x1ff99c[_0x2e00d8(0x350)](_0x37a583);}),{'missingDay1':_0x2325c9,'notInDay2':_0x1ff99c};},_0x524af0=dbPerformance[_0x26ebdb(0x206)](_0x26ebdb(0x320))['cloneDeep']()['value']();if(_0x524af0['length']>0x1){const {missingDay1:_0x24b77a,notInDay2:_0x33e3fb}=_0x238b19(_0x30d9df,_0x524af0[0x1][_0x26ebdb(0x1a8)]);_0x30d9df=[..._0x30d9df,..._0x24b77a],_0x33e3fb['forEach'](_0x5d3c0d=>{const _0x5a5ee2=_0x26ebdb;let _0x40a835=_0x30d9df[_0x5a5ee2(0x1f6)](_0x35ce26=>_0x35ce26[_0x5a5ee2(0x23b)]==_0x5d3c0d['coin']);_0x40a835!=-0x1&&_0x30d9df[_0x5a5ee2(0x2e3)](_0x40a835,0x1);});}_0x30d9df['sort']((_0x58578b,_0x51cba2)=>_0x58578b[_0x26ebdb(0x23b)]>_0x51cba2[_0x26ebdb(0x23b)]?0x1:_0x51cba2[_0x26ebdb(0x23b)]>_0x58578b['coin']?-0x1:0x0);let _0x22b739=[{'date':_0x39efad[_0x26ebdb(0x323)],'changes':_0x30d9df}];_0x524af0[_0x26ebdb(0x25c)]>0x2&&_0x524af0[_0x26ebdb(0x1d7)]((_0x3add6a,_0x4ff161)=>{const _0x13bb34=_0x26ebdb;if(_0x4ff161>0x0&&_0x4ff161<_0x524af0[_0x13bb34(0x25c)]-0x1){const {missingDay1:_0x3354ad,notInDay2:_0x23d3a1}=_0x238b19(_0x524af0[_0x4ff161][_0x13bb34(0x1a8)],_0x524af0[_0x4ff161+0x1][_0x13bb34(0x1a8)]);_0x30d9df=[],(_0x3354ad['length']!=0x0||_0x23d3a1['length']!=0x0)&&(_0x3354ad[_0x13bb34(0x25c)]!=0x0&&_0x30d9df[_0x13bb34(0x350)](..._0x3354ad),_0x23d3a1[_0x13bb34(0x25c)]!=0x0&&(_0x23d3a1['forEach'](_0x54ff42=>{const _0x4da9b9=_0x13bb34;_0x54ff42[_0x4da9b9(0x358)]=-_0x54ff42[_0x4da9b9(0x358)];}),_0x30d9df['push'](..._0x23d3a1)),_0x30d9df['sort']((_0x49cece,_0x117a6a)=>_0x49cece[_0x13bb34(0x23b)]>_0x117a6a[_0x13bb34(0x23b)]?0x1:_0x117a6a[_0x13bb34(0x23b)]>_0x49cece[_0x13bb34(0x23b)]?-0x1:0x0),_0x22b739[_0x13bb34(0x350)]({'date':_0x524af0[_0x4ff161+0x1][_0x13bb34(0x298)],'changes':_0x30d9df}));}}),dbConfig['get'](_0x26ebdb(0x260))[_0x26ebdb(0x21a)]({'botID':botID})[_0x26ebdb(0x1c1)]({..._0x39efad,'liquidity':_0x22b739})[_0x26ebdb(0x313)]();}}if(isOlderVersion(_0x2b44e2,_0x26ebdb(0x303))){let _0x4c8295=dbConfig['get']('bot')[_0x26ebdb(0x21a)]({'botID':botID})[_0x26ebdb(0x2b6)]();if(_0x4c8295){const _0x178515=_0x4c8295[_0x26ebdb(0x2d0)],_0x3e6e51=_0x178515?capitalize(_0x178515):_0x26ebdb(0x1d4);dbConfig[_0x26ebdb(0x206)]('bot')[_0x26ebdb(0x21a)]({'botID':botID})[_0x26ebdb(0x1c1)]({'exchange':_0x3e6e51})[_0x26ebdb(0x313)]();}}if(isOlderVersion(_0x2b44e2,_0x26ebdb(0x217))){let _0x1cbac8=dbConfig[_0x26ebdb(0x206)](_0x26ebdb(0x260))[_0x26ebdb(0x21a)]({'botID':botID})[_0x26ebdb(0x2b6)]();if(_0x1cbac8){const _0x468932=_0x1cbac8[_0x26ebdb(0x2b4)],_0x3e0c89=_0x468932?_0x26ebdb(0x1d1):![];dbConfig[_0x26ebdb(0x206)]('bot')['find']({'botID':botID})[_0x26ebdb(0x1c1)]({'marketcapEnabled':_0x3e0c89})[_0x26ebdb(0x313)]();}}if(isOlderVersion(_0x2b44e2,_0x26ebdb(0x32a))){let _0x5597a5=dbConfig[_0x26ebdb(0x206)](_0x26ebdb(0x260))[_0x26ebdb(0x21a)]({'botID':botID})['value']();if(_0x5597a5){const _0x52bd6f=_0x5597a5[_0x26ebdb(0x36f)],_0x143269=_0x52bd6f?_0x26ebdb(0x250):![];dbConfig[_0x26ebdb(0x206)](_0x26ebdb(0x260))['find']({'botID':botID})[_0x26ebdb(0x1c1)]({'autoliquidity':_0x143269})[_0x26ebdb(0x313)]();}}let _0x2e2347=dbPerformance[_0x26ebdb(0x206)](_0x26ebdb(0x337))['value']();isOlderVersion(_0x2e2347,_0x26ebdb(0x351))&&setStartDatePerformance();let _0x30f7a4=dbCoinResults[_0x26ebdb(0x206)](_0x26ebdb(0x337))['value']();if(isOlderVersion(_0x30f7a4,'2.7.1')){let _0x51d751=dbCoinResults['get']('coins')[_0x26ebdb(0x2b6)]();if(_0x51d751[_0x26ebdb(0x25c)]!=0x0)pnlGenerationNeeded=!![];}updateFileVersions();}function updateFileVersions(){const _0x2f9283=_0x11db1f;dbConfig['set'](_0x2f9283(0x337),serverversion)[_0x2f9283(0x313)](),dbPerformance[_0x2f9283(0x2eb)](_0x2f9283(0x337),serverversion)[_0x2f9283(0x313)](),dbLogs[_0x2f9283(0x2eb)]('version',serverversion)['write'](),dbCoinResults['set']('version',serverversion)[_0x2f9283(0x313)]();}function getConfiguration(_0x4eb6e2){const _0x4ac4cb=_0x11db1f;let _0x255479=dbConfig[_0x4ac4cb(0x206)]('bot')[_0x4ac4cb(0x21a)]({'botID':_0x4eb6e2})[_0x4ac4cb(0x2b6)]();if(_0x255479){let _0x1ec772=![];typeof _0x255479['threshold']==_0x4ac4cb(0x24f)&&(_0x255479={..._0x255479,'threshold':Number(_0x255479[_0x4ac4cb(0x255)])},_0x1ec772=!![]),_0x255479[_0x4ac4cb(0x279)]==undefined&&(_0x255479={..._0x255479,'change24h':-0x14},_0x1ec772=!![]),_0x255479[_0x4ac4cb(0x1d0)]==undefined&&(_0x255479={..._0x255479,'fiat':_0x4ac4cb(0x359)},_0x1ec772=!![]),_0x255479['onepagemode']==undefined&&(_0x255479={..._0x255479,'onepagemode':settings[_0x4ac4cb(0x329)]},_0x1ec772=!![]),_0x255479['colorscheme']==undefined&&(_0x255479={..._0x255479,'colorscheme':_0x4ac4cb(0x362)},_0x1ec772=!![]),_0x255479[_0x4ac4cb(0x36f)]==undefined&&(_0x255479={..._0x255479,'autoliquidity':_0x4ac4cb(0x250)},_0x1ec772=!![]),_0x255479['marketcapApi']==undefined&&(_0x255479={..._0x255479,'marketcapApi':settings[_0x4ac4cb(0x2c2)]?!![]:![]},_0x1ec772=!![]),_0x255479[_0x4ac4cb(0x2b4)]==undefined&&(_0x255479={..._0x255479,'marketcapEnabled':![]},_0x1ec772=!![]),_0x255479['sandbox']==undefined&&(_0x255479={..._0x255479,'sandbox':![]},_0x1ec772=!![]),_0x1ec772&&(_0x255479={'botID':_0x255479[_0x4ac4cb(0x32f)],'exchange':_0x255479[_0x4ac4cb(0x2d0)],'apiKey':_0x255479['apiKey'],'apiSecret':_0x255479[_0x4ac4cb(0x23a)],'apiPassword':_0x255479['apiPassword'],'basecoin':_0x255479[_0x4ac4cb(0x35c)],'botname':_0x255479['botname'],'showname':_0x255479['showname'],'threshold':_0x255479[_0x4ac4cb(0x255)],'ordertype':_0x255479['ordertype'],'timeout':_0x255479['timeout'],'fiat':_0x255479[_0x4ac4cb(0x1d0)],'startdate':_0x255479[_0x4ac4cb(0x323)],'recreate':_0x255479[_0x4ac4cb(0x1fc)],'timeshift':_0x255479[_0x4ac4cb(0x368)],'onepagemode':_0x255479['onepagemode'],'headless':_0x255479[_0x4ac4cb(0x302)],'cooldown':_0x255479['cooldown'],'change24h':_0x255479[_0x4ac4cb(0x279)],'emojibuy':_0x255479[_0x4ac4cb(0x2e6)],'emojisell':_0x255479[_0x4ac4cb(0x1a9)],'colorscheme':_0x255479[_0x4ac4cb(0x1b9)],'marketcapApi':_0x255479[_0x4ac4cb(0x2c2)],'marketcapEnabled':_0x255479[_0x4ac4cb(0x2b4)],'sandbox':_0x255479['sandbox'],'portfolio':_0x255479[_0x4ac4cb(0x34c)],'autoliquidity':_0x255479[_0x4ac4cb(0x36f)],'liquidity':_0x255479[_0x4ac4cb(0x1c7)],'openOrders':_0x255479[_0x4ac4cb(0x221)]},dbConfig['get'](_0x4ac4cb(0x260))[_0x4ac4cb(0x2b9)]()[_0x4ac4cb(0x313)](),dbConfig[_0x4ac4cb(0x206)](_0x4ac4cb(0x260))[_0x4ac4cb(0x350)](_0x255479)[_0x4ac4cb(0x313)]());}else _0x255479={'botID':_0x4eb6e2,'exchange':'','apiKey':'','apiSecret':'','apiPassword':null,'basecoin':'','botname':_0x4ac4cb(0x317)+_0x4eb6e2,'showname':![],'threshold':0x3,'ordertype':_0x4ac4cb(0x314),'timeout':0x14,'fiat':_0x4ac4cb(0x359),'startdate':getDate(),'recreate':![],'timeshift':settings[_0x4ac4cb(0x368)],'onepagemode':settings['onepagemode'],'headless':![],'cooldown':0xa,'change24h':-0x14,'emojibuy':'','emojisell':'','colorscheme':_0x4ac4cb(0x362),'marketcapApi':settings[_0x4ac4cb(0x2c2)]?!![]:![],'marketcapEnabled':![],'sandbox':![],'portfolio':[],'autoliquidity':'update-liquidity','liquidity':[{'date':getDate(),'changes':[]}],'openOrders':[]};return _0x255479;}function emittedConfiguration(){const _0x4247c6=_0x11db1f;let _0x4f71b8;if(config[_0x4247c6(0x274)]=='')_0x4f71b8={...config,'configstate':_0x4247c6(0x26b)};else config[_0x4247c6(0x274)]==_0x4247c6(0x213)?_0x4f71b8={...config,'configstate':_0x4247c6(0x2ab)}:(_0x4f71b8={...config,'apiKey':_0x4247c6(0x242),'apiSecret':_0x4247c6(0x242)},config[_0x4247c6(0x1e1)]&&(_0x4f71b8[_0x4247c6(0x1e1)]=_0x4247c6(0x242)));return _0x4f71b8[_0x4247c6(0x28f)]=enableFiatToggle,_0x4f71b8;}function getSettings(){const _0x30ac6d=_0x11db1f;return dbSettings['get'](_0x30ac6d(0x2c9))[_0x30ac6d(0x2b6)]();}function getSecure(){const _0x5e560d=_0x11db1f;return dbSecure[_0x5e560d(0x206)](_0x5e560d(0x265))[_0x5e560d(0x2b6)]()||{};}function updateTimeshift(_0x2472b3){const _0x51aeae=_0x11db1f;let _0x31edfa=dbConfig[_0x51aeae(0x206)](_0x51aeae(0x260))['find']({'botID':botID})['value']();_0x31edfa&&dbConfig['get']('bot')[_0x51aeae(0x21a)]({'botID':botID})['assign']({'timeshift':_0x2472b3})[_0x51aeae(0x313)](),config[_0x51aeae(0x368)]=_0x2472b3,proxyEmit(_0x51aeae(0x1fb),emittedConfiguration());}function updateOnepagemode(_0x3e9abd){const _0x481e0c=_0x11db1f;let _0x3bda78=dbConfig[_0x481e0c(0x206)](_0x481e0c(0x260))['find']({'botID':botID})['value']();_0x3bda78&&dbConfig[_0x481e0c(0x206)](_0x481e0c(0x260))['find']({'botID':botID})['assign']({'onepagemode':_0x3e9abd})[_0x481e0c(0x313)](),config[_0x481e0c(0x329)]=_0x3e9abd,proxyEmit(_0x481e0c(0x1fb),emittedConfiguration());}function updateMarketcapApi(_0xfdb415){const _0x14ea0c=_0x11db1f,_0x1df3ee=_0xfdb415?!![]:![];let _0x3a0344=dbConfig['get'](_0x14ea0c(0x260))['find']({'botID':botID})[_0x14ea0c(0x2b6)]();_0x3a0344&&dbConfig['get'](_0x14ea0c(0x260))[_0x14ea0c(0x21a)]({'botID':botID})[_0x14ea0c(0x1c1)]({'marketcapApi':_0x1df3ee})['write'](),config[_0x14ea0c(0x2c2)]=_0x1df3ee,getMarketCap(),proxyEmit('configuration',emittedConfiguration());}async function storeConfiguration(_0x38d335){const _0x4290f3=_0x11db1f;logger[_0x4290f3(0x20c)]('Saving\x20configuration');_0x38d335[_0x4290f3(0x24a)]&&delete _0x38d335[_0x4290f3(0x24a)];if(pidBalances)clearTimeout(pidBalances);setBlockTransactionDetection(!![]);let _0x2f8572=![],_0x19a298=![],_0x1e2944=[];_0x38d335[_0x4290f3(0x34c)][_0x4290f3(0x1d7)](_0x153763=>{const _0x629ec9=_0x4290f3;if(!_0x153763[_0x629ec9(0x30f)]&&_0x153763['coin']!=_0x38d335[_0x629ec9(0x35c)])_0x1e2944[_0x629ec9(0x350)](_0x153763['symbol']);}),_0x1e2944[_0x4290f3(0x1d7)](_0xe083a4=>{const _0x2d0412=_0x4290f3,_0x2eba6a=currentCoins[_0x2d0412(0x21a)](_0x1ad750=>_0x1ad750[_0x2d0412(0x249)]==_0xe083a4);!_0x2eba6a&&(_0x2f8572=!![]);}),currentCoins[_0x4290f3(0x1d7)](_0x17941f=>{const _0x240f3e=_0x4290f3;if(_0x17941f['coin']!=config[_0x240f3e(0x35c)]){const _0x34384c=_0x1e2944[_0x240f3e(0x21a)](_0x230d9c=>_0x230d9c==_0x17941f[_0x240f3e(0x249)]);!_0x34384c&&(_0x2f8572=!![]);}}),_0x38d335[_0x4290f3(0x34c)]['forEach'](_0x20e4e2=>{const _0x5c941e=_0x4290f3,_0x387bfc=config[_0x5c941e(0x34c)][_0x5c941e(0x21a)](_0x54408b=>_0x54408b['coin']==_0x20e4e2[_0x5c941e(0x23b)]);if(_0x387bfc&&_0x20e4e2[_0x5c941e(0x304)]!=_0x387bfc[_0x5c941e(0x304)])_0x19a298=!![];});let _0x56c96f=dbConfig[_0x4290f3(0x206)](_0x4290f3(0x260))[_0x4290f3(0x21a)]({'botID':botID})[_0x4290f3(0x2b6)]();_0x38d335={..._0x38d335,'apiKey':decryptRSA(secure[_0x4290f3(0x1b6)],_0x38d335[_0x4290f3(0x274)]),'apiSecret':decryptRSA(secure['privateKey'],_0x38d335[_0x4290f3(0x23a)])};_0x38d335[_0x4290f3(0x1e1)]&&(_0x38d335['apiPassword']=decryptRSA(secure[_0x4290f3(0x1b6)],_0x38d335[_0x4290f3(0x1e1)]));let _0x6df00e=![];if(_0x56c96f){_0x38d335[_0x4290f3(0x274)]==_0x4290f3(0x242)?_0x38d335['apiKey']=config['apiKey']:_0x6df00e=!![];_0x38d335[_0x4290f3(0x23a)]==_0x4290f3(0x242)?_0x38d335['apiSecret']=config['apiSecret']:_0x6df00e=!![];if(_0x38d335[_0x4290f3(0x1e1)]==_0x4290f3(0x242))_0x38d335[_0x4290f3(0x1e1)]=config['apiPassword'];else{if(_0x38d335['apiPassword'])_0x6df00e=!![];}dbConfig[_0x4290f3(0x206)](_0x4290f3(0x260))[_0x4290f3(0x21a)]({'botID':botID})[_0x4290f3(0x1c1)](_0x38d335)[_0x4290f3(0x313)]();}else dbConfig[_0x4290f3(0x206)](_0x4290f3(0x260))[_0x4290f3(0x350)](_0x38d335)[_0x4290f3(0x313)](),_0x6df00e=!![],process['send']({'status':_0x4290f3(0x27e),'live':'running'},_0x1ed615=>{});process[_0x4290f3(0x347)]({'botname':_0x38d335['botname']},_0x43fd91=>{}),config={..._0x38d335},updateBotManager(),proxyEmit(_0x4290f3(0x36b)),setStartDatePerformance(),initialPerformanceStored=![],await initCoinResults();if(_0x6df00e)await reset(!![]);else _0x2f8572||_0x19a298?await reset(![]):getBalances();setBlockTransactionDetection(![]);}async function storeHeadless(_0x439ecc){const _0x4b52c3=_0x11db1f,_0xc20f88={...config,'headless':_0x439ecc[_0x4b52c3(0x302)]};let _0x474bcf=dbConfig['get']('bot')[_0x4b52c3(0x21a)]({'botID':botID})[_0x4b52c3(0x2b6)]();_0x474bcf&&dbConfig[_0x4b52c3(0x206)](_0x4b52c3(0x260))['find']({'botID':botID})[_0x4b52c3(0x1c1)](_0xc20f88)[_0x4b52c3(0x313)](),config={..._0xc20f88},updateBotManager(),proxyEmit('configuration',emittedConfiguration());}async function storeFiat(_0x1c1a6d){const _0x2b7477=_0x11db1f,_0x466b9d={...config,'fiat':_0x1c1a6d};let _0xb80e1b=dbConfig[_0x2b7477(0x206)](_0x2b7477(0x260))[_0x2b7477(0x21a)]({'botID':botID})['value']();_0xb80e1b&&dbConfig[_0x2b7477(0x206)]('bot')['find']({'botID':botID})[_0x2b7477(0x1c1)](_0x466b9d)['write'](),config={..._0x466b9d},proxyEmit(_0x2b7477(0x1fb),emittedConfiguration());}function resetHistory(){const _0x2bb92d=_0x11db1f;logger[_0x2bb92d(0x271)]('Resetting\x20bot\x20history');try{if(fs[_0x2bb92d(0x1be)](path[_0x2bb92d(0x1bc)](configpath,_0x2bb92d(0x25a)+botID+'-events.json')))fs['unlinkSync'](path['join'](configpath,_0x2bb92d(0x25a)+botID+_0x2bb92d(0x1db)));if(fs[_0x2bb92d(0x1be)](path[_0x2bb92d(0x1bc)](configpath,_0x2bb92d(0x25a)+botID+_0x2bb92d(0x2a2))))fs[_0x2bb92d(0x2b1)](path[_0x2bb92d(0x1bc)](configpath,'bot-'+botID+'-performance.json'));if(fs[_0x2bb92d(0x1be)](path[_0x2bb92d(0x1bc)](configpath,_0x2bb92d(0x25a)+botID+'-results.json')))fs[_0x2bb92d(0x2b1)](path[_0x2bb92d(0x1bc)](configpath,'bot-'+botID+_0x2bb92d(0x1cc)));}catch(_0x285f57){if(_0x285f57)logger[_0x2bb92d(0x271)]('Error\x20while\x20deleting\x20files:\x20',_0x285f57);}const _0x40a287=getDate();let _0x2d885b=[];currentCoins[_0x2bb92d(0x1d7)](_0x15728c=>{const _0x53ffb2=_0x2bb92d;_0x2d885b['push']({'coin':_0x15728c[_0x53ffb2(0x23b)],'number':_0x15728c[_0x53ffb2(0x358)],'price':_0x15728c[_0x53ffb2(0x344)]});});let _0x49e0b0=dbConfig[_0x2bb92d(0x206)](_0x2bb92d(0x260))[_0x2bb92d(0x21a)]({'botID':botID})[_0x2bb92d(0x2b6)]();_0x49e0b0&&(dbConfig[_0x2bb92d(0x206)](_0x2bb92d(0x260))['find']({'botID':botID})[_0x2bb92d(0x1c1)]({'liquidity':[{'date':_0x40a287,'changes':_0x2d885b}]})['write'](),config[_0x2bb92d(0x1c7)]=[]),restartBot(!![]);}function noslash(_0x20a848){const _0x569ecc=_0x11db1f;return _0x20a848[_0x569ecc(0x1dc)]('/','');}function updateHighestFee(_0x1a9d5f){const _0x2c2328=_0x11db1f;if(_0x1a9d5f[_0x2c2328(0x2bb)]){let _0x3b8b22={'filled':_0x1a9d5f[_0x2c2328(0x343)]*_0x1a9d5f[_0x2c2328(0x2d4)],'amount':_0x1a9d5f[_0x2c2328(0x343)]*_0x1a9d5f[_0x2c2328(0x2d4)],'side':_0x1a9d5f['side']=='sell'?_0x2c2328(0x371):_0x2c2328(0x355),'price':0x1/_0x1a9d5f[_0x2c2328(0x2d4)]};_0x1a9d5f={..._0x1a9d5f,..._0x3b8b22};}const _0x32385f=defaultFee*_0x1a9d5f[_0x2c2328(0x343)]*_0x1a9d5f['price'];lastFees[_0x2c2328(0x2df)]['length']===0x14&&lastFees[_0x2c2328(0x2df)][_0x2c2328(0x2e1)](),lastFees['recent20']['push'](_0x32385f),lastFees[_0x2c2328(0x1c2)]=Math['max'](...lastFees[_0x2c2328(0x2df)]);}async function updateNumberCoinsCcxt(_0x24159a){const _0x826801=_0x11db1f;logger['debug'](_0x826801(0x301)+_0x24159a[_0x826801(0x249)]+_0x826801(0x2a6)+_0x24159a[_0x826801(0x308)]+_0x826801(0x2a6)+_0x24159a[_0x826801(0x343)]+'\x20/\x20'+_0x24159a['amount']+'\x20|\x20'+_0x24159a['id']);let _0x5e8071=_0x24159a['status'],_0x255f0d=![];currentCoins[_0x826801(0x1d7)](_0x11799e=>{const _0xdaed1f=_0x826801;_0x11799e[_0xdaed1f(0x249)]==_0x24159a[_0xdaed1f(0x249)]&&(_0x255f0d=!![]);});if(!_0x255f0d)return;const _0x4d01fa=currentCoins[_0x826801(0x21a)](_0x107081=>_0x107081[_0x826801(0x249)]==_0x24159a['symbol']),_0x2ea10d=_0x4d01fa['coin'],_0x35c634=_0x3211c7=>{const _0x3fd390=_0x826801,_0x203970=currentCoins[_0x3fd390(0x21a)](_0x586082=>_0x586082['symbol']==_0x24159a[_0x3fd390(0x249)]);if(_0x203970)_0x203970[_0x3fd390(0x20f)]=_0x3211c7;};let _0x1357bd=![];for(const _0x10524f of lastOrders){const _0x52542b=0x64,_0xfd093c=0x1388;let _0x345d7a=0x0;while(!_0x10524f[_0x826801(0x2e0)]&&_0x345d7a*_0x52542b<_0xfd093c){_0x345d7a++,await sleep(_0x52542b);}if(_0x345d7a>0x0)logger[_0x826801(0x20c)](_0x826801(0x36a)+_0x345d7a*_0x52542b/0x3e8+_0x826801(0x310));_0x10524f[_0x826801(0x2e0)]==_0x24159a['id']&&(_0x1357bd=!![]);}if(_0x5e8071=='open'){_0x35c634(_0x826801(0x1ab));if(_0x24159a['filled']>0x0&&_0x24159a[_0x826801(0x343)]<_0x24159a['amount']){if(_0x1357bd){setBlockTransactionDetection(!![]),logger[_0x826801(0x20c)](_0x826801(0x232)+_0x24159a[_0x826801(0x343)]+_0x826801(0x30a)+_0x24159a['id']);const _0x5f56bc=await getCoins(balanceUpdateDelay,undefined,undefined,_0x2ea10d);[currentCoins,currentCoinsAll]=_0x5f56bc,setBlockTransactionDetection(![]);}else logger[_0x826801(0x20c)](_0x826801(0x232)+_0x24159a[_0x826801(0x343)]+_0x826801(0x270)+_0x24159a['id']),setBlockTransactionDetection(![]),await detectLiquidityChange(balanceUpdateDelay);}}else{if(_0x5e8071==_0x826801(0x1c5)){_0x35c634(_0x826801(0x1c5)),lastOrders=lastOrders[_0x826801(0x2e2)](_0x848686=>_0x848686[_0x826801(0x249)]!=_0x24159a[_0x826801(0x249)]);const _0x5a81b3=await getCoins(balanceUpdateDelay);[currentCoins,currentCoinsAll]=_0x5a81b3,setBlockTransactionDetection(![]),await getOpenOrders(),handleOpenOrders();}else{if(_0x5e8071=='closed'){if(lastOrders)for(const _0x348535 of lastOrders){if(_0x348535['orderId']==_0x24159a['id']){logger[_0x826801(0x20c)](_0x826801(0x2bc)+_0x24159a['id']),_0x1357bd=!![];if(_0x348535[_0x826801(0x343)]==0x0){setBlockTransactionDetection(!![]),logger[_0x826801(0x20c)](_0x826801(0x214)+_0x24159a['id']);if(_0x24159a[_0x826801(0x275)])_0x348535[_0x826801(0x2d4)]=_0x24159a['average'];else{if(_0x24159a[_0x826801(0x2d4)])_0x348535[_0x826801(0x2d4)]=_0x24159a[_0x826801(0x2d4)];else{}}_0x348535['filled']=_0x24159a[_0x826801(0x343)],updateHighestFee(_0x348535);const _0xc41da1=await getCoins(balanceUpdateDelay,undefined,undefined,_0x2ea10d);[currentCoins,currentCoinsAll]=_0xc41da1,setBlockTransactionDetection(![]),await validateOrders(),_0x35c634(_0x826801(0x343)),_0x348535[_0x826801(0x306)]={'currency':_0x24159a[_0x826801(0x306)]?_0x24159a[_0x826801(0x306)][_0x826801(0x2b3)]:null,'cost':_0x24159a['fee']?_0x24159a[_0x826801(0x306)][_0x826801(0x35b)]:0x0},await updatePnL(_0x348535);}}}!_0x1357bd&&(logger[_0x826801(0x20c)](_0x826801(0x241)+_0x24159a['id']),_0x35c634(_0x826801(0x343)),setBlockTransactionDetection(![]),await detectLiquidityChange(balanceUpdateDelay),await updateOpenOrders(),handleOpenOrders());}}}if(lastBalances){let _0x33dffb=JSON['parse'](lastBalances[_0x826801(0x34c)]);const _0x4ab334=_0x33dffb[_0x826801(0x21a)](_0x4237e3=>_0x4237e3[_0x826801(0x249)]==_0x24159a[_0x826801(0x249)]);if(_0x4ab334){if(_0x5e8071==_0x826801(0x1ab))_0x4ab334['orderstatus']=_0x4ab334[_0x826801(0x20f)]=='filled'?'filled':_0x826801(0x1ab);else{if(_0x5e8071==_0x826801(0x1c5))_0x4ab334['orderstatus']=_0x4ab334[_0x826801(0x20f)]==_0x826801(0x343)?_0x826801(0x343):'canceled';else _0x5e8071==_0x826801(0x312)&&(_0x4ab334[_0x826801(0x20f)]=_0x826801(0x343));}}lastBalances={...lastBalances,'portfolio':JSON[_0x826801(0x341)](_0x33dffb)},proxyEmit(_0x826801(0x21f),{'serverversion':serverversion,'balances':lastBalances});}}async function updateOpenOrders(){const _0x52cc0f=_0x11db1f;await getOpenOrders();let _0x48fa84=![];currentCoins[_0x52cc0f(0x1d7)](_0x263d4b=>{const _0x13f311=_0x52cc0f;_0x48fa84=allOpenOrders[_0x13f311(0x21a)](_0x5f7d30=>_0x5f7d30[_0x13f311(0x249)]==_0x263d4b['symbol']),_0x263d4b['orderstatus']=_0x48fa84?'open':_0x13f311(0x2dd);});}async function fetchBalance(_0x126a07=!![]){const _0x1f8585=_0x11db1f;let _0x527a1c,_0x473b77,_0x5b24,_0xc922fe=0x0;while(!_0x473b77&&_0xc922fe<maxRetries){try{return _0x527a1c=await exchange[_0x1f8585(0x1b8)](),_0x473b77=_0x527a1c[_0x1f8585(0x1ad)],_0x473b77;}catch(_0x388703){_0x5b24=_0x388703,_0xc922fe++,await sleep(retryInterval);}}return!_0x126a07?handleErrorNoStop(_0x5b24,_0x1f8585(0x1ae)):await handleError(_0x5b24,_0x1f8585(0x1ae)),![];}async function getCoins(_0x3f51d9=0x0,_0x5d702d=!![],_0x9b8fd9=config[_0x11db1f(0x35c)],_0x18a1d6){const _0x5c71aa=_0x11db1f;let _0x5b8017=[],_0x17b096=[],_0x442427=[],_0x13c215;if(_0x3f51d9)await sleep(_0x3f51d9);if(botPaused)return[currentCoins,currentCoinsAll];let _0x32fbc6=![],_0x16a1ec=0x0,_0x59f473,_0x20f3c4;_0x18a1d6&&(_0x59f473=currentCoins[_0x5c71aa(0x21a)](_0x40ddd4=>_0x40ddd4[_0x5c71aa(0x23b)]==_0x18a1d6),_0x59f473&&(_0x20f3c4=_0x59f473['prevnumber'],delete _0x59f473[_0x5c71aa(0x2e4)]));while(!_0x32fbc6){_0x13c215=await fetchBalance(_0x5d702d);if(_0x13c215){if(_0x18a1d6){if(_0x13c215[_0x18a1d6]!=_0x20f3c4)logger['debug']('Valid\x20balance\x20for\x20'+_0x18a1d6+':\x20'+_0x13c215[_0x18a1d6]+'\x20('+_0x20f3c4+')'),_0x32fbc6=!![];else{logger[_0x5c71aa(0x20c)](_0x5c71aa(0x1cb)+_0x18a1d6+':\x20'+_0x13c215[_0x18a1d6]+'\x20('+_0x20f3c4+')'),_0x16a1ec++;if(_0x16a1ec<balanceUpdateRetries)await sleep(balanceUpdateDelay);else{logger[_0x5c71aa(0x20c)]('Stopped\x20fetching\x20balance\x20after\x20'+_0x16a1ec+_0x5c71aa(0x315));break;}}}else break;}else return[currentCoins,currentCoinsAll];}for(const [_0x5195ce,_0x22fc18]of Object[_0x5c71aa(0x23f)](_0x13c215)){_0x442427[_0x5c71aa(0x350)](_0x5195ce);}config[_0x5c71aa(0x34c)][_0x5c71aa(0x1d7)](_0x247b6f=>{const _0x2d1ead=_0x5c71aa;!_0x442427[_0x2d1ead(0x29b)](_0x247b6f[_0x2d1ead(0x23b)])&&(_0x13c215[_0x247b6f[_0x2d1ead(0x23b)]]=0x0);});if(_0x9b8fd9=='')for(const [_0x121493,_0x57cb3f]of Object[_0x5c71aa(0x23f)](_0x13c215)){_0x57cb3f!=0x0&&_0x5b8017[_0x5c71aa(0x350)]({'coin':_0x121493});}else for(const [_0x1aa971,_0x5a69a5]of Object['entries'](_0x13c215)){const _0x1514b6=config[_0x5c71aa(0x34c)][_0x5c71aa(0x21a)](_0xe04e08=>_0xe04e08['coin']==_0x1aa971),_0x20293a=_0x1aa971+'/'+_0x9b8fd9,_0x251f4d=_0x9b8fd9+'/'+_0x1aa971,_0x24caf7=currentCoins['find'](_0xbc05fb=>_0xbc05fb['coin']==_0x1aa971);if((_0x5a69a5!=0x0||_0x1514b6)&&(allSymbols[_0x5c71aa(0x29b)](_0x20293a)||_0x1aa971==_0x9b8fd9))_0x24caf7?_0x5b8017[_0x5c71aa(0x350)]({..._0x24caf7,'number':Math[_0x5c71aa(0x210)](_0x5a69a5+(_0x1514b6&&_0x1514b6['offset']||0x0),0x0)}):_0x5b8017[_0x5c71aa(0x350)]({'coin':_0x1aa971,'symbol':_0x20293a,'reverse':![],'number':Math['max'](_0x5a69a5+(_0x1514b6&&_0x1514b6[_0x5c71aa(0x304)]||0x0),0x0),'orderstatus':_0x5c71aa(0x2dd)});else{if((_0x5a69a5!=0x0||_0x1514b6)&&allSymbols[_0x5c71aa(0x29b)](_0x251f4d))_0x24caf7?_0x5b8017['push']({..._0x24caf7,'number':Math[_0x5c71aa(0x210)](_0x5a69a5+(_0x1514b6&&_0x1514b6['offset']||0x0),0x0)}):_0x5b8017[_0x5c71aa(0x350)]({'coin':_0x1aa971,'symbol':_0x251f4d,'reverse':!![],'number':Math['max'](_0x5a69a5+(_0x1514b6&&_0x1514b6[_0x5c71aa(0x304)]||0x0),0x0),'orderstatus':_0x5c71aa(0x2dd)});else _0x1514b6&&_0x5b8017[_0x5c71aa(0x350)]({'coin':_0x1514b6['coin'],'symbol':_0x1514b6['symbol'],'reverse':_0x1514b6[_0x5c71aa(0x2bb)],'number':0x0,'orderstatus':_0x5c71aa(0x2dd)});}}return _0x5b8017[_0x5c71aa(0x2bd)]((_0x2e6255,_0x581057)=>_0x2e6255[_0x5c71aa(0x19a)]<_0x581057[_0x5c71aa(0x19a)]?0x1:_0x581057['delta']<_0x2e6255[_0x5c71aa(0x19a)]?-0x1:0x0),_0x17b096=cloneDeep(_0x5b8017),_0x5b8017=_0x5b8017[_0x5c71aa(0x2e2)](_0x3ad49f=>{const _0x26fee8=_0x5c71aa,_0x2a15d9=config[_0x26fee8(0x34c)]['find'](_0x1d5eac=>_0x1d5eac[_0x26fee8(0x23b)]==_0x3ad49f[_0x26fee8(0x23b)]);return _0x2a15d9&&!_0x2a15d9['excluded'];}),[_0x5b8017,_0x17b096];}async function getOpenOrders(){const _0x255811=_0x11db1f;let _0x3b29f9;allOpenOrders=[];try{for(const _0x49ed92 of config[_0x255811(0x34c)]){!_0x49ed92[_0x255811(0x30f)]&&_0x49ed92[_0x255811(0x23b)]!=config['basecoin']&&(_0x3b29f9=await exchange[_0x255811(0x1f7)](_0x49ed92['symbol']),_0x3b29f9[_0x255811(0x25c)]>0x0&&allOpenOrders[_0x255811(0x350)](_0x3b29f9[0x0]));}}catch(_0x2ae8d){await handleError(_0x2ae8d,_0x255811(0x327));}}async function handleOpenOrders(_0x5249b5=0x0){const _0x2af277=_0x11db1f;allOpenOrders[_0x2af277(0x25c)]==0x0&&lockOrders==ORDERS[_0x2af277(0x307)]&&allOrdersPlaced&&(_0x5249b5==0x0?(logger[_0x2af277(0x20c)](_0x2af277(0x287)),_0x5249b5++,await sleep(0xbb8),await getOpenOrders(),handleOpenOrders(0x1)):(logger[_0x2af277(0x20c)](_0x2af277(0x1da)),validateOrders(_0x2af277(0x26e))));}async function testAPI(){const _0x40e888=_0x11db1f;try{return await exchange[_0x40e888(0x1b8)](),!![];}catch(_0x14525a){loading[_0x40e888(0x2ec)]=!![],_0x14525a['toString']()['toLowerCase']()[_0x40e888(0x29b)]('timestamp')||_0x14525a['toString']()[_0x40e888(0x204)]()[_0x40e888(0x29b)]('request-time')?(logHistory(_0x40e888(0x237),_0x40e888(0x365)),loading['error']=_0x40e888(0x1e4)):handleErrorNoStop(_0x14525a,_0x40e888(0x349),!![]),logHistory('error',_0x40e888(0x32e)),logHistory(_0x40e888(0x237),_0x40e888(0x1c4)+loadCoinsRetryInterval/0xea60+_0x40e888(0x1bd)),logger[_0x40e888(0x20c)](_0x40e888(0x338),_0x14525a),emitLoadingProgress(),botPaused=!![],await sleep(loadCoinsRetryInterval),restartBot();}}async function testNewAPI(_0x31a2ab){const _0x29200a=_0x11db1f;logger['debug'](_0x29200a(0x289));const _0x387749=ccxt['pro'][_0x31a2ab['exchange'][_0x29200a(0x204)]()],_0x430f7e=new _0x387749({'apiKey':_0x31a2ab[_0x29200a(0x274)],'secret':_0x31a2ab[_0x29200a(0x23a)],'options':{'defaultType':'spot'}});if(_0x31a2ab[_0x29200a(0x1e1)])_0x430f7e[_0x29200a(0x1fe)]=_0x31a2ab['apiPassword'];if(_0x430f7e[_0x29200a(0x2d2)]['sandbox'])_0x430f7e['setSandboxMode'](_0x31a2ab['sandbox']);try{await _0x430f7e['fetchBalance'](),botPaused=![];}catch(_0x482186){logger[_0x29200a(0x20c)]('Error\x20in\x20testNewAPI():\x20'+_0x482186['toString']());throw _0x482186;}}function cloneDeep(_0x31c456){const _0x4aadd3=_0x11db1f;return JSON[_0x4aadd3(0x1f4)](JSON[_0x4aadd3(0x341)](_0x31c456));}async function getPortfolio(_0x353f33){const _0x2f138a=_0x11db1f;let _0x4235ff=[],_0x4360ee=[],_0x55a624=[],_0x291e38;_0x353f33[_0x2f138a(0x274)]=decryptRSA(secure[_0x2f138a(0x1b6)],_0x353f33[_0x2f138a(0x274)]),_0x353f33[_0x2f138a(0x23a)]=decryptRSA(secure[_0x2f138a(0x1b6)],_0x353f33[_0x2f138a(0x23a)]);if(_0x353f33[_0x2f138a(0x1e1)])_0x353f33[_0x2f138a(0x1e1)]=decryptRSA(secure['privateKey'],_0x353f33[_0x2f138a(0x1e1)]);if(_0x353f33[_0x2f138a(0x274)]!==_0x2f138a(0x242)||_0x353f33[_0x2f138a(0x23a)]!==_0x2f138a(0x242)||_0x353f33[_0x2f138a(0x1e1)]&&_0x353f33[_0x2f138a(0x1e1)]!==_0x2f138a(0x242)){if(config['exchange']){if(_0x353f33[_0x2f138a(0x274)]==_0x2f138a(0x242))_0x353f33[_0x2f138a(0x274)]=config['apiKey'];if(_0x353f33['apiSecret']==_0x2f138a(0x242))_0x353f33[_0x2f138a(0x23a)]=config[_0x2f138a(0x23a)];if(_0x353f33[_0x2f138a(0x1e1)]=='************')_0x353f33[_0x2f138a(0x1e1)]=config[_0x2f138a(0x1e1)];}try{if(_0x353f33[_0x2f138a(0x225)])await testNewAPI(_0x353f33);}catch(_0x457cd3){if(_0x457cd3[_0x2f138a(0x361)]()[_0x2f138a(0x29b)](_0x2f138a(0x28d))){logHistory(_0x2f138a(0x237),_0x2f138a(0x247)),logHistory(_0x2f138a(0x237),'Error\x20details:\x20'+_0x457cd3[_0x2f138a(0x361)]()),proxyEmit(_0x2f138a(0x2dc),![]);return;}else{if(_0x457cd3[_0x2f138a(0x361)]()[_0x2f138a(0x29b)](_0x2f138a(0x1ef))){logHistory('error','Exchange\x20permission\x20denied\x20-\x20make\x20sure\x20your\x20machine\x27s\x20IP\x20address\x20is\x20whitelisted\x20for\x20this\x20API\x20key\x20on\x20the\x20exchange'),logHistory(_0x2f138a(0x237),'Error\x20details:\x20'+_0x457cd3[_0x2f138a(0x361)]()),proxyEmit('portfolio1',![]);return;}else{logHistory(_0x2f138a(0x237),_0x2f138a(0x2a9)+_0x457cd3['toString']()),logger[_0x2f138a(0x20c)](_0x2f138a(0x338),_0x457cd3),proxyEmit(_0x2f138a(0x2dc),![]);return;}}}exchange?updateExchange(_0x353f33['apiKey'],_0x353f33[_0x2f138a(0x23a)],_0x353f33['apiPassword']):await initExchange(_0x353f33[_0x2f138a(0x2d0)],_0x353f33[_0x2f138a(0x274)],_0x353f33['apiSecret'],_0x353f33[_0x2f138a(0x1e1)],_0x353f33[_0x2f138a(0x262)]);await loadSymbols();const _0x50018b=await getCoins(0x0,![],_0x353f33[_0x2f138a(0x35c)]);_0x55a624=cloneDeep(_0x50018b[0x1]);}else{const _0x1f933b=await getCoins();_0x55a624=cloneDeep(_0x1f933b[0x1]);}if(_0x353f33['basecoin']=='')proxyEmit(_0x2f138a(0x2dc),!![]),proxyEmit(_0x2f138a(0x300),_0x55a624);else{_0x55a624['forEach'](_0x579c6f=>{const _0x3c9826=_0x2f138a;if(_0x579c6f[_0x3c9826(0x23b)]!=_0x353f33[_0x3c9826(0x35c)]&&allSymbols[_0x3c9826(0x29b)](_0x579c6f['symbol']))_0x4235ff[_0x3c9826(0x350)](_0x579c6f['symbol']);});if(_0x4235ff['length']==0x0)logHistory(_0x2f138a(0x237),'Make\x20sure\x20your\x20portfolio\x20contains\x20more\x20than\x20just\x20the\x20base\x20coin,\x20then\x20restart\x20the\x20bot');else{try{_0x4360ee=await getTickers(_0x4235ff);}catch(_0xf1a26f){logHistory('error','Unknown\x20error\x20-\x20check\x20logs'),logger[_0x2f138a(0x20c)](_0x2f138a(0x338),_0xf1a26f),proxyEmit(_0x2f138a(0x2dc),![]);return;}_0x55a624['forEach'](_0x216eba=>{const _0x2d040a=_0x2f138a;_0x216eba[_0x2d040a(0x23b)]!=_0x353f33[_0x2d040a(0x35c)]?_0x4360ee[_0x216eba[_0x2d040a(0x249)]]?_0x4360ee[_0x216eba['symbol']][_0x2d040a(0x344)]?_0x291e38=_0x216eba['reverse']?0x1/_0x4360ee[_0x216eba[_0x2d040a(0x249)]]['last']:_0x4360ee[_0x216eba[_0x2d040a(0x249)]][_0x2d040a(0x344)]:_0x291e38=0x0:_0x291e38=0x0:_0x291e38=0x1,_0x216eba['price']=formatResult(_0x291e38,0x8);}),await getMarketCap(_0x55a624),proxyEmit(_0x2f138a(0x2dc),!![]),proxyEmit('portfolio2',_0x55a624);}}}function truncateTradeAmount(_0x4b683e,_0x1848d0){const _0x25a0a5=_0x11db1f;let _0x35b073=0x0;try{_0x35b073=exchange[_0x25a0a5(0x28a)](_0x4b683e,_0x1848d0);}catch(_0xfc32f4){}return _0x35b073;}function checkMinimums(_0x2d84ed){const _0x15c33a=_0x11db1f;let _0xcafe1d=!![];const _0x23283e=!_0x2d84ed[_0x15c33a(0x2bb)]?markets[_0x2d84ed['symbol']]['limits'][_0x15c33a(0x340)]['min']:markets[_0x2d84ed['symbol']][_0x15c33a(0x36c)][_0x15c33a(0x35b)][_0x15c33a(0x27c)],_0x5bfeca=!_0x2d84ed[_0x15c33a(0x2bb)]?markets[_0x2d84ed[_0x15c33a(0x249)]]['limits'][_0x15c33a(0x35b)][_0x15c33a(0x27c)]:markets[_0x2d84ed[_0x15c33a(0x249)]]['limits'][_0x15c33a(0x340)][_0x15c33a(0x27c)],_0x6ac9c2=truncateTradeAmount(_0x2d84ed[_0x15c33a(0x249)],_0x2d84ed[_0x15c33a(0x2d1)]);_0x2d84ed['trade']=_0x6ac9c2;if(Math[_0x15c33a(0x261)](_0x6ac9c2)<_0x23283e)_0xcafe1d=![];if(Math[_0x15c33a(0x261)](_0x6ac9c2)*_0x2d84ed[_0x15c33a(0x344)]<_0x5bfeca)_0xcafe1d=![];let _0x52e325='';if(_0x2d84ed[_0x15c33a(0x311)]==_0x15c33a(0x355)){let _0x2c0f52=config[_0x15c33a(0x34c)]['find'](_0x563959=>_0x563959[_0x15c33a(0x23b)]==_0x2d84ed[_0x15c33a(0x23b)]);_0x2c0f52[_0x15c33a(0x304)]>0x0?Math[_0x15c33a(0x261)](_0x6ac9c2)>_0x2d84ed[_0x15c33a(0x358)]-_0x2c0f52[_0x15c33a(0x304)]&&(_0xcafe1d=![],_0x52e325=_0x15c33a(0x36e)+_0x2c0f52[_0x15c33a(0x23b)]+_0x15c33a(0x1e3)):Math[_0x15c33a(0x261)](_0x6ac9c2)>_0x2d84ed['number']&&(_0xcafe1d=![]);}if(_0x2d84ed[_0x15c33a(0x311)]==_0x15c33a(0x371)){let _0x3128da=config[_0x15c33a(0x34c)][_0x15c33a(0x21a)](_0x1657bf=>_0x1657bf[_0x15c33a(0x23b)]==config[_0x15c33a(0x35c)]),_0x1f5c43=currentCoins[_0x15c33a(0x21a)](_0x46239a=>_0x46239a[_0x15c33a(0x23b)]==config[_0x15c33a(0x35c)]);_0x3128da[_0x15c33a(0x304)]>0x0?Math[_0x15c33a(0x261)](_0x6ac9c2)*_0x2d84ed[_0x15c33a(0x344)]>_0x1f5c43[_0x15c33a(0x358)]-_0x3128da[_0x15c33a(0x304)]&&(_0xcafe1d=![],_0x52e325=_0x15c33a(0x36e)+config[_0x15c33a(0x35c)]+_0x15c33a(0x1e3)):Math[_0x15c33a(0x261)](_0x6ac9c2)*_0x2d84ed[_0x15c33a(0x344)]>_0x1f5c43[_0x15c33a(0x358)]&&(_0xcafe1d=![]);}return!_0xcafe1d&&_0x52e325&&!insufficientFundsWarningSent[_0x15c33a(0x29b)](_0x2d84ed[_0x15c33a(0x23b)])&&(logHistory('warning',_0x52e325),insufficientFundsWarningSent[_0x15c33a(0x350)](_0x2d84ed['coin'])),_0xcafe1d;}async function getBalances(_0x1209ac=!![]){const _0x41bcc2=_0x11db1f;if(botPaused)return;let _0x2259eb=0x0,_0x5b928d;const _0x33dd88=config[_0x41bcc2(0x255)];if(config[_0x41bcc2(0x302)]&&config[_0x41bcc2(0x279)]<0x0)await validate24hChanges();currentCoins[_0x41bcc2(0x1d7)](_0x15c676=>{const _0x1c9ac5=_0x41bcc2;if(_0x15c676['coin']!=config[_0x1c9ac5(0x35c)]){let _0x371576=gTicker[noslash(_0x15c676['symbol'])];_0x5b928d=_0x15c676['reverse']?0x1/_0x371576:_0x371576;}else _0x5b928d=0x1;let _0x32be41=_0x15c676[_0x1c9ac5(0x358)]*_0x5b928d;_0x2259eb+=_0x32be41,_0x15c676[_0x1c9ac5(0x344)]=formatResult(Number(_0x5b928d),0x8),_0x15c676[_0x1c9ac5(0x2b6)]=_0x32be41;}),currentCoins[_0x41bcc2(0x1d7)](_0x5867df=>{const _0x34edf4=_0x41bcc2;let _0xee6565=config[_0x34edf4(0x34c)][_0x34edf4(0x21a)](_0x13abd1=>_0x13abd1[_0x34edf4(0x23b)]==_0x5867df[_0x34edf4(0x23b)]),_0x463c5e=Number(_0xee6565['distribution']),_0x3b2215=_0x5867df[_0x34edf4(0x2b6)]/_0x2259eb*0x64,_0x31472c=_0x463c5e*_0x2259eb/0x64/_0x5867df['last']-_0x5867df[_0x34edf4(0x358)];_0x5867df[_0x34edf4(0x1ff)]=formatResult(_0x3b2215,0x3),_0x5867df['target']=formatResult(_0x463c5e,0x3),_0x5867df[_0x34edf4(0x2d1)]=formatResult(_0x31472c,0x8),_0x5867df['side']='',_0x5867df[_0x34edf4(0x268)]=![];if(_0x5867df[_0x34edf4(0x23b)]!=config['basecoin']){if(_0x5867df[_0x34edf4(0x1ff)]>_0x463c5e)_0x5867df[_0x34edf4(0x311)]=_0x34edf4(0x355),_0x5867df[_0x34edf4(0x268)]=checkMinimums(_0x5867df);else _0x5867df[_0x34edf4(0x1ff)]<_0x463c5e&&(_0x5867df['side']=_0x34edf4(0x371),_0x5867df['valid']=checkMinimums(_0x5867df));}_0x5867df[_0x34edf4(0x19a)]=_0x5867df[_0x34edf4(0x1ff)]/_0x5867df[_0x34edf4(0x33b)]-0x1;if(_0x5867df[_0x34edf4(0x20f)]=='filled'||_0x5867df['orderstatus']==_0x34edf4(0x1c5))_0x5867df[_0x34edf4(0x20f)]=_0x34edf4(0x2dd);}),currentCoins['sort']((_0x5ec632,_0x57157a)=>_0x5ec632['delta']<_0x57157a[_0x41bcc2(0x19a)]?0x1:_0x57157a[_0x41bcc2(0x19a)]<_0x5ec632['delta']?-0x1:0x0);const _0x2eae7e=await getFiat();lastBalances={'servertime':getServerTime(),'time':getTimeStamp(),'eur':_0x2eae7e[_0x41bcc2(0x1a2)],'usd':_0x2eae7e[_0x41bcc2(0x318)],'portfolio':JSON['stringify'](currentCoins),'threshold':_0x33dd88},proxyEmit(_0x41bcc2(0x21f),{'serverversion':serverversion,'balances':lastBalances});if(_0x1209ac){if(config[_0x41bcc2(0x302)])headlessMode({'portfolio':currentCoins,'threshold':_0x33dd88});else lockOrders==ORDERS['UNLOCKED']&&!coolingDown&¬ifyBalance({'portfolio':currentCoins,'threshold':_0x33dd88});}if(!initialPerformanceStored){initialPerformanceStored=!![],await storePerformance();const _0x1069f2=getNormalizedPerformance();getStartingBalances(_0x1069f2),emitPerformance(_0x1069f2);}lastPerformanceStored!==getHour()&&(await storePerformance(),lastPerformanceEmitted!==getDate()&&emitPerformance(getNormalizedPerformance()));if(pidBalances)clearTimeout(pidBalances);pidBalances=setTimeout(getBalances,getBalancesInterval);}function getPnL(){const _0x4e59e2=_0x11db1f;let _0x48983d=dbCoinResults[_0x4e59e2(0x206)](_0x4e59e2(0x1a8))[_0x4e59e2(0x2b6)](),_0x4fc6c8=0x0;return Object[_0x4e59e2(0x23f)](_0x48983d)[_0x4e59e2(0x1d7)](([_0x170dfe,_0x908a3])=>{const _0x3153da=_0x4e59e2;_0x4fc6c8+=_0x908a3[_0x3153da(0x34d)];}),_0x4fc6c8;}async function storePerformance(){const _0x5a821d=_0x11db1f;if(!lastBalances)return;let _0x27e4f2=[],_0x45d5ad;const _0x5a6c8a=getPnL();let _0x2c334d=JSON[_0x5a821d(0x1f4)](lastBalances['portfolio']);_0x2c334d[_0x5a821d(0x2bd)]((_0x4528d7,_0x5a4386)=>_0x4528d7['coin']>_0x5a4386[_0x5a821d(0x23b)]?0x1:_0x5a4386['coin']>_0x4528d7[_0x5a821d(0x23b)]?-0x1:0x0),_0x2c334d[_0x5a821d(0x1d7)](_0x63a6eb=>{const _0x13eb1b=_0x5a821d;let _0x190c8c={'coin':_0x63a6eb[_0x13eb1b(0x23b)],'number':_0x63a6eb[_0x13eb1b(0x358)],'price':_0x63a6eb['last']};_0x27e4f2[_0x13eb1b(0x350)](_0x190c8c);});const _0xea3f71=await getFiat(),_0x5281c9=getTimeStamp()[_0x5a821d(0x1e8)]('\x20')[0x0],_0x4ddc81=dbPerformance[_0x5a821d(0x206)](_0x5a821d(0x320))['find']({'date':_0x5281c9})['value']();_0x45d5ad={'date':_0x5281c9,'eur':_0xea3f71[_0x5a821d(0x1a2)],'usd':_0xea3f71[_0x5a821d(0x318)],'coins':_0x27e4f2,'pnl':_0x5a6c8a},_0x4ddc81?_0x45d5ad[_0x5a821d(0x298)]!=config['startdate']&&dbPerformance['get'](_0x5a821d(0x320))[_0x5a821d(0x21a)]({'date':_0x5281c9})[_0x5a821d(0x1c1)](_0x45d5ad)['write']():dbPerformance[_0x5a821d(0x206)]('data')[_0x5a821d(0x350)](_0x45d5ad)[_0x5a821d(0x313)](),lastPerformanceStored=getHour();}function getNormalizedPerformance(){const _0x30b612=_0x11db1f;let _0xa414=[];if(dbPerformance[_0x30b612(0x2d2)](_0x30b612(0x320))[_0x30b612(0x2b6)]()){let _0x4be1a6=dbPerformance[_0x30b612(0x206)]('data')['cloneDeep']()[_0x30b612(0x2e2)](_0x581b13=>{const _0x4e8c8e=_0x30b612;if(_0x581b13[_0x4e8c8e(0x1a8)][_0x4e8c8e(0x25c)]==0x0)return![];else return!![];})[_0x30b612(0x360)]('date')['value'](),_0x2be10f=[...config['liquidity']];_0x2be10f[_0x30b612(0x2bd)]((_0x2c469a,_0x3a6638)=>_0x2c469a['date']>_0x3a6638[_0x30b612(0x298)]?-0x1:_0x3a6638[_0x30b612(0x298)]>_0x2c469a[_0x30b612(0x298)]?0x1:0x0);let _0x40a40e=0x1,_0x3bffcc=[],_0xfded05=0x0;_0x4be1a6[_0x30b612(0x354)]()['reverse']()[_0x30b612(0x1d7)]((_0x21aad7,_0x148bd1)=>{const _0x452aa8=_0x30b612;if(_0x2be10f[_0xfded05]){if(_0x4be1a6[_0x4be1a6[_0x452aa8(0x25c)]-_0x148bd1]&&_0x2be10f[_0xfded05][_0x452aa8(0x298)]==_0x4be1a6[_0x4be1a6['length']-_0x148bd1][_0x452aa8(0x298)]){if(_0x148bd1<_0x4be1a6[_0x452aa8(0x25c)]){let _0x1b3446=0x0,_0x2e3384=0x0;_0x4be1a6[_0x4be1a6['length']-_0x148bd1][_0x452aa8(0x1a8)]['forEach'](_0x3c5f61=>{const _0x18c043=_0x452aa8;_0x2e3384+=_0x3c5f61[_0x18c043(0x358)]*_0x3c5f61[_0x18c043(0x2d4)];}),_0x2be10f[_0xfded05][_0x452aa8(0x31a)][_0x452aa8(0x1d7)](_0x3e56d1=>{const _0x3f857d=_0x452aa8;_0x1b3446+=_0x3e56d1['number']*_0x3e56d1[_0x3f857d(0x2d4)];}),_0x40a40e*=_0x1b3446/(_0x2e3384-_0x1b3446)+0x1;}_0xfded05++;}}let _0x4da7a2=0x0;_0x21aad7['coins']['forEach'](_0x1d501a=>{const _0x172008=_0x452aa8;_0x4da7a2+=_0x1d501a[_0x172008(0x358)]*_0x1d501a[_0x172008(0x2d4)];}),_0x3bffcc[_0x4be1a6[_0x452aa8(0x25c)]-_0x148bd1-0x1]=_0x4da7a2*(_0x40a40e-0x1);});let _0x3c8876=[];_0x2be10f=[...config[_0x30b612(0x1c7)]]||[];let _0x4b9438=0x0;_0xfded05=0x0,_0x4be1a6[_0x30b612(0x1d7)]((_0x54b97c,_0x211644)=>{const _0x518f13=_0x30b612;if(_0x2be10f[_0xfded05]){const _0x2de440=fns[_0x518f13(0x1f4)](_0x2be10f[_0xfded05][_0x518f13(0x298)],'yyyy/MM/dd',new Date()),_0xa68193=fns[_0x518f13(0x1f4)](_0x54b97c[_0x518f13(0x298)],_0x518f13(0x31d),new Date());if(fns[_0x518f13(0x2a4)](_0x2de440,_0xa68193)){let _0x33c144=0x0;_0x2be10f[_0xfded05][_0x518f13(0x31a)]['forEach'](_0x386fa8=>{const _0x56abcb=_0x518f13;!_0x3c8876[_0x386fa8[_0x56abcb(0x23b)]]?_0x3c8876[_0x386fa8['coin']]=_0x386fa8['number']:(_0x33c144=_0x3c8876[_0x386fa8['coin']],_0x3c8876[_0x386fa8[_0x56abcb(0x23b)]]+=_0x386fa8[_0x56abcb(0x358)]);const _0x2c5b8c=_0x54b97c[_0x56abcb(0x1a8)]['find'](_0x5aa788=>_0x5aa788[_0x56abcb(0x23b)]==_0x386fa8[_0x56abcb(0x23b)]);(!_0x2c5b8c||_0x2c5b8c[_0x56abcb(0x358)]==0x0)&&(_0x4b9438+=(-_0x386fa8['number']-_0x33c144)*_0x386fa8[_0x56abcb(0x2d4)]);}),_0xfded05++;}}_0x54b97c[_0x518f13(0x1a8)]['forEach']((_0x4515ae,_0x195a51)=>{const _0x663c11=_0x518f13;_0x3c8876[_0x4515ae['coin']]&&(_0x4515ae[_0x663c11(0x26b)]=_0x3c8876[_0x4515ae['coin']]);}),_0xa414['push']({'date':_0x54b97c['date'],'eur':_0x54b97c[_0x518f13(0x1a2)],'usd':_0x54b97c['usd'],'offset':_0x3bffcc[_0x211644],'netoffset':_0x4b9438,'coins':_0x54b97c[_0x518f13(0x1a8)],'pnl':_0x54b97c[_0x518f13(0x256)]});});}return _0xa414;}function emitPerformance(_0x594ea6){const _0x502365=_0x11db1f;_0x594ea6['length']!==0x0?(proxyEmit(_0x502365(0x2de),_0x594ea6),lastPerformanceEmitted=getDate()):proxyEmit(_0x502365(0x2de),[]);}function getPerf(_0x290597,_0x216f63){const _0x18b57b=_0x11db1f;let _0x536979=0x0,_0x262d0c=0x0,_0x33f50a=0x0;_0x290597[_0x18b57b(0x1a8)][_0x18b57b(0x1d7)](_0x1c094d=>{const _0x7fbd0b=_0x18b57b;_0x536979+=_0x1c094d[_0x7fbd0b(0x358)]*_0x1c094d[_0x7fbd0b(0x2d4)];});_0x216f63&&(_0x536979+=_0x290597[_0x18b57b(0x304)]);if(config[_0x18b57b(0x35c)]===_0x18b57b(0x21d)||config[_0x18b57b(0x35c)]===_0x18b57b(0x35e)||config[_0x18b57b(0x35c)]===_0x18b57b(0x1a0))_0x262d0c=_0x536979*_0x290597[_0x18b57b(0x1a2)],_0x33f50a=_0x536979*_0x290597[_0x18b57b(0x318)];else{if(usdBasecoins[_0x18b57b(0x29b)](config[_0x18b57b(0x35c)]))_0x262d0c=_0x536979*_0x290597[_0x18b57b(0x1a2)]/_0x290597['usd'],_0x33f50a=_0x536979;else config['basecoin']===_0x18b57b(0x288)&&(_0x262d0c=_0x536979,_0x33f50a=_0x536979*_0x290597[_0x18b57b(0x318)]/_0x290597[_0x18b57b(0x1a2)]);}return[_0x536979,_0x262d0c,_0x33f50a];}function CurrencyFactor(_0x2bd211,_0xcb3e61,_0x2ce1db){const _0x460758=_0x11db1f;let _0x4d27ab;if(_0xcb3e61===_0x460758(0x21d)||_0xcb3e61===_0x460758(0x35e)||_0xcb3e61===_0x460758(0x1a0))_0x4d27ab=_0x2ce1db===_0x460758(0x288)?_0x2bd211[_0x460758(0x1a2)]:_0x2bd211['usd'];else{if(usdBasecoins['includes'](_0xcb3e61))_0x4d27ab=_0x2ce1db===_0x460758(0x288)?_0x2bd211['eur']/_0x2bd211[_0x460758(0x318)]:0x1;else _0xcb3e61===_0x460758(0x288)&&(_0x4d27ab=_0x2ce1db==='EUR'?0x1:_0x2bd211['usd']/_0x2bd211[_0x460758(0x1a2)]);}return _0x4d27ab;}function getKPIs(_0x2bacc4,_0x125617=_0x11db1f(0x288)){const _0x412cfe=_0x11db1f,_0x2ac305=config[_0x412cfe(0x35c)],_0x3e6f50=lastBalances,_0x3e701c=currentCoins,_0x1edfca=getNormalizedPerformance(),_0x17c981=CurrencyFactor(_0x3e6f50,config[_0x412cfe(0x35c)],_0x125617);let _0x6c98e6=0x0;_0x3e701c['forEach'](_0x4cd11b=>{const _0x1da447=_0x412cfe;_0x6c98e6+=_0x4cd11b[_0x1da447(0x358)]*_0x4cd11b[_0x1da447(0x344)];});_0x2bacc4[_0x412cfe(0x29b)]('fiat')&&(_0x6c98e6*=_0x17c981);let _0x32e271;if(_0x6c98e6!==0x0){if(_0x2bacc4===_0x412cfe(0x35c)||_0x2bacc4==='fiat'){if(_0x2bacc4===_0x412cfe(0x35c))_0x32e271=(_0x6c98e6/startingBalances[_0x412cfe(0x35c)]-0x1)*0x64;else{if(_0x125617===_0x412cfe(0x288))_0x32e271=(_0x6c98e6/startingBalances['eur']-0x1)*0x64;else _0x32e271=(_0x6c98e6/startingBalances[_0x412cfe(0x318)]-0x1)*0x64;}}if(_0x2bacc4[_0x412cfe(0x29b)](_0x412cfe(0x224))){let _0x49eefd=0x0;if(startingBalances[_0x412cfe(0x1a8)])_0x3e701c[_0x412cfe(0x1d7)](_0x2c8f93=>{const _0x540ce0=_0x412cfe;let _0x208e3d=startingBalances[_0x540ce0(0x1a8)][_0x540ce0(0x21a)](_0x3db136=>_0x3db136[_0x540ce0(0x23b)]===_0x2c8f93['coin']);if(_0x208e3d&&_0x208e3d[_0x540ce0(0x23b)]&&_0x2c8f93[_0x540ce0(0x358)]!==0x0)_0x49eefd+=_0x208e3d[_0x540ce0(0x358)]*_0x2c8f93['last'];});let _0x552513=0x0;if(_0x1edfca[_0x412cfe(0x25c)]!==0x0){let _0x5471db=_0x1edfca[_0x1edfca[_0x412cfe(0x25c)]-0x1];_0x552513=_0x5471db[_0x412cfe(0x1b4)];}_0x49eefd-=_0x552513;let _0x5714c8;_0x2bacc4===_0x412cfe(0x244)&&(_0x5714c8=startingBalances[_0x412cfe(0x35c)]),_0x2bacc4===_0x412cfe(0x36d)&&(_0x5714c8=_0x125617==='EUR'?startingBalances[_0x412cfe(0x1a2)]:startingBalances[_0x412cfe(0x318)],_0x49eefd*=_0x17c981),_0x32e271=(_0x6c98e6-_0x49eefd)/_0x5714c8*0x64,_0x6c98e6=_0x6c98e6-_0x49eefd;}if(_0x2bacc4[_0x412cfe(0x29b)](_0x412cfe(0x256))){if(_0x1edfca[_0x412cfe(0x25c)]!==0x0&&_0x3e701c[_0x412cfe(0x25c)]!==0x0){let _0x369cbf,_0x39c825=_0x1edfca[_0x1edfca['length']-0x1][_0x412cfe(0x256)];_0x2bacc4['includes']('fiat')?(_0x369cbf=_0x125617===_0x412cfe(0x288)?startingBalances[_0x412cfe(0x1a2)]:startingBalances[_0x412cfe(0x318)],_0x39c825*=CurrencyFactor(_0x3e6f50,_0x2ac305,_0x125617)):_0x369cbf=startingBalances['basecoin'],_0x32e271=_0x39c825/_0x369cbf*0x64,_0x6c98e6=_0x39c825;}}if(_0x32e271){if(_0x32e271<0x64)_0x32e271=_0x32e271[_0x412cfe(0x1a3)](0x2);else{if(_0x32e271<0x3e8)_0x32e271=_0x32e271[_0x412cfe(0x1a3)](0x1);else _0x32e271=_0x32e271[_0x412cfe(0x1a3)](0x0);}}else _0x32e271=Number('0')[_0x412cfe(0x1a3)](0x2);if(_0x6c98e6){if(Math[_0x412cfe(0x261)](_0x6c98e6)<0.000001)_0x6c98e6=_0x6c98e6[_0x412cfe(0x1a3)](0x2);else{if(Math[_0x412cfe(0x261)](_0x6c98e6)<0.1)_0x6c98e6=_0x6c98e6[_0x412cfe(0x1a3)](0x6);else{if(Math[_0x412cfe(0x261)](_0x6c98e6)<0x1)_0x6c98e6=_0x6c98e6[_0x412cfe(0x1a3)](0x5);else{if(Math[_0x412cfe(0x261)](_0x6c98e6)<0xa)_0x6c98e6=_0x6c98e6[_0x412cfe(0x1a3)](0x4);else{if(Math[_0x412cfe(0x261)](_0x6c98e6)<0x64)_0x6c98e6=_0x6c98e6[_0x412cfe(0x1a3)](0x3);else{if(Math[_0x412cfe(0x261)](_0x6c98e6)<0x3e8)_0x6c98e6=_0x6c98e6[_0x412cfe(0x1a3)](0x2);else _0x6c98e6=_0x6c98e6[_0x412cfe(0x1a3)](0x2);}}}}}}else _0x6c98e6=Number('0')[_0x412cfe(0x1a3)](0x2);}else _0x32e271=Number('0')['toFixed'](0x2);if(_0x32e271>=0x0)_0x32e271='+'+_0x32e271;return{'value':_0x6c98e6,'change':_0x32e271};}async function getStartingBalances(_0x3b19ab,_0x25cf54=!![]){const _0x1fb8f2=_0x11db1f;if(_0x3b19ab[_0x1fb8f2(0x25c)]!==0x0){const [_0x522602,_0x318920,_0x73a229]=getPerf(_0x3b19ab[0x0],!![]);let _0xffe731=[];config[_0x1fb8f2(0x34c)][_0x1fb8f2(0x1d7)](_0x3a4e7e=>{const _0x19e839=_0x1fb8f2;let _0x4aba29=0x0,_0xb8d18f;config[_0x19e839(0x1c7)][_0x19e839(0x1d7)](_0x4526ff=>{const _0x4c479d=_0x19e839;let _0x199be9=_0x4526ff[_0x4c479d(0x31a)][_0x4c479d(0x21a)](_0x59d238=>_0x59d238[_0x4c479d(0x23b)]==_0x3a4e7e[_0x4c479d(0x23b)]);if(_0x199be9){_0x4aba29+=_0x199be9[_0x4c479d(0x358)];if(!_0xb8d18f)_0xb8d18f=_0x199be9[_0x4c479d(0x2d4)];}}),_0xffe731[_0x19e839(0x350)]({'coin':_0x3a4e7e[_0x19e839(0x23b)],'number':_0x4aba29,'initialprice':_0xb8d18f});});const _0xe14d78={'basecoin':_0x522602,'eur':_0x318920,'usd':_0x73a229,'coins':_0xffe731};if(_0x25cf54)proxyEmit(_0x1fb8f2(0x226),_0xe14d78);startingBalances=_0xe14d78;}}function headlessMode(_0x191657){const _0x138f00=_0x11db1f;let _0x581a3f=_0x191657[_0x138f00(0x34c)],_0x66c7ab=_0x191657[_0x138f00(0x255)],_0x513a99=[];for(let _0x148e6a of _0x581a3f){if(_0x148e6a[_0x138f00(0x23b)]!=config['basecoin']){if(_0x148e6a[_0x138f00(0x19a)]>=_0x66c7ab/0x64){if(_0x148e6a[_0x138f00(0x268)])_0x513a99[_0x138f00(0x350)](_0x148e6a);}else{if(_0x148e6a[_0x138f00(0x19a)]<=-_0x66c7ab/0x64){if(_0x148e6a['valid'])_0x513a99[_0x138f00(0x350)](_0x148e6a);}}}}_0x513a99[_0x138f00(0x25c)]>0x0&&placeOrder(_0x513a99);}function notifyBalance(_0x458670){const _0xe03716=_0x11db1f;let _0x1cc338=_0x458670[_0xe03716(0x34c)],_0x3bc9c7=_0x458670[_0xe03716(0x255)],_0x589caa=[];for(let _0x1f89f2 of _0x1cc338){if(_0x1f89f2[_0xe03716(0x23b)]!=config['basecoin']){if(_0x1f89f2[_0xe03716(0x19a)]>=_0x3bc9c7/0x64){if(_0x1f89f2[_0xe03716(0x268)])_0x589caa[_0xe03716(0x350)](_0x1f89f2);}else{if(_0x1f89f2[_0xe03716(0x19a)]<=-_0x3bc9c7/0x64){if(_0x1f89f2['valid'])_0x589caa[_0xe03716(0x350)](_0x1f89f2);}}}}if(_0x589caa[_0xe03716(0x25c)]>0x0){let _0x4139b2=_0x589caa[_0xe03716(0x2a1)](_0x3ce3ad=>_0x3ce3ad[_0xe03716(0x23b)]);_0x4139b2[_0xe03716(0x2bd)]();let _0x1d5734=_0x4139b2['join'](',\x20');if(!lastCoinsToBalance)logHistory(_0xe03716(0x220),'Manual\x20balancing\x20required');lastCoinsToBalance=_0x1d5734;}}function symbolToCoin(_0x4df148){const _0x549fcb=_0x11db1f;let _0x1105b2;if(_0x4df148['includes']('/'+config[_0x549fcb(0x35c)]))_0x1105b2=_0x4df148[_0x549fcb(0x1dc)]('/'+config[_0x549fcb(0x35c)],'');if(_0x4df148['includes'](config[_0x549fcb(0x35c)]+'/'))_0x1105b2=_0x4df148[_0x549fcb(0x1dc)](config['basecoin']+'/','');return _0x1105b2;}function setLockOrders(_0x2c4ded){const _0x2f4ad8=_0x11db1f;lockOrders=_0x2c4ded,logger[_0x2f4ad8(0x20c)](_0x2f4ad8(0x29e)+Object[_0x2f4ad8(0x1ba)](ORDERS)[lockOrders]);}async function unlockOrders(_0x349362=![]){const _0x7e3e1b=_0x11db1f;if(allOrdersPlaced&&lockOrders==ORDERS[_0x7e3e1b(0x307)]){setLockOrders(ORDERS[_0x7e3e1b(0x284)]);if(pidOrdersInitialTimeout)clearTimeout(pidOrdersInitialTimeout);if(pidOrdersTimeout)clearTimeout(pidOrdersTimeout);if(_0x349362){const _0x418dcb=await getCoins(balanceUpdateDelay);[currentCoins,currentCoinsAll]=_0x418dcb,setBlockTransactionDetection(![]);}validateOrdersState=_0x7e3e1b(0x26b),persistOpenOrders([]),setLockOrders(ORDERS[_0x7e3e1b(0x229)]);}}async function validateOrders(_0x35e057){const _0x727386=_0x11db1f;if(_0x35e057)validateOrdersState=_0x35e057;logger[_0x727386(0x20c)](_0x727386(0x267)+validateOrdersState+_0x727386(0x19c)+Object[_0x727386(0x1ba)](ORDERS)[lockOrders]);let _0x20a191=[],_0x80166a=config['ordertype']=='market'?validateOrderTimeout*0x3c*0x3e8/validateOrderInterval:config['timeout']*0x3c*0x3e8/validateOrderInterval;if(lockOrders!=ORDERS[_0x727386(0x307)])return;logger[_0x727386(0x20c)]('2\x20-\x20Validate\x20orders:\x20'+validateOrdersState);for(let _0x388e06=lastOrders['length']-0x1;_0x388e06>=0x0;_0x388e06--){let _0x3b223e=lastOrders[_0x388e06],_0x5bb1c3=![];_0x3b223e[_0x727386(0x343)]>0x0&&(_0x5bb1c3=!![]),_0x20a191[_0x727386(0x350)](_0x5bb1c3),_0x5bb1c3&&config[_0x727386(0x235)]!=_0x727386(0x314)&&logHistory('order',_0x727386(0x21b)+_0x3b223e[_0x727386(0x249)]+'\x20'+_0x3b223e[_0x727386(0x311)]+'\x20#'+formatResult(_0x3b223e[_0x727386(0x343)],0x8)+'\x20@'+formatResult(_0x3b223e['price'],0x8)),_0x5bb1c3&&lastOrders[_0x727386(0x2e3)](_0x388e06,0x1);}persistOpenOrders(lastOrders);const _0x10e251=coolingDown?'balancing\x20resumes\x20when\x20cooldown\x20ends':_0x727386(0x280);if(validateOrdersState==_0x727386(0x26b)){validateOrdersState=_0x727386(0x321);if(_0x20a191[_0x727386(0x29b)](![])){}else await unlockOrders();}else{if(validateOrdersState==_0x727386(0x321)){if(_0x20a191[_0x727386(0x29b)](![])){}else await unlockOrders();}else{if(validateOrdersState=='final'){let _0x10c1a6=!![];if(_0x20a191[_0x727386(0x29b)](![])){if(config[_0x727386(0x235)]==_0x727386(0x314))logHistory(_0x727386(0x2da),_0x727386(0x278)+Math[_0x727386(0x328)](_0x80166a*validateOrderInterval/0xea60)+_0x727386(0x1d9)+_0x10e251),await unlockOrders(!![]);else{_0x10c1a6=await cancelOrders();if(_0x10c1a6)logHistory(_0x727386(0x2da),_0x727386(0x2a0)+Math[_0x727386(0x328)](_0x80166a*validateOrderInterval/0xea60)+_0x727386(0x1d9)+_0x10e251),await unlockOrders(!![]);else{validateOrdersState='ongoing',logHistory(_0x727386(0x237),_0x727386(0x19b)+Math[_0x727386(0x328)](_0x80166a*validateOrderInterval/0xea60)+'\x20minutes\x20-\x20'+_0x10e251),logHistory(_0x727386(0x237),_0x727386(0x2af));const _0x2f0b33=config[_0x727386(0x235)]==_0x727386(0x314)?validateOrderTimeout*0x3c*0x3e8:config['timeout']*0x3c*0x3e8;if(pidOrdersTimeout)clearTimeout(pidOrdersTimeout);pidOrdersTimeout=setTimeout(function(){const _0x539509=_0x727386;validateOrders(_0x539509(0x2c4));},_0x2f0b33);}}}else await unlockOrders(!![]);}else{if(validateOrdersState==_0x727386(0x26e)){if(config[_0x727386(0x235)]!=_0x727386(0x314))logHistory('success',_0x727386(0x2ed)+_0x10e251);await unlockOrders(!![]);}}}}}async function cancelOrders(){const _0x3a9f22=_0x11db1f;let _0x7c227c=!![],_0x505b47;for(const _0x12893c of lastOrders){let _0x186bab=![],_0xebf7ce=0x0;while(!_0x186bab&&_0xebf7ce<maxRetries){try{const _0x197573=await exchange['cancelOrder'](_0x12893c[_0x3a9f22(0x2e0)],_0x12893c[_0x3a9f22(0x249)]);_0x186bab=!![];}catch(_0x5e6df2){_0x5e6df2[_0x3a9f22(0x361)]()[_0x3a9f22(0x29b)](_0x3a9f22(0x29d))||_0x5e6df2[_0x3a9f22(0x361)]()[_0x3a9f22(0x29b)]('InvalidOrder')?_0x186bab=!![]:(_0x505b47=_0x5e6df2,_0x186bab=![]);}!_0x186bab&&(_0xebf7ce++,await sleep(retryInterval));}_0x7c227c=_0x7c227c&&_0x186bab;}return!_0x7c227c&&await handleError(_0x505b47,'cancelOrders()'),_0x7c227c;}async function initCoinResults(_0x3ef975){const _0x58ad94=_0x11db1f;_0x3ef975?logger[_0x58ad94(0x20c)](_0x58ad94(0x335)+_0x3ef975):logger[_0x58ad94(0x20c)](_0x58ad94(0x27d)),config[_0x58ad94(0x34c)][_0x58ad94(0x1d7)](_0x15d3c4=>{const _0x306aeb=_0x58ad94;if(!_0x15d3c4[_0x306aeb(0x30f)]&&_0x15d3c4[_0x306aeb(0x23b)]!=config[_0x306aeb(0x35c)]){const _0x198b3e=currentCoins['find'](_0x9d321=>_0x9d321[_0x306aeb(0x23b)]==_0x15d3c4[_0x306aeb(0x23b)]),_0x337655=gTicker[noslash(_0x15d3c4['symbol'])];let _0x44d979=_0x198b3e?_0x198b3e[_0x306aeb(0x358)]:null,_0xd8ae32=_0x15d3c4[_0x306aeb(0x2bb)]?0x1/_0x337655:_0x337655,_0x2a1ae5;config[_0x306aeb(0x1c7)][_0x306aeb(0x1d7)](_0x2a87b9=>{const _0x41081b=_0x306aeb;!_0x2a1ae5&&(_0x2a1ae5=_0x2a87b9['changes']['find'](_0x143f86=>_0x143f86[_0x41081b(0x23b)]==_0x15d3c4[_0x41081b(0x23b)]),_0x2a1ae5&&(_0x44d979=_0x2a1ae5['number'],_0xd8ae32=_0x2a1ae5['price']));});let _0x225c24=dbCoinResults[_0x306aeb(0x206)](_0x306aeb(0x1a8))[_0x306aeb(0x21a)]({'coin':_0x15d3c4[_0x306aeb(0x23b)]})[_0x306aeb(0x2b6)]();if(!_0x225c24){const _0x194231={'coin':_0x15d3c4['coin'],'number':_0x44d979,'breakeven':_0xd8ae32,'realized':0x0,'unrealized':0x0,'fees':0x0,'sells':0x0,'buys':0x0};dbCoinResults[_0x306aeb(0x206)](_0x306aeb(0x1a8))['push'](_0x194231)[_0x306aeb(0x313)]();}else{if(_0x3ef975&&_0x15d3c4['coin']==_0x3ef975){const _0x151f4={'coin':_0x15d3c4[_0x306aeb(0x23b)],'number':_0x44d979,'breakeven':_0xd8ae32,'realized':0x0,'unrealized':0x0,'fees':0x0,'sells':0x0,'buys':0x0};dbCoinResults['get']('coins')[_0x306aeb(0x21a)]({'coin':_0x15d3c4[_0x306aeb(0x23b)]})[_0x306aeb(0x1c1)](_0x151f4)[_0x306aeb(0x313)]();}}}});}async function placeOrder(_0x57721a){const _0x47d3f0=_0x11db1f,_0x1d4bd5=config['ordertype']==_0x47d3f0(0x314)?_0x47d3f0(0x314):'limit';if(lockOrders==ORDERS[_0x47d3f0(0x229)]&&!coolingDown){setLockOrders(ORDERS['LOCKED']);while(transactionDetectionOngoing){await sleep(0x64);}logger['debug'](_0x47d3f0(0x2f3)+_0x57721a['map'](_0x46cd43=>_0x46cd43[_0x47d3f0(0x23b)])['join'](',\x20')),lastCoinsToBalance='',allOrdersPlaced=![],validateOrdersState='initial';let _0x26854a=![];lastOrders=[];const _0x499ea8=config[_0x47d3f0(0x255)];for(const _0x555317 of _0x57721a){let _0x461724,_0x55ddc8,_0x53a0f4,_0x5ba6bb,_0x4b380c,_0x4061fb=_0x555317[_0x47d3f0(0x249)];logger[_0x47d3f0(0x20c)](_0x47d3f0(0x33c)+_0x555317[_0x47d3f0(0x23b)]+'\x20'+_0x555317[_0x47d3f0(0x358)]+'\x20'+_0x555317[_0x47d3f0(0x344)]+'\x20'+_0x555317[_0x47d3f0(0x1ff)]+'%\x20'+_0x555317[_0x47d3f0(0x33b)]+'%\x20'+(0x64*_0x555317[_0x47d3f0(0x19a)])[_0x47d3f0(0x1a3)](0x2)+_0x47d3f0(0x2e5)+_0x499ea8[_0x47d3f0(0x1a3)](0x2)+'%)'),insufficientFundsWarningSent=insufficientFundsWarningSent[_0x47d3f0(0x2e2)](_0xc7029a=>_0xc7029a!==_0x555317[_0x47d3f0(0x23b)]);const _0x1b3040=currentCoins[_0x47d3f0(0x21a)](_0x1dae2c=>_0x1dae2c[_0x47d3f0(0x23b)]==_0x555317['coin']);_0x1b3040&&(_0x1b3040[_0x47d3f0(0x2e4)]=_0x555317[_0x47d3f0(0x358)]);try{const _0x485c70=await exchange[_0x47d3f0(0x1b7)](_0x4061fb);_0x461724=_0x555317[_0x47d3f0(0x2bb)]?0x1/_0x555317[_0x47d3f0(0x344)]:_0x555317[_0x47d3f0(0x344)],_0x55ddc8=_0x485c70[_0x47d3f0(0x293)],_0x53a0f4=_0x485c70[_0x47d3f0(0x1c0)];_0x555317['reverse']?(_0x5ba6bb=_0x555317[_0x47d3f0(0x311)]==_0x47d3f0(0x371)?_0x47d3f0(0x355):_0x47d3f0(0x371),_0x4b380c=Math[_0x47d3f0(0x261)](_0x555317['trade'])/_0x461724):(_0x5ba6bb=_0x555317[_0x47d3f0(0x311)],_0x4b380c=Math[_0x47d3f0(0x261)](_0x555317[_0x47d3f0(0x2d1)]));_0x1d4bd5==_0x47d3f0(0x1b1)&&(config[_0x47d3f0(0x235)]==_0x47d3f0(0x243)&&(_0x461724=_0x5ba6bb==_0x47d3f0(0x371)?_0x55ddc8:_0x53a0f4),config[_0x47d3f0(0x235)]==_0x47d3f0(0x2d7)&&(_0x461724=_0x5ba6bb==_0x47d3f0(0x371)?_0x53a0f4:_0x55ddc8));_0x4b380c=formatResult(_0x4b380c,0x8),_0x461724=formatResult(_0x461724,0x8);const _0x4533e2=_0x5ba6bb=='sell'?config[_0x47d3f0(0x1a9)]?String['fromCodePoint']('0x'+config[_0x47d3f0(0x1a9)])+'\x20':'':config[_0x47d3f0(0x2e6)]?String[_0x47d3f0(0x34f)]('0x'+config[_0x47d3f0(0x2e6)])+'\x20':'',_0x3337fb=_0x1d4bd5=='market'?_0x47d3f0(0x35d):config[_0x47d3f0(0x235)]==_0x47d3f0(0x243)?_0x47d3f0(0x25d):_0x47d3f0(0x29c),_0x62247a=(Math['floor'](Math[_0x47d3f0(0x2ae)]()*0x35a4e900)+0x5f5e100)[_0x47d3f0(0x361)]();lastOrders[_0x47d3f0(0x350)]({'customId':_0x62247a,'symbol':_0x4061fb,'coin':_0x555317[_0x47d3f0(0x23b)],'amount':_0x4b380c,'price':_0x461724,'side':_0x5ba6bb,'reverse':_0x555317[_0x47d3f0(0x2bb)],'filled':0x0});let _0x1cade6;_0x1d4bd5=='market'?_0x5ba6bb==_0x47d3f0(0x371)&&[_0x47d3f0(0x20e),'Bitget','Cex','Huobi',_0x47d3f0(0x2ad)][_0x47d3f0(0x29b)](config[_0x47d3f0(0x2d0)])?_0x1cade6=await exchange[_0x47d3f0(0x366)](_0x4061fb,_0x1d4bd5,_0x5ba6bb,_0x4b380c,_0x461724):_0x1cade6=await exchange['createOrder'](_0x4061fb,_0x1d4bd5,_0x5ba6bb,_0x4b380c,undefined):_0x1cade6=await exchange[_0x47d3f0(0x366)](_0x4061fb,_0x1d4bd5,_0x5ba6bb,_0x4b380c,_0x461724);const _0x2679c8=lastOrders[_0x47d3f0(0x25c)]-0x1;if(_0x2679c8>=0x0&&lastOrders[_0x2679c8][_0x47d3f0(0x33a)]==_0x62247a){lastOrders[_0x2679c8][_0x47d3f0(0x2e0)]=_0x1cade6['id'];if(_0x1cade6[_0x47d3f0(0x340)])lastOrders[_0x2679c8][_0x47d3f0(0x340)]=_0x1cade6[_0x47d3f0(0x340)];if(_0x1cade6[_0x47d3f0(0x2d4)])lastOrders[_0x2679c8][_0x47d3f0(0x2d4)]=_0x1cade6[_0x47d3f0(0x2d4)];lastOrders[_0x2679c8]['fee']=_0x1cade6[_0x47d3f0(0x306)];}if(_0x1cade6['amount'])_0x4b380c=_0x1cade6[_0x47d3f0(0x340)];if(_0x1cade6[_0x47d3f0(0x2d4)])_0x461724=_0x1cade6[_0x47d3f0(0x2d4)];if(_0x1d4bd5=='market')logHistory(_0x47d3f0(0x23e),''+_0x4533e2+_0x3337fb+_0x47d3f0(0x2ca)+_0x4061fb+'\x20'+_0x5ba6bb+'\x20#'+formatResult(_0x4b380c,0x8)+'\x20@'+formatResult(_0x461724,0x8));else logHistory(_0x47d3f0(0x23e),''+_0x4533e2+_0x3337fb+'\x20order:\x20'+_0x4061fb+'\x20'+_0x5ba6bb+'\x20#'+formatResult(_0x4b380c,0x8)+'\x20@'+formatResult(_0x461724,0x8));logger[_0x47d3f0(0x20c)]('ID:\x20'+_0x1cade6['id']+_0x47d3f0(0x2ba)+_0x62247a);if(config[_0x47d3f0(0x33d)]!=0x0){let _0x32af4d=null;if(cooldownTracker[_0x47d3f0(0x25c)]==config[_0x47d3f0(0x33d)]-0x1)_0x32af4d=cooldownTracker[_0x47d3f0(0x2e1)]();const _0x4cf051=getTimeStamp();cooldownTracker[_0x47d3f0(0x350)](_0x4cf051);if(_0x32af4d){const _0x2e7c4e=fns[_0x47d3f0(0x32c)](new Date(_0x4cf051),new Date(_0x32af4d));if(_0x2e7c4e<cooldownInterval){logHistory(_0x47d3f0(0x237),_0x47d3f0(0x1b0)+config[_0x47d3f0(0x33d)]+_0x47d3f0(0x1f3)+cooldownInterval/0x3c+_0x47d3f0(0x233)+cooldownPeriod/(0xe10*0x3e8)+_0x47d3f0(0x294)),coolingDown=!![];break;}}}}catch(_0x278e54){if(_0x278e54['toString']()['includes'](_0x47d3f0(0x24b)))lastOrders=lastOrders[_0x47d3f0(0x2e2)](_0x43dcd9=>_0x43dcd9[_0x47d3f0(0x249)]!=_0x4061fb),logHistory(_0x47d3f0(0x237),_0x47d3f0(0x1b5)+_0x4061fb),_0x26854a=!![];else{if(_0x278e54['toString']()['includes']('Invalid\x20quantity'))lastOrders=lastOrders[_0x47d3f0(0x2e2)](_0x575260=>_0x575260[_0x47d3f0(0x249)]!=_0x4061fb),logHistory(_0x47d3f0(0x237),_0x47d3f0(0x19d)+_0x4061fb),_0x26854a=!![];else{if(_0x278e54[_0x47d3f0(0x361)]()[_0x47d3f0(0x29b)](_0x47d3f0(0x331)))lastOrders=lastOrders['filter'](_0x46ad72=>_0x46ad72[_0x47d3f0(0x249)]!=_0x4061fb),logHistory('error',_0x47d3f0(0x26a)+_0x4061fb),logger['debug'](_0x278e54),_0x26854a=!![];else _0x278e54[_0x47d3f0(0x361)]()[_0x47d3f0(0x29b)](_0x47d3f0(0x1a1))?(lastOrders=lastOrders['filter'](_0x4bf0fc=>_0x4bf0fc[_0x47d3f0(0x249)]!=_0x4061fb),logHistory('error','Order\x20amount\x20is\x20too\x20small\x20to\x20trade:\x20'+_0x4061fb),_0x26854a=!![]):(lastOrders=lastOrders[_0x47d3f0(0x2e2)](_0xdaf738=>_0xdaf738['symbol']!=_0x4061fb),await handleError(_0x278e54,_0x47d3f0(0x25b),_0x4061fb));}}}}allOrdersPlaced=!![],persistOpenOrders(lastOrders);if(lastOrders['length']>0x0){const _0x5ce4bc=config['ordertype']=='market'?validateOrderTimeout*0x3c*0x3e8:config[_0x47d3f0(0x34e)]*0x3c*0x3e8;if(pidOrdersTimeout)clearTimeout(pidOrdersTimeout);pidOrdersTimeout=setTimeout(function(){const _0x415f5a=_0x47d3f0;validateOrders(_0x415f5a(0x2c4));},_0x5ce4bc);}else unlockOrders();_0x26854a&&config[_0x47d3f0(0x302)]&&(logHistory(_0x47d3f0(0x237),_0x47d3f0(0x309)+pauseBotMsg),await pauseBot(pauseBotInterval)),coolingDown&&(await sleep(cooldownPeriod),coolingDown=![],logHistory('success','Cooldown\x20ended\x20-\x20balancing\x20resumed'));}else{if(coolingDown)!config[_0x47d3f0(0x302)]&&logHistory(_0x47d3f0(0x237),_0x47d3f0(0x2fe));else lockOrders!=ORDERS[_0x47d3f0(0x229)]&&(!config[_0x47d3f0(0x302)]&&(config[_0x47d3f0(0x235)]=='market'?logHistory('error',_0x47d3f0(0x1bb)):logHistory('error',_0x47d3f0(0x231))));}}function persistOpenOrders(_0x2c5e8d){const _0xe70983=_0x11db1f,_0x466f6d={...config,'openOrders':_0x2c5e8d};let _0x263ae0=dbConfig[_0xe70983(0x206)](_0xe70983(0x260))[_0xe70983(0x21a)]({'botID':botID})[_0xe70983(0x2b6)]();_0x263ae0&&dbConfig[_0xe70983(0x206)]('bot')[_0xe70983(0x21a)]({'botID':botID})[_0xe70983(0x1c1)](_0x466f6d)[_0xe70983(0x313)]();}function restoreOrders(){const _0x2fab1b=_0x11db1f;let _0x2ec2e5;config[_0x2fab1b(0x221)]&&allOpenOrders[_0x2fab1b(0x1d7)](_0x2fcf36=>{const _0x4ccfef=_0x2fab1b,_0x5a392a=config[_0x4ccfef(0x221)][_0x4ccfef(0x21a)](_0x594fd2=>_0x594fd2[_0x4ccfef(0x2e0)]==_0x2fcf36['id']);_0x5a392a&&(lastOrders['push'](_0x5a392a),_0x2ec2e5=_0x2fcf36[_0x4ccfef(0x2c8)]);});if(lastOrders[_0x2fab1b(0x25c)]>0x0){setLockOrders(ORDERS[_0x2fab1b(0x307)]),validateOrdersState=_0x2fab1b(0x321),allOrdersPlaced=!![];const _0x59cb5b=new Date()['getTime'](),_0x6ec617=config[_0x2fab1b(0x235)]=='market'?validateOrderTimeout*0x3c*0x3e8:config['timeout']*0x3c*0x3e8;if(_0x2ec2e5+_0x6ec617>_0x59cb5b){if(pidOrdersTimeout)clearTimeout(pidOrdersTimeout);pidOrdersTimeout=setTimeout(function(){const _0x5d0774=_0x2fab1b;validateOrders(_0x5d0774(0x2c4));},_0x2ec2e5+_0x6ec617-_0x59cb5b);}else validateOrders(_0x2fab1b(0x2c4));}}async function sendMetricsTelegram(){const _0x496b27=_0x11db1f;if(!coinsLoaded){process['send']({'telegrammsg':'Bot\x20has\x20not\x20loaded\x20yet\x20-\x20try\x20again\x20in\x20a\x20minute'},_0x3062b7=>{});return;}if(!startingBalances)await getStartingBalances(getNormalizedPerformance());let _0x4f370e='';if(config[_0x496b27(0x305)])_0x4f370e=_0x496b27(0x1fa)+config[_0x496b27(0x2ea)]+'\x20metrics:</b>\x20\x0a\x0a';else _0x4f370e=_0x496b27(0x299)+botID+_0x496b27(0x228);const _0x19c56c=config['basecoin'],_0x51eac7=config[_0x496b27(0x1d0)],_0x2f8785=getKPIs(_0x496b27(0x35c)),_0x200a2c=getKPIs('fiat',_0x51eac7),_0x1ae856=getKPIs(_0x496b27(0x244)),_0x3c7f9f=getKPIs('net-fiat',_0x51eac7),_0x19ccd2=getKPIs(_0x496b27(0x218)),_0xd48d74=getKPIs(_0x496b27(0x263),_0x51eac7);_0x19c56c[_0x496b27(0x29b)](_0x51eac7)?(_0x4f370e+='<pre>',_0x4f370e+=_0x496b27(0x2c7)+_0x19c56c+':\x20'+_0x2f8785[_0x496b27(0x2b6)]+'\x20('+_0x2f8785[_0x496b27(0x19f)]+'%)\x0a',_0x4f370e+=_0x496b27(0x1f9)+_0x19c56c+':\x20'+_0x1ae856[_0x496b27(0x2b6)]+'\x20('+_0x1ae856[_0x496b27(0x19f)]+_0x496b27(0x2a7),_0x4f370e+='PnL\x20'+_0x19c56c+':\x20'+_0x19ccd2[_0x496b27(0x2b6)]+'\x20('+_0x19ccd2[_0x496b27(0x19f)]+_0x496b27(0x2a7),_0x4f370e+=_0x496b27(0x34b)):(_0x4f370e+=_0x496b27(0x205),_0x4f370e+='Value\x20'+_0x19c56c+':\x20'+_0x2f8785[_0x496b27(0x2b6)]+'\x20('+_0x2f8785[_0x496b27(0x19f)]+'%)\x0a',_0x4f370e+=_0x496b27(0x2c7)+_0x51eac7+':\x20'+_0x200a2c['value']+'\x20('+_0x200a2c['change']+_0x496b27(0x2a7),_0x4f370e+='Net\x20'+_0x19c56c+':\x20'+_0x1ae856[_0x496b27(0x2b6)]+'\x20('+_0x1ae856[_0x496b27(0x19f)]+'%)\x0a',_0x4f370e+='Net\x20'+_0x51eac7+':\x20'+_0x3c7f9f[_0x496b27(0x2b6)]+'\x20('+_0x3c7f9f[_0x496b27(0x19f)]+_0x496b27(0x2a7),_0x4f370e+=_0x496b27(0x207)+_0x19c56c+':\x20'+_0x19ccd2['value']+'\x20('+_0x19ccd2[_0x496b27(0x19f)]+_0x496b27(0x2a7),_0x4f370e+=_0x496b27(0x207)+_0x51eac7+':\x20'+_0xd48d74[_0x496b27(0x2b6)]+'\x20('+_0xd48d74['change']+'%)\x0a',_0x4f370e+=_0x496b27(0x34b)),process[_0x496b27(0x347)]({'telegrammsg':_0x4f370e},_0x287dfb=>{});}async function sendPortfolioTelegram(){const _0x3b8e52=_0x11db1f;if(!coinsLoaded||!currentCoins[0x0]['distribution']){process['send']({'telegrammsg':_0x3b8e52(0x2cd)},_0x2fe1e7=>{});return;}let _0x1757fb='';if(config[_0x3b8e52(0x305)])_0x1757fb=_0x3b8e52(0x1fa)+config['botname']+'\x20portfolio:</b>\x20\x0a\x0a';else _0x1757fb='<b>Bot\x20'+botID+_0x3b8e52(0x1aa);_0x1757fb+=_0x3b8e52(0x205),_0x1757fb+=_0x3b8e52(0x2cb),_0x1757fb+='Coin\x20\x20\x20|\x20\x20Distr|\x20Target|\x20\x20Delta\x20\x0a',_0x1757fb+='-------------------------------\x0a',currentCoins[_0x3b8e52(0x1d7)](_0x37da00=>{const _0x5ece01=_0x3b8e52;_0x1757fb+=_0x37da00[_0x5ece01(0x23b)][_0x5ece01(0x334)](0x7)+'|\x20'+formatPad(_0x37da00[_0x5ece01(0x1ff)],0x2,0x6)+'|\x20'+formatPad(_0x37da00[_0x5ece01(0x33b)],0x2,0x6)+'|\x20'+formatPad(_0x37da00['delta']*0x64,0x2,0x6)+'\x0a';}),_0x1757fb+=_0x3b8e52(0x34b),process[_0x3b8e52(0x347)]({'telegrammsg':_0x1757fb},_0x586247=>{});}function formatPad(_0x577920,_0x31b4e6,_0x579343){const _0x5f16e2=_0x11db1f,_0xdc417=formatResultString(_0x577920,_0x31b4e6);return _0xdc417?_0xdc417[_0x5f16e2(0x35a)](_0x579343):''[_0x5f16e2(0x35a)](_0x579343);}function logHistory(_0x2db2e7,_0x147f0b,_0x4ceb43=''){const _0x374349=_0x11db1f;logger[_0x374349(0x271)](''+_0x147f0b);let _0x485ab1={'time':getTimeStamp(),'type':_0x2db2e7,'event':_0x147f0b};dbLogs['get'](_0x374349(0x2e9))['push'](_0x485ab1)['write']();if(_0x4ceb43=='')_0x4ceb43=_0x147f0b;proxyEmit(_0x374349(0x1b3),{'log':_0x485ab1,'summary':_0x4ceb43}),process['send']({'telegram':{..._0x485ab1,'botname':config[_0x374349(0x2ea)],'showname':config[_0x374349(0x305)]}},_0x1ed979=>{});}function emitHistory(_0x240abd={}){const _0x173ae4=_0x11db1f;Object[_0x173ae4(0x1ba)](_0x240abd)['length']==0x0&&(_0x240abd={'type':[_0x173ae4(0x23e),_0x173ae4(0x1b3)],'event':'','page':0x1});if(_0x240abd['type'][_0x173ae4(0x29b)](_0x173ae4(0x1b3)))_0x240abd['type'][_0x173ae4(0x2e3)](_0x240abd[_0x173ae4(0x33e)][_0x173ae4(0x2fb)](_0x173ae4(0x1b3)),0x1,_0x173ae4(0x237),_0x173ae4(0x220),'success');if(dbLogs[_0x173ae4(0x2d2)](_0x173ae4(0x2e9))[_0x173ae4(0x2b6)]()){let _0x1c0699=dbLogs[_0x173ae4(0x206)](_0x173ae4(0x2e9))[_0x173ae4(0x2e2)](_0x52863a=>{const _0x1de6e3=_0x173ae4;if(_0x240abd[_0x1de6e3(0x33e)][_0x1de6e3(0x25c)]==0x0)return![];else return _0x240abd[_0x1de6e3(0x33e)][_0x1de6e3(0x29b)](_0x52863a['type']);})[_0x173ae4(0x2e2)](_0x5436d6=>{const _0x25c5fb=_0x173ae4;if(_0x240abd[_0x25c5fb(0x1b3)]=='')return!![];else return _0x5436d6[_0x25c5fb(0x1b3)][_0x25c5fb(0x204)]()[_0x25c5fb(0x29b)](_0x240abd[_0x25c5fb(0x1b3)][_0x25c5fb(0x204)]());})['sortBy'](_0x173ae4(0x325)),_0x38f509=_0x1c0699['value']()['length'];_0x1c0699=_0x1c0699['reverse']()['slice']((_0x240abd['page']-0x1)*logPageSize,_0x240abd['page']*logPageSize-0x1)[_0x173ae4(0x2bb)]()[_0x173ae4(0x2b6)](),proxyEmit(_0x173ae4(0x1a4),{'logs':_0x1c0699,'total':_0x38f509});}else proxyEmit(_0x173ae4(0x1a4),{'logs':[],'total':0x0});}function deleteHistoryAlerts(_0x188c55){const _0x7d3bd8=_0x11db1f;if(dbLogs['has']('logs')[_0x7d3bd8(0x2b6)]()){const _0x4c3ea6=dbLogs['get']('logs')[_0x7d3bd8(0x360)]('time')[_0x7d3bd8(0x2e2)](_0x412022=>{return _0x412022['type']=='order';})[_0x7d3bd8(0x2b6)]();dbLogs[_0x7d3bd8(0x206)](_0x7d3bd8(0x2e9))[_0x7d3bd8(0x2b9)]()[_0x7d3bd8(0x313)](),dbLogs[_0x7d3bd8(0x206)]('logs')[_0x7d3bd8(0x1c1)](_0x4c3ea6)[_0x7d3bd8(0x313)](),emitHistory(_0x188c55);}}async function pauseBot(_0x15fe50=pauseBotIntervalShort,_0x426c3a,_0x61cf1c,_0x492764=![]){const _0x37899f=_0x11db1f,_0xb52d8a=new Date()[_0x37899f(0x223)]();if(!lastErrorShown||_0xb52d8a-lastErrorShown>=_0x15fe50){lastErrorShown=_0xb52d8a;if(!lastBotPause)lastBotPause=_0xb52d8a,consecutivePauses=0x1;else{if(_0xb52d8a-lastBotPause-_0x15fe50<0x5a*0x3e8){consecutivePauses++;if(consecutivePauses>maxPauseRetries){if(_0x492764){logHistory('error',_0x426c3a+_0x37899f(0x1d3)),await killBot();return;}else logHistory(_0x37899f(0x237),_0x426c3a+pauseBotMsg),_0x15fe50=pauseBotInterval;}}else consecutivePauses=0x1;lastBotPause=_0xb52d8a;}_0x61cf1c?logger[_0x37899f(0x20c)]('('+consecutivePauses+')\x20'+_0x426c3a+_0x37899f(0x23d),_0x61cf1c):logger[_0x37899f(0x20c)]('('+consecutivePauses+')\x20'+_0x426c3a);if(!botPaused){botPaused=!![];if(pidBalances)clearTimeout(pidBalances);await sleep(_0x15fe50),botPaused=![],_0x15fe50==pauseBotIntervalShort?resumeBot(!![]):resumeBot(![]);}}}async function killBot(){const _0x4c629a=_0x11db1f;botPaused=!![],await sleep(0x3e8),process[_0x4c629a(0x347)]({'stop':_0x4c629a(0x202)},_0x91fe89=>{}),await sleep(0x7d0);}async function handleErrorNoStop(_0x971540,_0x2f9c1a,_0x30cd5f=![]){const _0x3a2ea2=_0x11db1f;if(botPaused)return;let _0x3e993d;const _0x562be2=config[_0x3a2ea2(0x2d0)]||_0x3a2ea2(0x25f);if(_0x2f9c1a)logger[_0x3a2ea2(0x20c)](_0x3a2ea2(0x2d5)+_0x2f9c1a);const _0x1a2028=()=>{const _0x5bce5b=_0x3a2ea2;loading[_0x5bce5b(0x237)]='api-issue',emitLoadingProgress();};if(_0x971540[_0x3a2ea2(0x361)]()[_0x3a2ea2(0x29b)](_0x3a2ea2(0x22d)))logHistory(_0x3a2ea2(0x237),_0x562be2+_0x3a2ea2(0x248)),_0x1a2028();else{if(_0x971540['toString']()[_0x3a2ea2(0x29b)]('Signature\x20for\x20this\x20request\x20is\x20not\x20valid'))logHistory('error',_0x562be2+_0x3a2ea2(0x1d6)),_0x1a2028();else{if(_0x971540[_0x3a2ea2(0x361)]()[_0x3a2ea2(0x29b)]('AuthenticationError'))config[_0x3a2ea2(0x1e1)]?_0x3e993d=_0x562be2+_0x3a2ea2(0x295):_0x3e993d=_0x562be2+_0x3a2ea2(0x1eb),logHistory(_0x3a2ea2(0x237),_0x3e993d+_0x3a2ea2(0x357)),_0x1a2028();else{if(_0x971540['toString']()[_0x3a2ea2(0x29b)]('PermissionDenied'))logHistory('error',_0x562be2+_0x3a2ea2(0x369)),_0x1a2028();else{if(!_0x30cd5f)await handleError(_0x971540,null);}}}}}async function handleError(_0x1c4f50,_0x4d36ca,_0x58866a=''){const _0x496cb4=_0x11db1f;if(botPaused)return;let _0x22808b;const _0x388bbf=config[_0x496cb4(0x2d0)]||_0x496cb4(0x25f);if(_0x4d36ca)logger[_0x496cb4(0x20c)](_0x496cb4(0x2d5)+_0x4d36ca);if(_0x1c4f50[_0x496cb4(0x361)]()['includes']('DDoSProtection'))_0x22808b=_0x388bbf+_0x496cb4(0x333),await pauseBot(undefined,_0x22808b,_0x1c4f50);else{if(_0x1c4f50[_0x496cb4(0x361)]()['includes']('RateLimitExceeded'))_0x22808b=_0x388bbf+_0x496cb4(0x212),await pauseBot(undefined,_0x22808b,_0x1c4f50);else{if(_0x1c4f50['toString']()[_0x496cb4(0x29b)](_0x496cb4(0x2a3))||_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x29b)](_0x496cb4(0x1af)))_0x22808b=_0x388bbf+_0x496cb4(0x1a6),await pauseBot(undefined,_0x22808b,_0x1c4f50['toString']());else{if(_0x1c4f50[_0x496cb4(0x361)]()['includes'](_0x496cb4(0x1d5)))_0x22808b=_0x388bbf+_0x496cb4(0x2bf),await pauseBot(undefined,_0x22808b,_0x1c4f50[_0x496cb4(0x361)]());else{if(_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x29b)]('NetworkError:\x20connection\x20closed\x20by\x20remote\x20server'))_0x22808b=_0x388bbf+_0x496cb4(0x1f8),await pauseBot(undefined,_0x22808b,_0x1c4f50[_0x496cb4(0x361)]());else{if(_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x204)]()[_0x496cb4(0x29b)](_0x496cb4(0x2c8))||_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x204)]()[_0x496cb4(0x29b)](_0x496cb4(0x1c6)))_0x22808b='Your\x20machine\x27s\x20internal\x20clock\x20may\x20be\x20out\x20of\x20sync\x20(see:\x20hodlerhacks.com/fix/3)',await pauseBot(undefined,_0x22808b,_0x1c4f50['toString']());else{if(_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x29b)](_0x496cb4(0x367)))_0x22808b=_0x388bbf+_0x496cb4(0x2fc),await pauseBot(undefined,_0x22808b,_0x1c4f50[_0x496cb4(0x361)]());else{if(_0x1c4f50 instanceof ccxt[_0x496cb4(0x2c0)])_0x22808b=_0x388bbf+'\x20network\x20error:\x20'+_0x1c4f50['toString'](),logger[_0x496cb4(0x20c)](_0x496cb4(0x230),_0x1c4f50),await pauseBot(undefined,_0x22808b,_0x1c4f50);else{if(_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x29b)](_0x496cb4(0x22d)))logHistory(_0x496cb4(0x237),_0x388bbf+_0x496cb4(0x2b7)),logHistory(_0x496cb4(0x237),_0x496cb4(0x219)),await killBot();else{if(_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x29b)]('Signature\x20for\x20this\x20request\x20is\x20not\x20valid'))logHistory(_0x496cb4(0x237),_0x388bbf+_0x496cb4(0x2f7)),logHistory(_0x496cb4(0x237),_0x496cb4(0x219)),await killBot();else{if(_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x29b)]('AuthenticationError')&&_0x1c4f50['toString']()['includes'](_0x496cb4(0x201)))_0x22808b=_0x388bbf+_0x496cb4(0x319),await pauseBot(undefined,_0x22808b,_0x1c4f50,!![]);else{if(_0x1c4f50[_0x496cb4(0x361)]()[_0x496cb4(0x29b)](_0x496cb4(0x28d)))config[_0x496cb4(0x1e1)]?_0x22808b=_0x388bbf+'\x20API\x20key,\x20secret\x20or\x20password\x20invalid\x20-\x20also\x20make\x20sure\x20your\x20machine\x27s\x20IP\x20address\x20is\x20whitelisted\x20for\x20this\x20API\x20key\x20on\x20the\x20exchange':_0x22808b=_0x388bbf+_0x496cb4(0x1eb),logHistory('error',_0x22808b),logHistory('error',_0x496cb4(0x219)),await killBot();else{if(_0x1c4f50[_0x496cb4(0x361)]()['includes'](_0x496cb4(0x1ef)))logHistory('error',_0x388bbf+_0x496cb4(0x266)),logHistory('error',_0x496cb4(0x219)),await killBot();else{if(_0x1c4f50[_0x496cb4(0x361)]()['includes']('InsufficientFunds'))logHistory('error',_0x496cb4(0x24c)+_0x58866a),logger['debug'](_0x496cb4(0x338),_0x1c4f50);else{if(_0x1c4f50 instanceof ccxt[_0x496cb4(0x1a5)]){_0x22808b=_0x388bbf+_0x496cb4(0x297)+_0x1c4f50[_0x496cb4(0x361)]();if(_0x58866a)_0x22808b+=_0x496cb4(0x1e7)+_0x58866a;await pauseBot(undefined,_0x22808b,_0x1c4f50);}else{_0x22808b=_0x496cb4(0x1f5)+_0x1c4f50['toString']();if(_0x58866a)_0x22808b+=_0x496cb4(0x1e7)+_0x58866a;await pauseBot(undefined,_0x22808b);}}}}}}}}}}}}}}}}function decryptRSA(_0x3e0cf6,_0x5b1b98){const _0x159c2e=_0x11db1f,_0x1299bb=forge[_0x159c2e(0x285)]['privateKeyFromPem'](_0x3e0cf6),_0x6a50f7=_0x1299bb[_0x159c2e(0x2c1)](forge[_0x159c2e(0x2aa)]['decode64'](_0x5b1b98),_0x159c2e(0x236),{'md':forge['md'][_0x159c2e(0x292)][_0x159c2e(0x200)](),'mgf1':{'md':forge['md'][_0x159c2e(0x292)]['create']()}});return _0x6a50f7;}async function withRetry(_0x52f2e3,_0x18f673){const _0x414727=_0x11db1f;let _0x40ce40=![],_0x830018=0x0,_0xd8c363,_0x124fce;while(_0x830018<maxRetries){try{_0xd8c363=await _0x18f673();break;}catch(_0x3b230f){_0x124fce=_0x3b230f,!_0x40ce40?(_0x40ce40=!![],logger[_0x414727(0x20c)](_0x414727(0x1dd)+_0x52f2e3+':',_0x3b230f[_0x414727(0x361)]())):await sleep(retryInterval);}_0x830018++;}if(_0x830018==0x0)return _0xd8c363;if(_0x830018>=maxRetries)throw _0x124fce;else return logger[_0x414727(0x20c)](_0x414727(0x2ff)+_0x830018+_0x414727(0x315)),_0xd8c363;}function formatResult(_0x96b5ea,_0xcc7020){const _0x5cbe00=_0x11db1f;return parseFloat(_0x96b5ea[_0x5cbe00(0x1a3)](_0xcc7020));}function formatResultTruncate(_0x1a18a2,_0x4b5707){const _0x5b9c54=_0x11db1f;let _0x453deb=formatResultString(_0x1a18a2,0xa),_0x2fc294=_0x453deb[_0x5b9c54(0x2fb)]('.');return _0x2fc294!=-0x1&&(_0x453deb=_0x453deb['slice'](0x0,_0x2fc294+_0x4b5707+0x1)),Number(_0x453deb);}function formatResultString(_0x28c510,_0x280730){const _0x33dfe4=_0x11db1f;let _0x7366dd;if(!(''+_0x28c510)[_0x33dfe4(0x29b)]('e'))_0x7366dd=+(Math[_0x33dfe4(0x328)](_0x28c510+'e+'+_0x280730)+'e-'+_0x280730);else{let _0x5d25c3=(''+_0x28c510)[_0x33dfe4(0x1e8)]('e'),_0x548b12='';+_0x5d25c3[0x1]+_0x280730>0x0&&(_0x548b12='+'),_0x7366dd=+(Math['round'](+_0x5d25c3[0x0]+'e'+_0x548b12+(+_0x5d25c3[0x1]+_0x280730))+'e-'+_0x280730);}return Number(_0x7366dd)[_0x33dfe4(0x1a3)](_0x280730);}function getServerTime(){const _0x3670f6=_0x11db1f,_0x432bd0=new Date();return _0x432bd0['getFullYear']()+'/'+(_0x432bd0['getMonth']()+0x1)[_0x3670f6(0x361)]()['padStart'](0x2,'0')+'/'+_0x432bd0[_0x3670f6(0x281)]()['toString']()[_0x3670f6(0x35a)](0x2,'0')+'\x20'+_0x432bd0['getHours']()[_0x3670f6(0x361)]()[_0x3670f6(0x35a)](0x2,'0')+':'+_0x432bd0[_0x3670f6(0x24d)]()['toString']()['padStart'](0x2,'0')+':'+_0x432bd0[_0x3670f6(0x1c9)]()[_0x3670f6(0x361)]()['padStart'](0x2,'0');}function getTimeStamp(){const _0x535471=_0x11db1f,_0x209a8e=shiftedTime();return _0x209a8e[_0x535471(0x373)]()+'/'+(_0x209a8e['getMonth']()+0x1)['toString']()[_0x535471(0x35a)](0x2,'0')+'/'+_0x209a8e[_0x535471(0x281)]()[_0x535471(0x361)]()['padStart'](0x2,'0')+'\x20'+_0x209a8e[_0x535471(0x22b)]()[_0x535471(0x361)]()['padStart'](0x2,'0')+':'+_0x209a8e['getMinutes']()[_0x535471(0x361)]()[_0x535471(0x35a)](0x2,'0')+':'+_0x209a8e['getSeconds']()[_0x535471(0x361)]()['padStart'](0x2,'0');}function getDate(){const _0x4428a8=_0x11db1f,_0x39a2a0=shiftedTime();return _0x39a2a0['getFullYear']()+'/'+(_0x39a2a0[_0x4428a8(0x21c)]()+0x1)[_0x4428a8(0x361)]()[_0x4428a8(0x35a)](0x2,'0')+'/'+_0x39a2a0['getDate']()['toString']()[_0x4428a8(0x35a)](0x2,'0');}function getHour(){const _0x9b52e4=_0x11db1f,_0x4e0d81=shiftedTime();return _0x4e0d81[_0x9b52e4(0x22b)]()[_0x9b52e4(0x361)]()['padStart'](0x2,'0');}function sleep(_0x14343c){return new Promise(_0x2e42a5=>setTimeout(_0x2e42a5,_0x14343c));}function shiftedTime(){const _0x20cbde=_0x11db1f,_0x198533=new Date();let _0x1429ff=_0x198533;if(config&&config['timeshift']!==0x0)_0x1429ff=fns[_0x20cbde(0x31c)](_0x198533,{'hours':config['timeshift']});return _0x1429ff;}function timer(_0x529f84){const _0x1088da=_0x11db1f,_0x57202a=new Date();!lasttime?console[_0x1088da(0x1d2)](getTimeStamp()+':\x20timer\x20>',_0x529f84,_0x57202a):console[_0x1088da(0x1d2)](getTimeStamp()+_0x1088da(0x2d9),_0x529f84,(_0x57202a-lasttime)/0x3e8),lasttime=_0x57202a;}