- Notifications
You must be signed in to change notification settings - Fork388
fix: update web3py to v6, apply no-implicit-optional, misc fixes#320
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
b4f0ad3
build(deps): updated dependencies
ErikBjare38b7870
fix: applied no-implicit-optional
ErikBjare00a97bd
fix: changed to using new names in updated web3py versions
ErikBjarec358849
fix: explicitly set gasPrice for tx's
ErikBjare8625211
fix: misc fixes
ErikBjare5fc8110
build(deps): updated dependencies
ErikBjare356e940
fix: fixed bug caused previously in PR
ErikBjarecb73004
build(deps): updated dependencies
ErikBjare27ca688
ci: added `poetry config installer.modern-installation false` to work…
ErikBjare8a96c07
fix: removed unused code
ErikBjare702419e
ci: fix ci
ErikBjareece7f1e
build(deps): pinned pydata-sphinx-theme to work around bug
ErikBjare1956fec
build(deps): changed version marker for web3
ErikBjareFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions.github/workflows/docs.yml
This file contains hidden or 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
2 changes: 2 additions & 0 deletions.github/workflows/test.yml
This file contains hidden or 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
4 changes: 2 additions & 2 deletionsMakefile
This file contains hidden or 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
2,906 changes: 1,539 additions & 1,367 deletionspoetry.lock
Large diffs are not rendered by default.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
6 changes: 5 additions & 1 deletionpyproject.toml
This file contains hidden or 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
43 changes: 22 additions & 21 deletionstests/test_uniswap.py
This file contains hidden or 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 |
---|---|---|
@@ -9,20 +9,17 @@ | ||
from time import sleep | ||
from web3 import Web3 | ||
from uniswap import Uniswap | ||
from uniswap.constants import ETH_ADDRESS | ||
from uniswap.exceptions import InsufficientBalance | ||
from uniswap.tokens import get_tokens | ||
from uniswap.util import ( | ||
_str_to_addr, | ||
default_tick_range, | ||
_addr_to_str, | ||
) | ||
logger = logging.getLogger(__name__) | ||
logging.basicConfig(level=logging.INFO) | ||
@@ -35,6 +32,13 @@ | ||
RECEIPT_TIMEOUT = 5 | ||
ONE_ETH = 10**18 | ||
ONE_DAI = 10**18 | ||
ONE_USDC = 10**6 | ||
ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" | ||
@dataclass | ||
class GanacheInstance: | ||
provider: str | ||
@@ -53,7 +57,7 @@ def client(request, web3: Web3, ganache: GanacheInstance): | ||
) | ||
@pytest.fixture(scope="function") | ||
ErikBjare marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
def tokens(client: Uniswap): | ||
return get_tokens(client.netname) | ||
@@ -65,14 +69,18 @@ def test_assets(client: Uniswap): | ||
""" | ||
tokens = get_tokens(client.netname) | ||
for token_name, amount in [ | ||
("DAI", 10_000 * ONE_DAI), | ||
("USDC", 10_000 * ONE_USDC), | ||
]: | ||
token_addr = tokens[token_name] | ||
price = client.get_price_output(_str_to_addr(ETH_ADDRESS), token_addr, amount) | ||
logger.info(f"Cost of {amount} {token_name}: {price}") | ||
logger.info("Buying...") | ||
txid = client.make_trade_output(tokens["ETH"], token_addr, amount) | ||
tx = client.w3.eth.wait_for_transaction_receipt(txid, timeout=RECEIPT_TIMEOUT) | ||
assert tx["status"] == 1, f"Transaction failed: {tx}" | ||
@pytest.fixture(scope="module") | ||
@@ -96,7 +104,7 @@ def ganache() -> Generator[GanacheInstance, None, None]: | ||
) | ||
port = 10999 | ||
defaultGasPrice =100_000_000_000 #100 gwei | ||
p = subprocess.Popen( | ||
f"""ganache | ||
--port {port} | ||
@@ -125,16 +133,9 @@ def does_not_raise(): | ||
yield | ||
# TODO: Change pytest.param(..., mark=pytest.mark.xfail) to the expectation/raises method | ||
@pytest.mark.usefixtures("client", "web3") | ||
class TestUniswap(object): | ||
# ------ Exchange ------------------------------------------------------------------ | ||
def test_get_fee_maker(self, client: Uniswap): | ||
if client.version not in [1, 2]: | ||
@@ -343,7 +344,7 @@ def test_v3_deploy_pool_with_liquidity( | ||
amount1, | ||
tick_lower=min_tick, | ||
tick_upper=max_tick, | ||
deadline=2**64, | ||
) | ||
assert r["status"] | ||
@@ -357,7 +358,7 @@ def test_v3_deploy_pool_with_liquidity( | ||
@pytest.mark.parametrize( | ||
"deadline", | ||
[(2**64)], | ||
) | ||
def test_close_position(self, client: Uniswap, deadline): | ||
if client.version != 3: | ||
@@ -445,7 +446,7 @@ def test_make_trade( | ||
txid = client.make_trade(input_token, output_token, qty, recipient) | ||
tx = web3.eth.wait_for_transaction_receipt(txid, timeout=RECEIPT_TIMEOUT) | ||
assert tx["status"], f"Transaction failed with status {tx['status']}: {tx}" | ||
# TODO: Checks for ETH, taking gas into account | ||
bal_in_after = client.get_token_balance(input_token) | ||
@@ -460,7 +461,7 @@ def test_make_trade( | ||
# Token -> Token | ||
("DAI", "USDC", ONE_USDC, None, does_not_raise), | ||
# Token -> ETH | ||
("DAI", "ETH",ONE_ETH // 10, None, does_not_raise), | ||
# FIXME: These should probably be uncommented eventually | ||
# ("ETH", "UNI", int(0.000001 * ONE_ETH), ZERO_ADDRESS), | ||
# ("UNI", "ETH", int(0.000001 * ONE_ETH), ZERO_ADDRESS), | ||
6 changes: 3 additions & 3 deletionsuniswap/cli.py
This file contains hidden or 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
6 changes: 3 additions & 3 deletionsuniswap/tokens.py
This file contains hidden or 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.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.