mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 09:27:25 +00:00
exchanges: link gate.io public api
look like a proper api with currencies labels but disabled by default, to reduce api calls on new setups...
This commit is contained in:
parent
d915066991
commit
d85425bcf8
4 changed files with 92 additions and 0 deletions
|
@ -14,6 +14,7 @@ function BackendPricesUpdate()
|
|||
updatePoloniexMarkets();
|
||||
updateBleutradeMarkets();
|
||||
updateCryptoBridgeMarkets();
|
||||
updateGateioMarkets();
|
||||
updateGraviexMarkets();
|
||||
updateKrakenMarkets();
|
||||
updateKuCoinMarkets();
|
||||
|
@ -333,6 +334,53 @@ function updateCryptoBridgeMarkets($force = false)
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function updateGateioMarkets($force = false)
|
||||
{
|
||||
$exchange = 'gateio';
|
||||
if (exchange_get($exchange, 'disabled')) return;
|
||||
|
||||
$list = getdbolist('db_markets', "name LIKE '$exchange%'");
|
||||
if (empty($list)) return;
|
||||
|
||||
$markets = gateio_api_query('tickers');
|
||||
if(!is_array($markets)) return;
|
||||
|
||||
foreach($list as $market)
|
||||
{
|
||||
$coin = getdbo('db_coins', $market->coinid);
|
||||
if(!$coin) continue;
|
||||
|
||||
$symbol = $coin->getOfficialSymbol();
|
||||
if (market_get($exchange, $symbol, "disabled")) {
|
||||
$market->disabled = 1;
|
||||
$market->message = 'disabled from settings';
|
||||
$market->save();
|
||||
continue;
|
||||
}
|
||||
|
||||
$dbpair = strtolower($symbol).'_btc';
|
||||
foreach ($markets as $pair => $ticker) {
|
||||
if ($pair != $dbpair) continue;
|
||||
$price2 = (doubleval($ticker['highestBid']) + doubleval($ticker['lowestAsk'])) / 2;
|
||||
$market->price = AverageIncrement($market->price, doubleval($ticker['highestBid']));
|
||||
$market->price2 = AverageIncrement($market->price2, $price2);
|
||||
$market->pricetime = time();
|
||||
$market->priority = -1;
|
||||
$market->txfee = 0.2; // trade pct
|
||||
$market->save();
|
||||
|
||||
if (empty($coin->price2)) {
|
||||
$coin->price = $market->price;
|
||||
$coin->price2 = $market->price2;
|
||||
$coin->market = $exchange;
|
||||
$coin->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function updateGraviexMarkets($force = false)
|
||||
{
|
||||
$exchange = 'graviex';
|
||||
|
|
|
@ -13,6 +13,7 @@ function updateRawcoins()
|
|||
exchange_set_default('empoex', 'disabled', true);
|
||||
exchange_set_default('coinexchange', 'disabled', true);
|
||||
exchange_set_default('coinsmarkets', 'disabled', true);
|
||||
exchange_set_default('gateio', 'disabled', true);
|
||||
exchange_set_default('jubi', 'disabled', true);
|
||||
exchange_set_default('nova', 'disabled', true);
|
||||
exchange_set_default('stocksexchange', 'disabled', true);
|
||||
|
@ -236,6 +237,22 @@ function updateRawcoins()
|
|||
}
|
||||
}
|
||||
|
||||
if (!exchange_get('gateio', 'disabled')) {
|
||||
$json = gateio_api_query('marketlist');
|
||||
$list = arraySafeVal($json,'data');
|
||||
if(!empty($list))
|
||||
{
|
||||
dborun("UPDATE markets SET deleted=true WHERE name='gateio'");
|
||||
foreach($list as $item) {
|
||||
if ($item['curr_b'] != 'BTC')
|
||||
continue;
|
||||
$symbol = trim(strtoupper($item['symbol']));
|
||||
$name = trim($item['name']);
|
||||
updateRawCoin('gateio', $symbol, $name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!exchange_get('nova', 'disabled')) {
|
||||
$list = nova_api_query('markets');
|
||||
if(is_object($list) && !empty($list->markets))
|
||||
|
|
|
@ -19,6 +19,7 @@ require_once("bleutrade.php");
|
|||
require_once("ccexapi.php");
|
||||
require_once("cexio.php");
|
||||
require_once("cryptobridge.php");
|
||||
require_once("gateio.php");
|
||||
require_once("graviex.php");
|
||||
require_once("cryptohub.php");
|
||||
require_once("kraken.php");
|
||||
|
@ -105,6 +106,8 @@ function getMarketUrl($coin, $marketName)
|
|||
$url = "https://c-cex.com/?p={$lowsymbol}-{$lowbase}";
|
||||
else if($market == 'empoex')
|
||||
$url = "http://www.empoex.com/trade/{$symbol}-{$base}";
|
||||
else if($market == 'gateio')
|
||||
$url = "https://gate.io/trade/{$symbol}_{$base}";
|
||||
else if($market == 'graviex')
|
||||
$url = "https://graviex.net/markets/{$lowsymbol}{$lowbase}";
|
||||
else if($market == 'jubi')
|
||||
|
|
24
web/yaamp/core/exchange/gateio.php
Normal file
24
web/yaamp/core/exchange/gateio.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
// https://data.gate.io/api2/1/marketlist
|
||||
// https://data.gate.io/api2/1/ticker/btc_usdt
|
||||
|
||||
function gateio_api_query($method, $params='')
|
||||
{
|
||||
$uri = "https://data.gate.io/api2/1/{$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));
|
||||
|
||||
// array required for ticker "foreach"
|
||||
$obj = json_decode($execResult, true);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue