Browse Source

Merge pull request #78 from artemii235/etomic

#66 #75. Harcode 1 ETOMIC for ETH/ERC20 trades. Do not request balances for disabled ETH/ERC20.
pass-iguana-arg
Artem Pikulin 7 years ago
committed by GitHub
parent
commit
f132697f1b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      etomic_build/client/buy_BEER_OTHER
  2. 4
      etomic_build/seed/sell_BEER_OTHER
  3. 28
      iguana/exchanges/LP_ordermatch.c
  4. 4
      iguana/exchanges/LP_swap.c
  5. 11
      iguana/exchanges/LP_utxo.c
  6. 10
      start_BEER_OTHER_trade.sh
  7. 10
      start_BEER_OTHER_trade_inverted.sh

4
etomic_build/client/buy_BEER_OTHER

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
source userpass source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":1}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":2}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"$1\",\"rel\":\"BEER\",\"basevolume\":0.1,\"price\":1}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":2}"

4
etomic_build/seed/sell_BEER_OTHER

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
source userpass source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":0.9}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":1.9}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":0.1,\"price\":0.9}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":1.9}"

28
iguana/exchanges/LP_ordermatch.c

@ -190,12 +190,12 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str
if ( strcmp(autxo->coinaddr,qp->destaddr) != 0 ) if ( strcmp(autxo->coinaddr,qp->destaddr) != 0 )
return(-10); return(-10);
} }
if ( autxo != 0 && destvalue < qp->desttxfee+qp->destsatoshis ) if ( strcmp(destcoin, "ETOMIC") != 0 && autxo != 0 && destvalue < qp->desttxfee+qp->destsatoshis )
{ {
printf("destvalue %.8f destsatoshis %.8f is too small txfee %.8f?\n",dstr(destvalue),dstr(qp->destsatoshis),dstr(qp->desttxfee)); printf("destvalue %.8f destsatoshis %.8f is too small txfee %.8f?\n",dstr(destvalue),dstr(qp->destsatoshis),dstr(qp->desttxfee));
return(-11); 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)); 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); 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)); 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); return(-14);
} }
if ( butxo != 0 ) if ( butxo != 0 && strcmp(srccoin, "ETOMIC") != 0)
{ {
if ( qp->satoshis < (srcvalue / LP_MINVOL) || srcvalue < qp->txfee*LP_MINSIZE_TXFEEMULT ) 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)); memset(butxo,0,sizeof(*butxo));
if ( iambob != 0 ) 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; targetval2 = (targetval / 8) * 9 + 3*txfee;
fee = txfee; fee = txfee;
ratio = LP_MINVOL; ratio = LP_MINVOL;
} }
else 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; targetval2 = (targetval / 777) + 3*desttxfee;
fee = desttxfee; fee = desttxfee;
ratio = LP_MINCLIENTVOL; 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); printf("quote %s/%s validate error %.0f\n",qp->srccoin,qp->destcoin,qprice);
return(-3); 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); 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); 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->vout = butxo->payment.vout;
qp->txid2 = butxo->deposit.txid; qp->txid2 = butxo->deposit.txid;
qp->vout2 = butxo->deposit.vout; 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); qp->quotetime = (uint32_t)time(NULL);
} }
else else
@ -1604,7 +1616,7 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha
autxo->swap_satoshis = destsatoshis; autxo->swap_satoshis = destsatoshis;
//printf("first path dest %.8f from %.8f\n",dstr(destsatoshis),dstr(autxo->swap_satoshis)); //printf("first path dest %.8f from %.8f\n",dstr(destsatoshis),dstr(autxo->swap_satoshis));
} }
else if ( autxo->swap_satoshis - desttxfee < destsatoshis ) else if ( autxo->swap_satoshis - desttxfee < destsatoshis && relcoin->etomic[0] == 0)
{ {
autxo->swap_satoshis -= desttxfee; autxo->swap_satoshis -= desttxfee;
destsatoshis = autxo->swap_satoshis; destsatoshis = autxo->swap_satoshis;

4
iguana/exchanges/LP_swap.c

@ -1201,11 +1201,11 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256
#ifndef NOTETOMIC #ifndef NOTETOMIC
if (strcmp(alicestr, "ETOMIC") == 0) { if (strcmp(alicestr, "ETOMIC") == 0) {
swap->I.alicerealsat = swap->I.alicesatoshis; swap->I.alicerealsat = swap->I.alicesatoshis;
//swap->I.alicesatoshis = 100000000; swap->I.alicesatoshis = 100000000;
} }
if (strcmp(bobstr, "ETOMIC") == 0) { if (strcmp(bobstr, "ETOMIC") == 0) {
swap->I.bobrealsat = swap->I.bobsatoshis; swap->I.bobrealsat = swap->I.bobsatoshis;
//swap->I.bobsatoshis = 100000000; swap->I.bobsatoshis = 100000000;
} }
#endif #endif
if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE )

11
iguana/exchanges/LP_utxo.c

@ -787,7 +787,14 @@ cJSON *LP_balances(char *coinaddr)
} }
else else
{ {
if ( (balance= LP_RTsmartbalance(coin)) != 0 ) #ifndef NOTETOMIC
if (coin->etomic[0] == 0 || coin->inactive == 0) {
#endif
balance = LP_RTsmartbalance(coin);
#ifndef NOTETOMIC
}
#endif
if ( balance != 0 )
{ {
item = cJSON_CreateObject(); item = cJSON_CreateObject();
jaddstr(item,"coin",coin->symbol); jaddstr(item,"coin",coin->symbol);
@ -1185,7 +1192,7 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol
return(-1); return(-1);
} }
destaddr[0] = destaddr2[0] = 0; 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; bypass = 1;
if ( bypass != 0 ) if ( bypass != 0 )
val = satoshis; val = satoshis;

10
start_BEER_OTHER_trade.sh

@ -1,12 +1,8 @@
#!/bin/bash #!/bin/bash
docker-compose exec -T clientnode ./setpassphrase
sleep 5
docker-compose exec -T clientnode ./enable docker-compose exec -T clientnode ./enable
sleep 5 sleep 3
docker-compose exec -T seednode ./setpassphrase
sleep 5
docker-compose exec -T seednode ./enable docker-compose exec -T seednode ./enable
sleep 5 sleep 3
docker-compose exec -T seednode ./sell_BEER_OTHER $1 docker-compose exec -T seednode ./sell_BEER_OTHER $1
sleep 5 sleep 3
docker-compose exec -T clientnode ./buy_BEER_OTHER $1 docker-compose exec -T clientnode ./buy_BEER_OTHER $1

10
start_BEER_OTHER_trade_inverted.sh

@ -1,12 +1,8 @@
#!/bin/bash #!/bin/bash
docker-compose exec -T clientnode ./setpassphrase
sleep 5
docker-compose exec -T clientnode ./enable docker-compose exec -T clientnode ./enable
sleep 5 sleep 3
docker-compose exec -T seednode ./setpassphrase
sleep 5
docker-compose exec -T seednode ./enable docker-compose exec -T seednode ./enable
sleep 5 sleep 3
docker-compose exec -T clientnode ./buy_BEER_OTHER $1 docker-compose exec -T clientnode ./buy_BEER_OTHER $1
sleep 5 sleep 3
docker-compose exec -T seednode ./sell_BEER_OTHER $1 docker-compose exec -T seednode ./sell_BEER_OTHER $1
Loading…
Cancel
Save