Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2018
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tell application "JSON Helper"
  2.     --Monitor the amount of SC owned
  3.     set walletWithoutSiaMining to 0
  4.     set binance to 0
  5.     set siaMiningData to fetch JSON from "http://mining.luxor.tech/API/SC/user/ff2412ae9d0b15b6005a79f1143dd5eea02ee60b8baa544666124ce44fc770a08e15b461c747/" with cleaning feed
  6.     set siaMiningTotalPaid to (total_payouts) of siaMiningData as real
  7.     set siaMiningBalance to (balance) of siaMiningData as real
  8.    
  9.     set totalSC to walletWithoutSiaMining + binance + siaMiningTotalPaid + siaMiningBalance
  10.    
  11.     set binanceScBtcData to fetch JSON from "https://www.binance.com/api/v3/ticker/price?symbol=SCBTC" with cleaning feed
  12.     set binanceScBtcPrice to price of binanceScBtcData as real
  13.    
  14.     set binanceBtcUsdtData to fetch JSON from "https://www.binance.com/api/v3/ticker/price?symbol=BTCUSDT" with cleaning feed
  15.     set binanceBtcUsdtPrice to price of binanceBtcUsdtData as real
  16.    
  17.     set dollarPriceOfSc to binanceScBtcPrice * binanceBtcUsdtPrice
  18.    
  19.     set totalSC to (my number_to_string(totalSC))
  20.     set totalSC to round (totalSC * 10000)
  21.    
  22.     set totalPriceOfMySC to round (totalSC * dollarPriceOfSc)
  23.    
  24.     set totalDelimitedSC to do shell script "echo " & totalSC & " | perl -lpe'1 while s/^([-+]?\\d+)(\\d{3})/$1,$2/'"
  25.     return ("" & totalDelimitedSC & " SC ($" & totalPriceOfMySC & ")")
  26.    
  27.    
  28. end tell
  29.  
  30.  
  31. on number_to_string(this_number)
  32.     set this_number to this_number as string
  33.     if this_number contains "E+" then
  34.         set x to the offset of "." in this_number
  35.         set y to the offset of "+" in this_number
  36.         set z to the offset of "E" in this_number
  37.         set the decimal_adjust to characters (y - (length of this_number)) thru ¬
  38.             -1 of this_number as string as number
  39.         if x is not 0 then
  40.             set the first_part to characters 1 thru (x - 1) of this_number as string
  41.         else
  42.             set the first_part to ""
  43.         end if
  44.         set the second_part to characters (x + 1) thru (z - 1) of this_number as string
  45.         set the converted_number to the first_part
  46.         repeat with i from 1 to the decimal_adjust
  47.             try
  48.                 set the converted_number to the converted_number & character i of the second_part
  49.             on error
  50.                 set the converted_number to the converted_number & "0"
  51.             end try
  52.         end repeat
  53.         return the converted_number
  54.     else
  55.         return this_number
  56.     end if
  57. end number_to_string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement