-
-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add support for unverified uniswap v3 pools [APE-1616] #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
from ape.types import AddressType, ContractType | ||
|
||
from ape_etherscan.client import ClientFactory, get_etherscan_uri | ||
from ape_etherscan.utils import UNISWAP_V3_POOL_ABI, UNISWAP_V3_POSITIONS_NFT | ||
from ape_etherscan.verify import SourceVerifier | ||
|
||
|
||
|
@@ -34,16 +35,39 @@ def get_contract_type(self, address: AddressType) -> Optional[ContractType]: | |
# Handle non-checksummed addresses | ||
address = self.conversion_manager.convert(str(address), AddressType) | ||
|
||
client = self._client_factory.get_contract_client(address) | ||
source_code = client.get_source_code() | ||
contract_client = self._client_factory.get_contract_client(address) | ||
source_code = contract_client.get_source_code() | ||
if not (abi_string := source_code.abi): | ||
return None | ||
|
||
try: | ||
abi = json.loads(abi_string) | ||
except JSONDecodeError as err: | ||
logger.error(f"Error with contract ABI: {err}") | ||
return None | ||
contract_creation = contract_client.get_creation_data() | ||
if not contract_creation: | ||
return None | ||
|
||
if not hasattr(contract_creation[0], "txHash"): | ||
return None | ||
|
||
tx_hash = contract_creation[0].txHash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idea: could use walrus like you do during |
||
if not tx_hash: | ||
return None | ||
|
||
proxy_client = self._client_factory.get_proxy_client(tx_hash) | ||
transaction_by_hash = proxy_client.get_transaction_by_hash() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of making a new client, you could do |
||
if not (to_address := transaction_by_hash.toAddress): | ||
return None | ||
|
||
if not self.conversion_manager.is_type(to_address, AddressType): | ||
to_address = self.conversion_manager.convert(str(to_address), AddressType) | ||
|
||
if to_address == UNISWAP_V3_POSITIONS_NFT: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would like @fubuloubu 's thought here, else I will return after I have reread the description of the PR and done research... gut feeling at first review: it this something that ape's proxy system should be handling? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose would like it that more protocol-specific handling end up in the protocol SDK libraries, so we don't end up cluttering the plugins/core a lot But this is popular, so could be convinced |
||
abi = UNISWAP_V3_POOL_ABI | ||
|
||
else: | ||
logger.error(f"Error with contract ABI: {err}") | ||
return None | ||
|
||
contract_type = ContractType(abi=abi, contractName=source_code.name) | ||
if source_code.name == "Vyper_contract" and "symbol" in contract_type.view_methods: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: much of this proxy checking here could be abstracted into a helper method on this instance to avoid so much stuff happening in the except block