From c3f2e90c26f51d943182bf40c7c4e2ea72e0e32a Mon Sep 17 00:00:00 2001 From: crackfoo Date: Fri, 1 Apr 2016 00:01:17 -0300 Subject: [PATCH] yobit: add auto withdraw BTC fixed (tpruvot) --- web/yaamp/core/trading/yobit_trading.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/web/yaamp/core/trading/yobit_trading.php b/web/yaamp/core/trading/yobit_trading.php index 4db79b5..8a212d0 100644 --- a/web/yaamp/core/trading/yobit_trading.php +++ b/web/yaamp/core/trading/yobit_trading.php @@ -215,6 +215,30 @@ function doYobitTrading($quick=false) $db_order->uuid = $res['return']['order_id']; $db_order->created = time(); $db_order->save(); + + if(floatval(EXCH_AUTO_WITHDRAW) > 0 && $savebalance->balance >= (EXCH_AUTO_WITHDRAW + 0.0002)) + { + $btcaddr = YAAMP_BTCADDRESS; + $amount = $savebalance->balance + 0.0002; + debuglog("[yobit] - withdraw $amount to $btcaddr"); + + sleep(1); + $res = yobit_api_query2('WithdrawCoinsToAddress', array('coinName' => 'BTC', 'amount' => $amount, 'address' => $btcaddr)); + if($res && $res['success']) + { + $withdraw = new db_withdraws; + $withdraw->market = 'yobit'; + $withdraw->address = $btcaddr; + $withdraw->amount = $amount; + $withdraw->time = time(); + $withdraw->save(); + + $savebalance->balance = 0; + $savebalance->save(); + } else { + debuglog("yobit: withdraw error ".json_encode($res)); + } + } } }