Skip to content

Commit f2d4021

Browse files
remove exchangeBytecode in favor of .creationCode
1 parent d12ca78 commit f2d4021

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

contracts/UniswapV2Factory.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
pragma solidity 0.5.15;
22

3+
import "./UniswapV2.sol";
34
import "./interfaces/IUniswapV2Factory.sol";
45
import "./interfaces/IUniswapV2.sol";
56

67
contract UniswapV2Factory is IUniswapV2Factory {
7-
bytes public exchangeBytecode;
88
address public feeToSetter;
99
address public feeTo;
1010

@@ -13,9 +13,7 @@ contract UniswapV2Factory is IUniswapV2Factory {
1313

1414
event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint);
1515

16-
constructor(bytes memory _exchangeBytecode, address _feeToSetter) public {
17-
require(_exchangeBytecode.length >= 32, "UniswapV2Factory: SHORT_BYTECODE");
18-
exchangeBytecode = _exchangeBytecode;
16+
constructor(address _feeToSetter) public {
1917
feeToSetter = _feeToSetter;
2018
}
2119

@@ -37,7 +35,7 @@ contract UniswapV2Factory is IUniswapV2Factory {
3735
require(tokenA != address(0) && tokenB != address(0), "UniswapV2Factory: ZERO_ADDRESS");
3836
(address token0, address token1) = sortTokens(tokenA, tokenB);
3937
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;
4139
bytes32 salt = keccak256(abi.encodePacked(token0, token1));
4240
assembly { // solium-disable-line security/no-inline-assembly
4341
exchange := create2(0, add(exchangeBytecodeMemory, 32), mload(exchangeBytecodeMemory), salt)

contracts/interfaces/IUniswapV2Factory.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pragma solidity 0.5.15;
33
interface IUniswapV2Factory {
44
event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint256);
55

6-
function exchangeBytecode() external view returns (bytes memory);
76
function feeToSetter() external view returns (address);
87
function feeTo() external view returns (address);
98

0 commit comments

Comments
 (0)