I am studying Uniswap source code and there is something I do not understand in this file:
https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2Factory.sol:
This factory can create new pairs (createPair function):
bytes memory bytecode = type(UniswapV2Pair).creationCode;
bytes32 salt = keccak256(abi.encodePacked(token0, token1));
assembly {
pair := create2(0, add(bytecode, 32), mload(bytecode), salt)
}
for me, these 4 lines do the same thing than:
pair = new UniswapV2Pair()
I do not understand what they want to do with the 4 lines of codes. Do you have any idea ?
Thanks a lot