Skip to content

Commit

Permalink
Add Uniswap price integration
Browse files Browse the repository at this point in the history
  • Loading branch information
santteegt committed Apr 1, 2020
1 parent f750372 commit 4268378
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/economy/management/commands/get_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def cryptocompare():

def uniswap():
"""Hangle pulling market data from Uniswap using its subgraph node on mainnet."""
pull_uniswap_tokens_only = ['PAN']
endpoint = 'https://api.thegraph.com/subgraphs/name/graphprotocol/uniswap'
query_limit = 100
skip = 0
Expand Down Expand Up @@ -212,12 +211,8 @@ def uniswap():
for exchange in json_data['data']['exchanges']:
try:
token_name = exchange['tokenSymbol']
if token_name not in pull_uniswap_tokens_only:
continue
if float(exchange['price']) == 0.: # Skip exchange pairs with zero value
continue
if token_name == 'ETH':
continue # dont pull ETH/ETH and ETH/USD pricing
to_amount = (float(exchange['price']) + float(exchange['lastPrice'])) / 2.
ConversionRate.objects.create(
from_amount=1,
Expand Down Expand Up @@ -284,6 +279,12 @@ def handle(self, *args, **options):
except Exception as e:
print(e)

try:
print('uniswap')
uniswap()
except Exception as e:
print(e)

try:
print('refresh')
refresh_bounties()
Expand Down

0 comments on commit 4268378

Please sign in to comment.