This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LlamaAccountMulticallFactory.sol
66 lines (58 loc) · 2.86 KB
/
LlamaAccountMulticallFactory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import {LlamaAccountMulticallExtension} from "src/account-multicall/LlamaAccountMulticallExtension.sol";
import {LlamaAccountMulticallGuard} from "src/account-multicall/LlamaAccountMulticallGuard.sol";
import {LlamaAccountMulticallStorage} from "src/account-multicall/LlamaAccountMulticallStorage.sol";
/// @title LlamaAccountMulticallFactory
/// @author Llama (devsdosomething@llama.xyz)
/// @notice This contract enables Llama instances to deploy an account multicall module.
contract LlamaAccountMulticallFactory {
/// @dev Configuration of new Llama account multicall module.
struct LlamaAccountMulticallConfig {
address llamaExecutor; // The address of the Llama executor.
uint256 nonce; // The nonce of the new account multicall module.
LlamaAccountMulticallStorage.TargetSelectorAuthorization[] data; // The target-selectors to authorize.
}
/// @dev Emitted when a new Llama account multicall module is created.
event LlamaAccountMulticallModuleCreated(
address indexed deployer,
address indexed llamaExecutor,
uint256 nonce,
address accountMulticallGuard,
address accountMulticallExtension,
address accountMulticallStorage,
uint256 chainId
);
/// @notice Deploys a new Llama account multicall module.
/// @param accountMulticallConfig The configuration of the new Llama account multicall module.
/// @return accountMulticallGuard The deployed account multicall guard.
/// @return accountMulticallExtension The deployed account multicall extension.
/// @return accountMulticallStorage The deployed account multicall storage.
function deploy(LlamaAccountMulticallConfig memory accountMulticallConfig)
external
returns (
LlamaAccountMulticallGuard accountMulticallGuard,
LlamaAccountMulticallExtension accountMulticallExtension,
LlamaAccountMulticallStorage accountMulticallStorage
)
{
bytes32 salt =
keccak256(abi.encodePacked(msg.sender, accountMulticallConfig.llamaExecutor, accountMulticallConfig.nonce));
// Deploy and initialize account multicall storage.
accountMulticallStorage = new LlamaAccountMulticallStorage{salt: salt}(accountMulticallConfig.llamaExecutor);
accountMulticallStorage.initializeAuthorizedTargetSelectors(accountMulticallConfig.data);
// Deploy account multicall extension.
accountMulticallExtension = new LlamaAccountMulticallExtension{salt: salt}(accountMulticallStorage);
// Deploy account multicall guard.
accountMulticallGuard = new LlamaAccountMulticallGuard{salt: salt}(accountMulticallExtension);
emit LlamaAccountMulticallModuleCreated(
msg.sender,
accountMulticallConfig.llamaExecutor,
accountMulticallConfig.nonce,
address(accountMulticallGuard),
address(accountMulticallExtension),
address(accountMulticallStorage),
block.chainid
);
}
}