Skip to content

Commit

Permalink
Handle MEVProvider with Gnosis Safe
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Jan 9, 2025
1 parent cfcd6f0 commit f7e10b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion eth_defi/hotwallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,14 @@ def transact_and_broadcast_with_contract(
"""Transacts with a contract, broadcasts transaction.
- Shorthand method
- Build a transaction and signs it
- Build a contract function call transaction and signs it
- Always use a correct manually managed nonce
Example:
.. code-block:: python
deployer = HotWallet.from_private_key(os.environ["PRIVATE_KEY"])
bound_func = module.functions.whitelistUniswapV3Router(uniswap_v3.swap_router.address, "Allow Uniswap v3")
tx_hash = deployer.transact_and_broadcast_with_contract(bound_func)
Expand Down
4 changes: 2 additions & 2 deletions eth_defi/lagoon/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def deploy_safe_trading_strategy_module(
def setup_guard(
web3: Web3,
safe: Safe,
deployer: LocalAccount,
deployer: HotWallet,
owner: HexAddress,
asset_manager: HexAddress,
vault: Contract,
Expand All @@ -366,7 +366,7 @@ def setup_guard(
uniswap_v3: UniswapV3Deployment = None,
):

assert isinstance(deployer, HotWallet)
assert isinstance(deployer, HotWallet), f"Got: {deployer}"
assert type(owner) == str
assert isinstance(module, Contract)
assert isinstance(vault, Contract)
Expand Down
12 changes: 10 additions & 2 deletions eth_defi/safe/safe_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@

from safe_eth.eth import EthereumClient

from eth_defi.provider.mev_blocker import MEVBlockerProvider


def create_safe_ethereum_client(web3: Web3) -> EthereumClient:
"""Safe library wants to use its own funny client.
- Translate Web3 endpoints to EthereumClient
"""
# TODO: Handle MEVProvider
provider = web3.provider
url = provider.endpoint_uri

if isinstance(provider, MEVBlockerProvider):
# EthereumClient() does not understand about Base sequencer,
# MEVBlocker, etc.
url = provider.call_endpoint_uri
else:
url = provider.endpoint_uri
return EthereumClient(url)

0 comments on commit f7e10b5

Please sign in to comment.