Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
NULL_ADDRESS_STRING = "0x0000000000000000000000000000000000000000"

REQUEST_TIMEOUT = 5
API_NUM_OF_RETRIES = 5

# Time limit, currently set to 1 full day, after which Coingecko Token List is re-fetched (in seconds)
COINGECKO_TOKEN_LIST_RELOAD_TIME = 86400
Expand Down
33 changes: 18 additions & 15 deletions src/fees/compute_fees.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from hexbytes import HexBytes
from web3 import Web3

from src.constants import REQUEST_TIMEOUT, NULL_ADDRESS
from src.constants import REQUEST_TIMEOUT, NULL_ADDRESS, API_NUM_OF_RETRIES

# types for trades

Expand Down Expand Up @@ -405,21 +405,24 @@ def get_all_data(self, tx_hash: HexBytes) -> SettlementData:
return settlement_data

def get_auction_data(self, tx_hash: HexBytes):
for environment, url in self.orderbook_urls.items():
try:
response = requests.get(
url + f"solver_competition/by_tx_hash/{tx_hash.to_0x_hex()}",
timeout=REQUEST_TIMEOUT,
)
response.raise_for_status()
auction_data = response.json()
sleep(0.5) # introducing some delays so that we don't overload the api
return auction_data, environment
except requests.exceptions.HTTPError as err:
if err.response.status_code == 404:
pass
for i in range(API_NUM_OF_RETRIES):
for environment, url in self.orderbook_urls.items():
try:
response = requests.get(
url + f"solver_competition/by_tx_hash/{tx_hash.to_0x_hex()}",
timeout=REQUEST_TIMEOUT,
)
sleep(
0.5
) # introducing some delays so that we don't overload the api
response.raise_for_status()
auction_data = response.json()
return auction_data, environment
except requests.exceptions.HTTPError as err:
if err.response.status_code == 404:
pass
raise ConnectionError(
f"Error fetching off-chain data for tx {tx_hash.to_0x_hex()}"
f"Error fetching api auction data for tx {tx_hash.to_0x_hex()}"
)

def get_order_data(self, uid: HexBytes, environment: str):
Expand Down