Skip to content

Instantly share code, notes, and snippets.

@Macarse
Created September 14, 2020 22:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Macarse/6da0350801ad9d9eb249999ea873050d to your computer and use it in GitHub Desktop.
Save Macarse/6da0350801ad9d9eb249999ea873050d to your computer and use it in GitHub Desktop.
DPI value calculated through Coingecko API
from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()
per_set = {
"YFI": 0.000798,
"LEND": 33.272727,
"SNX": 3.148585,
"COMP": 0.08535,
"MKR": 0.023989,
"LRC": 30.833333,
"REN": 23.814815,
"KNC": 5.186441,
"BAL": 0.192346,
"REP": 0.107378
}
token_id = { "YFI": "0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e",
"LEND": "0x80fb784b7ed66730e8b1dbd9820afd29931aab03",
"SNX": "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",
"COMP": "0xc00e94cb662c3520282e6f5717214004a7f26888",
"MKR": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
"LRC": "0xbbbbca6a901c926f240b89eacb641d8aec7aeafd",
"REN": "0x408e41876cccdc0f92210600ef50372656052a38",
"KNC": "0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
"BAL": "0xba100000625a3754423978a60c9317c58a424e3d",
"REP": "0x221657776846890989a759ba2973e427dff5c9bb",
"DPI": "0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b"
}
currencies = ','.join(list(token_id.values()))
prices = cg.get_token_price(id='ethereum', contract_addresses=currencies, vs_currencies='usd')
total_value = 0
for token in per_set:
multiplier = per_set[token]
total_value += multiplier * prices[token_id[token]]['usd']
print("Total value: " + str(total_value))
print("DPI value: " + str(prices[token_id["DPI"]]['usd']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment