mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-29 14:50:44 +00:00
exchanges: drop allcoin, add safecex
RIP allcoin.com, welcome safecex!
This commit is contained in:
parent
6fb14b3346
commit
ee51f1936a
6 changed files with 52 additions and 88 deletions
|
@ -49,7 +49,6 @@ class CoindbCommand extends CConsoleCommand
|
||||||
|
|
||||||
$nbUpdated = $this->grabBterIcons();
|
$nbUpdated = $this->grabBterIcons();
|
||||||
$nbUpdated += $this->grabCcexIcons();
|
$nbUpdated += $this->grabCcexIcons();
|
||||||
$nbUpdated += $this->grabAllcoinIcons();
|
|
||||||
$nbUpdated += $this->grabCryptopiaIcons();
|
$nbUpdated += $this->grabCryptopiaIcons();
|
||||||
$nbUpdated += $this->grabAlcurexIcons();
|
$nbUpdated += $this->grabAlcurexIcons();
|
||||||
$nbUpdated += $this->grabBanxIcons();
|
$nbUpdated += $this->grabBanxIcons();
|
||||||
|
@ -289,42 +288,6 @@ class CoindbCommand extends CConsoleCommand
|
||||||
return $nbUpdated;
|
return $nbUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Icon grabber - Allcoin
|
|
||||||
*/
|
|
||||||
public function grabAllcoinIcons()
|
|
||||||
{
|
|
||||||
$url = 'http://www.allcoin.com/img/icon/';
|
|
||||||
$nbUpdated = 0;
|
|
||||||
$sql = "SELECT DISTINCT coins.id FROM coins INNER JOIN markets M ON M.coinid = coins.id ".
|
|
||||||
"WHERE M.name='allcoin' AND IFNULL(coins.image,'') = ''";
|
|
||||||
$coins = dbolist($sql);
|
|
||||||
if (empty($coins))
|
|
||||||
return 0;
|
|
||||||
echo "allcoin: try to download new icons...\n";
|
|
||||||
foreach ($coins as $coin) {
|
|
||||||
$coin = getdbo('db_coins', $coin["id"]);
|
|
||||||
$symbol = $coin->symbol;
|
|
||||||
if (!empty($coin->symbol2)) $symbol = $coin->symbol2;
|
|
||||||
$local = $this->basePath."/images/coin-{$symbol}.png";
|
|
||||||
try {
|
|
||||||
$data = @ file_get_contents($url.strtolower($symbol).'.png');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strlen($data) < 2048) continue;
|
|
||||||
echo $symbol." icon found\n";
|
|
||||||
file_put_contents($local, $data);
|
|
||||||
if (filesize($local) > 0) {
|
|
||||||
$coin->image = "/images/coin-{$symbol}.png";
|
|
||||||
$nbUpdated += $coin->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($nbUpdated)
|
|
||||||
echo "$nbUpdated icons downloaded from allcoin\n";
|
|
||||||
return $nbUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icon grabber - Cryptsy (jpg only)
|
* Icon grabber - Cryptsy (jpg only)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,13 +8,13 @@ function BackendPricesUpdate()
|
||||||
updatePoloniexMarkets();
|
updatePoloniexMarkets();
|
||||||
updateBleutradeMarkets();
|
updateBleutradeMarkets();
|
||||||
updateCCexMarkets();
|
updateCCexMarkets();
|
||||||
updateCryptsyMarkets();
|
|
||||||
updateCryptopiaMarkets();
|
updateCryptopiaMarkets();
|
||||||
updateYobitMarkets();
|
updateYobitMarkets();
|
||||||
updateAllcoinMarkets();
|
updateSafecexMarkets();
|
||||||
updateAlcurexMarkets();
|
updateAlcurexMarkets();
|
||||||
updateBterMarkets();
|
updateBterMarkets();
|
||||||
updateEmpoexMarkets();
|
updateEmpoexMarkets();
|
||||||
|
updateCryptsyMarkets();
|
||||||
updateJubiMarkets();
|
updateJubiMarkets();
|
||||||
updateBanxioMarkets();
|
updateBanxioMarkets();
|
||||||
|
|
||||||
|
@ -683,34 +683,33 @@ function updateBanxioMarkets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAllcoinMarkets()
|
function updateSafecexMarkets()
|
||||||
{
|
{
|
||||||
$data = allcoin_api_query('pairs');
|
$data = safecex_api_query('getmarkets');
|
||||||
if(!is_object($data)) return;
|
if(empty($data)) return;
|
||||||
|
|
||||||
$list = getdbolist('db_markets', "name='allcoin'");
|
$list = getdbolist('db_markets', "name='safecex'");
|
||||||
foreach($list as $market)
|
foreach($list as $market)
|
||||||
{
|
{
|
||||||
$coin = getdbo('db_coins', $market->coinid);
|
$coin = getdbo('db_coins', $market->coinid);
|
||||||
if(!$coin || !$coin->installed) continue;
|
if(!$coin || !$coin->installed) continue;
|
||||||
|
|
||||||
$pair = strtoupper($coin->symbol).'_BTC';
|
$pair = strtoupper($coin->symbol).'/BTC';
|
||||||
|
|
||||||
if (isset($data->data[$pair])) {
|
foreach ($data as $ticker) {
|
||||||
$ticker = $data->data[$pair];
|
if ($ticker->market === $pair) {
|
||||||
$market->price = AverageIncrement($market->price, $ticker->top_bid);
|
|
||||||
$market->price2 = AverageIncrement($market->price2, $ticker->top_ask);
|
$price2 = ($ticker->bid + $ticker->ask)/2;
|
||||||
$market->deleted = (floatval($ticker->volume_24h_BTC) < 0.01);
|
$market->price2 = AverageIncrement($market->price2, $price2);
|
||||||
$market->save();
|
$market->price = AverageIncrement($market->price, $ticker->bid*0.98);
|
||||||
if (empty($coin->price2)) {
|
$market->save();
|
||||||
$coin->price = $market->price;
|
if (empty($coin->price)) {
|
||||||
$coin->price2 = $market->price2;
|
$coin->price = $market->price;
|
||||||
$coin->save();
|
$coin->price2 = $market->price2;
|
||||||
}
|
$coin->save();
|
||||||
if ($coin->name == 'unknown' && !empty($ticker->name)) {
|
}
|
||||||
$coin->name = $ticker->name;
|
debuglog("safecex: $pair $market->price ".bitcoinvaluetoa($market->price2));
|
||||||
$coin->save();
|
break;
|
||||||
debuglog("allcoin: update $symbol name {$coin->name}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,16 +85,16 @@ function updateRawcoins()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = allcoin_api_query('pairs');
|
$list = safecex_api_query('getmarkets');
|
||||||
if(isset($list->data))
|
if(!empty($list))
|
||||||
{
|
{
|
||||||
dborun("UPDATE markets SET deleted=true WHERE name='allcoin'");
|
dborun("UPDATE markets SET deleted=true WHERE name='safecex'");
|
||||||
foreach($list->data as $pair => $item) {
|
foreach($list as $pair => $item) {
|
||||||
if (strtoupper($item->exchange) !== 'BTC')
|
$e = explode('/', $item->market);
|
||||||
|
if (strtoupper($e[1]) !== 'BTC')
|
||||||
continue;
|
continue;
|
||||||
if (intval($item->status) == -2)
|
$symbol = strtoupper($e[0]);
|
||||||
continue;
|
updateRawCoin('safecex', $symbol);
|
||||||
updateRawCoin('allcoin', $item->type, $item->name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// https://www.allcoin.com/pub/api#market_summary
|
|
||||||
// https://www.allcoin.com/api2/pairs
|
|
||||||
|
|
||||||
function allcoin_api_query($method, $params='')
|
|
||||||
{
|
|
||||||
$uri = "https://www.allcoin.com/api2/{$method}{$params}";
|
|
||||||
|
|
||||||
$ch = curl_init($uri);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
|
|
||||||
$execResult = strip_tags(curl_exec($ch));
|
|
||||||
$obj = json_decode($execResult);
|
|
||||||
|
|
||||||
return $obj;
|
|
||||||
}
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("cryptsy.php");
|
|
||||||
require_once("poloniex.php");
|
require_once("poloniex.php");
|
||||||
require_once("bittrex.php");
|
require_once("bittrex.php");
|
||||||
require_once("ccexapi.php");
|
require_once("ccexapi.php");
|
||||||
require_once("bleutrade.php");
|
require_once("bleutrade.php");
|
||||||
require_once("yobit.php");
|
require_once("yobit.php");
|
||||||
require_once("allcoin.php");
|
require_once("cryptsy.php");
|
||||||
|
require_once("safecex.php");
|
||||||
require_once("bter.php");
|
require_once("bter.php");
|
||||||
require_once("empoex.php");
|
require_once("empoex.php");
|
||||||
require_once("jubi.php");
|
require_once("jubi.php");
|
||||||
|
@ -38,8 +38,8 @@ function getMarketUrl($coin, $marketName)
|
||||||
$url = "https://www.cryptopia.co.nz/Exchange?market={$symbol}_BTC";
|
$url = "https://www.cryptopia.co.nz/Exchange?market={$symbol}_BTC";
|
||||||
else if($marketName == 'alcurex')
|
else if($marketName == 'alcurex')
|
||||||
$url = "https://alcurex.org/index.php/crypto/market?pair={$lowsymbol}_btc";
|
$url = "https://alcurex.org/index.php/crypto/market?pair={$lowsymbol}_btc";
|
||||||
else if($marketName == 'allcoin')
|
else if($marketName == 'safecex')
|
||||||
$url = "https://www.allcoin.com/trade/{$symbol}_BTC";
|
$url = "https://safecex.com/market?q={$symbol}/BTC";
|
||||||
else if($marketName == 'bter')
|
else if($marketName == 'bter')
|
||||||
$url = "https://bter.com/trade/{$lowsymbol}_btc";
|
$url = "https://bter.com/trade/{$lowsymbol}_btc";
|
||||||
else if($marketName == 'banx')
|
else if($marketName == 'banx')
|
||||||
|
|
19
web/yaamp/core/exchange/safecex.php
Normal file
19
web/yaamp/core/exchange/safecex.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// https://safecex.com/help/api
|
||||||
|
|
||||||
|
// https://safecex.com/api/getmarkets
|
||||||
|
// https://safecex.com/api/getmarket?market=VTC/BTC
|
||||||
|
|
||||||
|
function safecex_api_query($method, $params='')
|
||||||
|
{
|
||||||
|
$uri = "https://safecex.com/api/{$method}{$params}";
|
||||||
|
|
||||||
|
$ch = curl_init($uri);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
|
$execResult = strip_tags(curl_exec($ch));
|
||||||
|
$obj = json_decode($execResult);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue