94 lines
3.9 KiB
Python
94 lines
3.9 KiB
Python
import os
|
|
import json
|
|
from web3 import Web3
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
# Aerodrome Slipstream Config
|
|
RPC_URL = os.environ.get("BASE_RPC_URL")
|
|
NPM_ADDRESS = "0x827922686190790b37229fd06084350E74485b72"
|
|
WETH = "0x4200000000000000000000000000000000000006"
|
|
USDC = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
TARGET_POOL = "0xdbc6998296caa1652a810dc8d3baf4a8294330f1"
|
|
|
|
# ABIs
|
|
NPM_ABI = json.loads('[{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]')
|
|
FACTORY_ABI = json.loads('[{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"int24","name":"","type":"int24"}],"name":"getPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]')
|
|
|
|
def main():
|
|
print(f"Connecting to {RPC_URL}...")
|
|
w3 = Web3(Web3.HTTPProvider(RPC_URL))
|
|
if not w3.is_connected():
|
|
print("Failed to connect.")
|
|
return
|
|
|
|
print(f"NPM: {NPM_ADDRESS}")
|
|
npm = w3.eth.contract(address=NPM_ADDRESS, abi=NPM_ABI)
|
|
|
|
try:
|
|
factory_addr = npm.functions.factory().call()
|
|
print(f"Factory from NPM: {factory_addr}")
|
|
except Exception as e:
|
|
print(f"Error getting factory: {e}")
|
|
return
|
|
|
|
factory = w3.eth.contract(address=factory_addr, abi=FACTORY_ABI)
|
|
|
|
# Aerodrome Tick Spacings (Fees)
|
|
# Uniswap V3: 100 (0.01%), 500 (0.05%), 3000 (0.3%), 10000 (1%)
|
|
# Aerodrome Slipstream might use tickSpacing directly or different fee numbers.
|
|
# Slipstream: 1 (0.01%), 50 (0.05%), 200 (0.3%), 2000 (1%) ???
|
|
# Or maybe it uses standard Uniswap fees?
|
|
# Let's try standard first, then tickSpacing values.
|
|
|
|
# Common Uniswap V3 Fees
|
|
fees_to_test = [100, 500, 3000, 10000]
|
|
# Aerodrome specific? (1, 50, 100, 200) - Aerodrome uses tickSpacing as the identifier in getPool sometimes?
|
|
# Wait, Uniswap V3 Factory getPool takes (tokenA, tokenB, fee).
|
|
# Some forks take (tokenA, tokenB, tickSpacing).
|
|
|
|
fees_to_test += [1, 50, 200, 2000]
|
|
|
|
print(f"Testing getPool for WETH/USDC...")
|
|
|
|
found = False
|
|
for fee in fees_to_test:
|
|
try:
|
|
pool = factory.functions.getPool(WETH, USDC, fee).call()
|
|
print(f"Fee {fee}: {pool}")
|
|
if pool.lower() == TARGET_POOL.lower():
|
|
print(f"✅ MATCH FOUND! Fee Tier is: {fee}")
|
|
found = True
|
|
except Exception as e:
|
|
print(f"Fee {fee}: Error ({e})")
|
|
|
|
# ... (Existing code)
|
|
if not found:
|
|
# ... (Existing code)
|
|
pass
|
|
|
|
# DEBUG SLOT0
|
|
print(f"\nDebugging slot0 for {TARGET_POOL}...")
|
|
target_pool_checksum = Web3.to_checksum_address(TARGET_POOL)
|
|
|
|
# Try raw call to see data length
|
|
raw_data = w3.eth.call({
|
|
'to': target_pool_checksum,
|
|
'data': w3.keccak(text="slot0()").hex()[:10]
|
|
})
|
|
print(f"Raw Slot0 Data ({len(raw_data)} bytes): {raw_data.hex()}")
|
|
|
|
# Try standard ABI
|
|
POOL_ABI = json.loads('[{"inputs":[],"name":"slot0","outputs":[{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"internalType":"int24","name":"tick","type":"int24"},{"internalType":"uint16","name":"observationIndex","type":"uint16"},{"internalType":"uint16","name":"observationCardinality","type":"uint16"},{"internalType":"uint16","name":"observationCardinalityNext","type":"uint16"},{"internalType":"uint24","name":"feeProtocol","type":"uint24"},{"internalType":"bool","name":"unlocked","type":"bool"}],"stateMutability":"view","type":"function"}]')
|
|
|
|
pool_c = w3.eth.contract(address=target_pool_checksum, abi=POOL_ABI)
|
|
try:
|
|
data = pool_c.functions.slot0().call()
|
|
print(f"Standard V3 Slot0 Data: {data}")
|
|
except Exception as e:
|
|
print(f"Standard V3 Slot0 Failed: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|