|
@ -129,7 +129,7 @@ cJSON *LP_quotejson(struct LP_quoteinfo *qp) |
|
|
jadd64bits(retjson,"destsatoshis",qp->destsatoshis); |
|
|
jadd64bits(retjson,"destsatoshis",qp->destsatoshis); |
|
|
if ( qp->satoshis != 0 ) |
|
|
if ( qp->satoshis != 0 ) |
|
|
{ |
|
|
{ |
|
|
price = (double)qp->destsatoshis / qp->satoshis; |
|
|
price = (double)(qp->destsatoshis-qp->desttxfee) / (qp->satoshis - qp->txfee); |
|
|
jaddnum(retjson,"price",price); |
|
|
jaddnum(retjson,"price",price); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -205,7 +205,7 @@ char *LP_quotereceived(cJSON *argjson) |
|
|
{ |
|
|
{ |
|
|
struct LP_cacheinfo *ptr; double price; struct LP_quoteinfo Q; |
|
|
struct LP_cacheinfo *ptr; double price; struct LP_quoteinfo Q; |
|
|
LP_quoteparse(&Q,argjson); |
|
|
LP_quoteparse(&Q,argjson); |
|
|
price = (double)Q.destsatoshis / Q.satoshis; |
|
|
price = (double)(Q.destsatoshis-Q.desttxfee) / (Q.satoshis - Q.txfee); |
|
|
if ( (ptr= LP_cacheadd(Q.srccoin,Q.destcoin,Q.txid,Q.vout,price,&Q)) != 0 ) |
|
|
if ( (ptr= LP_cacheadd(Q.srccoin,Q.destcoin,Q.txid,Q.vout,price,&Q)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
ptr->Q = Q; |
|
|
ptr->Q = Q; |
|
@ -305,7 +305,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str |
|
|
return(-33); |
|
|
return(-33); |
|
|
} |
|
|
} |
|
|
if ( qp->satoshis != 0 ) |
|
|
if ( qp->satoshis != 0 ) |
|
|
qprice = ((double)qp->destsatoshis / qp->satoshis); |
|
|
qprice = ((double)(qp->destsatoshis-qp->desttxfee) / (qp->satoshis-qp->txfee)); |
|
|
LP_txfees(&txfee,&desttxfee,qp->srccoin,qp->destcoin); |
|
|
LP_txfees(&txfee,&desttxfee,qp->srccoin,qp->destcoin); |
|
|
if ( txfee < qp->txfee ) |
|
|
if ( txfee < qp->txfee ) |
|
|
txfee = qp->txfee; |
|
|
txfee = qp->txfee; |
|
@ -461,7 +461,7 @@ uint64_t LP_basesatoshis(double relvolume,double price,uint64_t txfee,uint64_t d |
|
|
{ |
|
|
{ |
|
|
printf("basesatoshis %.8f (rel %.8f / price %.8f)\n",dstr(SATOSHIDEN * ((relvolume + dstr(desttxfee)) / price) + 2*txfee),relvolume,price); |
|
|
printf("basesatoshis %.8f (rel %.8f / price %.8f)\n",dstr(SATOSHIDEN * ((relvolume + dstr(desttxfee)) / price) + 2*txfee),relvolume,price); |
|
|
if ( relvolume > dstr(desttxfee) && price > SMALLVAL ) |
|
|
if ( relvolume > dstr(desttxfee) && price > SMALLVAL ) |
|
|
return(SATOSHIDEN * ((relvolume - dstr(desttxfee)) / price)); |
|
|
return(SATOSHIDEN * ((relvolume + dstr(desttxfee)) / price) + txfee); |
|
|
else return(0); |
|
|
else return(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|