Skip to content
Permalink
Browse files
remove exchangeBytecode in favor of .creationCode
  • Loading branch information
NoahZinsmeister committed Jan 7, 2020
1 parent d12ca78 commit f2d4021498ae02e42adc95cdf18cae93d9aab3c9
Showing 2 changed files with 3 additions and 6 deletions.
@@ -1,10 +1,10 @@
pragma solidity 0.5.15;

import "./UniswapV2.sol";
import "./interfaces/IUniswapV2Factory.sol";
import "./interfaces/IUniswapV2.sol";

contract UniswapV2Factory is IUniswapV2Factory {
bytes public exchangeBytecode;
address public feeToSetter;
address public feeTo;

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

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

constructor(bytes memory _exchangeBytecode, address _feeToSetter) public {
require(_exchangeBytecode.length >= 32, "UniswapV2Factory: SHORT_BYTECODE");
exchangeBytecode = _exchangeBytecode;
constructor(address _feeToSetter) public {
feeToSetter = _feeToSetter;
}

@@ -37,7 +35,7 @@ contract UniswapV2Factory is IUniswapV2Factory {
require(tokenA != address(0) && tokenB != address(0), "UniswapV2Factory: ZERO_ADDRESS");
(address token0, address token1) = sortTokens(tokenA, tokenB);
require(getExchange_[token0][token1] == address(0), "UniswapV2Factory: EXCHANGE_EXISTS");
bytes memory exchangeBytecodeMemory = exchangeBytecode; // load bytecode into memory because create2 requires it
bytes memory exchangeBytecodeMemory = type(UniswapV2).creationCode;
bytes32 salt = keccak256(abi.encodePacked(token0, token1));
assembly { // solium-disable-line security/no-inline-assembly
exchange := create2(0, add(exchangeBytecodeMemory, 32), mload(exchangeBytecodeMemory), salt)
@@ -3,7 +3,6 @@ pragma solidity 0.5.15;
interface IUniswapV2Factory {
event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint256);

function exchangeBytecode() external view returns (bytes memory);
function feeToSetter() external view returns (address);
function feeTo() external view returns (address);

0 comments on commit f2d4021

Please sign in to comment.