Calculation changelog
v0.5 20160303 add Jordan Lee’s NBT holdings https://discuss.nubits.com/t/nsr-buyback-calculations/3347/90; modify Jordan Lee’s BTC holdings https://discuss.nubits.com/t/nsr-buyback-calculations/3347/92; add URL to displayed btc and nbt addresses; add url error handling
Output
As of Sat Mar 5 01:59:00 UTC 2016
"blocks" : 773994,
Total NBT = 1273828.2321
FSRT multisig
Balance of BhCnQrYrA5LZm871dtMQEXeU93gmqbhdrC is 0 NBT
FSRT singlesig
Balance of BFTnCyMX1nsTNp6X7Bcm1qVocvShdbwtMi is 151500 NBT
JordanLee singlesig
Balance of B5Zi5XJ1sgS6mWGu7bWJqGVnuXwiMXi7qj is 150000 NBT
JordanLee singlesig from liquidity ops
Balance of BT9AWq9r1i6kghZc6LtrvNb2wRFh7JLCdP is 34539.155 NBT
FLOT 3-of-5 multisig
Balance of BqyRzFtWXDmjxrYpyJD42MLE5xc8FrB4js is 148563.3816 NBT
Total NBT in circulation is 789225.695500 NBT.
Required 15% reserve is 118383.854325 NBT
Tier 4 Funds
Tier 4 buy side funds controlled by FLOT
FLOT 5-of-8 multisig old
Balance of 3QDWJ2yqJ5iTUg6cSpAwxx95ba3NG97hzG is 0 BTC
FLOT 5-of-8 multisig new
Balance of 3HikFkS2Zinab1TJq7dqp6wSPyLu7i7bhe is 192.77846541 BTC
Tier 4 buy side funds controlled by JordanLee 138.0 BTC
NuSafe has $30000 for T4
bitfinex mid price is 406.34 USD
Tier 4 buy side funds total 330.778465 BTC and $30000.000000, valued $164408.521635 (404.608263 BTC)
118383.854325 NBT excluded from the share buyback calculation equals 291.341867 BTC.
404.608263 - 291.341867 = 113.266396 BTC sits in the share buyback pool.
10 percent of this 11.326640 BTC will be used for share buyback next week.
That is equivalent to approximately $4602.466731.
Code
# Nushare buyback calculation v0.5
# mhps 2016
# change log
# v0.5 20160303 add Jordan Lee's NBT holdings https://discuss.nubits.com/t/nsr-buyback-calculations/3347/90; modify Jordan Lee's BTC holdings https://discuss.nubits.com/t/nsr-buyback-calculations/3347/92; add URL to displayed btc and nbt addresses; add url error handling
# v0.4.1 update Jordan Lee's T4 BTC holdings
# v0.4 update Jordan Lee's T4 BTC holdings; comment out gateways; add NuSafe
# v0.3 https://discuss.nubits.com/t/nsr-buyback-calculations/3347/56
# replace this to how nud is run locally
NUD=./daemon/nd
echo As of `date --utc`
$NUD --unit=B getinfo | grep 'blocks'
totalNBT=`$NUD --unit=B getinfo | awk '$1 ~ /moneysupply/{print $3}' | tr -d ,`
#totalNBT=1273828.2321
echo Total NBT = $totalNBT
echo $totalNBT > templist
echo
function nbtBalance { tempval=`curl -s http://blockexplorer.nu/api/addressInfo/$1 | awk 'BEGIN{RS=",\"";FS=":"}{print $1,$2}' | grep totalBalanceInt | awk '{print $2}'`;if [[ $tempval == "" ]]; then echo Block explorer is down; exit; else echo Balance of [$1]\(http://blockexplorer.nu/address/$1\) is $tempval NBT; fi }
function btcBalance { tempval=`curl -s http://btc.blockr.io/api/v1/address/info/$1 | awk 'BEGIN{RS=",\"";FS=":"}{print $1,$2}' | grep balance\" | awk '{print $2}'`;if [[ $tempval == "" ]]; then echo Block explorer is down; exit; else echo Balance of [$1]\(http://btc.blockr.io/address/info/$1\) is $tempval BTC; fi }
function btcPrice { tempval=`curl -s https://api.bitfinex.com/v1/pubticker/btcusd | awk 'BEGIN{RS=",\"";FS=":"}{print $1,$2}' | grep mid | awk '{print $2}'| tr -d \"`;if [[ $tempval == "" ]]; then echo bitfinex BTC price source is down; exit; else echo bitfinex mid price is $tempval USD; fi }
echo FSRT multisig
nbtBalance BhCnQrYrA5LZm871dtMQEXeU93gmqbhdrC
echo $tempval >> templist
echo FSRT singlesig
nbtBalance BFTnCyMX1nsTNp6X7Bcm1qVocvShdbwtMi
echo $tempval >> templist
echo JordanLee singlesig
nbtBalance B5Zi5XJ1sgS6mWGu7bWJqGVnuXwiMXi7qj
echo $tempval >> templist
echo JordanLee singlesig [from liquidity ops]\(https://discuss.nubits.com/t/nsr-buyback-calculations/3347/90\)
nbtBalance BT9AWq9r1i6kghZc6LtrvNb2wRFh7JLCdP
echo $tempval >> templist
echo FLOT 3-of-5 multisig
nbtBalance BqyRzFtWXDmjxrYpyJD42MLE5xc8FrB4js
echo $tempval >> templist
#cat templist
# calc the first line minus rest of the lines
circNBT=`awk '{if(n) c-=$1; else {c=$1;n=1}}END{printf "%f",c;printf "%f",c*0.15 > "reserve"}' templist`
echo
echo Total NBT in circulation is $circNBT NBT.
echo Required 15% reserve is `cat reserve` NBT
echo
echo **Tier 4 Funds**
echo
echo Tier 4 buy side funds controlled by FLOT
echo FLOT 5-of-8 multisig old
btcBalance 3QDWJ2yqJ5iTUg6cSpAwxx95ba3NG97hzG
echo $tempval > templist
echo FLOT 5-of-8 multisig new
btcBalance 3HikFkS2Zinab1TJq7dqp6wSPyLu7i7bhe
echo $tempval >> templist
jltbc=138.0
echo Tier 4 buy side funds controlled by JordanLee [$jltbc BTC]\(https://discuss.nubits.com/t/nsr-buyback-calculations/3347/92\)
echo $jltbc >> templist
nuSafe=30000
echo NuSafe has [\$$nuSafe]\(https://discuss.nubits.com/t/flot-operations-buy-side-btc-related/3117/317\) for T4
# echo
# echo status of sell side gateway:
# $NUD getliquidityinfo B | grep BETwD8nSjtj9ADSvej2na34xmsMYwPRymv -A 2
# echo status of buy side gateway:
# $NUD getliquidityinfo B | grep BFGMPykfKxXZ1otrCZcsbnTwJjKHPP9dsP -A 2
echo
btcPrice
bp=$tempval
awk '{c+=$1}END{\
printf "Tier 4 buy side funds total %f BTC and $%f, valued $%f (%f BTC)\n\n",c,NS,c*BTCP+NS,c+NS/BTCP;\
printf "%f NBT excluded from the share buyback calculation equals %f BTC.\n",RES,RES/BTCP;\
pool=c+NS/BTCP-RES/BTCP;\
printf "%f - %f = %f BTC sits in the share buyback pool.\n",c+NS/BTCP,RES/BTCP,pool;\
printf "10 percent of this **%f BTC will be used for share buyback next week.**\n",pool*0.1;\
printf "That is equivalent to approximately $%f.\n",pool*0.1*BTCP;\
}' RES=`cat reserve` NS=$nuSafe BTCP=$bp templist