From bfdf9a3265a97452a512aa4e179de338975bda4f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 15 Jun 2018 17:30:07 +0700 Subject: [PATCH] #66 Possibly finish forcing 1 ETOMIC for ETH/ERC20 trades. --- iguana/exchanges/LP_ordermatch.c | 24 ++++++++++++++++++------ iguana/exchanges/LP_swap.c | 4 ++-- iguana/exchanges/LP_utxo.c | 2 +- start_BEER_OTHER_trade.sh | 10 +++------- start_BEER_OTHER_trade_inverted.sh | 10 +++------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 7dc3b7c0c..957e87d45 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -195,7 +195,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str printf("destvalue %.8f destsatoshis %.8f is too small txfee %.8f?\n",dstr(destvalue),dstr(qp->destsatoshis),dstr(qp->desttxfee)); return(-11); } - if ( butxo != 0 && srcvalue < qp->txfee+qp->satoshis ) + if ( strcmp(srccoin, "ETOMIC") != 0 && butxo != 0 && srcvalue < qp->txfee+qp->satoshis ) { printf("srcvalue %.8f [%.8f] satoshis %.8f is too small txfee %.8f?\n",dstr(srcvalue),dstr(srcvalue) - dstr(qp->txfee+qp->satoshis),dstr(qp->satoshis),dstr(qp->txfee)); return(-33); @@ -213,7 +213,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str printf("error -14: txfee %.8f < %.8f or desttxfee %.8f < %.8f\n",dstr(qp->txfee),dstr(LP_REQUIRED_TXFEE*txfee),dstr(qp->desttxfee),dstr(LP_REQUIRED_TXFEE*desttxfee)); return(-14); } - if ( butxo != 0 ) + if ( butxo != 0 && strcmp(srccoin, "ETOMIC") != 0) { if ( qp->satoshis < (srcvalue / LP_MINVOL) || srcvalue < qp->txfee*LP_MINSIZE_TXFEEMULT ) { @@ -413,14 +413,22 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb memset(butxo,0,sizeof(*butxo)); if ( iambob != 0 ) { - targetval = LP_basesatoshis(relvolume,price,txfee,desttxfee) + 3*txfee; + if (strcmp(coin->symbol, "ETOMIC") == 0) { + targetval = 100000000 + 3*txfee; + } else { + targetval = LP_basesatoshis(relvolume,price,txfee,desttxfee) + 3*txfee; + } targetval2 = (targetval / 8) * 9 + 3*txfee; fee = txfee; ratio = LP_MINVOL; } else { - targetval = relvolume*SATOSHIDEN + 3*desttxfee; + if (strcmp(coin->symbol, "ETOMIC") == 0) { + targetval = 100000000 + 3*desttxfee; + } else { + targetval = relvolume*SATOSHIDEN + 3*desttxfee; + } targetval2 = (targetval / 777) + 3*desttxfee; fee = desttxfee; ratio = LP_MINCLIENTVOL; @@ -906,7 +914,7 @@ double LP_trades_pricevalidate(struct LP_quoteinfo *qp,struct iguana_info *coin, printf("quote %s/%s validate error %.0f\n",qp->srccoin,qp->destcoin,qprice); return(-3); } - if ( qprice < (price - 0.00000001) * 0.998 ) + if ( qprice < (price - 0.00000001) * 0.998) { printf(" quote price %.8f (%llu/%llu %.8f) too low vs %.8f for %s/%s price %.8f %.8f\n",qprice,(long long)qp->destsatoshis,(long long)(qp->satoshis-qp->txfee),(double)qp->destsatoshis/(qp->satoshis-qp->txfee),price,qp->srccoin,qp->destcoin,price,(price - 0.00000001) * 0.998); return(-77); @@ -1009,7 +1017,11 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru qp->vout = butxo->payment.vout; qp->txid2 = butxo->deposit.txid; qp->vout2 = butxo->deposit.vout; - qp->satoshis = butxo->swap_satoshis;// + qp->txfee; + if (coin->etomic[0] == 0) { + qp->satoshis = butxo->swap_satoshis;// + qp->txfee; + } else { + qp->satoshis = LP_basesatoshis(dstr(qp->destsatoshis), price, qp->txfee, qp->desttxfee); + } qp->quotetime = (uint32_t)time(NULL); } else diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index f16efbd20..5c7af583e 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1201,11 +1201,11 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 #ifndef NOTETOMIC if (strcmp(alicestr, "ETOMIC") == 0) { swap->I.alicerealsat = swap->I.alicesatoshis; - //swap->I.alicesatoshis = 100000000; + swap->I.alicesatoshis = 100000000; } if (strcmp(bobstr, "ETOMIC") == 0) { swap->I.bobrealsat = swap->I.bobsatoshis; - //swap->I.bobsatoshis = 100000000; + swap->I.bobsatoshis = 100000000; } #endif if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 4e9928aa2..944876a90 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -1192,7 +1192,7 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol return(-1); } destaddr[0] = destaddr2[0] = 0; - if ( coin != 0 && IAMLP != 0 && coin->inactive != 0 ) + if ( coin != 0 && (strcmp(coin->symbol, "ETOMIC") == 0 || (coin->inactive != 0 && IAMLP != 0))) bypass = 1; if ( bypass != 0 ) val = satoshis; diff --git a/start_BEER_OTHER_trade.sh b/start_BEER_OTHER_trade.sh index 23a5acee1..a81500397 100755 --- a/start_BEER_OTHER_trade.sh +++ b/start_BEER_OTHER_trade.sh @@ -1,12 +1,8 @@ #!/bin/bash -docker-compose exec -T clientnode ./setpassphrase -sleep 5 docker-compose exec -T clientnode ./enable -sleep 5 -docker-compose exec -T seednode ./setpassphrase -sleep 5 +sleep 3 docker-compose exec -T seednode ./enable -sleep 5 +sleep 3 docker-compose exec -T seednode ./sell_BEER_OTHER $1 -sleep 5 +sleep 3 docker-compose exec -T clientnode ./buy_BEER_OTHER $1 \ No newline at end of file diff --git a/start_BEER_OTHER_trade_inverted.sh b/start_BEER_OTHER_trade_inverted.sh index 68ef9ab3f..1b0f9d4be 100755 --- a/start_BEER_OTHER_trade_inverted.sh +++ b/start_BEER_OTHER_trade_inverted.sh @@ -1,12 +1,8 @@ #!/bin/bash -docker-compose exec -T clientnode ./setpassphrase -sleep 5 docker-compose exec -T clientnode ./enable -sleep 5 -docker-compose exec -T seednode ./setpassphrase -sleep 5 +sleep 3 docker-compose exec -T seednode ./enable -sleep 5 +sleep 3 docker-compose exec -T clientnode ./buy_BEER_OTHER $1 -sleep 5 +sleep 3 docker-compose exec -T seednode ./sell_BEER_OTHER $1 \ No newline at end of file