-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Integrate safe-eth-py library, so we do not need to copy-paste all Safe integration Python code - Fetch Safe core metadata, for Lagoon vault info - Perform a swap using wildcard access module in the Lagoon test setup
- Loading branch information
Showing
16 changed files
with
2,588 additions
and
1,985 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Lagoon protocol API | ||
------------------- | ||
|
||
Lagoon protocol vaults integration. | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary_velvet | ||
:recursive: | ||
|
||
eth_defi.lagoon.vault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Gnosis Safe API | ||
--------------- | ||
|
||
Gnosis Safe multisignature wallet integration. | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary_safe | ||
:recursive: | ||
|
||
eth_defi.safe.trace | ||
eth_defi.safe.safe_compat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Velvet Capital API | ||
------------------ | ||
|
||
Velvet Capital vaults integration. | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary_velvet | ||
:recursive: | ||
|
||
eth_defi.velvet | ||
eth_defi.velvet.config | ||
eth_defi.velvet.deposit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Gnosis safe integration.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""safe-eth-py RPC compatibility layer.""" | ||
from web3 import Web3 | ||
|
||
from safe_eth.eth import EthereumClient | ||
|
||
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 | ||
return EthereumClient(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Safe multisig transaction tranasction error handling.""" | ||
|
||
from hexbytes import HexBytes | ||
from web3 import Web3 | ||
|
||
from safe_eth.eth.account_abstraction.constants import EXECUTION_FROM_MODULE_FAILURE_TOPIC, EXECUTION_FROM_MODULE_SUCCESS_TOPIC | ||
|
||
|
||
def assert_safe_success(web3: Web3, tx_hash: HexBytes): | ||
"""Assert that a Gnosis safe transaction succeeded. | ||
- Gnosis safe swallows any reverts | ||
- We need to extract Gnosis Safe logs from the tx receipt and check if they are successful | ||
:raise AssertionError: | ||
If the transaction failed | ||
""" | ||
|
||
receipt = web3.eth.get_transaction_receipt(tx_hash) | ||
|
||
success = 0 | ||
failure = 0 | ||
|
||
for logs in receipt["logs"]: | ||
if logs["topics"][0] == EXECUTION_FROM_MODULE_SUCCESS_TOPIC: | ||
success += 1 | ||
elif logs["topics"][0] == EXECUTION_FROM_MODULE_FAILURE_TOPIC: | ||
failure += 1 | ||
|
||
if success == 0 and failure == 0: | ||
raise AssertionError(f"Does not look like a Gnosis Safe transction") | ||
elif success + failure > 1: | ||
raise AssertionError(f"Too many success and failures in tx. Some weird nested case?") | ||
elif failure == 1: | ||
raise AssertionError(f"Gnosis Safe tx failed") | ||
elif success == 1: | ||
return | ||
else: | ||
raise RuntimeError("Should not happen") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.