Browse Source

Test

etomic
jl777 7 years ago
parent
commit
33bf3c8a3c
  1. 11
      iguana/exchanges/LP_prices.c

11
iguana/exchanges/LP_prices.c

@ -103,22 +103,21 @@ void LP_pubkey_update(struct LP_pubkeyinfo *pubp,uint32_t baseind,uint32_t relin
scale64 *= 10; scale64 *= 10;
scale--; scale--;
} }
if ( numutxos > (1L << sizeof(pq->numutxos)) ) if ( numutxos >= 256 )
pq->numutxos = (1L << sizeof(pq->numutxos)) - 1; pq->numutxos = 255;
else pq->numutxos = numutxos; else pq->numutxos = numutxos;
aveutxo = (balance + (scale64>>1)) / numutxos; aveutxo = (balance + (scale64>>1)) / numutxos;
if ( (ave64= (aveutxo / scale64)) > (1LL << 32) ) if ( (ave64= (aveutxo / scale64)) >= (1LL << 32) )
ave64 = (1LL << 32) - 1; ave64 = (1LL << 32) - 1;
max64 = ((maxutxo + (scale64>>1)) / scale64); max64 = ((maxutxo + (scale64>>1)) / scale64);
if ( max64 > (1LL << 32) ) if ( max64 >= (1LL << 32) )
max64 = (1LL << 32) - 1; max64 = (1LL << 32) - 1;
pq->aveutxo = (uint32_t)ave64; pq->aveutxo = (uint32_t)ave64;
pq->maxutxo = (uint32_t)max64; pq->maxutxo = (uint32_t)max64;
printf("base.%s rel.%s utxocoin.%s balance %.8f numutxos.%u %u scale64 = %llu, ave %llu, ave32 %u (%llu) max32 %u (%llu)\n",LP_priceinfos[baseind].symbol,LP_priceinfos[relind].symbol,utxocoin,dstr(balance),numutxos,pq->numutxos,(long long)scale64,(long long)aveutxo,pq->aveutxo,(long long)pq->aveutxo * scale64,pq->maxutxo,(long long)pq->maxutxo * scale64); printf("price %.8f base.%s rel.%s utxocoin.%s balance %.8f numutxos.%u %u scale64 = %llu, ave %llu, ave32 %u (%llu) max32 %u (%llu)\n",price,LP_priceinfos[baseind].symbol,LP_priceinfos[relind].symbol,utxocoin,dstr(balance),numutxos,pq->numutxos,(long long)scale64,(long long)aveutxo,pq->aveutxo,(long long)pq->aveutxo * scale64,pq->maxutxo,(long long)pq->maxutxo * scale64);
int64_t avesatoshis,maxsatoshis; int64_t avesatoshis,maxsatoshis;
price = LP_pubkey_price(&numutxos,&avesatoshis,&maxsatoshis,pubp,baseind,relind); price = LP_pubkey_price(&numutxos,&avesatoshis,&maxsatoshis,pubp,baseind,relind);
printf("checkprice %.8f numutxos.%d ave %.8f max %.8f\n",price,numutxos,dstr(avesatoshis),dstr(maxsatoshis)); printf("checkprice %.8f numutxos.%d ave %.8f max %.8f\n",price,numutxos,dstr(avesatoshis),dstr(maxsatoshis));
} }
} }

Loading…
Cancel
Save