Skip to content

Commit

Permalink
removing incompatible type reference for upcoming web3.py version change
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewcasale committed Nov 10, 2023
1 parent 148df4b commit 3871a9b
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions fastlane_bot/helpers/submithandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@

import json
from dataclasses import dataclass, asdict
from typing import List, Any, Dict
from typing import List, Any, Dict, Callable

import requests
from eth_utils import to_hex
from web3._utils.threads import Timeout
from web3._utils.transactions import fill_nonce
from web3.contract import ContractFunction
from web3.exceptions import TimeExhausted
from web3.types import TxParams

Expand Down Expand Up @@ -111,9 +110,7 @@ def _get_transaction(self, tx_details: TxParams) -> TxParams:
"""
return fill_nonce(self.ConfigObj.w3, tx_details)

def _get_transaction_receipt(
self, tx_hash: str, timeout: int
):
def _get_transaction_receipt(self, tx_hash: str, timeout: int):
"""
Gets the transaction receipt for a given transaction hash.
Expand Down Expand Up @@ -203,13 +200,13 @@ def _get_gas_price(self) -> int:
self.ConfigObj.w3.eth.gas_price * self.ConfigObj.DEFAULT_GAS_PRICE_OFFSET
)

def _get_gas(self, tx_function: ContractFunction, address: str) -> int:
def _get_gas(self, tx_function: Callable, address: str) -> int:
"""
Gets the gas for the transaction.
Parameters
----------
tx_function: ContractFunction
tx_function: Callable
The transaction function.
Returns
Expand Down Expand Up @@ -263,7 +260,11 @@ def _get_tx_details(self):
}

def submit_transaction_tenderly(
self, route_struct: List[RouteStruct], src_address: str, src_amount: int, flashloan_struct: List[Dict[str, int or str]] = None
self,
route_struct: List[RouteStruct],
src_address: str,
src_amount: int,
flashloan_struct: List[Dict[str, int or str]] = None,
) -> Any:
"""
Submits a transaction to the network.
Expand Down Expand Up @@ -301,29 +302,33 @@ def submit_transaction_tenderly(
address = self.ConfigObj.w3.toChecksumAddress(
self.ConfigObj.BINANCE14_WALLET_ADDRESS
)
return self.arb_contract.functions.flashloanAndArb(
route_struct, src_address, src_amount
).transact(
{
"gas": self.ConfigObj.DEFAULT_GAS,
"from": address,
"nonce": self._get_nonce(address),
"gasPrice": 0,
}
) if flashloan_struct is None else self.arb_contract.functions.flashloanAndArbV2(
return (
self.arb_contract.functions.flashloanAndArb(
route_struct, src_address, src_amount
).transact(
{
"gas": self.ConfigObj.DEFAULT_GAS,
"from": address,
"nonce": self._get_nonce(address),
"gasPrice": 0,
}
)
if flashloan_struct is None
else self.arb_contract.functions.flashloanAndArbV2(
flashloan_struct, route_struct
).transact(
{
"gas": self.ConfigObj.DEFAULT_GAS,
"from": address,
"nonce": self._get_nonce(address),
"gasPrice": 0,
}
{
"gas": self.ConfigObj.DEFAULT_GAS,
"from": address,
"nonce": self._get_nonce(address),
"gasPrice": 0,
}
)
)

def _get_transaction_details(
self,
tx_function: ContractFunction,
tx_function: Callable,
tx_params: TxParams,
from_address: str,
to_address: str,
Expand All @@ -333,7 +338,7 @@ def _get_transaction_details(
Parameters
----------
tx_function: ContractFunction
tx_function: Callable
The transaction function.
tx_params: TxParams
The transaction parameters.
Expand Down Expand Up @@ -398,7 +403,7 @@ def _get_nonce(self, address: str) -> int:
# build transaction
def _build_transaction(
self,
tx_function: ContractFunction,
tx_function: Callable,
tx_params: TxParams,
from_address: str,
to_address: str,
Expand All @@ -408,7 +413,7 @@ def _build_transaction(
Parameters
----------
tx_function: ContractFunction
tx_function: Callable
The transaction function.
tx_params: TxParams
The transaction parameters.
Expand All @@ -428,7 +433,7 @@ def _build_transaction(
# submit transaction
def _submit_transaction(
self,
tx_function: ContractFunction,
tx_function: Callable,
tx_params: TxParams,
from_address: str,
to_address: str,
Expand All @@ -439,7 +444,7 @@ def _submit_transaction(
Parameters
----------
tx_function: ContractFunction
tx_function: Callable
The transaction function.
tx_params: TxParams
The transaction parameters.
Expand Down

0 comments on commit 3871a9b

Please sign in to comment.