Conversation
Greptile SummaryThis PR cleans up the Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Uniswap4
participant Permit2
participant ERC20
participant Router
Note over Uniswap4: __init__: version param removed,<br/>max_slippage default 0.1→0.01
Caller->>Uniswap4: approve(token)
alt token is NOT ETH (fixed: uses _addr_to_str comparison)
Uniswap4->>ERC20: approve(permit2_address, max_approval)
ERC20-->>Uniswap4: tx
Note over Uniswap4: sleep(7s)
end
Uniswap4->>Permit2: approve(token, router_address, max_approval, expiration)
Permit2-->>Uniswap4: tx
Uniswap4-->>Caller: tx hash
Caller->>Uniswap4: _token_to_token_swap_output(input=ETH, qty, qtycap)
Note over Uniswap4: amount_in_max = (1 + slippage) * qtycap<br/>BUG FIX: ether_amount = amount_in_max (was qty)
Uniswap4->>Router: execute(commands, [exact_out_params], deadline)<br/>value = amount_in_max
Router-->>Uniswap4: tx hash
Uniswap4-->>Caller: tx hash
Last reviewed commit: "review fixes" |
uniswap/uniswap4.py
Outdated
| @@ -76,7 +75,7 @@ def __init__( | |||
| :param provider: Can be optionally set to a Web3 provider URI. If none set, will fall back to the PROVIDER environment variable, or web3 if set. | |||
| :param web3: Can be optionally set to a custom Web3 instance. | |||
| :param version: Which version of the Uniswap contracts to use. | |||
There was a problem hiding this comment.
Stale
:param version: docstring entry
The version parameter was removed from __init__ in this PR, but its :param version: docstring entry on line 77 was left behind. This dangling doc entry will confuse users and tool-generated documentation.
| :param version: Which version of the Uniswap contracts to use. |
(Simply delete the line — no replacement needed.)
| except Exception: | ||
| raise InvalidToken(address) |
There was a problem hiding this comment.
Original exception context is silently dropped
The previous code logged a logger.warning(...) with the original exception before re-raising InvalidToken. That log was removed here, and the bare except Exception: clause means the root cause (e.g., network error, ABI mismatch, contract revert) is now completely invisible to the caller and to logs.
Prefer chaining exceptions so the original traceback is preserved:
| except Exception: | |
| raise InvalidToken(address) | |
| except Exception as e: | |
| raise InvalidToken(address) from e |
No description provided.