Browse Source

Test

etomic
jl777 8 years ago
parent
commit
33c303f65c
  1. 2
      basilisk/basilisk_swap.c
  2. 16
      basilisk/basilisk_tradebot.c
  3. 15
      basilisk/jumblr.c
  4. 1
      iguana/m_osx
  5. 1
      includes/iguana_funcs.h

2
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); bits256_str(str,depositspent), jaddbits256(item,"depositspent",depositspent);
if ( finishedflag != 0 ) 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); sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname);
if ( (fp= fopen(fname,"wb")) != 0 ) if ( (fp= fopen(fname,"wb")) != 0 )
{ {

16
basilisk/basilisk_tradebot.c

@ -317,7 +317,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
} else noquoteflag++; } else noquoteflag++;
} }
// MVP -> USD myrequest.0 pendingid.0 noquoteflag.1 havequoteflag.0 maxi.-1 0.00000000 // 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); destvolume = dstr(maxamount);
//printf("destvolume <- %.8f\n",dstr(destvolume)); //printf("destvolume <- %.8f\n",dstr(destvolume));
if ( fabs(destvolume) < SMALLVAL ) 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)); aveprice = instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount));
destvolume = aveprice * dstr(list[0].srcamount); destvolume = aveprice * dstr(list[0].srcamount);
printf("set destvolume %.8f\n",destvolume); 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 ( 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 ) 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 ) if ( destamount > minamount )
destamount = minamount + ((destamount - minamount) * (1 + (rand() % 100))) / 100.; 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]); 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 ) if ( (retjson= cJSON_Parse(retstr)) != 0 )
{ {
@ -351,8 +356,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
free_json(retjson); free_json(retjson);
} }
free(retstr); 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)); 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? if ( balance > destamount && (int64_t)destamount > 0 && destamount >= minamount ) // max?
{ {

15
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->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); 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)); 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 ) if ( strcmp("KMD",symbol) == 0 )
{ {
ptr->BTC2KMD = ptr->btcprice; 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); //jumblr_utxoupdate(myinfo,"KMD",ptr->coin,ptr->kmdprice,ptr->depositaddr,ptr->deposit_privkey,estfee);
} }
ptr->lasttime = (uint32_t)time(NULL); 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"); } // 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; double vol,avail; struct iguana_info *kmdcoin,*coinbtc = 0;
kmdcoin = iguana_coinfind("KMD"); kmdcoin = iguana_coinfind("KMD");
coinbtc = iguana_coinfind("BTC"); 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 ) if ( myinfo->IAMNOTARY != 0 || myinfo->IAMLP != 0 )
return; return;
if ( kmdcoin == 0 || coinbtc == 0 ) 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 ) 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)); minbtc = (kmdcoin->DEXinfo.btcprice * 1.2) * (JUMBLR_INCR + 3*(JUMBLR_INCR * JUMBLR_FEE + JUMBLR_TXFEE));
btcavail = dstr(jumblr_balance(myinfo,coinbtc,kmdcoin->DEXinfo.depositaddr)); btcavail = dstr(jumblr_balance(myinfo,coinbtc,kmdcoin->DEXinfo.depositaddr));
if ( toKMD == 0 && coinbtc != 0 && btcavail > (minbtc + kmdcoin->DEXinfo.DEXpending) ) 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); } //else printf("btcavail %.8f pending %.8f\n",btcavail,pending);
minkmd = 100.; minkmd = 100.;
kmdavail = dstr(jumblr_balance(myinfo,kmdcoin,kmdcoin->DEXinfo.jumblraddr)); if ( toKMD != 0 && coinbtc != 0 && kmdcoin->DEXinfo.KMDavail > (minkmd + kmdcoin->DEXinfo.KMDpending) )
if ( toKMD != 0 && coinbtc != 0 && kmdavail > (minkmd + kmdcoin->DEXinfo.KMDpending) )
{ {
avail = (kmdavail - kmdcoin->DEXinfo.KMDpending); avail = (kmdcoin->DEXinfo.KMDavail - kmdcoin->DEXinfo.KMDpending);
printf("KMD deposits %.8f, min %.8f, avail %.8f\n",kmdavail,minkmd,avail); printf("KMD deposits %.8f, min %.8f, avail %.8f\n",kmdcoin->DEXinfo.KMDavail,minkmd,avail);
/*if ( avail > 100.*JUMBLR_INCR ) /*if ( avail > 100.*JUMBLR_INCR )
vol = 100.*JUMBLR_INCR; vol = 100.*JUMBLR_INCR;
else if ( avail > 10.*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); 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); } else printf("notlp.%d kmdprice %.8f\n",myinfo->IAMLP,kmdcoin->DEXinfo.btcprice);
} }

1
iguana/m_osx

@ -3,6 +3,7 @@
rm ../agents/iguana *.o rm ../agents/iguana *.o
git pull git pull
cd secp256k1; ./m_unix; cd .. 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 -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 -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 gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lnanomsg -lcurl -lssl -lcrypto -lpthread -lz -lm

1
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); 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); 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 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 ]---- // ------------------------------------------------------[ Preparation ]----
// Initialise a gfshare context for producing shares // Initialise a gfshare context for producing shares

Loading…
Cancel
Save