From 33c303f65c4ff3416adb7529e34989295836702a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 16 Apr 2017 18:33:30 +0300 Subject: [PATCH] Test --- basilisk/basilisk_swap.c | 2 +- basilisk/basilisk_tradebot.c | 16 ++++++++++------ basilisk/jumblr.c | 15 +++++++-------- iguana/m_osx | 1 + includes/iguana_funcs.h | 1 + 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index f607e9567..e256b9ddf 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -3610,7 +3610,7 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t bits256_str(str,depositspent), jaddbits256(item,"depositspent",depositspent); if ( finishedflag != 0 ) { - printf("SWAP %u-%u finished!\n",requestid,quoteid); + //printf("SWAP %u-%u finished!\n",requestid,quoteid); sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname); if ( (fp= fopen(fname,"wb")) != 0 ) { diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index 706d73709..f704595e2 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -317,7 +317,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk } else noquoteflag++; } // MVP -> USD myrequest.0 pendingid.0 noquoteflag.1 havequoteflag.0 maxi.-1 0.00000000 - double retvals[4],refprice=0.,profitmargin,aveprice,destvolume; cJSON *retjson; char *retstr; + struct iguana_info *coin; char coinaddr[64]; double retvals[4],refprice=0.,profitmargin,aveprice,destvolume; destvolume = dstr(maxamount); //printf("destvolume <- %.8f\n",dstr(destvolume)); if ( fabs(destvolume) < SMALLVAL ) @@ -327,9 +327,9 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk aveprice = instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount)); destvolume = aveprice * dstr(list[0].srcamount); printf("set destvolume %.8f\n",destvolume); - } else printf("destvolume %.8f <- minamount\n",destvolume); + } // else printf("destvolume %.8f <- minamount\n",destvolume); } - printf("%s -> %s myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f destvol %f\n",list[0].src,list[0].dest,myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount),destvolume); + printf("%s -> %s myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f destvol %.8f\n",list[0].src,list[0].dest,myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount),destvolume); if ( myinfo->IAMLP != 0 && myrequest == 0 && pendingid == 0 && noquoteflag != 0 && ((profitmargin= tradebot_liquidity_active(myinfo,&refprice,"DEX",list[0].src,list[0].dest,destvolume)) > 0. || refprice != 0.) ) { if ( profitmargin == 0. || (aveprice= instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,.1 * dstr(list[0].srcamount))) == 0. || refprice > aveprice ) @@ -343,7 +343,12 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk if ( destamount > minamount ) destamount = minamount + ((destamount - minamount) * (1 + (rand() % 100))) / 100.; printf("%s/%s pm %f aveprice %f src %.8f dest %.8f avebid %f bidvol %f, aveask %f askvol %f\n",list[0].src,list[0].dest,profitmargin,aveprice,dstr(list[0].srcamount),dstr(destamount),retvals[0],retvals[1],retvals[2],retvals[3]); - if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 ) + if ( (coin= iguana_coinfind(list[0].dest)) != 0 ) + { + bitcoin_address(coinaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33); + balance = dstr(jumblr_balance(myinfo,coin,coinaddr)); + } + /*if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { @@ -351,8 +356,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk free_json(retjson); } free(retstr); - } - // BTC balance 0.00500000 destamount 0.00041951 aveprice 0.00421619 minamount 0.00020000 + }*/ printf("%s balance %.8f destamount %.8f aveprice %.8f maxamount %.8f minamount %.8f\n",list[0].dest,dstr(balance),dstr(destamount),aveprice,dstr(maxamount),dstr(minamount)); if ( balance > destamount && (int64_t)destamount > 0 && destamount >= minamount ) // max? { diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index b8b202312..21d04b334 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -685,7 +685,6 @@ void jumblr_DEXupdate(struct supernet_info *myinfo,struct iguana_info *coin,char ptr->avail = dstr(jumblr_balance(myinfo,ptr->coin,ptr->depositaddr)); ptr->btcprice = get_theoretical(&avebid,&aveask,&highbid,&lowask,&CMC_average,changes,CMCname,symbol,"BTC",&ptr->USD_average); KMDavail = dstr(jumblr_balance(myinfo,ptr->coin,ptr->KMDjumblraddr)); - printf("%s avail %.8f KMDavail %.8f btcprice %.8f deposit.(%s %s) -> jumblr.(%s %s)\n",symbol,ptr->avail,KMDavail,ptr->btcprice,ptr->depositaddr,ptr->KMDdepositaddr,ptr->jumblraddr,ptr->KMDjumblraddr); if ( strcmp("KMD",symbol) == 0 ) { ptr->BTC2KMD = ptr->btcprice; @@ -702,6 +701,7 @@ void jumblr_DEXupdate(struct supernet_info *myinfo,struct iguana_info *coin,char //jumblr_utxoupdate(myinfo,"KMD",ptr->coin,ptr->kmdprice,ptr->depositaddr,ptr->deposit_privkey,estfee); } ptr->lasttime = (uint32_t)time(NULL); + printf("%s avail %.8f KMDavail %.8f btcprice %.8f deposit.(%s %s) -> jumblr.(%s %s)\n",symbol,ptr->avail,KMDavail,ptr->btcprice,ptr->depositaddr,ptr->KMDdepositaddr,ptr->jumblraddr,ptr->KMDjumblraddr); } // else printf("skip\n"); } @@ -716,7 +716,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32 double vol,avail; struct iguana_info *kmdcoin,*coinbtc = 0; kmdcoin = iguana_coinfind("KMD"); coinbtc = iguana_coinfind("BTC"); - printf("jumblr_DEXcheck numswaps.%d notary.%d IAMLP.%d %p %p %f\n",myinfo->numswaps,myinfo->IAMNOTARY,myinfo->IAMLP,kmdcoin,coinbtc,kmdcoin->DEXinfo.btcprice); + //printf("jumblr_DEXcheck numswaps.%d notary.%d IAMLP.%d %p %p %f\n",myinfo->numswaps,myinfo->IAMNOTARY,myinfo->IAMLP,kmdcoin,coinbtc,kmdcoin->DEXinfo.btcprice); if ( myinfo->IAMNOTARY != 0 || myinfo->IAMLP != 0 ) return; if ( kmdcoin == 0 || coinbtc == 0 ) @@ -731,7 +731,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32 } if ( myinfo->numswaps == 0 && myinfo->IAMLP == 0 && kmdcoin->DEXinfo.btcprice > SMALLVAL ) { - double minbtc,minkmd,btcavail,kmdavail; char *retstr; cJSON *vals; bits256 hash; + double minbtc,minkmd,btcavail; char *retstr; cJSON *vals; bits256 hash; minbtc = (kmdcoin->DEXinfo.btcprice * 1.2) * (JUMBLR_INCR + 3*(JUMBLR_INCR * JUMBLR_FEE + JUMBLR_TXFEE)); btcavail = dstr(jumblr_balance(myinfo,coinbtc,kmdcoin->DEXinfo.depositaddr)); if ( toKMD == 0 && coinbtc != 0 && btcavail > (minbtc + kmdcoin->DEXinfo.DEXpending) ) @@ -767,11 +767,10 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32 } } //else printf("btcavail %.8f pending %.8f\n",btcavail,pending); minkmd = 100.; - kmdavail = dstr(jumblr_balance(myinfo,kmdcoin,kmdcoin->DEXinfo.jumblraddr)); - if ( toKMD != 0 && coinbtc != 0 && kmdavail > (minkmd + kmdcoin->DEXinfo.KMDpending) ) + if ( toKMD != 0 && coinbtc != 0 && kmdcoin->DEXinfo.KMDavail > (minkmd + kmdcoin->DEXinfo.KMDpending) ) { - avail = (kmdavail - kmdcoin->DEXinfo.KMDpending); - printf("KMD deposits %.8f, min %.8f, avail %.8f\n",kmdavail,minkmd,avail); + avail = (kmdcoin->DEXinfo.KMDavail - kmdcoin->DEXinfo.KMDpending); + printf("KMD deposits %.8f, min %.8f, avail %.8f\n",kmdcoin->DEXinfo.KMDavail,minkmd,avail); /*if ( avail > 100.*JUMBLR_INCR ) vol = 100.*JUMBLR_INCR; else if ( avail > 10.*JUMBLR_INCR ) @@ -798,7 +797,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32 } free_json(vals); } - } else printf("btcavail %.8f pending %.8f\n",btcavail,kmdcoin->DEXinfo.KMDpending); + } else printf("kmdavail %.8f pending %.8f\n",kmdcoin->DEXinfo.KMDavail,kmdcoin->DEXinfo.KMDpending); } else printf("notlp.%d kmdprice %.8f\n",myinfo->IAMLP,kmdcoin->DEXinfo.btcprice); } diff --git a/iguana/m_osx b/iguana/m_osx index e752b11cc..b7a296285 100755 --- a/iguana/m_osx +++ b/iguana/m_osx @@ -3,6 +3,7 @@ rm ../agents/iguana *.o git pull cd secp256k1; ./m_unix; cd .. +cd ../crypto777; ./m_unix; cd ../iguana gcc -g -Wno-address-of-packed-member -Wno-deprecated -c -O2 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c gcc -g -Wno-address-of-packed-member -Wno-deprecated -c -DLIQUIDITY_PROVIDER=1 main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c iguana_ramchain.c gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lnanomsg -lcurl -lssl -lcrypto -lpthread -lz -lm diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index b8061eb61..c082dcabf 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -633,6 +633,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32 bits256 jumblr_privkey(struct supernet_info *myinfo,char *BTCaddr,uint8_t pubtype,char *KMDaddr,char *prefix); char *jumblr_importprivkey(struct supernet_info *myinfo,struct iguana_info *coin,char *wifstr); int64_t iguana_esttxfee(struct supernet_info *myinfo,struct iguana_info *coin,char *rawtx,char *signedtx,int32_t numvins); +int64_t jumblr_balance(struct supernet_info *myinfo,struct iguana_info *coin,char *addr); // ------------------------------------------------------[ Preparation ]---- // Initialise a gfshare context for producing shares