1
1
pragma solidity 0.5.15 ;
2
2
3
+ import "./UniswapV2.sol " ;
3
4
import "./interfaces/IUniswapV2Factory.sol " ;
4
5
import "./interfaces/IUniswapV2.sol " ;
5
6
6
7
contract UniswapV2Factory is IUniswapV2Factory {
7
- bytes public exchangeBytecode;
8
8
address public feeToSetter;
9
9
address public feeTo;
10
10
@@ -13,9 +13,7 @@ contract UniswapV2Factory is IUniswapV2Factory {
13
13
14
14
event ExchangeCreated (address indexed token0 , address indexed token1 , address exchange , uint );
15
15
16
- constructor (bytes memory _exchangeBytecode , address _feeToSetter ) public {
17
- require (_exchangeBytecode.length >= 32 , "UniswapV2Factory: SHORT_BYTECODE " );
18
- exchangeBytecode = _exchangeBytecode;
16
+ constructor (address _feeToSetter ) public {
19
17
feeToSetter = _feeToSetter;
20
18
}
21
19
@@ -37,7 +35,7 @@ contract UniswapV2Factory is IUniswapV2Factory {
37
35
require (tokenA != address (0 ) && tokenB != address (0 ), "UniswapV2Factory: ZERO_ADDRESS " );
38
36
(address token0 , address token1 ) = sortTokens (tokenA, tokenB);
39
37
require (getExchange_[token0][token1] == address (0 ), "UniswapV2Factory: EXCHANGE_EXISTS " );
40
- bytes memory exchangeBytecodeMemory = exchangeBytecode; // load bytecode into memory because create2 requires it
38
+ bytes memory exchangeBytecodeMemory = type (UniswapV2).creationCode;
41
39
bytes32 salt = keccak256 (abi.encodePacked (token0, token1));
42
40
assembly { // solium-disable-line security/no-inline-assembly
43
41
exchange := create2 (0 , add (exchangeBytecodeMemory, 32 ), mload (exchangeBytecodeMemory), salt)
0 commit comments