From d6066bec9e31e0d9ae18a0c039001db678d5d033 Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Mon, 31 Oct 2022 06:08:30 +0530 Subject: [PATCH] added _createAndInitializePoolIfNecessary --- .../mainnet/connectors/uniswap/v3/helpers.sol | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/contracts/mainnet/connectors/uniswap/v3/helpers.sol b/contracts/mainnet/connectors/uniswap/v3/helpers.sol index 7fcb6765..bfab471a 100644 --- a/contracts/mainnet/connectors/uniswap/v3/helpers.sol +++ b/contracts/mainnet/connectors/uniswap/v3/helpers.sol @@ -66,6 +66,27 @@ abstract contract Helpers is DSMath, Basic { } } + function _createAndInitializePoolIfNecessary ( + address tokenA, + address tokenB, + uint24 fee, + int24 initialTick + ) internal returns (address pool) { + (TokenInterface token0Contract_, TokenInterface token1Contract_) = changeEthAddress( + tokenA, + tokenB + ); + + (address token0_, address token1_) = sortTokenAddress(address(token0Contract_), address(token1Contract_)); + + return nftManager.createAndInitializePoolIfNecessary( + token0_, + token1_, + fee, + TickMath.getSqrtRatioAtTick(initialTick) + ); + } + /** * @dev Mint function which interact with Uniswap v3 */