@@ -28,11 +28,12 @@ library Clones {
28
28
function clone (address implementation ) internal returns (address instance ) {
29
29
/// @solidity memory-safe-assembly
30
30
assembly {
31
- // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
32
- // of the `implementation` address with the bytecode before the address.
33
- mstore (0x00 , or (shr (0xe8 , shl (0x60 , implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000 ))
34
- // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
35
- mstore (0x20 , or (shl (0x78 , implementation), 0x5af43d82803e903d91602b57fd5bf3 ))
31
+ // Stores the bytecode after address
32
+ mstore (0x20 , 0x5af43d82803e903d91602b57fd5bf3 )
33
+ // implementation address
34
+ mstore (0x11 , implementation)
35
+ // Packs the first 3 bytes of the `implementation` address with the bytecode before the address.
36
+ mstore (0x00 , or (shr (0x88 , implementation), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000 ))
36
37
instance := create (0 , 0x09 , 0x37 )
37
38
}
38
39
if (instance == address (0 )) {
@@ -50,11 +51,12 @@ library Clones {
50
51
function cloneDeterministic (address implementation , bytes32 salt ) internal returns (address instance ) {
51
52
/// @solidity memory-safe-assembly
52
53
assembly {
53
- // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
54
- // of the `implementation` address with the bytecode before the address.
55
- mstore (0x00 , or (shr (0xe8 , shl (0x60 , implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000 ))
56
- // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
57
- mstore (0x20 , or (shl (0x78 , implementation), 0x5af43d82803e903d91602b57fd5bf3 ))
54
+ // Stores the bytecode after address
55
+ mstore (0x20 , 0x5af43d82803e903d91602b57fd5bf3 )
56
+ // implementation address
57
+ mstore (0x11 , implementation)
58
+ // Packs the first 3 bytes of the `implementation` address with the bytecode before the address.
59
+ mstore (0x00 , or (shr (0x88 , implementation), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000 ))
58
60
instance := create2 (0 , 0x09 , 0x37 , salt)
59
61
}
60
62
if (instance == address (0 )) {
0 commit comments