From 05950ffd93f30e85f2c2dca117e3839e69e42d23 Mon Sep 17 00:00:00 2001 From: Tristian Date: Thu, 30 Mar 2017 01:12:48 -0400 Subject: [PATCH] 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) --- web/yaamp/core/backend/markets.php | 16 +++++++--------- web/yaamp/core/trading/livecoin_trading.php | 9 ++++++--- web/yaamp/modules/thread/CronjobController.php | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/web/yaamp/core/backend/markets.php b/web/yaamp/core/backend/markets.php index 9bba248..3f23e06 100644 --- a/web/yaamp/core/backend/markets.php +++ b/web/yaamp/core/backend/markets.php @@ -1068,16 +1068,14 @@ function updateLiveCoinMarkets() $data = $livecoin->getDepositAddress($coin->symbol); if(!empty($data) && objSafeVal($data, 'wallet', '') != '') { $addr = arraySafeVal($data, 'wallet'); - if (!empty($addr) && $addr != $market->deposit_address) { - if (strpos($addr, 'Error') !== false) - $market->message = $addr; - else { - $market->deposit_address = $addr; - // delimiter "::" for memo / payment id - $market->message = null; - debuglog("$exchange: deposit address for {$coin->symbol} updated"); - } + if (!empty($addr)) { + $market->deposit_address = $addr; + // delimiter "::" for memo / payment id + $market->message = null; + debuglog("$exchange: deposit address for {$coin->symbol} updated"); $market->save(); + } else { + debuglog("$exchange: Failed to update deposit address, ".json_decode($data); } } } diff --git a/web/yaamp/core/trading/livecoin_trading.php b/web/yaamp/core/trading/livecoin_trading.php index f3cfa14..01df0d4 100644 --- a/web/yaamp/core/trading/livecoin_trading.php +++ b/web/yaamp/core/trading/livecoin_trading.php @@ -228,7 +228,7 @@ function doLiveCoinTrading($quick = false) sleep(1); $res = $livecoin->sellLimit($pair, $sellprice, $amount); - if (!$res->success == 'true' && $res->added == 'true') { + if (!($res->success === TRUE && $res->added === TRUE)) { debuglog('LiveCoin: Sell failed'); continue; } @@ -247,15 +247,16 @@ function doLiveCoinTrading($quick = false) } /* Withdrawals */ + $btcaddr = YAAMP_BTCADDRESS; $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)) { $amount = $savebalance->balance - $withdraw_fee; debuglog("$exchange: withdraw $amount BTC to $btcaddr"); sleep(1); $res = $livecoin->withdrawCoin($amount, 'BTC', $btcaddr); debuglog("$exchange: withdraw ".json_encode($res)); - if ($res) { + if (!$res->fault) { $withdraw = new db_withdraws; $withdraw->market = 'livecoin'; $withdraw->address = $btcaddr; @@ -265,6 +266,8 @@ function doLiveCoinTrading($quick = false) $withdraw->save(); $savebalance->balance = 0; $savebalance->save(); + } else { + debuglog("$exchange: Withdraw Failed ".json_encode($res)); } } } diff --git a/web/yaamp/modules/thread/CronjobController.php b/web/yaamp/modules/thread/CronjobController.php index 362c97e..68fdcf7 100644 --- a/web/yaamp/modules/thread/CronjobController.php +++ b/web/yaamp/modules/thread/CronjobController.php @@ -135,7 +135,7 @@ class CronjobController extends CommonController doBittrexTrading(); doCryptopiaTrading(); doKrakenTrading(); - doLivecoinTrading(); + doLiveCoinTrading(); doPoloniexTrading(); break;