Skip to content

Commit

Permalink
Merge pull request #45 from artemii235/etomic
Browse files Browse the repository at this point in the history
Merge latest fixes from jl777 dev branch.
  • Loading branch information
artemii235 authored May 16, 2018
2 parents 7ca0510 + 2d12ffa commit 7579120
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
5 changes: 4 additions & 1 deletion iguana/exchanges/LP_portfolio.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ int32_t LP_autoref_clear(char *base,char *rel)
void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
{
static cJSON *tickerjson; static uint32_t lasttime;
char *retstr,*base,*rel; cJSON *retjson,*bid,*ask,*fundjson,*argjson; uint64_t bidsatoshis,asksatoshis; int32_t i,changed; double bidprice,askprice,bch_usd,bch_btc,nxtkmd,price,factor,offset,newprice,buymargin,sellmargin,price_btc,price_usd,kmd_btc,kmd_usd; struct LP_priceinfo *kmdpp,*fiatpp,*nxtpp,*basepp,*relpp;
char *retstr,*base,*rel; cJSON *retjson,*bid,*ask,*fundjson,*argjson; uint64_t bidsatoshis,asksatoshis; int32_t i,changed; double bidprice,askprice,bch_usd,ltc_btc,bch_btc,nxtkmd,price,factor,offset,newprice,buymargin,sellmargin,price_btc,price_usd,kmd_btc,kmd_usd; struct LP_priceinfo *kmdpp,*fiatpp,*nxtpp,*basepp,*relpp;
printf("AUTOPRICE numautorefs.%d\n",num_LP_autorefs);
if ( (retstr= issue_curlt("https://bittrex.com/api/v1.1/public/getmarketsummaries",LP_HTTP_TIMEOUT*10)) == 0 )
{
Expand Down Expand Up @@ -551,6 +551,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
}
kmd_btc = LP_CMCbtcprice(&kmd_usd,"komodo");
bch_btc = LP_CMCbtcprice(&bch_usd,"bitcoin-cash");
ltc_btc = LP_CMCbtcprice(&bch_usd,"litecoin");
for (i=0; i<num_LP_autorefs; i++)
{
rel = LP_autorefs[i].rel;
Expand Down Expand Up @@ -609,6 +610,8 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
price = kmd_btc / price_btc;
else if ( strcmp(rel,"BCH") == 0 && bch_btc > SMALLVAL )
price = bch_btc / price_btc;
else if ( strcmp(rel,"LTC") == 0 && ltc_btc > SMALLVAL )
price = ltc_btc / price_btc;
else if ( strcmp(rel,"BTC") == 0 )
price = 1. / price_btc;
else continue;
Expand Down
16 changes: 9 additions & 7 deletions iguana/exchanges/LP_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ char *LP_createblasttransaction(uint64_t *changep,int32_t *changeoutp,cJSON **tx
return(0);
}
}
if ( change < 6000 )
if ( change < 6000 || change < txfee )
change = 0;
*changep = change;
if ( change != 0 )
Expand Down Expand Up @@ -1913,15 +1913,17 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)

char *LP_autosplit(struct iguana_info *coin)
{
char *retstr; cJSON *argjson,*withdrawjson,*outputs,*item; int64_t total,balance,halfval;
char *retstr; cJSON *argjson,*withdrawjson,*outputs,*item; int64_t total,balance,halfval,txfee;
if ( coin->etomic[0] == 0 )
{
if ( coin->electrum != 0 )
balance = LP_unspents_load(coin->symbol,coin->smartaddr);
else balance = LP_RTsmartbalance(coin);
//printf("%s balance %.8f\n",coin->symbol,dstr(balance));
balance -= coin->txfee - 0.001;
if ( balance > coin->txfee )
if ( (txfee= coin->txfee) == 0 ) // BTC
txfee = LP_txfeecalc(coin,0,500);
balance -= (txfee + 100000);
//printf("balance %.8f, txfee %.8f, threshold %.8f\n",dstr(balance),dstr(txfee),dstr((1000000 - (txfee + 100000))));
if ( balance > txfee && balance >= (1000000 - (txfee + 100000)) )
{
halfval = (balance / 100) * 45;
argjson = cJSON_CreateObject();
Expand All @@ -1938,11 +1940,11 @@ char *LP_autosplit(struct iguana_info *coin)
jadd(argjson,"outputs",outputs);
jaddnum(argjson,"broadcast",1);
jaddstr(argjson,"coin",coin->symbol);
//printf("autosplit.(%s)\n",jprint(argjson,0));
//printf("halfval %.8f autosplit.(%s)\n",dstr(halfval),jprint(argjson,0));
retstr = LP_withdraw(coin,argjson);
free_json(argjson);
return(retstr);
} else return(clonestr("{\"error\":\"less than 0.0011 in balance\"}"));
} else return(clonestr("{\"error\":\"balance too small to autosplit, please make more deposits\"}"));
}
return(clonestr("{\"error\":\"couldnt autosplit\"}"));
}
Expand Down
Loading

0 comments on commit 7579120

Please sign in to comment.