Skip to content
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

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open

Uniswap v4 support #340

wants to merge 57 commits into from

Conversation

ErikBjare
Copy link
Member

Just a PR with all the changes in the dev/v4 branch.

Closes #337

@ErikBjare ErikBjare mentioned this pull request Jul 4, 2023
liquid-8 and others added 5 commits August 21, 2023 17:29
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.
@ErikBjare ErikBjare marked this pull request as ready for review January 8, 2024 08:47
Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Attention: Patch coverage is 34.74576% with 154 lines in your changes missing coverage. Please review.

Project coverage is 46.75%. Comparing base (4f15d2e) to head (3dbb914).

Current head 3dbb914 differs from pull request most recent head f7297f9

Please upload reports for the commit f7297f9 to get more accurate results.

Files Patch % Lines
uniswap/uniswap4.py 24.61% 147 Missing ⚠️
uniswap/util.py 20.00% 4 Missing ⚠️
uniswap/types.py 90.32% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@liquid-8
Copy link
Member

liquid-8 commented Jun 6, 2024

@ErikBjare ^^

Comment on lines +80 to +100
# 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",
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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",
}

Comment on lines +751 to +777
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)
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uniswap v4 support
2 participants