mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-30 15:20:36 +00:00
c-cex: add new apis + auto withdraw
This commit is contained in:
parent
d1905c6665
commit
7e739906a1
2 changed files with 50 additions and 2 deletions
|
@ -94,13 +94,39 @@ class CcexAPI
|
|||
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=makeorder&pair={$pair}&q={$quantity}&t={$type}&r={$price}");
|
||||
}
|
||||
|
||||
public function cancelOrder($order){
|
||||
public function cancelOrder($order) {
|
||||
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=cancelorder&id={$order}");
|
||||
}
|
||||
|
||||
public function getBalance(){
|
||||
public function getBalance() {
|
||||
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=getbalance");
|
||||
}
|
||||
|
||||
// If not exists - will generate new
|
||||
public function getDepositAddress($symbol) {
|
||||
$coin = strtolower($symbol);
|
||||
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=getaddress&coin={$coin}");
|
||||
}
|
||||
|
||||
public function checkDeposit($symbol, $txid) {
|
||||
$coin = strtolower($symbol);
|
||||
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=checkdeposit&coin={$coin}&tid={$txid}");
|
||||
}
|
||||
|
||||
public function withdraw($symbol, $amount, $address) {
|
||||
$coin = strtolower($symbol);
|
||||
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=withdraw&coin={$coin}&amount={$amount}&address={$address}");
|
||||
}
|
||||
|
||||
public function getDepositHistory($symbol, $limit=100) {
|
||||
$coin = strtolower($symbol);
|
||||
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=deposithistory&coin={$coin}&limit={$limit}");
|
||||
}
|
||||
|
||||
public function getWithdrawalHistory($symbol, $limit=100) {
|
||||
$coin = strtolower($symbol);
|
||||
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=withdrawalhistory&coin={$coin}&limit={$limit}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -192,6 +192,28 @@ function doCCexTrading($quick=false)
|
|||
$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("[ccex] - withdraw $amount to $btcaddr");
|
||||
sleep(1);
|
||||
$res = $ccex->withdraw('BTC', $amount, $btcaddr);
|
||||
debuglog("[ccex] - withdraw: ".json_encode($res));
|
||||
if(isset($res['return']))
|
||||
{
|
||||
$withdraw = new db_withdraws;
|
||||
$withdraw->market = 'c-cex';
|
||||
$withdraw->address = $btcaddr;
|
||||
$withdraw->amount = $amount;
|
||||
$withdraw->time = time();
|
||||
$withdraw->uuid = $res['return'];
|
||||
$withdraw->save();
|
||||
|
||||
$savebalance->balance = 0;
|
||||
$savebalance->save();
|
||||
}
|
||||
}
|
||||
// debuglog('-------------- doCCexTrading() done');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue