-
Notifications
You must be signed in to change notification settings - Fork 368
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
Uniswap v4 support #340
base: master
Are you sure you want to change the base?
Uniswap v4 support #340
Conversation
Poolid function fix; Splitting methods to contract's calls wraps and market functions.
Pool manager ABI added; Poolid function fix; Splitting methods to contract's calls wraps and market functions.
UniswapV4 alpha
and more
and more
and more!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #340 +/- ##
===========================================
- Coverage 71.22% 46.75% -24.48%
===========================================
Files 11 12 +1
Lines 1074 1309 +235
===========================================
- Hits 765 612 -153
- Misses 309 697 +388 ☔ View full report in Codecov by Sentry. |
fix p2.3
fix pt2.4
fix p2.5
price fetching refactored; custom gas pricing; misc
typing fixes
typing fix 2
typing fixes
some more fixes
@ErikBjare ^^ |
ABIs update
final fixes and clean-ups
typing fix
more stupidity fix
# need to replace with actual addresses after release | ||
_poolmanager_contract_addresses = { | ||
"mainnet": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | ||
"ropsten": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | ||
"rinkeby": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | ||
"görli": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | ||
"xdai": "0xA818b4F111Ccac7AA31D0BCc0806d64F2E0737D7", | ||
"binance": "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73", | ||
"binance_testnet": "0x6725F303b657a9451d8BA641348b6761A6CC7a17", | ||
} | ||
|
||
# need to replace with actual addresses after release | ||
_quoter_contract_addresses = { | ||
"mainnet": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | ||
"ropsten": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | ||
"rinkeby": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | ||
"görli": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | ||
"xdai": "0xA818b4F111Ccac7AA31D0BCc0806d64F2E0737D7", | ||
"binance": "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73", | ||
"binance_testnet": "0x6725F303b657a9451d8BA641348b6761A6CC7a17", | ||
} |
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.
# need to replace with actual addresses after release | |
_poolmanager_contract_addresses = { | |
"mainnet": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"ropsten": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"rinkeby": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"görli": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"xdai": "0xA818b4F111Ccac7AA31D0BCc0806d64F2E0737D7", | |
"binance": "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73", | |
"binance_testnet": "0x6725F303b657a9451d8BA641348b6761A6CC7a17", | |
} | |
# need to replace with actual addresses after release | |
_quoter_contract_addresses = { | |
"mainnet": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"ropsten": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"rinkeby": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"görli": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"xdai": "0xA818b4F111Ccac7AA31D0BCc0806d64F2E0737D7", | |
"binance": "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73", | |
"binance_testnet": "0x6725F303b657a9451d8BA641348b6761A6CC7a17", | |
} | |
# TODO: replace with actual addresses after official deployment | |
_poolmanager_contract_addresses = { | |
#"mainnet": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"ropsten": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"rinkeby": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"görli": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
#"xdai": "0xA818b4F111Ccac7AA31D0BCc0806d64F2E0737D7", | |
#"binance": "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73", | |
"binance_testnet": "0x6725F303b657a9451d8BA641348b6761A6CC7a17", | |
} | |
# TODO: replace with actual addresses after official deployment | |
_quoter_contract_addresses = { | |
#"mainnet": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"ropsten": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"rinkeby": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
"görli": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", | |
#"xdai": "0xA818b4F111Ccac7AA31D0BCc0806d64F2E0737D7", | |
#"binance": "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73", | |
"binance_testnet": "0x6725F303b657a9451d8BA641348b6761A6CC7a17", | |
} |
def get_token(self, address: AddressLike, abi_name: str = "erc20") -> ERC20Token: | ||
""" | ||
Retrieves metadata from the ERC20 contract of a given token, like its name, symbol, and decimals. | ||
""" | ||
# FIXME: This function should always return the same output for the same input | ||
# and would therefore benefit from caching | ||
if address == ETH_ADDRESS: | ||
return ERC20Token("ETH", address, "Ether", 18) | ||
token_contract = _load_contract(self.w3, abi_name, address=address) | ||
try: | ||
_name = token_contract.functions.name().call() | ||
_symbol = token_contract.functions.symbol().call() | ||
decimals = token_contract.functions.decimals().call() | ||
except Exception as e: | ||
logger.warning( | ||
f"Exception occurred while trying to get token {_addr_to_str(address)}: {e}" | ||
) | ||
raise InvalidToken(address) | ||
try: | ||
name = _name.decode() | ||
except: | ||
name = _name | ||
try: | ||
symbol = _symbol.decode() | ||
except: | ||
symbol = _symbol | ||
return ERC20Token(symbol, address, name, decimals) |
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.
Can we reuse this from the other class? Uniswap.get_token(self, address, abi_name)
?
Many such cases, not sure what to do about them all.
Just a PR with all the changes in the
dev/v4
branch.Closes #337