Spaces:
Runtime error
Runtime error
gauravlochab
commited on
Commit
·
7aacc73
1
Parent(s):
18fcfae
feat: Add delay before making API request for token price
Browse files- app_value_locked.py +2 -1
app_value_locked.py
CHANGED
|
@@ -4,6 +4,7 @@ from web3 import Web3
|
|
| 4 |
from datetime import datetime, timedelta
|
| 5 |
from typing import List, Dict, Optional
|
| 6 |
import pandas as pd
|
|
|
|
| 7 |
|
| 8 |
ADDRESSES = {
|
| 9 |
"optimism": {
|
|
@@ -240,7 +241,7 @@ def get_token_decimals(web3, token_address):
|
|
| 240 |
def get_token_price_usd(chain, token_address):
|
| 241 |
chain_dict = {"optimism": "optimistic-ethereum", "base": "base", "ethereum": "ethereum"}
|
| 242 |
chain_name = chain_dict.get(chain, chain)
|
| 243 |
-
|
| 244 |
url = f"https://api.coingecko.com/api/v3/simple/token_price/{chain_name}?contract_addresses={token_address}&vs_currencies=usd"
|
| 245 |
|
| 246 |
headers = {
|
|
|
|
| 4 |
from datetime import datetime, timedelta
|
| 5 |
from typing import List, Dict, Optional
|
| 6 |
import pandas as pd
|
| 7 |
+
import time
|
| 8 |
|
| 9 |
ADDRESSES = {
|
| 10 |
"optimism": {
|
|
|
|
| 241 |
def get_token_price_usd(chain, token_address):
|
| 242 |
chain_dict = {"optimism": "optimistic-ethereum", "base": "base", "ethereum": "ethereum"}
|
| 243 |
chain_name = chain_dict.get(chain, chain)
|
| 244 |
+
time.sleep(2)
|
| 245 |
url = f"https://api.coingecko.com/api/v3/simple/token_price/{chain_name}?contract_addresses={token_address}&vs_currencies=usd"
|
| 246 |
|
| 247 |
headers = {
|