Browse Source

Test

etomic
jl777 8 years ago
parent
commit
4dcfe358b7
  1. 1
      iguana/exchanges/LP_include.h
  2. 16
      iguana/exchanges/LP_ordermatch.c
  3. 4
      iguana/exchanges/LP_transaction.c

1
iguana/exchanges/LP_include.h

@ -24,6 +24,7 @@
#define LP_HTTP_TIMEOUT 1 #define LP_HTTP_TIMEOUT 1
#define LP_MAXPEER_ERRORS 3 #define LP_MAXPEER_ERRORS 3
#define LP_AUTOTRADE_TIMEOUT 3 #define LP_AUTOTRADE_TIMEOUT 3
#define LP_MIN_TXFEE 10000
#define LP_DEXFEE(destsatoshis) ((destsatoshis) / INSTANTDEX_INSURANCEDIV) #define LP_DEXFEE(destsatoshis) ((destsatoshis) / INSTANTDEX_INSURANCEDIV)
#define LP_DEPOSITSATOSHIS(satoshis) ((satoshis) + (satoshis >> 3)) #define LP_DEPOSITSATOSHIS(satoshis) ((satoshis) + (satoshis >> 3))

16
iguana/exchanges/LP_ordermatch.c

@ -125,8 +125,8 @@ int32_t LP_quoteinfoinit(struct LP_quoteinfo *qp,struct LP_utxoinfo *utxo,char *
if ( qp->timestamp == 0 ) if ( qp->timestamp == 0 )
qp->timestamp = (uint32_t)time(NULL); qp->timestamp = (uint32_t)time(NULL);
safecopy(qp->destcoin,destcoin,sizeof(qp->destcoin)); safecopy(qp->destcoin,destcoin,sizeof(qp->destcoin));
if ( (qp->txfee= LP_getestimatedrate(utxo->coin)*LP_AVETXSIZE) < 10000 ) if ( (qp->txfee= LP_getestimatedrate(utxo->coin)*LP_AVETXSIZE) < LP_MIN_TXFEE )
qp->txfee = 10000; qp->txfee = LP_MIN_TXFEE;
qp->satoshis = destsatoshis / price + 0.49; qp->satoshis = destsatoshis / price + 0.49;
if ( utxo->iambob == 0 || qp->txfee >= qp->satoshis || qp->txfee >= utxo->deposit.value || utxo->deposit.value < LP_DEPOSITSATOSHIS(qp->satoshis) ) if ( utxo->iambob == 0 || qp->txfee >= qp->satoshis || qp->txfee >= utxo->deposit.value || utxo->deposit.value < LP_DEPOSITSATOSHIS(qp->satoshis) )
{ {
@ -138,8 +138,8 @@ int32_t LP_quoteinfoinit(struct LP_quoteinfo *qp,struct LP_utxoinfo *utxo,char *
qp->txid2 = utxo->deposit.txid; qp->txid2 = utxo->deposit.txid;
qp->vout2 = utxo->deposit.vout; qp->vout2 = utxo->deposit.vout;
qp->destsatoshis = destsatoshis; qp->destsatoshis = destsatoshis;
if ( (qp->desttxfee= LP_getestimatedrate(qp->destcoin) * LP_AVETXSIZE) < 10000 ) if ( (qp->desttxfee= LP_getestimatedrate(qp->destcoin) * LP_AVETXSIZE) < LP_MIN_TXFEE )
qp->desttxfee = 10000; qp->desttxfee = LP_MIN_TXFEE;
if ( qp->desttxfee >= qp->destsatoshis ) if ( qp->desttxfee >= qp->destsatoshis )
{ {
printf("quoteinit desttxfee %.8f < %.8f destsatoshis\n",dstr(qp->desttxfee),dstr(qp->destsatoshis)); printf("quoteinit desttxfee %.8f < %.8f destsatoshis\n",dstr(qp->desttxfee),dstr(qp->destsatoshis));
@ -535,8 +535,10 @@ char *LP_autotrade(char *myipaddr,int32_t mypubsock,double profitmargin,char *ba
if ( (autxo= LP_utxo_bestfit(rel,SATOSHIDEN * volume)) == 0 ) if ( (autxo= LP_utxo_bestfit(rel,SATOSHIDEN * volume)) == 0 )
return(clonestr("{\"error\":\"cant find utxo that is big enough\"}")); return(clonestr("{\"error\":\"cant find utxo that is big enough\"}"));
bestmetric = ordermatchprice = 0.; bestmetric = ordermatchprice = 0.;
desttxfee = LP_getestimatedrate(rel) * LP_AVETXSIZE; if ( (desttxfee= LP_getestimatedrate(rel) * LP_AVETXSIZE) < LP_MINTXFEE )
txfee = LP_getestimatedrate(base) * LP_AVETXSIZE; desttxfee = LP_MIN_TXFEE;
if ( (txfee= LP_getestimatedrate(base) * LP_AVETXSIZE) < LP_MINTXFEE )
txfee = LP_MIN_TXFEE;
if ( timeout == 0 ) if ( timeout == 0 )
timeout = LP_AUTOTRADE_TIMEOUT; timeout = LP_AUTOTRADE_TIMEOUT;
if ( (obookstr= LP_orderbook(base,rel)) != 0 ) if ( (obookstr= LP_orderbook(base,rel)) != 0 )
@ -567,7 +569,7 @@ char *LP_autotrade(char *myipaddr,int32_t mypubsock,double profitmargin,char *ba
satoshis = destsatoshis / price; satoshis = destsatoshis / price;
if ( destsatoshis > desttxfee && destsatoshis-desttxfee > (autxo->payment.value >> 1) && satoshis-txfee > (butxo->S.satoshis >> 1) && satoshis < butxo->payment.value-txfee ) if ( destsatoshis > desttxfee && destsatoshis-desttxfee > (autxo->payment.value >> 1) && satoshis-txfee > (butxo->S.satoshis >> 1) && satoshis < butxo->payment.value-txfee )
{ {
printf("price %.8f/%.8f best %.8f destsatoshis %.8f * metric %.8f -> (%f)\n",price,bestprice,bestmetric,dstr(destsatoshis),metric,dstr(destsatoshis) * metric * metric * metric); printf("value %.8f price %.8f/%.8f best %.8f destsatoshis %.8f * metric %.8f -> (%f)\n",dstr(autxo->payment.value),price,bestprice,bestmetric,dstr(destsatoshis),metric,dstr(destsatoshis) * metric * metric * metric);
metric = dstr(destsatoshis) * metric * metric * metric; metric = dstr(destsatoshis) * metric * metric * metric;
if ( bestmetric == 0. || metric < bestmetric ) if ( bestmetric == 0. || metric < bestmetric )
{ {

4
iguana/exchanges/LP_transaction.c

@ -881,8 +881,8 @@ int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pub
if ( coin->estimatedrate == 0. ) if ( coin->estimatedrate == 0. )
coin->estimatedrate = LP_getestimatedrate(coin->symbol); coin->estimatedrate = LP_getestimatedrate(coin->symbol);
newtxfee = coin->estimatedrate * len; newtxfee = coin->estimatedrate * len;
if ( newtxfee < 10000 ) if ( newtxfee < LP_MIN_TXFEE )
newtxfee = 10000; newtxfee = LP_MIN_TXFEE;
printf("txfee %.8f -> newtxfee %.8f\n",dstr(txfee),dstr(newtxfee)); printf("txfee %.8f -> newtxfee %.8f\n",dstr(txfee),dstr(newtxfee));
} else break; } else break;
} }

Loading…
Cancel
Save