Skip to content

Commit

Permalink
fix the bug--hex interp of token amount strings from python
Browse files Browse the repository at this point in the history
  • Loading branch information
Anirudh Suresh authored and Anirudh Suresh committed Jan 31, 2024
1 parent 96b9bda commit acbf1ba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
34 changes: 18 additions & 16 deletions beacon/protocols/beacon_TokenVault.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def create_liquidation_opp(
"repay_tokens": [
{
"contract": account["token_address_debt"],
"amount": str(account["amount_debt"]),
"amount": hex(account["amount_debt"]).replace("0x", ""),
}
],
"receipt_tokens": [
{
"contract": account["token_address_collateral"],
"amount": str(account["amount_collateral"]),
"amount": hex(account["amount_collateral"]).replace("0x", ""),
}
]
}
Expand Down Expand Up @@ -231,20 +231,22 @@ async def main():
accounts, price_feed_client.prices_dict)

if args.send_beacon:
resp = await client.post(
args.beacon_server_url,
json=accounts_liquidatable
)
if resp.status_code == 422:
logging.error(
"Invalid request body format, should provide a list of LiquidationOpportunity")
elif resp.status_code == 404:
logging.error("Provided beacon server endpoint url not found")
elif resp.status_code == 405:
logging.error(
"Provided beacon server endpoint url does not support POST requests")
else:
logging.info(f"Response, post to beacon: {resp.text}")
for account_liquidatable in accounts_liquidatable:
resp = await client.post(
args.beacon_server_url,
json=account_liquidatable
)
if resp.status_code == 422:
logging.error(
"Invalid request body format, should provide a list of LiquidationOpportunity")
elif resp.status_code == 404:
logging.error(
"Provided beacon server endpoint url not found")
elif resp.status_code == 405:
logging.error(
"Provided beacon server endpoint url does not support POST requests")
else:
logging.info(f"Response, post to beacon: {resp.text}")
else:
logging.info(
f"List of liquidatable accounts:\n{accounts_liquidatable}")
Expand Down
3 changes: 2 additions & 1 deletion beacon/searcher/searcher_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from web3.auto import w3
from eth_abi import encode
from typing import TypedDict
from eth_account.datastructures import SignedMessage


class UserLiquidationParams(TypedDict):
Expand All @@ -17,7 +18,7 @@ def construct_signature_liquidator(
bid: int,
valid_until: int,
secret_key: str
) -> web3.types.ECDSASignature:
) -> SignedMessage:
"""
Constructs a signature for a liquidator's transaction to submit to the LiquidationAdapter contract.
Expand Down
6 changes: 2 additions & 4 deletions beacon/utils/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
BEACON_SERVER_ENDPOINT = "http://localhost:9000"
AUCTION_SERVER_ENDPOINT = f"http://localhost:9000/bid"

BEACON_SERVER_ENDPOINT_SURFACE = f"{
BEACON_SERVER_ENDPOINT}/liquidation/submit_opportunity"
BEACON_SERVER_ENDPOINT_GETOPPS = f"{
BEACON_SERVER_ENDPOINT}/liquidation/fetch_opportunities"
BEACON_SERVER_ENDPOINT_SURFACE = f"{BEACON_SERVER_ENDPOINT}/liquidation/submit_opportunity"
BEACON_SERVER_ENDPOINT_GETOPPS = f"{BEACON_SERVER_ENDPOINT}/liquidation/fetch_opportunities"

0 comments on commit acbf1ba

Please sign in to comment.