mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Added createAndInitializePool function
This commit is contained in:
parent
a2be2a1276
commit
70a341244d
|
@ -1,6 +1,14 @@
|
||||||
pragma solidity ^0.7.0;
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
contract Events {
|
contract Events {
|
||||||
|
event LogcreateAndInitializePool (
|
||||||
|
address tokenA,
|
||||||
|
address tokenB,
|
||||||
|
address pool,
|
||||||
|
uint24 fee,
|
||||||
|
int24 initialTick
|
||||||
|
);
|
||||||
|
|
||||||
event LogMint(
|
event LogMint(
|
||||||
uint256 indexed tokenId,
|
uint256 indexed tokenId,
|
||||||
uint256 liquidity,
|
uint256 liquidity,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
pragma solidity ^0.7.6;
|
pragma solidity ^0.7.6;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import {TokenInterface} from "../../../common/interfaces.sol";
|
import { TokenInterface} from "../../../common/interfaces.sol";
|
||||||
import {DSMath} from "../../../common/math.sol";
|
import { DSMath } from "../../../common/math.sol";
|
||||||
import {Basic} from "../../../common/basic.sol";
|
import { Basic } from "../../../common/basic.sol";
|
||||||
import "./interface.sol";
|
import "./interface.sol";
|
||||||
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
|
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
|
||||||
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
|
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
|
||||||
|
@ -65,6 +65,27 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _createAndInitializePoolIfNecessary (
|
||||||
|
address tokenA,
|
||||||
|
address tokenB,
|
||||||
|
uint24 fee,
|
||||||
|
int24 initialTick
|
||||||
|
) internal returns (address pool) {
|
||||||
|
(tokenA, tokenB) = sortTokenAddress(tokenA, tokenB);
|
||||||
|
|
||||||
|
(TokenInterface _token0, TokenInterface _token1) = changeMaticAddress(
|
||||||
|
tokenA,
|
||||||
|
tokenB
|
||||||
|
);
|
||||||
|
|
||||||
|
return nftManager.createAndInitializePoolIfNecessary(
|
||||||
|
address(_token0),
|
||||||
|
address(_tokenA),
|
||||||
|
fee,
|
||||||
|
TickMath.getSqrtRatioAtTick(initialTick)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Mint function which interact with Uniswap v3
|
* @dev Mint function which interact with Uniswap v3
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,6 +11,31 @@ import {Helpers} from "./helpers.sol";
|
||||||
import {Events} from "./events.sol";
|
import {Events} from "./events.sol";
|
||||||
|
|
||||||
abstract contract UniswapResolver is Helpers, Events {
|
abstract contract UniswapResolver is Helpers, Events {
|
||||||
|
|
||||||
|
function createAndInitializePool (
|
||||||
|
address tokenA,
|
||||||
|
address tokenB,
|
||||||
|
uint24 fee,
|
||||||
|
int24 initialTick
|
||||||
|
) {
|
||||||
|
|
||||||
|
address pool = _createAndInitializePoolIfNecessary(
|
||||||
|
tokenA,
|
||||||
|
tokenB,
|
||||||
|
fee,
|
||||||
|
initialTick
|
||||||
|
);
|
||||||
|
|
||||||
|
_eventName = "LogcreateAndInitializePool(address,address,address,uint24,int24)";
|
||||||
|
_eventParam = abi.encode(
|
||||||
|
tokenA,
|
||||||
|
tokenB,
|
||||||
|
pool,
|
||||||
|
fee,
|
||||||
|
initialTick
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Mint New Position
|
* @dev Mint New Position
|
||||||
* @notice Mint New NFT LP Position
|
* @notice Mint New NFT LP Position
|
||||||
|
|
Loading…
Reference in New Issue
Block a user