Last active
April 3, 2024 08:13
-
-
Save AshwinSekar/ff7149c591971d89836e81547d36e0b5 to your computer and use it in GitHub Desktop.
Check the current status of the TVC proposal on mainnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export LC_NUMERIC="en_US.UTF-8" | |
RPC_URL="https://api.mainnet-beta.solana.com" | |
MINT="tvcUX2gkQWsPYK2Uq7DeuX9ZJTFF9V3BGJ2isfLMgrg" | |
YES_ACCT="5ByopEuFqdd1AvXc6czKu6JQkCXdbWJwFMc4Bxe2dgYQ" | |
NO_ACCT="AhaUueUXYWEuksQdAJMjvjPGAbjnXhYdk2ZrBVtNA9YT" | |
ABSTAIN_ACCT="AYHPwv8WSNBKYStSQJ7NfgtWxMPz5WSw3MeDtc2Pww5r" | |
function fetch_vote_token_balance() { | |
if ! curl -s $RPC_URL -X POST -H "Content-Type: application/json" -d \ | |
'{ "jsonrpc": "2.0", "id": 1, "method": "getTokenAccountBalance", "params": ["'"$1"'"] }' | jq ".result.value.uiAmountString" | tr -d '"'; then | |
echo "ERROR: curl failed" | |
exit 1 | |
fi | |
} | |
function fetch_total_supply() { | |
if ! curl -s $RPC_URL -X POST -H "Content-Type: application/json" -d \ | |
'{ "jsonrpc": "2.0", "id": 1, "method": "getTokenSupply", "params": ["'$MINT'"] }' | jq ".result.value.uiAmountString" | tr -d '"'; then | |
echo "ERROR: curl failed" | |
exit 1 | |
fi | |
} | |
function print_row() { | |
printf '%8s | %8.4f%% | %20d\n' "$1" "$2" "$3" | |
} | |
YES=$(fetch_vote_token_balance $YES_ACCT) | |
NO=$(fetch_vote_token_balance $NO_ACCT) | |
ABSTAIN=$(fetch_vote_token_balance $ABSTAIN_ACCT) | |
TOTAL=$(echo "$YES + $NO + $ABSTAIN" | bc) | |
SUPPLY=$(fetch_total_supply) | |
YES_PCT=$(echo "scale=4; $YES / $SUPPLY * 100" | bc) | |
NO_PCT=$(echo "scale=4; $NO / $SUPPLY * 100" | bc) | |
ABSTAIN_PCT=$(echo "scale=4; $ABSTAIN / $SUPPLY * 100" | bc) | |
TOTAL_PCT=$(echo "scale=4; $TOTAL / $SUPPLY * 100" | bc) | |
print_row "YES" "$YES_PCT" "$YES" | |
print_row "NO" "$NO_PCT" "$NO" | |
print_row "ABSTAIN" "$ABSTAIN_PCT" "$ABSTAIN" | |
echo "" | |
print_row "CASTED" "$TOTAL_PCT" "$TOTAL" | |
print_row "SUPPLY" "100" "$SUPPLY" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment