forked from Uniswap/v3-periphery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoolAddressTest.sol
31 lines (27 loc) · 1020 Bytes
/
PoolAddressTest.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
import '../libraries/PoolAddress.sol';
import { UniswapV3Pool } from '@birthdayresearchforks/uniswap-v3-core/contracts/UniswapV3Pool.sol';
contract PoolAddressTest {
function POOL_INIT_CODE_HASH() external pure returns (bytes32) {
return keccak256(type(UniswapV3Pool).creationCode);
}
function computeAddress(
address factory,
address token0,
address token1,
uint24 fee
) external pure returns (address) {
return PoolAddress.computeAddress(factory, PoolAddress.PoolKey({token0: token0, token1: token1, fee: fee}));
}
function getGasCostOfComputeAddress(
address factory,
address token0,
address token1,
uint24 fee
) external view returns (uint256) {
uint256 gasBefore = gasleft();
PoolAddress.computeAddress(factory, PoolAddress.PoolKey({token0: token0, token1: token1, fee: fee}));
return gasBefore - gasleft();
}
}