From 127187e1fa646e6b7093a879d41e923090f10e7e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Dec 2017 16:54:00 +0400 Subject: [PATCH] Test --- iguana/exchanges/LP_prices.c | 15 ++++++++++----- iguana/exchanges/supernet | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 806059bba..f9fa7046b 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -1114,15 +1114,17 @@ void LP_pricefeedupdate(bits256 pubkey,char *base,char *rel,double price,char *u // printf("error finding %s/%s %.8f\n",base,rel,price); } -double LP_CMCbtcprice(char *symbol) +double LP_CMCbtcprice(double *price_usdp,char *symbol) { char *retstr; cJSON *ticker,*item; double price_btc = 0.; + *price_usdp = 0.; if ( (retstr= cmc_ticker(symbol)) != 0 ) { if ( (ticker= cJSON_Parse(retstr)) != 0 ) { item = jitem(ticker,0); price_btc = jdouble(item,"price_btc"); + *price_usdp = jdouble(item,"price_usd"); //printf("%.8f item.(%s)\n",price_btc,jprint(item,0)); free_json(ticker); } @@ -1133,7 +1135,7 @@ double LP_CMCbtcprice(char *symbol) cJSON *LP_fundvalue(cJSON *argjson) { - cJSON *holdings,*item,*newitem,*array,*retjson; int32_t i,iter,n; double divisor,btcprice,balance,btcsum; struct iguana_info *coin; char *symbol,*coinaddr; int64_t fundvalue,KMDvalue = 0; + cJSON *holdings,*item,*newitem,*array,*retjson; int32_t i,iter,n; double usdprice,divisor,btcprice,balance,btcsum; struct iguana_info *coin; char *symbol,*coinaddr; int64_t fundvalue,KMDvalue = 0; fundvalue = 0; btcsum = 0.; array = cJSON_CreateArray(); @@ -1165,7 +1167,7 @@ cJSON *LP_fundvalue(cJSON *argjson) jaddnum(newitem,"KMD",dstr(KMDvalue)); fundvalue += KMDvalue; } - else if ( iter == 0 && (btcprice= LP_CMCbtcprice(symbol)) > SMALLVAL ) + else if ( iter == 0 && (btcprice= LP_CMCbtcprice(&usdprice,symbol)) > SMALLVAL ) { btcsum += btcprice * balance; jaddnum(newitem,"BTC",btcprice * balance); @@ -1178,9 +1180,10 @@ cJSON *LP_fundvalue(cJSON *argjson) } retjson = cJSON_CreateObject(); jadd(retjson,"holdings",array); + btcprice = LP_CMCbtcprice(&usdprice,"komodo"); if ( btcsum != 0 ) { - if ( (btcprice= LP_CMCbtcprice("komodo")) > SMALLVAL ) + if ( btcprice > SMALLVAL ) { fundvalue += (btcsum / btcprice) * SATOSHIDEN; jaddnum(retjson,"KMD_BTC",btcprice); @@ -1192,7 +1195,9 @@ cJSON *LP_fundvalue(cJSON *argjson) if ( (divisor= jdouble(argjson,"divisor")) != 0 ) { jaddnum(retjson,"divisor",divisor); - jaddnum(retjson,"fundvalue",dstr(fundvalue)); + jaddnum(retjson,"NAV_KMD",dstr(fundvalue)/divisor); + jaddnum(retjson,"NAV_BTC",(btcprice * dstr(fundvalue))/divisor); + jaddnum(retjson,"NAV_USD",(usdprice * dstr(fundvalue))/divisor); } return(retjson); } diff --git a/iguana/exchanges/supernet b/iguana/exchanges/supernet index 0b71993f4..4058bc4d0 100755 --- a/iguana/exchanges/supernet +++ b/iguana/exchanges/supernet @@ -3,4 +3,4 @@ source userpass # this will only work for watchonly addresses that have been rescanned and with active coins curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":13000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":650000}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":13000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":816016}"