67 lines
2.8 KiB
Python
67 lines
2.8 KiB
Python
import os
|
|
import sys
|
|
import json
|
|
import time
|
|
from web3 import Web3
|
|
from dotenv import load_dotenv
|
|
|
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
from clp_abis import ERC20_ABI
|
|
|
|
load_dotenv()
|
|
RPC_URL = os.environ.get("BASE_RPC_URL")
|
|
w3 = Web3(Web3.HTTPProvider(RPC_URL))
|
|
private_key = os.environ.get("MAIN_WALLET_PRIVATE_KEY")
|
|
account = w3.eth.account.from_key(private_key)
|
|
|
|
NPM_ADDRESS = "0x827922686190790b37229fd06084350E74485b72"
|
|
WETH = "0x4200000000000000000000000000000000000006"
|
|
USDC = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
|
|
# Modified ABI: int24 tickSpacing instead of uint24 fee, AND sqrtPriceX96
|
|
MINT_ABI = json.loads('''
|
|
[
|
|
{"inputs": [{"components": [{"internalType": "address", "name": "token0", "type": "address"}, {"internalType": "address", "name": "token1", "type": "address"}, {"internalType": "int24", "name": "tickSpacing", "type": "int24"}, {"internalType": "int24", "name": "tickLower", "type": "int24"}, {"internalType": "int24", "name": "tickUpper", "type": "int24"}, {"internalType": "uint256", "name": "amount0Desired", "type": "uint256"}, {"internalType": "uint256", "name": "amount1Desired", "type": "uint256"}, {"internalType": "uint256", "name": "amount0Min", "type": "uint256"}, {"internalType": "uint256", "name": "amount1Min", "type": "uint256"}, {"internalType": "address", "name": "recipient", "type": "address"}, {"internalType": "uint256", "name": "deadline", "type": "uint256"}, {"internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160"}], "internalType": "struct INonfungiblePositionManager.MintParams", "name": "params", "type": "tuple"}], "name": "mint", "outputs": [{"internalType": "uint256", "name": "tokenId", "type": "uint256"}, {"internalType": "uint128", "name": "liquidity", "type": "uint128"}, {"internalType": "uint256", "name": "amount0", "type": "uint256"}, {"internalType": "uint256", "name": "amount1", "type": "uint256"}], "stateMutability": "payable", "type": "function"}
|
|
]
|
|
''')
|
|
|
|
def try_mint():
|
|
npm = w3.eth.contract(address=NPM_ADDRESS, abi=MINT_ABI)
|
|
|
|
# Tick Logic for 0xb2cc (TS=100)
|
|
# Current Tick -195800
|
|
current_tick = -195800
|
|
|
|
# Align to 100
|
|
# -196000 and -195600
|
|
tl = -196000
|
|
tu = -195600
|
|
|
|
# Amounts
|
|
a0 = 10000000000000000 # 0.01 ETH
|
|
a1 = 10000000 # 10 USDC
|
|
|
|
# tickSpacing param
|
|
ts = 100
|
|
|
|
params = (
|
|
WETH, USDC,
|
|
ts, # int24
|
|
tl, tu,
|
|
a0, a1,
|
|
0, 0,
|
|
account.address,
|
|
int(time.time()) + 180,
|
|
0 # sqrtPriceX96
|
|
)
|
|
|
|
print(f"Simulating mint with TS={ts} (int24)...")
|
|
try:
|
|
npm.functions.mint(params).call({'from': account.address, 'gas': 1000000})
|
|
print("✅ SUCCESS!")
|
|
except Exception as e:
|
|
print(f"❌ FAILED: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
try_mint()
|