From eb6d6fe7f0d5b11e59ade3c71d1e1d805fdfdae5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Nov 2017 16:10:25 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_prices.c | 7 ++++--- iguana/exchanges/LP_signatures.c | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 4962d2972..4db3df60d 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -106,14 +106,15 @@ void LP_pubkey_update(struct LP_pubkeyinfo *pubp,uint32_t baseind,uint32_t relin if ( numutxos > (1L << sizeof(pq->numutxos)) ) pq->numutxos = (1L << sizeof(pq->numutxos)) - 1; else pq->numutxos = numutxos; - aveutxo = balance / numutxos; + aveutxo = (balance + (scale64>>1)) / numutxos; if ( (ave64= (aveutxo / scale64)) > (1LL << 32) ) ave64 = (1LL << 32) - 1; - if ( (max64= (maxutxo / scale64)) > (1LL << 32) ) + max64 = ((maxutxo + (scale64>>1)) / scale64); + if ( max64 > (1LL << 32) ) max64 = (1LL << 32) - 1; pq->aveutxo = (uint32_t)ave64; pq->maxutxo = (uint32_t)max64; - printf("scale64 = %llu, ave %llu, ave32 %u (%llu) max32 %u (%llu)\n",(long long)scale64,(long long)aveutxo,pq->aveutxo,(long long)pq->aveutxo * scale64,pq->maxutxo,(long long)pq->maxutxo * scale64); + printf("base.%s scale64 = %llu, ave %llu, ave32 %u (%llu) max32 %u (%llu)\n",LP_priceinfos[baseind].symbol,(long long)scale64,(long long)aveutxo,pq->aveutxo,(long long)pq->aveutxo * scale64,pq->maxutxo,(long long)pq->maxutxo * scale64); } } diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 5a7ab184d..6089e8366 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -472,6 +472,7 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re { if ( (numutxos= LP_address_minmax(&balance,&minsize,&maxsize,ap)) != 0 ) { + printf("%s numutxos.%d balance %.8f min %.8f max %.8f\n",base,numutxos,dstr(balance),dstr(minsize),dstr(maxsize)); jaddnum(reqjson,"n",numutxos); jaddnum(reqjson,"bal",dstr(balance)); jaddnum(reqjson,"min",dstr(minsize));