Open bitcoinbrisbane opened 3 hours ago
Im trying to call the uniswap getPool function getPool(address,address,uint24), but im getting the error
getPool(address,address,uint24)
Request failed: argument count mismatch: got 1 for 3
My sample code.
func GetPoolAddress(tokenIn, tokenOut common.Address) common.Address { client := w3.MustDial("https://eth-mainnet.g.alchemy.com/v2/") defer client.Close() factorAddress := "0x1F98431c8aD98523631AE4a59f267346ea31F984" fmt.Println(factorAddress) _factoryAddress := common.HexToAddress(factorAddress) // funcBalanceOf := w3.MustNewFunc("balanceOf(address)", "uint256") fee := &big.Int{} fee.SetInt64(3000) // fee := uint24(3000) // Fee tier of 0.3% getPool := w3.MustNewFunc("getPool(address,address,uint24)", "address") input, err := getPool.EncodeArgs(tokenIn, tokenOut, fee) fmt.Println(input) if err != nil { log.Fatalf("Failed to encode arguments: %v", err) } var poolAddress string if err := client.Call( eth.CallFunc(_factoryAddress, getPool, input).Returns(&poolAddress), ); err != nil { fmt.Printf("Request failed: %v\n", err) } return common.HexToAddress(poolAddress) }
Oh, found this.. very helpful https://raw.githubusercontent.com/lmittmann/w3/refs/heads/main/examples/uniswap_quote/main.go
Im trying to call the uniswap getPool function
getPool(address,address,uint24)
, but im getting the errorRequest failed: argument count mismatch: got 1 for 3
My sample code.