mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
coinbene public api, optional
(disabled by default in settings table)
This commit is contained in:
parent
46d40cd75c
commit
42a6e8529e
4 changed files with 80 additions and 1 deletions
|
@ -20,6 +20,7 @@ function BackendPricesUpdate()
|
|||
updateKrakenMarkets();
|
||||
updateKuCoinMarkets();
|
||||
updateCCexMarkets();
|
||||
updateCoinbeneMarkets();
|
||||
updateCrex24Markets();
|
||||
updateCryptopiaMarkets();
|
||||
updateHitBTCMarkets();
|
||||
|
@ -982,6 +983,46 @@ function updateAlcurexMarkets()
|
|||
}
|
||||
}
|
||||
|
||||
function updateCoinbeneMarkets()
|
||||
{
|
||||
$exchange = 'coinbene';
|
||||
if (exchange_get($exchange, 'disabled')) return;
|
||||
|
||||
$list = getdbolist('db_markets', "name LIKE '$exchange%'");
|
||||
if (empty($list)) return;
|
||||
|
||||
$data = coinbene_api_query('market/ticker', 'symbol=all');
|
||||
$data = objSafeVal($data,'ticker');
|
||||
if(!is_array($data)) return;
|
||||
|
||||
foreach($list as $market) {
|
||||
$coin = getdbo('db_coins', $market->coinid);
|
||||
if(!$coin) continue;
|
||||
if(!$coin->installed && !$coin->watch) continue;
|
||||
|
||||
$symbol = $coin->getOfficialSymbol();
|
||||
if (market_get($exchange, $symbol, "disabled")) {
|
||||
$market->disabled = 1;
|
||||
$market->message = 'disabled from settings';
|
||||
$market->save();
|
||||
continue;
|
||||
}
|
||||
|
||||
$pair = $symbol.'BTC';
|
||||
foreach($data as $ticker) {
|
||||
if ($ticker->symbol != $pair) continue;
|
||||
|
||||
$price2 = ($ticker->bid+$ticker->ask)/2;
|
||||
$market->price2 = AverageIncrement($market->price2, $price2);
|
||||
$market->price = AverageIncrement($market->price, $ticker->bid);
|
||||
$market->pricetime = time();
|
||||
$market->save();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateCrex24Markets()
|
||||
{
|
||||
$exchange = 'crex24';
|
||||
|
|
|
@ -11,6 +11,7 @@ function updateRawcoins()
|
|||
exchange_set_default('binance', 'disabled', true);
|
||||
exchange_set_default('bter', 'disabled', true);
|
||||
exchange_set_default('empoex', 'disabled', true);
|
||||
exchange_set_default('coinbene', 'disabled', true);
|
||||
exchange_set_default('coinexchange', 'disabled', true);
|
||||
exchange_set_default('coinsmarkets', 'disabled', true);
|
||||
exchange_set_default('gateio', 'disabled', true);
|
||||
|
@ -65,6 +66,19 @@ function updateRawcoins()
|
|||
}
|
||||
}
|
||||
|
||||
if (!exchange_get('coinbene', 'disabled')) {
|
||||
$data = coinbene_api_query('market/symbol');
|
||||
$list = objSafeVal($data, 'symbol');
|
||||
if(is_array($list) && !empty($list)) {
|
||||
dborun("UPDATE markets SET deleted=true WHERE name='coinbene'");
|
||||
foreach($list as $ticker) {
|
||||
if ($ticker->quoteAsset != 'BTC') continue;
|
||||
$symbol = $ticker->baseAsset;
|
||||
updateRawCoin('coinbene', $symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!exchange_get('crex24', 'disabled')) {
|
||||
$list = crex24_api_query('currencies');
|
||||
if(is_array($list) && !empty($list)) {
|
||||
|
@ -450,7 +464,7 @@ function updateRawCoin($marketname, $symbol, $name='unknown')
|
|||
}
|
||||
|
||||
// some other to ignore...
|
||||
if (in_array($marketname, array('crex24','yobit','kucoin','tradesatoshi')))
|
||||
if (in_array($marketname, array('crex24','yobit','coinbene','kucoin','tradesatoshi')))
|
||||
return;
|
||||
|
||||
if (market_get($marketname, $symbol, "disabled")) {
|
||||
|
|
21
web/yaamp/core/exchange/coinbene.php
Normal file
21
web/yaamp/core/exchange/coinbene.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
// https://api.coinbene.com/v1/market/symbol
|
||||
// https://api.coinbene.com/v1/market/ticker?symbol=all
|
||||
|
||||
function coinbene_api_query($method, $params='')
|
||||
{
|
||||
$uri = "https://api.coinbene.com/v1/{$method}";
|
||||
if (!empty($params)) $uri .= "?{$params}";
|
||||
|
||||
$ch = curl_init($uri);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
$execResult = strip_tags(curl_exec($ch));
|
||||
$obj = json_decode($execResult);
|
||||
return $obj;
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ require_once("bitz.php");
|
|||
require_once("bleutrade.php");
|
||||
require_once("ccexapi.php");
|
||||
require_once("cexio.php");
|
||||
require_once("coinbene.php");
|
||||
require_once("crex24.php");
|
||||
require_once("cryptobridge.php");
|
||||
require_once("gateio.php");
|
||||
|
@ -93,6 +94,8 @@ function getMarketUrl($coin, $marketName)
|
|||
$url = "https://bter.com/trade/{$lowsymbol}_{$lowbase}";
|
||||
else if($market == 'cexio')
|
||||
$url = "https://cex.io/trade/{$symbol}-{$base}";
|
||||
else if($market == 'coinbene')
|
||||
$url = "https://www.coinbene.com/#/market?pairId={$symbol}{$base}";
|
||||
else if($market == 'coinexchange')
|
||||
$url = "https://www.coinexchange.io/market/{$symbol}/{$base}";
|
||||
else if($market == 'coinsmarkets')
|
||||
|
|
Loading…
Add table
Reference in a new issue