Add testnets, minor constructor improvements by liquid-8 · Pull Request #467 · uniswap-python/uniswap-python · GitHub
Skip to content

Add testnets, minor constructor improvements#467

Merged
liquid-8 merged 2 commits into
uniswap-python:dev/v4-finfrom
liquid-8:uniswap4_RC
Jun 8, 2026
Merged

Add testnets, minor constructor improvements#467
liquid-8 merged 2 commits into
uniswap-python:dev/v4-finfrom
liquid-8:uniswap4_RC

Conversation

@liquid-8

@liquid-8 liquid-8 commented Jun 7, 2026

Copy link
Copy Markdown
Member

No description provided.

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

@greptile-apps

greptile-apps Bot commented Jun 7, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds two testnet networks (sepolia, chain ID 11155111, and unichain_sepolia, chain ID 1301) to the V4 contract address maps, and refactors the Uniswap4 constructor to load each contract inside its own try/except NameNotFound block so that a missing address on a given network doesn't abort the entire object construction.

  • Testnet addresses are populated in all six V4 address dictionaries (router, quoter, stateview, permit2, poolmanager, position_manager), but _position_descriptor_contract_addresses_v4 stores empty strings "" for both new networks — _str_to_addr("") raises NameNotFound, which is silently swallowed, leaving self.position_descriptor unset.
  • Silent partial init: the new try/except pattern logs failures but does not set the attribute to None; every downstream method that uses the unset attribute (currencyRatioPriority, tokenURI, approve, etc.) will raise AttributeError with no helpful context.
  • Casing inconsistency: several new sepolia entries use mixed-case EIP-55 checksummed strings while all existing entries are lowercase.

Confidence Score: 3/5

Not ready to merge — the empty-string position descriptor addresses on testnet will silently leave the instance partially initialised, and the broader swallow-and-continue pattern exposes every method that touches those contracts to opaque AttributeErrors at runtime.

The constructor refactor is well-intentioned but leaves the object in an undefined state when a contract address is missing or empty; callers get no indication of this during construction and see confusing AttributeErrors later. This is directly triggered by the empty-string entries added in the same PR for position_descriptor on Sepolia and Unichain Sepolia.

Both files need attention: uniswap/constants.py for the empty position_descriptor addresses and mixed-case hex strings, and uniswap/uniswap4.py for the silent partial-initialisation pattern in the constructor.

Important Files Changed

Filename Overview
uniswap/uniswap4.py Constructor refactored to wrap each contract load in its own try/except block, silently swallowing NameNotFound; leaves the instance in a partially-initialized state if any contract address is invalid or empty, causing confusing AttributeErrors later.
uniswap/constants.py Adds Sepolia and Unichain Sepolia testnet contract addresses across all V4 address maps; position_descriptor entries are empty strings which immediately break initialization on those networks, and several new addresses use mixed-case hex inconsistent with the rest of the file.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant Uniswap4.__init__
    participant constants.py
    participant _str_to_addr
    participant _load_contract

    Caller->>Uniswap4.__init__: new Uniswap4(address, key, ...)
    Uniswap4.__init__->>constants.py: lookup address maps by net_name
    constants.py-->>Uniswap4.__init__: returns address strings (may be "")

    loop for each contract
        Uniswap4.__init__->>_str_to_addr: _str_to_addr(address_string)
        alt address valid
            _str_to_addr-->>Uniswap4.__init__: Address bytes
            Uniswap4.__init__->>_load_contract: load ABI + attach to Web3
            _load_contract-->>Uniswap4.__init__: Contract object
            Uniswap4.__init__->>Uniswap4.__init__: "self.X = contract"
        else address is empty or invalid
            _str_to_addr-->>Uniswap4.__init__: raises NameNotFound
            Uniswap4.__init__->>Uniswap4.__init__: logger.error — self.X never set
        end
    end

    Uniswap4.__init__-->>Caller: returns without error
    Caller->>Uniswap4.__init__: self.position_descriptor.functions.tokenURI(...)
    Uniswap4.__init__-->>Caller: AttributeError: no attribute 'position_descriptor'
Loading

Reviews (1): Last reviewed commit: "Add testnets, minor constructor improvem..." | Re-trigger Greptile

Comment thread uniswap/uniswap4.py
Comment thread uniswap/constants.py
Comment thread uniswap/constants.py
@liquid-8 liquid-8 merged commit 303de33 into uniswap-python:dev/v4-fin Jun 8, 2026
4 of 5 checks passed
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.

1 participant