我试着用这个功能来创造一个新的职位:
export const newMint = async (
token0: string,
token1: string,
fee: number,
tickLower: number,
tickUpper: number,
amount0Desired: string,
amount1Desired: string,
amount0Min: number,
amount1Min: number,
recipient: string,
deadline: number
) => {
try {
const signer = new ethers.providers.Web3Provider(window.ethereum).getSigner()
const nonfungible = new ethers.Contract(
nftAddress,
positionManagerABI,
signer
)
const data = ethers.utils.defaultAbiCoder.encode(
[
"address",
"address",
'uint24',
'int24',
'int24',
'uint256',
'uint256',
'uint256',
'uint256',
'address',
'uint256'
],
[
token0,
token1,
fee,
tickLower,
tickUpper,
amount0Desired,
amount1Desired,
amount0Min,
amount1Min,
recipient,
deadline
]
)
nonfungible.mint(data)
} catch (error) {
console.log(error, "this is the error for newMinting")
console.log(
token0,
token1,
fee,
tickLower,
tickUpper,
amount0Desired,
amount1Desired,
amount0Min,
amount1Min,
recipient,
deadline
)
}
}我通过这个电话正确地说:
const addLiquidity = () => {
newMint(
token0,
token1,
3000,
-887220,
887220,
String(Number(ethers.utils.parseEther(formattedAmounts[Field.INPUT])) * ether),
String(Number(ethers.utils.parseEther(formattedAmounts[Field.OUTPUT])) * ether),
0,
0,
userAddress,
tS + 3000
)
}通过这个函数获得时间戳:
export const timestamp = async () => {
try {
const block = await provider.getBlock('latest')
return block
} catch (error) {
console.log(error, 'error for timestamp')
}
}我认为所有的对角线都没问题,问题是对结构进行编码:
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}我的想法是,ethers.utils.defaultAbiCoder.encode并不适合作为最佳方法。有人能给我个提示吗?
错误:
Error: unexpected character at position 46 (argument="param", value="struct INonfungiblePositionManager.MintParams params", code=INVALID_ARGUMENT, version=abi/5.6.1)发布于 2022-10-09 00:55:09
人类可读的abi使用UniswapV3Periphery的abi提供程序。
https://ethereum.stackexchange.com/questions/136842
复制相似问题