Verified contractPartialAGPL-3.0-or-later
DefaultPAUAssembler
Address0x1c810593cdda9fcda8e61a54da4e9e7de7878bc0
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.34
- Same code
4 more contracts
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- AGPL-3.0-or-later
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,426,025
- Creation transaction
- 0x4375e61851…093a9e00a2
- Main copy (most transactions)
- 0xc812aad3…bfecca2e
2 files
- src/DefaultPAUAssembler.solmain8.14 KB
- src/interfaces/IDefaultPAUAssembler.sol7.83 KB
src/DefaultPAUAssembler.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.34;
import { IDefaultPAUAssembler } from "./interfaces/IDefaultPAUAssembler.sol";
interface IALMProxyLike {
function CONTROLLER() external view returns (bytes32);
}
interface IAccessControlLike {
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
}
interface IAdministeredAgentFactoryLike {
function deploy(address admin) external returns (address);
}
interface IAdministeredAgentLike {
function addActor(address actor) external;
function addAdmin(address admin) external;
function addGrantor(address grantor) external;
function addRevoker(address revoker) external;
function removeAdmin(address admin) external;
}
interface IControllerLike {
function updateIntegrations(bytes32[] calldata ids) external;
}
interface IPAUFactoryLike {
function deployAccessControls(address admin) external returns (address accessControls);
function deployALMProxy(address admin) external returns (address almProxy);
function deployController(address accessControls, address proxy, address rateLimits)
external
returns (address controller);
function deployRateLimits(address admin) external returns (address rateLimits);
}
interface IRateLimitsLike {
function CONTROLLER() external view returns (bytes32);
}
contract DefaultPAUAssembler is IDefaultPAUAssembler {
/**********************************************************************************************/
/*** Constants ***/
/**********************************************************************************************/
bytes32 internal constant _ALLOCATOR_ROLE = keccak256("ALLOCATOR_ROLE");
bytes32 internal constant _DEFAULT_ADMIN_ROLE = 0x00;
/// @inheritdoc IDefaultPAUAssembler
string public constant override VERSION = "1.0.0";
/**********************************************************************************************/
/*** Declarations ***/
/**********************************************************************************************/
/// @inheritdoc IDefaultPAUAssembler
address public immutable administeredAgentFactory;
/// @inheritdoc IDefaultPAUAssembler
address public immutable pauFactory;
/**********************************************************************************************/
/*** Constructor ***/
/**********************************************************************************************/
constructor(address administeredAgentFactory_, address pauFactory_) {
require(administeredAgentFactory_ != address(0), ZeroAdministeredAgentFactory());
require(pauFactory_ != address(0), ZeroPAUFactory());
administeredAgentFactory = administeredAgentFactory_;
pauFactory = pauFactory_;
}
/**********************************************************************************************/
/*** External Interactive Functions ***/
/**********************************************************************************************/
/// @inheritdoc IDefaultPAUAssembler
function deploy(
bytes32[] memory integrationIds,
AdminConfig memory adminConfig,
AdministeredAgentConfig[] memory allocatorAgentConfigs
)
external
override
returns (
address proxy,
address controller,
address accessControls,
address rateLimits,
address[] memory allocatorAgents
)
{
// Step 1: Deploy all PAU contracts.
accessControls = IPAUFactoryLike(pauFactory).deployAccessControls(address(this));
proxy = IPAUFactoryLike(pauFactory).deployALMProxy(address(this));
rateLimits = IPAUFactoryLike(pauFactory).deployRateLimits(address(this));
controller =
IPAUFactoryLike(pauFactory).deployController(accessControls, proxy, rateLimits);
// Step 2: Deploy and configure all allocator agents.
allocatorAgents = new address[](allocatorAgentConfigs.length);
for (uint256 i = 0; i < allocatorAgentConfigs.length; i++) {
allocatorAgents[i] =
IAdministeredAgentFactoryLike(administeredAgentFactory).deploy(address(this));
_configureAgent(allocatorAgents[i], allocatorAgentConfigs[i]);
IAdministeredAgentLike(allocatorAgents[i]).removeAdmin(address(this));
}
// Step 3: Configure all roles in PAU system.
_grantRoles(accessControls, controller, proxy, rateLimits, adminConfig, allocatorAgents);
// Step 4: Set up all facets and wirings in controller.
if (integrationIds.length > 0) {
IControllerLike(controller).updateIntegrations(integrationIds);
}
// Step 5: Revoke all roles from assembler.
IAccessControlLike(accessControls).revokeRole(_DEFAULT_ADMIN_ROLE, address(this));
IAccessControlLike(proxy).revokeRole(_DEFAULT_ADMIN_ROLE, address(this));
IAccessControlLike(rateLimits).revokeRole(_DEFAULT_ADMIN_ROLE, address(this));
emit Deployment(
proxy,
controller,
accessControls,
rateLimits,
allocatorAgents,
integrationIds,
adminConfig,
allocatorAgentConfigs
);
}
/**********************************************************************************************/
/*** Internal Interactive Functions ***/
/**********************************************************************************************/
function _configureAgent(address agent, AdministeredAgentConfig memory config) internal {
require(config.admins.length > 0, NoAgentAdmins());
for (uint256 i = 0; i < config.admins.length; ++i) {
IAdministeredAgentLike(agent).addAdmin(config.admins[i]);
}
for (uint256 i = 0; i < config.actors.length; ++i) {
IAdministeredAgentLike(agent).addActor(config.actors[i]);
}
for (uint256 i = 0; i < config.grantors.length; ++i) {
IAdministeredAgentLike(agent).addGrantor(config.grantors[i]);
}
for (uint256 i = 0; i < config.revokers.length; ++i) {
IAdministeredAgentLike(agent).addRevoker(config.revokers[i]);
}
}
function _grantDefaultAdmins(address target, address[] memory admins) internal {
require(admins.length > 0, NoDefaultAdmins());
for (uint256 i = 0; i < admins.length; ++i) {
require(admins[i] != address(0), ZeroDefaultAdmin());
IAccessControlLike(target).grantRole(_DEFAULT_ADMIN_ROLE, admins[i]);
}
}
function _grantRoles(
address accessControls,
address controller,
address proxy,
address rateLimits,
AdminConfig memory adminConfig,
address[] memory allocatorAgents
)
internal
{
_grantDefaultAdmins(accessControls, adminConfig.accessControlAdmins);
for (uint256 i = 0; i < allocatorAgents.length; ++i) {
IAccessControlLike(accessControls).grantRole(_ALLOCATOR_ROLE, allocatorAgents[i]);
}
_grantDefaultAdmins(proxy, adminConfig.proxyAdmins);
IAccessControlLike(proxy).grantRole(IALMProxyLike(proxy).CONTROLLER(), controller);
_grantDefaultAdmins(rateLimits, adminConfig.rateLimitsAdmins);
IAccessControlLike(rateLimits).grantRole(IRateLimitsLike(rateLimits).CONTROLLER(), controller);
}
}
src/interfaces/IDefaultPAUAssembler.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.34;
/**
* @title IDefaultPAUAssembler
* @notice External interface for the {DefaultPAUAssembler}, a one-shot helper that deploys and
* configures a full PAU stack (ALMProxy, RateLimits, Controller) with allocators as
* AdministeredAgent contracts, in a single transaction. It wires up roles, syncs
* integrations on the Controller, configures each AdministeredAgent with the uniquely
* supplied admins/actors/grantors/revokers.
* @dev All deployed contracts are returned as plain addresses; callers cast them to the
* relevant component interfaces as needed.
*/
interface IDefaultPAUAssembler {
/**********************************************************************************************/
/*** Custom Errors ***/
/**********************************************************************************************/
/// @notice Thrown when an admin array for an AdministeredAgent is empty.
error NoAgentAdmins();
/// @notice Thrown when an admin array for a component's default admins is empty.
error NoDefaultAdmins();
/// @notice Thrown when the supplied PAU factory is the zero address.
error ZeroPAUFactory();
/// @notice Thrown when the supplied AdministeredAgent factory is the zero address.
error ZeroAdministeredAgentFactory();
/// @notice Thrown when a supplied default admin address is the zero address.
error ZeroDefaultAdmin();
/**********************************************************************************************/
/*** Structs ***/
/**********************************************************************************************/
/**
* @notice Admins to be granted admin rights on each component of the deployed stack.
* @param accessControlAdmins Admins for the AccessControls contract.
* @param proxyAdmins Admins for the ALMProxy contract.
* @param rateLimitsAdmins Admins for the RateLimits contract.
*/
struct AdminConfig {
address[] accessControlAdmins;
address[] proxyAdmins;
address[] rateLimitsAdmins;
}
/**
* @notice Configuration applied to an AdministeredAgent after deployment.
* @param admins Addresses to configure as admins on the agent.
* @param actors Addresses to configure as actors on the agent.
* @param grantors Addresses to configure as grantors on the agent.
* @param revokers Addresses to configure as revokers on the agent.
*/
struct AdministeredAgentConfig {
address[] admins;
address[] actors;
address[] grantors;
address[] revokers;
}
/**********************************************************************************************/
/*** Events ***/
/**********************************************************************************************/
/**
* @notice Emitted once a PAU stack and AdministeredAgents have been deployed and configured.
* @param proxy The deployed ALMProxy contract.
* @param controller The deployed Controller contract.
* @param accessControls The deployed AccessControls contract.
* @param rateLimits The deployed RateLimits contract.
* @param allocatorAgents The deployed allocators as AdministeredAgent contracts.
* @param integrationIds The integration IDs synced on the Controller.
* @param adminConfig The admin configuration applied across the stack.
* @param allocatorAgentConfigs The configurations applied to each AdministeredAgent allocator.
*/
event Deployment(
address indexed proxy,
address indexed controller,
address accessControls,
address rateLimits,
address[] allocatorAgents,
bytes32[] integrationIds,
AdminConfig adminConfig,
AdministeredAgentConfig[] allocatorAgentConfigs
);
/**********************************************************************************************/
/*** View/Pure Functions ***/
/**********************************************************************************************/
/**
* @notice Semantic version of this assembler implementation.
* @return The version string.
*/
function VERSION() external view returns (string memory);
/**
* @notice The underlying PAU factory used to deploy each individual component.
* @return The address of the PAU factory.
*/
function pauFactory() external view returns (address);
/**
* @notice The factory used to deploy the AdministeredAgent.
* @return The address of the AdministeredAgent factory.
*/
function administeredAgentFactory() external view returns (address);
/**********************************************************************************************/
/*** Interactive Functions ***/
/**********************************************************************************************/
/**
* @notice Deploys and configures a full PAU stack (ALMProxy, RateLimits, Controller) with
* allocators as AdministeredAgent contracts, in a single transaction. Wires up roles,
* syncs integrations on the Controller, configures each AdministeredAgent with the
* respective supplied admins/actors/grantors/revokers.
* @dev Emits {Deployment} on completion. After this call, this assembler holds no privileged
* roles on any of the returned contracts. The Controller is granted CONTROLLER on the
* ALMProxy (the role that gates `doCall` for a standard proxy).
*
* Notes:
* - When `integrationIds` is empty, the Controller `updateIntegrations` call is
* skipped entirely (the Controller reverts on an empty array), so a stack can be
* deployed with no integrations and configured later by an admin.
* @param integrationIds Integration IDs to sync on the Controller via
* `updateIntegrations` (may be empty).
* @param adminConfig Admins to grant across the deployed stack.
* @param allocatorAgentConfigs Admin/actor/grantor/revoker configuration for the allocator
* AdministeredAgent contracts.
* @return proxy The deployed ALMProxy contract.
* @return controller The deployed Controller contract.
* @return accessControls The deployed AccessControls contract.
* @return rateLimits The deployed RateLimits contract.
* @return allocatorAgents The deployed allocator AdministeredAgent contracts.
*/
function deploy(
bytes32[] memory integrationIds,
AdminConfig memory adminConfig,
AdministeredAgentConfig[] memory allocatorAgentConfigs
)
external
returns (
address proxy,
address controller,
address accessControls,
address rateLimits,
address[] memory allocatorAgents
);
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.