Guest User

Untitled

a guest
Aug 11th, 2018
168
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. NOW=$(date +"%m_%d_%y")
  2. log=/c/Users/Z170/Documents/Mining/auto-miner/autominer_log_$NOW.txt
  3. date +"%H:%M" >> $log
  4. #get values from curl
  5. declare -a arrCOIN=("PURK" "HAVEN" "TUBE" "MSR" "XTL" "GRFT" "WOW")
  6. declare -a arrURL=("https://purk.miner.rocks/api/stats" "https://haven.miner.rocks/api/stats" "https://bittube.miner.rocks/api/stats" "https://masari.miner.rocks/api/stats" "https://stellite.miner.rocks/api/stats" "https://graft.miner.rocks/api/stats" "https://api.wownero.minercartel.com/api/network/stats")
  7. declare -a arrJSON=("purk.json" "haven.json" "tube.json" "msr.json" "xtl.json" "grft.json" "wow.json" "qrl.json")
  8. declare -a arrPrice=("https://tradeogre.com/api/v1/ticker/BTC-PURK" "https://tradeogre.com/api/v1/ticker/BTC-XHV" "https://tradeogre.com/api/v1/ticker/BTC-TUBE" "https://tradeogre.com/api/v1/ticker/BTC-MSR" "https://tradeogre.com/api/v1/ticker/BTC-XTL" "https://tradeogre.com/api/v1/ticker/BTC-GRFT" "https://tradeogre.com/api/v1/ticker/BTC-WOW")
  9. declare -a arrBlockTime=(90 120 120 120 60 120 300)
  10. declare -a arrBlockReward=(80 26.3 427 22.5 15450 1475 170)
  11. declare -a arrHRfactor=(2400 0.75 0.72 1.8 1 1 1)
  12. HIGHESTFOUND=0
  13. CURRENTCOIN=$(eval "cat /c/Users/Z170/Documents/Mining/auto-miner/CURRENTCOIN.txt")
  14. BASECOIN=HAVEN
  15.  
  16. for((i=0;i<${#arrCOIN[@]};i++))
  17. do
  18. echo $i
  19. COIN=${arrCOIN[$i]}
  20. COINURL=${arrURL[$i]}
  21. JSON=${arrJSON[$i]}
  22. PRICEURL=${arrPrice[$i]}
  23. BLOCKTIME=${arrBlockTime[$i]}
  24. BLOCKREWARD=${arrBlockReward[$i]}
  25. HRFACTOR=${arrHRfactor[$i]}
  26.  
  27. RESULT=$(eval "curl $COINURL | jq '.' > $JSON")
  28. echo RESULT
  29.  
  30. if [ "$COIN" = "WOW" ]; then
  31.  
  32. # DIFF=$(eval "curl https://api.wownero.minercartel.com/api/network/stats | jq '.difficulty'")
  33. NETDIFF=$(eval "curl https://api.wownero.minercartel.com/api/network/stats | jq '.difficulty'")
  34. AVG30B=$(eval "curl https://cryptoknight.cc/rpc/wownero/stats | jq '.network.difficulty'")
  35. WAVG24H=$(eval "curl https://wow.luckypool.io/api/network/stats | jq '.difficulty'")
  36.  
  37. else
  38. NETDIFF=$(eval "cat $JSON | jq '.network.difficulty'")
  39. AVG30B=$(eval "cat $JSON | jq '.pool.stats.diffs.avg30b'")
  40. WAVG24H=$(eval "cat $JSON | jq '.pool.stats.diffs.wavg24h'")
  41. fi
  42.  
  43. echo NETDIFF:$NETDIFF AVG30B:$AVG30B WAVG24H:$WAVG24H
  44. let AVGVALUE=(3*$NETDIFF+$AVG30B+2*$WAVG24H)/6
  45. echo AVGVALUE:$AVGVALUE
  46.  
  47. BIDPRICE=$(eval "curl $PRICEURL | jq -r '.bid'")
  48. echo BIDPRICE:$BIDPRICE
  49.  
  50. #convert math
  51. let NETHASH=($AVGVALUE/$BLOCKTIME)
  52. echo NETHASH:$NETHASH
  53. # let COINPERDAY=(((950*$BLOCKTIME*$HRFACTOR)/$AVGVALUE)*(60*24*$BLOCKREWARD))
  54. TOTALCOINS=`echo print 3600/$BLOCKTIME*24*$BLOCKREWARD | perl`
  55. echo TOTALCOINS:$TOTALCOINS
  56. # let COINPERDAY=`echo - | awk '{print (1000*$HRFACTOR*$TOTALCOINS)/$NETHASH}'`
  57. # echo - | awk '{print (1000*$HRFACTOR*$TOTALCOINS)/$NETHASH}'
  58. # let COINPERDAY=print 1000*$HRFACTOR*$TOTALCOINS/$NETHASH. | perl
  59. COINPERDAY=`echo print 1000*$HRFACTOR*$TOTALCOINS/$NETHASH | perl`
  60. # ROUNDED=`printf "%.4f" $COINPERDAY`
  61. echo COINPERDAY:$COINPERDAY
  62. # echo ROUNDED:$ROUNDED
  63. # echo print $ROUNDED*$BIDPRICE. | perl
  64. BTCPERDAY=`echo print $COINPERDAY*$BIDPRICE*1000 | perl`
  65. # echo print $BIDPRICE*$COINPERDAY. | perl
  66. echo $COIN:$BTCPERDAY
  67. echo ' '$COIN:$BTCPERDAY, >> $log
  68.  
  69. if [ "$COIN" = "$BASECOIN" ]; then
  70. BUFFER=`echo print $BTCPERDAY*1.2 | perl`
  71. echo BUFFER:$BUFFER
  72. if [ ${BUFFER%.*} -eq ${HIGHESTFOUND%.*} ] && [ ${BUFFER#*.} \> ${HIGHESTFOUND#*.} ] || [ ${BUFFER%.*} -gt ${HIGHESTFOUND%.*} ]; then
  73. HIGHESTFOUND=$BUFFER
  74. HIGHESTCOIN=$COIN
  75. echo HIGHESTCOIN:$HIGHESTCOIN
  76. echo HIGHESTFOUND:$HIGHESTFOUND
  77. fi
  78. elif [ "$COIN" = "$CURRENTCOIN" ]; then
  79. BUFFER=`echo print $BTCPERDAY*1.1 | perl`
  80. echo BUFFER:$BUFFER
  81. if [ ${BUFFER%.*} -eq ${HIGHESTFOUND%.*} ] && [ ${BUFFER#*.} \> ${HIGHESTFOUND#*.} ] || [ ${BUFFER%.*} -gt ${HIGHESTFOUND%.*} ]; then
  82. HIGHESTFOUND=$BUFFER
  83. HIGHESTCOIN=$COIN
  84. echo HIGHESTCOIN:$HIGHESTCOIN
  85. echo HIGHESTFOUND:$HIGHESTFOUND
  86. fi
  87. elif [ ${BTCPERDAY%.*} -eq ${HIGHESTFOUND%.*} ] && [ ${BTCPERDAY#*.} \> ${HIGHESTFOUND#*.} ] || [ ${BTCPERDAY%.*} -gt ${HIGHESTFOUND%.*} ]; then
  88. HIGHESTFOUND=$BTCPERDAY
  89. HIGHESTCOIN=$COIN
  90. echo HIGHESTCOIN:$HIGHESTCOIN
  91. echo HIGHESTFOUND:$HIGHESTFOUND
  92. fi
  93. done
  94. #get NH prices
  95. declare -a arrNH=("V7" "HVY")
  96. #declare -a arrNHURL=("https://api.nicehash.com/api?method=stats.global.current" "https://api.nicehash.com/api?method=stats.global.24h")
  97. declare -a arrALGO=(30 31)
  98. declare -a arrFACTOR=(1 0.75)
  99. NH_JSON=$(eval "curl https://api.nicehash.com/api?method=stats.global.current | jq '.' > nh.json")
  100. NH_24H_JSON=$(eval "curl https://api.nicehash.com/api?method=stats.global.24h | jq '.' > nh24.json")
  101.  
  102. for((i=0;i<${#arrNH[@]};i++))
  103. do
  104. echo $i
  105. NH=${arrNH[$i]}
  106. ALGO=${arrALGO[$i]}
  107. FACTOR=${arrFACTOR[$i]}
  108. NH_CURRENT=$(eval "cat nh.json | jq -r '.result.stats[$ALGO].price'")
  109. NH_24H=$(eval "cat nh24.json | jq -r '.result.stats[$ALGO].price'")
  110. NH_SUM=`echo print 3*$NH_CURRENT+$NH_24H | perl`
  111. BTCPERDAY=`echo print $NH_SUM/4*$FACTOR | perl`
  112. echo $NH:$BTCPERDAY
  113. echo ' '$NH:$BTCPERDAY, >> $log
  114.  
  115. if [ "$NH" = "$CURRENTCOIN" ]; then
  116. BUFFER=`echo print $BTCPERDAY*1.1 | perl`
  117. if [ ${BUFFER%.*} -eq ${HIGHESTFOUND%.*} ] && [ ${BUFFER#*.} \> ${HIGHESTFOUND#*.} ] || [ ${BUFFER%.*} -gt ${HIGHESTFOUND%.*} ]; then
  118. HIGHESTFOUND=$BUFFER
  119. HIGHESTCOIN=$NH
  120. echo HIGHESTCOIN:$HIGHESTCOIN
  121. echo HIGHESTFOUND:$HIGHESTFOUND
  122. fi
  123. elif [ ${BTCPERDAY%.*} -eq ${HIGHESTFOUND%.*} ] && [ ${BTCPERDAY#*.} \> ${HIGHESTFOUND#*.} ] || [ ${BTCPERDAY%.*} -gt ${HIGHESTFOUND%.*} ]; then
  124. HIGHESTFOUND=$BTCPERDAY
  125. HIGHESTCOIN=$NH
  126. echo HIGHESTCOIN:$HIGHESTCOIN
  127. echo HIGHESTFOUND:$HIGHESTFOUND
  128. fi
  129.  
  130. done
  131.  
  132. echo CURRENTCOIN:$CURRENTCOIN
  133. echo BUFFER:$BUFFER
  134. echo HIGHESTCOIN:$HIGHESTCOIN
  135. echo HIGHESTFOUND:$HIGHESTFOUND
  136.  
  137. echo ' 'CURRENTCOIN:$CURRENTCOIN, BUFFER:$BUFFER, HIGHESTCOIN:$HIGHESTCOIN, HIGHESTVALUE:$HIGHESTFOUND$'\r' >> $log
  138.  
  139. if [ "$CURRENTCOIN" != "$HIGHESTCOIN" ]; then
  140.  
  141. #kill miner
  142. taskkill -fi "WINDOWTITLE eq C:\WINDOWS\system32\cmd.exe*" -f -t
  143. sleep 5
  144.  
  145. CURRENTCOIN=$HIGHESTCOIN
  146. echo "$CURRENTCOIN" > /c/Users/Z170/Documents/Mining/auto-miner/CURRENTCOIN.txt
  147.  
  148. #start miner
  149. cd /c/Users/Z170/Documents/Mining/auto-miner/
  150. start "$HIGHESTCOIN".bat
  151. else
  152. echo CURRENTCOIN stays the same
  153.  
  154. fi
RAW Paste Data