diff --git a/.gitignore b/.gitignore index 27b6205c6..d11ca0576 100755 --- a/.gitignore +++ b/.gitignore @@ -431,3 +431,23 @@ iguana/DEXstats.dSYM/Contents/Info.plist iguana/DEXstats.dSYM/Contents/Resources/DWARF/DEXstats iguana/confs/dc54d862abd6809d9fd200759538014248f18a5a69e7bc22c0a1f2111a896157 + +iguana/confs/589983f94d17d8e0dc6fbf3fce34b20efc81183c0ab0158cf81a60f03711e15c + +iguana/confs/67201409eb7644e398c8090ac6e3ccf4b69d186b8478aa8488211e9b474dd245 + +iguana/confs/982dfa0e535a6e856cca3cd919af03f50050408fcfed1cd71bb4aa1e2e69070f + +iguana/confs/aa45c35599c9c75a9788fa9740ce8713cc457919e6f6f7d8d8115da5193f5722 + +iguana/confs/ab828d4425655df6bf409f0e23be49ae4a19b2c974008385b18a7a9c79b0314c + +iguana/confs/b29fa937dd00ed7dd73ff4eef8b49bd3103ebddaee9fae05f44ffed42c5a4611 + +iguana/confs/LTC_hdrs.txt + +iguana/confs/LTC_oldhdrs.txt + +iguana/DB/LTC_peers.dat + +iguana/debug.log diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index 481640038..e98a64509 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -329,7 +329,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk printf("set destvolume %.8f\n",destvolume); } // else printf("destvolume %.8f <- minamount\n",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); + 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 ) @@ -370,7 +370,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk } else if ( myrequest != 0 && pendingid == 0 && maxi >= 0 ) // automatch best quote { - if ( minamount != 0 && maxamount >= minamount && time(NULL) > list[0].timestamp+BASILISK_AUCTION_DURATION ) + if ( minamount != 0 && maxamount >= minamount )//&& time(NULL) > list[0].timestamp+BASILISK_AUCTION_DURATION ) { *issueR = list[maxi]; for (i=0; ictx,pubkey33,privkey); bitcoin_address(coinaddr,pubtype,pubkey33,33); bitcoin_address(KMDaddr,60,pubkey33,33); - //printf("(%s) -> (%s %s)\n",passphrase,coinaddr,KMDaddr); + printf("(%s) -> (%s %s)\n",passphrase,coinaddr,KMDaddr); return(privkey); } @@ -62,7 +62,7 @@ cJSON *smartaddress_extrajson(struct smartaddress *ap) cJSON *smartaddress_json(struct smartaddress *ap) { - char coinaddr[64],symbol[64]; uint8_t desttype,tmp,rmd160[20]; int32_t j,n; struct iguana_info *coin,*dest; cJSON *array,*item,*retjson; + char coinaddr[64],symbol[64]; uint8_t desttype,tmp,rmd160[20]; int32_t j,n; struct iguana_info *coin,*dest; cJSON *array,*item,*retjson; double amount; retjson = cJSON_CreateObject(); jaddstr(retjson,"type",ap->typestr); strcpy(symbol,ap->typestr), touppercase(symbol); @@ -80,11 +80,15 @@ cJSON *smartaddress_json(struct smartaddress *ap) item = cJSON_CreateObject(); jaddstr(item,"coin",coin->symbol); jaddstr(item,"address",coinaddr); + if ( (amount= ap->symbols[j].srcavail) != 0 ) + jaddnum(item,"sourceamount",amount); if ( dest != 0 ) { bitcoin_addr2rmd160(&tmp,rmd160,coinaddr); bitcoin_address(coinaddr,desttype,rmd160,20); jaddstr(item,"dest",coinaddr); + if ( (amount= ap->symbols[j].destamount) != 0 ) + jaddnum(item,"destamount",amount); if ( coin->DEXinfo.depositaddr[0] != 0 ) { jaddstr(item,"jumblr_deposit",coin->DEXinfo.depositaddr); @@ -125,9 +129,11 @@ void smartaddress_symboladd(struct smartaddress *ap,char *symbol,double maxbid,d } } -void smartaddress_minmaxupdate(struct supernet_info *myinfo,char *_type,char *_symbol,double maxbid,double minask) +struct smartaddress *smartaddressptr(struct smartaddress_symbol **ptrp,struct supernet_info *myinfo,char *_type,char *_symbol) { char type[64],symbol[64]; int32_t i,j,n; struct smartaddress *ap; + if ( ptrp != 0 ) + *ptrp = 0; strcpy(type,_type), tolowercase(type); strcpy(symbol,_symbol), touppercase(symbol); for (i=0; inumsmartaddrs; i++) @@ -140,12 +146,36 @@ void smartaddress_minmaxupdate(struct supernet_info *myinfo,char *_type,char *_s { if ( strcmp(ap->symbols[j].symbol,symbol) == 0 ) { - dxblend(&ap->symbols[j].maxbid,maxbid,0.5); - dxblend(&ap->symbols[j].minask,minask,0.5); + if ( ptrp != 0 ) + *ptrp = &ap->symbols[j]; + return(ap); } } } } + return(0); +} + +void smartaddress_minmaxupdate(struct supernet_info *myinfo,char *_type,char *_symbol,double maxbid,double minask) +{ + struct smartaddress *ap; struct smartaddress_symbol *sp; + if ( (ap= smartaddressptr(&sp,myinfo,_type,_symbol)) != 0 && sp != 0 ) + { + dxblend(&sp->maxbid,maxbid,0.5); + dxblend(&sp->minask,minask,0.5); + } +} + +void smartaddress_availupdate(struct supernet_info *myinfo,char *_type,char *_symbol,double srcavail,double destamount) +{ + struct smartaddress *ap; struct smartaddress_symbol *sp; + if ( (ap= smartaddressptr(&sp,myinfo,_type,_symbol)) != 0 && sp != 0 ) + { + if ( srcavail > SMALLVAL ) + sp->srcavail = srcavail; + if ( destamount > SMALLVAL ) + sp->destamount = destamount; + } } int32_t _smartaddress_add(struct supernet_info *myinfo,bits256 privkey,char *type,char *symbol,double maxbid,double minask) @@ -184,6 +214,7 @@ int32_t _smartaddress_add(struct supernet_info *myinfo,bits256 privkey,char *typ bitcoin_pubkey33(myinfo->ctx,ap->pubkey33,privkey); calc_rmd160_sha256(ap->rmd160,ap->pubkey33,33); ap->pubkey = curve25519(privkey,curve25519_basepoint9()); + char str[65]; printf("pubkey.(%s) ",bits256_str(str,ap->pubkey)); bitcoin_address(coinaddr,0,ap->pubkey33,33); for (i=0; i<20; i++) printf("%02x",ap->rmd160[i]); @@ -267,6 +298,8 @@ int32_t smartaddress_pubkey(struct supernet_info *myinfo,char *typestr,double *b break; } portable_mutex_unlock(&myinfo->smart_mutex); + char str[65]; if ( retval < 0 ) + printf("smartaddress_pubkey no match for %s\n",bits256_str(str,pubkey)); return(retval); } @@ -346,9 +379,9 @@ void smartaddress_coinupdate(struct supernet_info *myinfo,char *symbol,double BT } // else printf("skip\n"); } -void smartaddress_dex(struct supernet_info *myinfo,int32_t selector,struct iguana_info *basecoin,char *coinaddr,double maxavail,struct iguana_info *relcoin,double maxbid,double minask,cJSON *extraobj,double maxvol) +void smartaddress_dex(struct supernet_info *myinfo,char *type,int32_t selector,struct iguana_info *basecoin,char *coinaddr,double maxavail,struct iguana_info *relcoin,double maxbid,double minask,cJSON *extraobj,double maxvol) { - double minamount,minbtc,price,avail,vol,btc2kmd,basebtc,relbtc,baseusd,relusd; char *retstr; cJSON *vals; bits256 hash; + double minamount,minbtc,price,avail,vol,btc2kmd,basebtc,relbtc,baseusd,relusd; char *retstr; cJSON *vals; bits256 hash; struct smartaddress *ap; basebtc = basecoin->DEXinfo.btcprice; relbtc = relcoin->DEXinfo.btcprice; baseusd = basecoin->DEXinfo.USD_average; @@ -373,10 +406,10 @@ void smartaddress_dex(struct supernet_info *myinfo,int32_t selector,struct iguan minbtc = btc2kmd * (JUMBLR_INCR + 3*(JUMBLR_INCR * JUMBLR_FEE + JUMBLR_TXFEE)); if ( minamount == 0. && basebtc > SMALLVAL ) minamount = (minbtc / basebtc); - printf("%s/%s minbtc %.8f btcprice %.8f -> minamount %.8f price %.8f vs maxbid %.8f DEXratio %.5f\n",basecoin->symbol,relcoin->symbol,minbtc,basecoin->DEXinfo.btcprice,minamount,price,maxbid,myinfo->DEXratio); + printf("DEX %s/%s maxavail %.8f minbtc %.8f btcprice %.8f -> minamount %.8f price %.8f vs maxbid %.8f DEXratio %.5f DEXpending %.8f\n",basecoin->symbol,relcoin->symbol,maxavail,minbtc,basecoin->DEXinfo.btcprice,minamount,price,maxbid,myinfo->DEXratio,basecoin->DEXinfo.DEXpending); if ( minamount > SMALLVAL && maxavail > minamount + basecoin->DEXinfo.DEXpending && (maxbid == 0. || price <= maxbid) ) { - avail = (maxavail - (minamount + basecoin->DEXinfo.DEXpending)); + avail = (maxavail - basecoin->DEXinfo.DEXpending); /*if ( avail >= (100. * minamount) ) vol = (100. * minamount); else if ( avail >= (10. * minamount) ) @@ -391,6 +424,8 @@ void smartaddress_dex(struct supernet_info *myinfo,int32_t selector,struct iguan jaddstr(vals,"dest",relcoin->symbol); jaddnum(vals,"amount",vol); jaddnum(vals,"minprice",price); + if ( (ap= smartaddressptr(0,myinfo,type,basecoin->symbol)) != 0 ) + jaddbits256(vals,"srchash",ap->pubkey); if ( selector != 0 ) { jaddnum(vals,"usejumblr",selector); @@ -404,8 +439,8 @@ void smartaddress_dex(struct supernet_info *myinfo,int32_t selector,struct iguan free(retstr); } free_json(vals); - } - } + } else printf("avail %.8f < minamount %.8f\n",avail,minamount); + } //else printf("failed if check %d %d %d %d\n",minamount > SMALLVAL,maxavail > minamount + basecoin->DEXinfo.DEXpending,maxbid == 0,price <= maxbid); /* minbtc = (basecoin->DEXinfo.btcprice * 1.2) * (JUMBLR_INCR + 3*(JUMBLR_INCR * JUMBLR_FEE + JUMBLR_TXFEE)); btcavail = dstr(jumblr_balance(myinfo,coinbtc,kmdcoin->DEXinfo.depositaddr)); @@ -473,7 +508,7 @@ void smartaddress_depositjumblr(struct supernet_info *myinfo,char *symbol,char * if ( (basecoin= iguana_coinfind(symbol)) != 0 && (relcoin= iguana_coinfind("KMD")) != 0 ) { if ( strcmp(coinaddr,basecoin->DEXinfo.depositaddr) == 0 ) - smartaddress_dex(myinfo,1,basecoin,coinaddr,basecoin->DEXinfo.avail,relcoin,maxbid,minask,extraobj,0.); + smartaddress_dex(myinfo,"deposit",1,basecoin,coinaddr,basecoin->DEXinfo.avail,relcoin,maxbid,minask,extraobj,0.); else printf("smartaddress_jumblr.%s: mismatch deposit address (%s) vs (%s)\n",symbol,coinaddr,basecoin->DEXinfo.depositaddr); } } @@ -494,7 +529,7 @@ void smartaddress_jumblr(struct supernet_info *myinfo,char *symbol,char *coinadd if ( (basecoin= iguana_coinfind("KMD")) != 0 && (relcoin= iguana_coinfind(symbol)) != 0 ) { if ( strcmp(coinaddr,basecoin->DEXinfo.jumblraddr) == 0 ) - smartaddress_dex(myinfo,2,basecoin,coinaddr,basecoin->DEXinfo.jumblravail,relcoin,maxbid,minask,extraobj,credits); + smartaddress_dex(myinfo,"jumblr",2,basecoin,coinaddr,basecoin->DEXinfo.jumblravail,relcoin,maxbid,minask,extraobj,credits); else printf("smartaddress_jumblr.%s: mismatch jumblr address (%s) vs (%s)\n",symbol,coinaddr,basecoin->DEXinfo.jumblraddr); } } @@ -526,10 +561,13 @@ void smartaddress_action(struct supernet_info *myinfo,int32_t selector,char *typ touppercase(rel); if ( (relcoin= iguana_coinfind(rel)) != 0 && (basecoin= iguana_coinfind(symbol)) != 0 ) { - if ( myinfo->numswaps == 0 || (basecoin->FULLNODE < 0 && relcoin->FULLNODE < 0) ) + if ( myinfo->numswaps == 0 )//|| (basecoin->FULLNODE < 0 && relcoin->FULLNODE < 0) ) { if ( (avail= dstr(jumblr_balance(myinfo,basecoin,coinaddr))) > SMALLVAL ) - smartaddress_dex(myinfo,0,basecoin,coinaddr,avail,relcoin,maxbid,minask,extraobj,0.); + { + smartaddress_availupdate(myinfo,typestr,symbol,avail,SMALLVAL*0.99); + smartaddress_dex(myinfo,typestr,0,basecoin,coinaddr,avail,relcoin,maxbid,minask,extraobj,0.); + } } } } diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 2e1cc17a9..b02a38a68 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -95,7 +95,7 @@ struct supernet_address char NXTADDR[32],BTC[64],BTCD[64]; }; -struct smartaddress_symbol { double maxbid,minask; char symbol[16]; }; +struct smartaddress_symbol { double maxbid,minask,srcavail,destamount; char symbol[16]; }; struct smartaddress {