mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
api: handle cryptobridge public balances
via the BitShares Block Explorer API...
This commit is contained in:
parent
7ad0900772
commit
a36f11d6ba
5 changed files with 80 additions and 0 deletions
|
@ -55,6 +55,7 @@ define('EXCH_CEXIO_KEY', '');
|
||||||
define('EXCH_COINMARKETS_USER', '');
|
define('EXCH_COINMARKETS_USER', '');
|
||||||
define('EXCH_COINMARKETS_PIN', '');
|
define('EXCH_COINMARKETS_PIN', '');
|
||||||
define('EXCH_CREX24_KEY', '');
|
define('EXCH_CREX24_KEY', '');
|
||||||
|
define('EXCH_CRYPTOBRIDGE_ID', '');
|
||||||
define('EXCH_BINANCE_KEY', '');
|
define('EXCH_BINANCE_KEY', '');
|
||||||
define('EXCH_BITSTAMP_ID','');
|
define('EXCH_BITSTAMP_ID','');
|
||||||
define('EXCH_BITSTAMP_KEY','');
|
define('EXCH_BITSTAMP_KEY','');
|
||||||
|
|
75
web/yaamp/core/trading/cryptobridge_trading.php
Normal file
75
web/yaamp/core/trading/cryptobridge_trading.php
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
# API able to query balances
|
||||||
|
# https://cryptofresh.com/api/account/balances?account=...
|
||||||
|
|
||||||
|
function cryptobridge_api_user($method, $params='')
|
||||||
|
{
|
||||||
|
$uri = "https://cryptofresh.com/api/{$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);
|
||||||
|
|
||||||
|
$execResult = strip_tags(curl_exec($ch));
|
||||||
|
$arr = json_decode($execResult, true);
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function doCryptobridgeTrading($quick=false)
|
||||||
|
{
|
||||||
|
$exchange = 'cryptobridge';
|
||||||
|
$updatebalances = true;
|
||||||
|
|
||||||
|
if (empty(EXCH_CRYPTOBRIDGE_ID)) return;
|
||||||
|
if (exchange_get($exchange, 'disabled')) return;
|
||||||
|
|
||||||
|
$balances = cryptobridge_api_user('account/balances','account='.EXCH_CRYPTOBRIDGE_ID);
|
||||||
|
if (!is_array($balances)) return;
|
||||||
|
|
||||||
|
$savebalance = getdbosql('db_balances', "name='$exchange'");
|
||||||
|
if (is_object($savebalance)) {
|
||||||
|
$savebalance->balance = 0;
|
||||||
|
$savebalance->onsell = 0;
|
||||||
|
$savebalance->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($balances as $asset => $balance)
|
||||||
|
{
|
||||||
|
$parts = explode('.', $asset);
|
||||||
|
$symbol = arraySafeVal($parts,1);
|
||||||
|
if (empty($symbol) || $parts[0] != 'BRIDGE') continue;
|
||||||
|
|
||||||
|
if ($symbol == 'BTC') {
|
||||||
|
if (is_object($savebalance)) {
|
||||||
|
$savebalance->balance = arraySafeVal($balance,'balance',0);
|
||||||
|
$savebalance->onsell = arraySafeVal($balance,'orders',0);
|
||||||
|
$savebalance->save();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($updatebalances) {
|
||||||
|
// store available balance in market table
|
||||||
|
$coins = getdbolist('db_coins', "symbol=:symbol OR symbol2=:symbol",
|
||||||
|
array(':symbol'=>$symbol)
|
||||||
|
);
|
||||||
|
if (empty($coins)) continue;
|
||||||
|
foreach ($coins as $coin) {
|
||||||
|
$market = getdbosql('db_markets', "coinid=:coinid AND name='$exchange'", array(':coinid'=>$coin->id));
|
||||||
|
if (!$market) continue;
|
||||||
|
$market->balance = arraySafeVal($balance,'balance',0);
|
||||||
|
$market->ontrade = arraySafeVal($balance,'orders',0);
|
||||||
|
$market->balancetime = time();
|
||||||
|
$market->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!YAAMP_ALLOW_EXCHANGE) return;
|
||||||
|
|
||||||
|
// more could be done i guess
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ require_once('yobit_trading.php');
|
||||||
require_once('alcurex_trading.php');
|
require_once('alcurex_trading.php');
|
||||||
require_once('coinsmarkets_trading.php');
|
require_once('coinsmarkets_trading.php');
|
||||||
require_once('crex24_trading.php');
|
require_once('crex24_trading.php');
|
||||||
|
require_once('cryptobridge_trading.php');
|
||||||
require_once('cryptopia_trading.php');
|
require_once('cryptopia_trading.php');
|
||||||
require_once('hitbtc_trading.php');
|
require_once('hitbtc_trading.php');
|
||||||
require_once('kucoin_trading.php');
|
require_once('kucoin_trading.php');
|
||||||
|
@ -88,6 +89,7 @@ function runExchange($exchangeName=false)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cryptobridge':
|
case 'cryptobridge':
|
||||||
|
doCryptobridgeTrading(true);
|
||||||
updateCryptoBridgeMarkets();
|
updateCryptoBridgeMarkets();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ if (!defined('EXCH_CCEX_KEY')) define('EXCH_CCEX_KEY', '');
|
||||||
if (!defined('EXCH_CEXIO_ID')) define('EXCH_CEXIO_ID', '');
|
if (!defined('EXCH_CEXIO_ID')) define('EXCH_CEXIO_ID', '');
|
||||||
if (!defined('EXCH_CEXIO_KEY')) define('EXCH_CEXIO_KEY', '');
|
if (!defined('EXCH_CEXIO_KEY')) define('EXCH_CEXIO_KEY', '');
|
||||||
if (!defined('EXCH_CREX24_KEY')) define('EXCH_CREX24_KEY', '');
|
if (!defined('EXCH_CREX24_KEY')) define('EXCH_CREX24_KEY', '');
|
||||||
|
if (!defined('EXCH_CRYPTOBRIDGE_ID')) define('EXCH_CRYPTOBRIDGE_ID', '');
|
||||||
if (!defined('EXCH_CRYPTOPIA_KEY')) define('EXCH_CRYPTOPIA_KEY', '');
|
if (!defined('EXCH_CRYPTOPIA_KEY')) define('EXCH_CRYPTOPIA_KEY', '');
|
||||||
if (!defined('EXCH_HITBTC_KEY')) define('EXCH_HITBTC_KEY', '');
|
if (!defined('EXCH_HITBTC_KEY')) define('EXCH_HITBTC_KEY', '');
|
||||||
if (!defined('EXCH_POLONIEX_KEY')) define('EXCH_POLONIEX_KEY', '');
|
if (!defined('EXCH_POLONIEX_KEY')) define('EXCH_POLONIEX_KEY', '');
|
||||||
|
|
|
@ -143,6 +143,7 @@ class CronjobController extends CommonController
|
||||||
doCCexTrading();
|
doCCexTrading();
|
||||||
doBterTrading();
|
doBterTrading();
|
||||||
doBleutradeTrading();
|
doBleutradeTrading();
|
||||||
|
doCryptobridgeTrading();
|
||||||
doKuCoinTrading();
|
doKuCoinTrading();
|
||||||
doNovaTrading();
|
doNovaTrading();
|
||||||
doYobitTrading();
|
doYobitTrading();
|
||||||
|
|
Loading…
Add table
Reference in a new issue