import os import sys import json from web3 import Web3 from dotenv import load_dotenv # Add project root to sys.path sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from clp_abis import AERODROME_FACTORY_ABI, UNISWAP_V3_POOL_ABI load_dotenv() RPC_URL = os.environ.get("BASE_RPC_URL") if not RPC_URL: print("Error: BASE_RPC_URL not set") sys.exit(1) w3 = Web3(Web3.HTTPProvider(RPC_URL)) FACTORY_ADDRESS = "0x827922686190790b37229fd06084350E74485b72" WETH = "0x4200000000000000000000000000000000000006" USDC = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" TICK_SPACING = 1 def check_pool(): print(f"Connecting to Base... {w3.client_version}") # 1. Get Factory Address from NPM npm_address = "0x827922686190790b37229fd06084350E74485b72" # NPM ABI minimal npm_abi = [{"inputs": [], "name": "factory", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}] npm = w3.eth.contract(address=npm_address, abi=npm_abi) try: factory_address = npm.functions.factory().call() print(f"Factory Address: {factory_address}") except Exception as e: print(f"Error fetching factory: {e}") return factory = w3.eth.contract(address=factory_address, abi=AERODROME_FACTORY_ABI) # 2. Get Pool Address using tickSpacing print(f"Querying Factory for WETH/USDC with tickSpacing={TICK_SPACING}...") try: pool_address = factory.functions.getPool(WETH, USDC, TICK_SPACING).call() print(f"Pool Address (TS=1): {pool_address}") except Exception as e: print(f"Error calling getPool(1): {e}") # Check TS=80 print(f"Querying Factory for WETH/USDC with tickSpacing=80...") try: pool_address_80 = factory.functions.getPool(WETH, USDC, 80).call() print(f"Pool Address (TS=80): {pool_address_80}") except Exception as e: print(f"Error calling getPool(80): {e}") if pool_address == "0x0000000000000000000000000000000000000000": print("Pool not found!") return # 3. Check Pool Details pool = w3.eth.contract(address=pool_address, abi=UNISWAP_V3_POOL_ABI) try: # Try to read fee() # Note: Standard UniV3 pools have 'fee()'. # Aerodrome Slipstream pools might not, or it might be different. fee = pool.functions.fee().call() print(f"Pool.fee(): {fee}") except Exception as e: print(f"Could not read pool.fee(): {e}") try: # Read tickSpacing() ts = pool.functions.tickSpacing().call() print(f"Pool.tickSpacing(): {ts}") except Exception as e: print(f"Could not read pool.tickSpacing(): {e}") try: # Read slot0 slot0 = pool.functions.slot0().call() print(f"Pool.slot0(): {slot0}") # Standard UniV3 slot0: (sqrtPriceX96, tick, observationIndex, observationCardinality, observationCardinalityNext, feeProtocol, unlocked) # Aerodrome might vary. except Exception as e: print(f"Could not read pool.slot0(): {e}") if __name__ == "__main__": check_pool()