Conversation
Pool manager contract ABI
Deleted due to naming fix
Deleted due to naming fix
Deleted due to naming fix
Deleted due to naming fix
Deleted due to naming fix
Naming fix
Liquidity pools list management class added, UniswapV4 improvements.
ErikBjare
left a comment
There was a problem hiding this comment.
Generally approved. Haven't checked why CI is failing yet.
Could use some auto-formatting by ruff.
|
Ah, I see CI is failing due to outdated actions. I think we can merge this and address the outdated CI and any CI issues related to this PR in follow-up. |
refactor
refactor
refactor
|
@greptileai review |
Greptile OverviewGreptile SummaryThis PR adds Uniswap V4 support to the library, introducing new classes for V4 trading operations, pool discovery, and contract interactions across 12+ blockchain networks. Key additions:
Critical issues found:
Confidence Score: 0/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Uniswap4
participant Permit2
participant Router
participant Quoter
participant StateView
participant PoolManager
participant Token
User->>Uniswap4: initialize with address and provider
Uniswap4->>Uniswap4: Load contract addresses for chain
Uniswap4->>Router: Initialize router contract
Uniswap4->>Quoter: Initialize quoter contract
Uniswap4->>StateView: Initialize stateview contract
Uniswap4->>Permit2: Initialize permit2 contract
User->>Uniswap4: approve token
Uniswap4->>Token: approve permit2 contract
Token-->>Uniswap4: transaction hash
Uniswap4->>Permit2: approve router with amount and expiration
Permit2-->>Uniswap4: transaction hash
User->>Uniswap4: get spot price for token pair
Uniswap4->>StateView: getSlot0 for pool
StateView-->>Uniswap4: sqrtPriceX96
Uniswap4-->>User: calculated spot price
User->>Uniswap4: get quote for exact input
Uniswap4->>Quoter: quoteExactInputSingle with pool key
Quoter-->>Uniswap4: output amount
Uniswap4-->>User: quote amount
User->>Uniswap4: execute swap with exact input
Uniswap4->>Uniswap4: Encode V4 SWAP command
Uniswap4->>Uniswap4: Encode actions for swap settle and take
Uniswap4->>Router: execute with commands and deadline
Router->>PoolManager: unlock and execute swap
PoolManager-->>Router: swap result
Router-->>Uniswap4: transaction hash
Uniswap4-->>User: transaction hash
|
moved to util
moved to types
moved to constants
Structure refactoring; fixes; StateView contract support added
| max_slippage: float = 0.1, | ||
| max_gas: float = 250000.0, | ||
| max_gprice: float = 1.80, | ||
| london_fork: int = 1, |
| version: int = 4, | ||
| max_slippage: float = 0.1, | ||
| max_gas: float = 250000.0, | ||
| max_gprice: float = 1.80, |
There was a problem hiding this comment.
| max_gprice: float = 1.80, | |
| max_gas_price: float = 1.80, |
| self.gas_limit = max_gas | ||
| self.gas_price = max_gprice |
There was a problem hiding this comment.
Actually, maybe just make it all consistently "gas_limit" and "gas_price"
| self.gas_limit = max_gas | ||
| self.gas_price = max_gprice | ||
| self.london_style = london_fork | ||
| self.london_priorityfee = max_priorityfee |
There was a problem hiding this comment.
self.priority_fee, no need to mention london
There was a problem hiding this comment.
Strange that this diff became so messy
| AddressLike = Union[Address, ChecksumAddress] | ||
|
|
||
| @dataclass | ||
| class pool_key: |
There was a problem hiding this comment.
| class pool_key: | |
| class PoolKey: |
| currency0 : str | ||
| currency1 : str | ||
| fee : int | ||
| tick_spacing : int | ||
| hooks : str No newline at end of file |
There was a problem hiding this comment.
Not auto-formatted? I guess we don't have pre-commit hooks set up in this repo? (we should probably adopt ruff and ruff-format)
There was a problem hiding this comment.
Strange that this diff too became super messy, maybe you're changing the line endings from \n to \n\r? (Windows?)
pre-commit with ruff-format would fix this I think
ErikBjare
left a comment
There was a problem hiding this comment.
Nice, better structure!
I think it would be worthwhile to add a proper pre-commit/prek config with ruff and ruff-format though, would probably fix the weird diffs that suggest a lot more has changed than it has.
Basic functionality, like price fetching, quoting, and making simple swaps etc