@@ -39,12 +39,11 @@ library Clones {
39
39
}
40
40
/// @solidity memory-safe-assembly
41
41
assembly {
42
- // Stores the bytecode after address
43
- mstore (0x20 , 0x5af43d82803e903d91602b57fd5bf3 )
44
- // implementation address
45
- mstore (0x11 , implementation)
46
- // Packs the first 3 bytes of the `implementation` address with the bytecode before the address.
47
- mstore (0x00 , or (shr (0x88 , implementation), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000 ))
42
+ // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
43
+ // of the `implementation` address with the bytecode before the address.
44
+ mstore (0x00 , or (shr (0xe8 , shl (0x60 , implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000 ))
45
+ // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
46
+ mstore (0x20 , or (shl (0x78 , implementation), 0x5af43d82803e903d91602b57fd5bf3 ))
48
47
instance := create (value, 0x09 , 0x37 )
49
48
}
50
49
if (instance == address (0 )) {
@@ -80,12 +79,11 @@ library Clones {
80
79
}
81
80
/// @solidity memory-safe-assembly
82
81
assembly {
83
- // Stores the bytecode after address
84
- mstore (0x20 , 0x5af43d82803e903d91602b57fd5bf3 )
85
- // implementation address
86
- mstore (0x11 , implementation)
87
- // Packs the first 3 bytes of the `implementation` address with the bytecode before the address.
88
- mstore (0x00 , or (shr (0x88 , implementation), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000 ))
82
+ // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
83
+ // of the `implementation` address with the bytecode before the address.
84
+ mstore (0x00 , or (shr (0xe8 , shl (0x60 , implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000 ))
85
+ // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
86
+ mstore (0x20 , or (shl (0x78 , implementation), 0x5af43d82803e903d91602b57fd5bf3 ))
89
87
instance := create2 (value, 0x09 , 0x37 , salt)
90
88
}
91
89
if (instance == address (0 )) {
0 commit comments