Skip to content

Commit

Permalink
Merge pull request #53 from cowprotocol/bug_fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
harisang authored Sep 6, 2024
2 parents a62813b + de04615 commit ed86ebd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)

NULL_ADDRESS = Web3.to_checksum_address("0x0000000000000000000000000000000000000000")
NULL_ADDRESS_STRING = "0x0000000000000000000000000000000000000000"

REQUEST_TIMEOUT = 5

Expand Down
4 changes: 4 additions & 0 deletions src/fees/compute_fees.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from fractions import Fraction
import math
import os
from time import sleep
from typing import Any
import requests
import json
Expand Down Expand Up @@ -412,6 +413,7 @@ def get_auction_data(self, tx_hash: HexBytes):
)
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:
Expand All @@ -427,6 +429,7 @@ def get_order_data(self, uid: HexBytes, environment: str):
url,
timeout=REQUEST_TIMEOUT,
)
sleep(0.5) # introducing some delays so that we don't overload the api
if response.ok == False:
# jit CoW AMM detected
return None
Expand All @@ -437,6 +440,7 @@ def get_trade_data(self, uid: HexBytes, tx_hash: HexBytes, environment: str):
prefix = self.orderbook_urls[environment]
url = prefix + f"trades?orderUid={uid.to_0x_hex()}"
response = requests.get(url)
sleep(0.5) # introducing some delays so that we don't overload the api
trade_data_temp = response.json()
for t in trade_data_temp:
if HexBytes(t["txHash"]) == tx_hash:
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from sqlalchemy.engine import Engine
from src.helpers.config import check_db_connection, logger
from src.helpers.helper_functions import read_sql_file
from src.constants import NULL_ADDRESS_STRING


class Database:
Expand Down Expand Up @@ -102,9 +103,10 @@ def write_fees(
tx_hash_bytes = bytes.fromhex(tx_hash[2:])
token_address_bytes = bytes.fromhex(token_address[2:])
order_uid_bytes = bytes.fromhex(order_uid[2:])
null_address_bytes = bytes.fromhex(NULL_ADDRESS_STRING[2:])

query = read_sql_file("src/sql/insert_fee.sql")
final_recipient = None
final_recipient = null_address_bytes
if recipient != "":
final_recipient = bytes.fromhex(recipient[2:])

Expand Down

0 comments on commit ed86ebd

Please sign in to comment.