Skip to content

Instantly share code, notes, and snippets.

@agustif
Created March 10, 2024 16:44
Show Gist options
  • Save agustif/f3c9cc633826c778ee803d2095655db9 to your computer and use it in GitHub Desktop.
Save agustif/f3c9cc633826c778ee803d2095655db9 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set locale to ensure proper decimal point representation
export LC_NUMERIC="en_US.UTF-8"
# Fetches price from Coingecko Terminal for Higher MemeCoin
# Curl command to fetch price
RESULT=$(curl -s 'https://api.geckoterminal.com/api/v2/simple/networks/base/token_price/0x0578d8A44db98B23BF096A382e016e29a5Ce0ffe' -H 'accept: application/json')
# Extracting price from the response and formatting to 4 decimals
PRICE=$(echo "$RESULT" | jq -r '.data.attributes.token_prices["0x0578d8a44db98b23bf096a382e016e29a5ce0ffe"]' | awk '{printf "%.4f", $1}')
# Your holdings of Higher MemeCoin (in this case, 1,000,000) 1M
HOLDINGS=1000000
# Calculating total value of holdings with 2 decimal points
TOTAL_VALUE=$(echo "scale=2; $PRICE * $HOLDINGS" | bc)
# Printing the total value with 2 decimal points
printf "%.4f" "$PRICE"
printf " %.2f" "$TOTAL_VALUE"
printf " $"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment