Fix some LiveCoin error checking (#100)

* Fix some LiveCoin error checking
* Correct LiveCoin withdrawl fee
* Fix typo in LiveCoin trading call
* Log returned data not address (tofix)
This commit is contained in:
Tristian 2017-03-30 01:12:48 -04:00 committed by Tanguy Pruvot
parent a30feff2d2
commit 05950ffd93
3 changed files with 14 additions and 13 deletions

View file

@ -1068,16 +1068,14 @@ function updateLiveCoinMarkets()
$data = $livecoin->getDepositAddress($coin->symbol); $data = $livecoin->getDepositAddress($coin->symbol);
if(!empty($data) && objSafeVal($data, 'wallet', '') != '') { if(!empty($data) && objSafeVal($data, 'wallet', '') != '') {
$addr = arraySafeVal($data, 'wallet'); $addr = arraySafeVal($data, 'wallet');
if (!empty($addr) && $addr != $market->deposit_address) { if (!empty($addr)) {
if (strpos($addr, 'Error') !== false) $market->deposit_address = $addr;
$market->message = $addr; // delimiter "::" for memo / payment id
else { $market->message = null;
$market->deposit_address = $addr; debuglog("$exchange: deposit address for {$coin->symbol} updated");
// delimiter "::" for memo / payment id
$market->message = null;
debuglog("$exchange: deposit address for {$coin->symbol} updated");
}
$market->save(); $market->save();
} else {
debuglog("$exchange: Failed to update deposit address, ".json_decode($data);
} }
} }
} }

View file

@ -228,7 +228,7 @@ function doLiveCoinTrading($quick = false)
sleep(1); sleep(1);
$res = $livecoin->sellLimit($pair, $sellprice, $amount); $res = $livecoin->sellLimit($pair, $sellprice, $amount);
if (!$res->success == 'true' && $res->added == 'true') { if (!($res->success === TRUE && $res->added === TRUE)) {
debuglog('LiveCoin: Sell failed'); debuglog('LiveCoin: Sell failed');
continue; continue;
} }
@ -247,15 +247,16 @@ function doLiveCoinTrading($quick = false)
} }
/* Withdrawals */ /* Withdrawals */
$btcaddr = YAAMP_BTCADDRESS;
$withdraw_min = exchange_get($exchange, 'withdraw_min_btc', EXCH_AUTO_WITHDRAW); $withdraw_min = exchange_get($exchange, 'withdraw_min_btc', EXCH_AUTO_WITHDRAW);
$withdraw_fee = exchange_get($exchange, 'withdraw_fee_btc', 0.0002); $withdraw_fee = exchange_get($exchange, 'withdraw_fee_btc', 0.0005);
if (floatval($withdraw_min) > 0 && $savebalance->balance >= ($withdraw_min + $withdraw_fee)) { if (floatval($withdraw_min) > 0 && $savebalance->balance >= ($withdraw_min + $withdraw_fee)) {
$amount = $savebalance->balance - $withdraw_fee; $amount = $savebalance->balance - $withdraw_fee;
debuglog("$exchange: withdraw $amount BTC to $btcaddr"); debuglog("$exchange: withdraw $amount BTC to $btcaddr");
sleep(1); sleep(1);
$res = $livecoin->withdrawCoin($amount, 'BTC', $btcaddr); $res = $livecoin->withdrawCoin($amount, 'BTC', $btcaddr);
debuglog("$exchange: withdraw ".json_encode($res)); debuglog("$exchange: withdraw ".json_encode($res));
if ($res) { if (!$res->fault) {
$withdraw = new db_withdraws; $withdraw = new db_withdraws;
$withdraw->market = 'livecoin'; $withdraw->market = 'livecoin';
$withdraw->address = $btcaddr; $withdraw->address = $btcaddr;
@ -265,6 +266,8 @@ function doLiveCoinTrading($quick = false)
$withdraw->save(); $withdraw->save();
$savebalance->balance = 0; $savebalance->balance = 0;
$savebalance->save(); $savebalance->save();
} else {
debuglog("$exchange: Withdraw Failed ".json_encode($res));
} }
} }
} }

View file

@ -135,7 +135,7 @@ class CronjobController extends CommonController
doBittrexTrading(); doBittrexTrading();
doCryptopiaTrading(); doCryptopiaTrading();
doKrakenTrading(); doKrakenTrading();
doLivecoinTrading(); doLiveCoinTrading();
doPoloniexTrading(); doPoloniexTrading();
break; break;