diff --git a/web/yaamp/core/backend/markets.php b/web/yaamp/core/backend/markets.php index 5156a5e3b..b9a332f87 100644 --- a/web/yaamp/core/backend/markets.php +++ b/web/yaamp/core/backend/markets.php @@ -11,6 +11,7 @@ function BackendPricesUpdate() settings_prefetch_all(); updateBittrexMarkets(); + updateBitzMarkets(); updatePoloniexMarkets(); updateBleutradeMarkets(); updateCryptoBridgeMarkets(); @@ -288,6 +289,42 @@ function updateBleutradeMarkets() } + ///////////////////////////////////////////////////////////////////////////////////////////// + +function updateBitzMarkets($force = false) +{ + $exchange = 'bitz'; + if (exchange_get($exchange, 'disabled')) return; + + $markets = bitz_api_query('tickerall'); + + foreach($markets as $c => $ticker) + { + $pairs = explode('_', $c); + $symbol = strtoupper(reset($pairs)); $base = end($pairs); + if($symbol == 'BTC' || $base != 'btc') continue; + + if (market_get($exchange, $symbol, "disabled")) { + $market->disabled = 1; + $market->message = 'disabled from settings'; + } + $coin = getdbosql('db_coins', "symbol='{$symbol}'"); + if(!$coin) continue; + if(!$coin->installed && !$coin->watch) continue; + $market = getdbosql('db_markets', "coinid={$coin->id} and name='{$exchange}'"); + + if(!$market) continue; + $price2 = ($ticker->bidPrice + $ticker->askPrice)/2; + $market->price2 = AverageIncrement($market->price2, $price2); + $market->price = AverageIncrement($market->price, $ticker->bidPrice); + $market->pricetime = time(); + $market->priority = -1; + $market->txfee = 0.2; // trade pct + $market->save(); + // debuglog("$exchange: update $symbol: {$market->price} {$market->price2}"); + } +} + ///////////////////////////////////////////////////////////////////////////////////////////// function updateCryptoBridgeMarkets($force = false) diff --git a/web/yaamp/core/backend/rawcoins.php b/web/yaamp/core/backend/rawcoins.php index 8d38269c1..70de461f0 100644 --- a/web/yaamp/core/backend/rawcoins.php +++ b/web/yaamp/core/backend/rawcoins.php @@ -36,6 +36,19 @@ function updateRawcoins() } } + if (!exchange_get('bitz', 'disabled')) { + $list = bitz_api_query('tickerall'); + + dborun("UPDATE markets SET deleted=true WHERE name='bitz'"); + foreach($list as $c => $ticker) { + $e = explode('_', $c); + if (strtoupper($e[1]) !== 'BTC') + continue; + $symbol = strtoupper($e[0]); + updateRawCoin('bitz', $symbol); + } + } + if (!exchange_get('bleutrade', 'disabled')) { $list = bleutrade_api_query('public/getcurrencies'); if(isset($list->result) && !empty($list->result)) @@ -417,7 +430,7 @@ function updateRawCoin($marketname, $symbol, $name='unknown') } } - if (in_array($marketname, array('nova','askcoin','binance','coinexchange','coinsmarkets','cryptobridge','hitbtc'))) { + if (in_array($marketname, array('nova','askcoin','binance','bitz','coinexchange','coinsmarkets','cryptobridge','hitbtc'))) { // don't polute too much the db with new coins, its better from exchanges with labels return; } diff --git a/web/yaamp/core/exchange/bitz.php b/web/yaamp/core/exchange/bitz.php new file mode 100644 index 000000000..37405710e --- /dev/null +++ b/web/yaamp/core/exchange/bitz.php @@ -0,0 +1,24 @@ +data; +} diff --git a/web/yaamp/core/exchange/exchange.php b/web/yaamp/core/exchange/exchange.php index 5bafc90a0..2cad682ea 100644 --- a/web/yaamp/core/exchange/exchange.php +++ b/web/yaamp/core/exchange/exchange.php @@ -15,6 +15,7 @@ function strip_data($data) require_once("bitstamp.php"); require_once("bittrex.php"); +require_once("bitz.php"); require_once("bleutrade.php"); require_once("ccexapi.php"); require_once("cexio.php"); @@ -82,6 +83,8 @@ function getMarketUrl($coin, $marketName) $url = "https://www.binance.com/trade.html?symbol={$symbol}_{$base}"; else if($market == 'bittrex') $url = "https://bittrex.com/Market/Index?MarketName={$base}-{$symbol}"; + else if($market == 'bitz') + $url = "https://www.bit-z.com/exchange/{$symbol}_{$base}"; else if($market == 'poloniex') $url = "https://poloniex.com/exchange#{$lowbase}_{$lowsymbol}"; else if($market == 'bleutrade') diff --git a/web/yaamp/core/trading/trading.php b/web/yaamp/core/trading/trading.php index f82205ebc..c8575fb1b 100644 --- a/web/yaamp/core/trading/trading.php +++ b/web/yaamp/core/trading/trading.php @@ -90,6 +90,9 @@ function runExchange($exchangeName=false) doBittrexTrading(true); updateBittrexMarkets(); break; + case 'bitz': + updateBitzMarkets(); + break; case 'cexio': getCexIoBalances(); diff --git a/web/yaamp/defaultconfig.php b/web/yaamp/defaultconfig.php index 589c11ee2..71e89b769 100644 --- a/web/yaamp/defaultconfig.php +++ b/web/yaamp/defaultconfig.php @@ -48,6 +48,8 @@ if (!defined('YAAMP_BTCADDRESS')) define('YAAMP_BTCADDRESS', ''); if (!defined('YAAMP_SITE_URL')) define('YAAMP_SITE_URL', 'localhost'); if (!defined('YAAMP_API_URL')) define('YAAMP_API_URL', YAAMP_SITE_URL); +if (!defined('YAAMP_API_PAYOUTS')) define('YAAMP_API_PAYOUTS', false); +if (!defined('YAAMP_API_PAYOUTS_PERIOD')) define('YAAMP_API_PAYOUTS_PERIOD', 24 * 60 * 60); if (!defined('YAAMP_STRATUM_URL')) define('YAAMP_STRATUM_URL', YAAMP_SITE_URL); if (!defined('YAAMP_SITE_NAME')) define('YAAMP_SITE_NAME', 'YiiMP'); if (!defined('YAAMP_DEFAULT_ALGO')) define('YAAMP_DEFAULT_ALGO', 'x11'); diff --git a/web/yaamp/modules/api/ApiController.php b/web/yaamp/modules/api/ApiController.php index d1217c5b4..b6a7f0553 100644 --- a/web/yaamp/modules/api/ApiController.php +++ b/web/yaamp/modules/api/ApiController.php @@ -284,6 +284,29 @@ public function actionWalletEx() } echo "]"; + + if(YAAMP_API_PAYOUTS) + { + $json_payouts = controller()->memcache->get("api_payouts-$user->id"); + if (empty($json_payouts)) { + $json_payouts = ",\"payouts\": "; + $json_payouts .= "["; + $list = getdbolist('db_payouts', "account_id={$user->id} AND completed>0 AND tx IS NOT NULL AND time >= ".(time() - YAAMP_API_PAYOUTS_PERIOD)." ORDER BY time DESC"); + foreach($list as $j => payout) + { + if($j) $json_payouts .= ", "; + $json_payouts .= "{"; + $json_payouts .= "\"time\": \"$payout->time\","; + $json_payouts .= "\"amount\": \"$payout->amount\","; + $json_payouts .= "\"tx\": \"$payout->tx\""; + $json_payouts .= "}"; + } + $json_payouts .= "]"; + controller()->memcache->set("api_payouts-$user->id", $json_payouts, 60, MEMCACHE_COMPRESSED); + } + echo str_replace("},","},\n", $json_payouts); + } + echo "}"; } diff --git a/web/yaamp/modules/site/api.php b/web/yaamp/modules/site/api.php index 2a7520b02..0c84881ed 100644 --- a/web/yaamp/modules/site/api.php +++ b/web/yaamp/modules/site/api.php @@ -45,9 +45,19 @@ "accepted": 82463372.083, "rejected": 0 }] + + "payouts":[{ + "time": "1529860641", + "amount": "0.001", + "tx": "transaction_id_of_the_payout" + }] + } - +
Pool Status
request: