Browse Source

Fix decimals value handling for ERC20 tokens.

pass-iguana-arg
Artem Pikulin 7 years ago
parent
commit
2eeb227a1b
  1. 18
      Jenkinsfile
  2. 4
      etomic_build/client/buy_BEER_ETH
  3. 4
      etomic_build/client/buy_BEER_OTHER
  4. 3
      etomic_build/client/enable
  5. 2
      etomic_build/coins
  6. 3
      etomic_build/seed/enable
  7. 4
      etomic_build/seed/sell_BEER_ETH
  8. 4
      etomic_build/seed/sell_BEER_OTHER
  9. 9
      iguana/exchanges/LP_coins.c
  10. 14
      iguana/exchanges/LP_etomic.c
  11. 4
      start_BEER_OTHER_trade.sh
  12. 12
      start_BEER_OTHER_trade_inverted.sh

18
Jenkinsfile

@ -17,13 +17,23 @@ cmake ..
cmake --build . --target marketmaker-testnet'''
}
}
stage('Trade') {
stage('Trade BEER/ETH') {
steps {
sh '''docker-compose build
docker-compose up -d
./start_BEER_ETH_trade.sh
COMPOSE_HTTP_TIMEOUT=601 timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode)
COMPOSE_HTTP_TIMEOUT=601 timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode)
./start_BEER_OTHER_trade.sh ETH
timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode)
timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode)
docker-compose down'''
}
}
stage('Trade ETH/BEER') {
steps {
sh '''docker-compose build
docker-compose up -d
./start_BEER_OTHER_trade_inverted.sh ETH
timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode)
timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode)
docker-compose down'''
}
}

4
etomic_build/client/buy_BEER_ETH

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

4
etomic_build/client/buy_BEER_OTHER

@ -0,0 +1,4 @@
#!/bin/bash
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\":\"sell\",\"base\":\"$1\",\"rel\":\"BEER\",\"basevolume\":0.1,\"price\":1}"

3
etomic_build/client/enable

@ -2,5 +2,6 @@
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"NODEC\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"JST\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}"

2
etomic_build/coins

File diff suppressed because one or more lines are too long

3
etomic_build/seed/enable

@ -1,6 +1,7 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"NODEC\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"JST\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}"

4
etomic_build/seed/sell_BEER_ETH

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

4
etomic_build/seed/sell_BEER_OTHER

@ -0,0 +1,4 @@
#!/bin/bash
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\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":0.1,\"price\":0.9}"

9
iguana/exchanges/LP_coins.c

@ -373,7 +373,7 @@ struct iguana_info *LP_coinadd(struct iguana_info *cdata)
return(coin);
}
uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain,uint8_t wiftaddr,uint8_t taddr,uint16_t busport,char *confpath)
uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain,uint8_t wiftaddr,uint8_t taddr,uint16_t busport,char *confpath,uint8_t decimals)
{
static void *ctx;
char *name2; uint16_t origport = port;
@ -429,6 +429,7 @@ uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asse
coin->zcash = LP_IS_BITCOINGOLD;
printf("set coin.%s <- LP_IS_BITCOINGOLD %d\n",symbol,coin->zcash);
}
coin->decimals = decimals;
return(port);
}
@ -472,7 +473,7 @@ struct iguana_info *LP_coinfind(char *symbol)
else if ( strcmp(symbol,"KMD") == 0 )
name = "komodo";
else return(0);
port = LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,0,0,busport,0);
port = LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,0,0,busport,0,0);
if ( port == 0 )
isinactive = 1;
else isinactive = 0;
@ -516,8 +517,8 @@ struct iguana_info *LP_coincreate(cJSON *item)
else if ( (name= jstr(item,"name")) == 0 )
name = symbol;
cdata.decimals = juint(item,"decimals");
if ( LP_coininit(&cdata,symbol,name,assetname==0?"":assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,juint(item,"wiftaddr"),juint(item,"taddr"),LP_busport(port),jstr(item,"confpath")) < 0 )
uint8_t decimals = juint(item,"decimals");
if ( LP_coininit(&cdata,symbol,name,assetname==0?"":assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,juint(item,"wiftaddr"),juint(item,"taddr"),LP_busport(port),jstr(item,"confpath"),decimals) < 0 )
{
coin = LP_coinadd(&cdata);
coin->inactive = (uint32_t)time(NULL);

14
iguana/exchanges/LP_etomic.c

@ -211,9 +211,10 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap)
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
struct iguana_info *ecoin;
struct iguana_info *ecoin, *alice_coin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
alice_coin = LP_coinfind(swap->dest);
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32);
@ -233,7 +234,6 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap)
}
uint8arrayToHex(input.bobSecret, invertedSecret.bytes, 32);
struct iguana_info *alice_coin = LP_coinfind(swap->alicecoin);
input.decimals = alice_coin->decimals;
strcpy(txData.from, swap->etomicdest);
@ -281,7 +281,7 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap)
}
uint8arrayToHex(input.aliceSecret, invertedSecret.bytes, 32);
uint8arrayToHex(input.bobHash, swap->secretBn, 20);
struct iguana_info *alice_coin = LP_coinfind(swap->alicecoin);
struct iguana_info *alice_coin = LP_coinfind(swap->dest);
input.decimals = alice_coin->decimals;
strcpy(txData.from, swap->etomicsrc);
@ -408,7 +408,7 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap)
struct iguana_info *ecoin, *bobcoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
bobcoin = LP_coinfind(swap->bobcoin);
bobcoin = LP_coinfind(swap->src);
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx);
@ -558,7 +558,7 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap)
struct iguana_info *ecoin, *bobcoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
bobcoin = LP_coinfind(swap->bobcoin);
bobcoin = LP_coinfind(swap->src);
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx);
@ -604,7 +604,7 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap)
struct iguana_info *ecoin, *bobcoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
bobcoin = LP_coinfind(swap->bobcoin);
bobcoin = LP_coinfind(swap->src);
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32);
@ -652,7 +652,7 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap)
struct iguana_info *ecoin, *bobcoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
bobcoin = LP_coinfind(swap->bobcoin);
bobcoin = LP_coinfind(swap->src);
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32);

4
start_BEER_ETH_trade.sh → start_BEER_OTHER_trade.sh

@ -7,6 +7,6 @@ docker-compose exec -T seednode ./setpassphrase
sleep 5
docker-compose exec -T seednode ./enable
sleep 5
docker-compose exec -T seednode ./sell_BEER_ETH
docker-compose exec -T seednode ./sell_BEER_OTHER $1
sleep 5
docker-compose exec -T clientnode ./buy_BEER_ETH
docker-compose exec -T clientnode ./buy_BEER_OTHER $1

12
start_BEER_OTHER_trade_inverted.sh

@ -0,0 +1,12 @@
#!/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
docker-compose exec -T seednode ./enable
sleep 5
docker-compose exec -T clientnode ./buy_BEER_OTHER $1
sleep 5
docker-compose exec -T seednode ./sell_BEER_OTHER $1
Loading…
Cancel
Save