Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions uniswap/assets/uniswap-v4/quoter.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_poolManager",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "poolManager",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "bytes", "name": "path", "type": "bytes" },
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" }
],
"name": "quoteExactInput",
"outputs": [
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "tokenIn", "type": "address" },
{ "internalType": "address", "name": "tokenOut", "type": "address" },
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" },
{
"internalType": "uint160",
"name": "sqrtPriceLimitX96",
"type": "uint160"
}
],
"name": "quoteExactInputSingle",
"outputs": [
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "bytes", "name": "path", "type": "bytes" },
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" }
],
"name": "quoteExactOutput",
"outputs": [
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "tokenIn", "type": "address" },
{ "internalType": "address", "name": "tokenOut", "type": "address" },
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" },
{
"internalType": "uint160",
"name": "sqrtPriceLimitX96",
"type": "uint160"
}
],
"name": "quoteExactOutputSingle",
"outputs": [
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "function"
}
]
12 changes: 11 additions & 1 deletion uniswap/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"harmony_testnet": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
}

# need to replace with actual addresses
# need to replace with actual addresses after release
_poolmanager_contract_addresses = {
"mainnet": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
"ropsten": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
Expand All @@ -85,6 +85,16 @@
"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",
}
MAX_UINT_128 = (2**128) - 1

# Source: https://github.com/Uniswap/v3-core/blob/v1.0.0/contracts/libraries/TickMath.sol#L8-L11
Expand Down
16 changes: 16 additions & 0 deletions uniswap/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,19 @@ class UniswapV4_tick_info:

def __repr__(self) -> str:
return f"Tick info (liquidityGross: {self.liquidityGross}; liquidityNet: {self.liquidityNet}; feeGrowthOutside0X128: {self.feeGrowthOutside0X128}; feeGrowthOutside1X128: {self.feeGrowthOutside1X128!r})"

@dataclass
class UniswapV4_PathKey:
# The lower currency of the pool, sorted numerically
currency0 : Address
# The higher currency of the pool, sorted numerically
currency1 : Address
# The pool swap fee, capped at 1_000_000. If the first bit is 1, the pool has a dynamic fee and must be exactly equal to 0x800000
fee : int
# Ticks that involve positions must be a multiple of tick spacing
tickSpacing : int
# The hooks of the pool
hooks : list[Address]

def __repr__(self) -> (Address, Address, int, int, list[Address]):
return (self.currency0, self.currency1, self.fee, self.tickSpacing, self.hooks)
Loading