mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
api: kucoin v2 private api changes
This commit is contained in:
parent
20655e5700
commit
a5de1e3d1a
3 changed files with 11 additions and 12 deletions
|
@ -191,8 +191,8 @@ class ExchangeCommand extends CConsoleCommand
|
|||
$balance = kraken_api_user('Balance');
|
||||
echo("kraken btc: ".json_encode($balance)."\n");
|
||||
}
|
||||
if (!empty(EXCH_KUCOIN_KEY)) {
|
||||
$balance = kucoin_api_user('accounts'/*,array('currency=BTC')*/);
|
||||
if (!empty(EXCH_KUCOIN_KEY) && !empty(EXCH_KUCOIN_PASSPHRASE)) {
|
||||
$balance = kucoin_api_user('accounts',array('currency'=>'BTC'));
|
||||
if (!is_object($balance) || !isset($balance->data)) echo "kucoin error ".json_encode($balance)."\n";
|
||||
else echo("kucoin: ".json_encode($balance->data)."\n");
|
||||
}
|
||||
|
|
|
@ -339,14 +339,13 @@ function updateRawcoins()
|
|||
}
|
||||
|
||||
if (!exchange_get('kucoin', 'disabled')) {
|
||||
$list = kucoin_api_query('market/open/coins');
|
||||
$list = kucoin_api_query('currencies');
|
||||
if(is_object($list) && isset($list->data) && !empty($list->data))
|
||||
{
|
||||
dborun("UPDATE markets SET deleted=true WHERE name='kucoin'");
|
||||
foreach($list->data as $item) {
|
||||
$symbol = $item->coin;
|
||||
$name = $item->name;
|
||||
if (strpos($item->withdrawRemark,'Ethereum')) continue;
|
||||
$symbol = $item->name;
|
||||
$name = $item->fullName;
|
||||
updateRawCoin('kucoin', $symbol, $name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,14 +74,14 @@ function kucoin_api_user($method, $params=NULL, $isPostMethod=false)
|
|||
|
||||
$req = $isPostMethod ? "POST" : "GET";
|
||||
$tosign = "{$nonce}{$req}{$endpoint}{$body}";
|
||||
$hmac = strtolower(hash_hmac('sha256', base64_encode($tosign), EXCH_KUCOIN_SECRET));
|
||||
$hmac = hash_hmac('sha256', $tosign, EXCH_KUCOIN_SECRET, true);
|
||||
|
||||
$headers = array(
|
||||
'Content-Type: application/json;charset=UTF-8',
|
||||
'KC-API-KEY: '.EXCH_KUCOIN_KEY,
|
||||
'KC-API-PASSPHRASE: '.EXCH_KUCOIN_PASSPHRASE,
|
||||
'KC-API-TIMESTAMP: '.$nonce,
|
||||
'KC-API-SIGN: '.$hmac,
|
||||
'KC-API-SIGN: '.base64_encode($hmac),
|
||||
);
|
||||
|
||||
$ch = curl_init();
|
||||
|
@ -145,14 +145,14 @@ function kucoin_update_market($market)
|
|||
}
|
||||
|
||||
$t1 = microtime(true);
|
||||
$query = kucoin_api_query("$pair/open/tick");
|
||||
$query = kucoin_api_query('market/orderbook/level1','symbol='.$pair);
|
||||
if(!kucoin_result_valid($query)) return false;
|
||||
$ticker = $query->data;
|
||||
|
||||
$price2 = ((double) $ticker->buy + (double)$ticker->sell)/2;
|
||||
$price2 = ((double) $ticker->bestBid + (double)$ticker->bestAsk)/2;
|
||||
$market->price2 = AverageIncrement($market->price2, $price2);
|
||||
$market->price = AverageIncrement($market->price, $ticker->buy);
|
||||
$market->pricetime = time();
|
||||
$market->price = AverageIncrement($market->price, $ticker->bestBid);
|
||||
$market->pricetime = min(time(), 0 + $ticker->sequence);
|
||||
$market->save();
|
||||
|
||||
$apims = round((microtime(true) - $t1)*1000,3);
|
||||
|
|
Loading…
Add table
Reference in a new issue