Skip to content

Commit

Permalink
feat: mvp of scratch deploy (mostly misses checks)
Browse files Browse the repository at this point in the history
  • Loading branch information
arwer13 committed Feb 28, 2024
1 parent b9ab538 commit 4995f0d
Show file tree
Hide file tree
Showing 33 changed files with 3,359 additions and 55 deletions.
100 changes: 56 additions & 44 deletions contracts/0.4.24/template/LidoTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ contract LidoTemplate is IsContract {

event TmplAPMDeployed(address apm);
event TmplReposCreated();
event TmplAppInstalled(address appProxy, bytes32 appId);
event TmplAppInstalled(address appProxy, bytes32 appId, bytes initializeData);
event TmplDAOAndTokenDeployed(address dao, address token);
event TmplTokensIssued(uint256 totalAmount);
event TmplDaoFinalized();
Expand Down Expand Up @@ -208,6 +208,51 @@ contract LidoTemplate is IsContract {
ens.setOwner(node, _to);
}

function createStdAragonRepos(
address _agentImpl,
address _financeImpl,
address _tokenManagerImpl,
address _votingImpl
) external onlyOwner {
uint16[3] memory initialSemanticVersion = [uint16(1), uint16(0), uint16(0)];

bytes memory dummyContentURI = new bytes(0);

APMRegistry lidoRegistry = deployState.lidoRegistry;

apmRepos.aragonAgent = lidoRegistry.newRepoWithVersion(
ARAGON_AGENT_APP_NAME,
this,
initialSemanticVersion,
_agentImpl,
dummyContentURI
);

apmRepos.aragonFinance = lidoRegistry.newRepoWithVersion(
ARAGON_FINANCE_APP_NAME,
this,
initialSemanticVersion,
_financeImpl,
dummyContentURI
);

apmRepos.aragonTokenManager = lidoRegistry.newRepoWithVersion(
ARAGON_TOKEN_MANAGER_APP_NAME,
this,
initialSemanticVersion,
_tokenManagerImpl,
dummyContentURI
);

apmRepos.aragonVoting = lidoRegistry.newRepoWithVersion(
ARAGON_VOTING_APP_NAME,
this,
initialSemanticVersion,
_votingImpl,
dummyContentURI
);
}

function createRepos(
uint16[3] _initialSemanticVersion,
address _lidoImplAddress,
Expand All @@ -216,6 +261,7 @@ contract LidoTemplate is IsContract {
bytes _nodeOperatorsRegistryContentURI,
address _oracleImplAddress,
bytes _oracleContentURI

) external onlyOwner {
require(deployState.lidoRegistry != address(0), ERROR_REGISTRY_NOT_DEPLOYED);

Expand Down Expand Up @@ -247,44 +293,6 @@ contract LidoTemplate is IsContract {
_oracleContentURI
);

// create Aragon app repos pointing to latest upstream versions

AppVersion memory latest = _apmResolveLatest(ARAGON_AGENT_APP_ID);
apmRepos.aragonAgent = lidoRegistry.newRepoWithVersion(
ARAGON_AGENT_APP_NAME,
this,
_initialSemanticVersion,
latest.contractAddress,
latest.contentURI
);

latest = _apmResolveLatest(ARAGON_FINANCE_APP_ID);
apmRepos.aragonFinance = lidoRegistry.newRepoWithVersion(
ARAGON_FINANCE_APP_NAME,
this,
_initialSemanticVersion,
latest.contractAddress,
latest.contentURI
);

latest = _apmResolveLatest(ARAGON_TOKEN_MANAGER_APP_ID);
apmRepos.aragonTokenManager = lidoRegistry.newRepoWithVersion(
ARAGON_TOKEN_MANAGER_APP_NAME,
this,
_initialSemanticVersion,
latest.contractAddress,
latest.contentURI
);

latest = _apmResolveLatest(ARAGON_VOTING_APP_ID);
apmRepos.aragonVoting = lidoRegistry.newRepoWithVersion(
ARAGON_VOTING_APP_NAME,
this,
_initialSemanticVersion,
latest.contractAddress,
latest.contentURI
);

emit TmplReposCreated();
}

Expand Down Expand Up @@ -393,6 +401,8 @@ contract LidoTemplate is IsContract {
require(state.dao != address(0), ERROR_DAO_NOT_DEPLOYED);
require(bytes(_daoName).length > 0, ERROR_INVALID_ID);

state.stakingRouter = _stakingRouter;

if (_unvestedTokensAmount != 0) {
// using issue + assign to avoid setting the additional MINT_ROLE for the template
state.tokenManager.issue(_unvestedTokensAmount);
Expand Down Expand Up @@ -495,7 +505,7 @@ contract LidoTemplate is IsContract {
) internal returns (address) {
address latestBaseAppAddress = _apmResolveLatest(_appId).contractAddress;
address instance = address(_dao.newAppInstance(_appId, latestBaseAppAddress, _initializeData, _setDefault));
emit TmplAppInstalled(instance, _appId);
emit TmplAppInstalled(instance, _appId, _initializeData);
return instance;
}

Expand Down Expand Up @@ -597,12 +607,12 @@ contract LidoTemplate is IsContract {

// NodeOperatorsRegistry
perms[0] = _state.operators.MANAGE_SIGNING_KEYS();
perms[1] = _state.operators.MANAGE_NODE_OPERATOR_ROLE();
perms[2] = _state.operators.SET_NODE_OPERATOR_LIMIT_ROLE();
for (i = 0; i < 3; ++i) {
perms[1] = _state.operators.SET_NODE_OPERATOR_LIMIT_ROLE();
for (i = 0; i < 2; ++i) {
_createPermissionForVoting(acl, _state.operators, perms[i], voting);
}
acl.createPermission(_state.stakingRouter, _state.operators, _state.operators.STAKING_ROUTER_ROLE(), voting);
acl.createPermission(_state.agent, _state.operators, _state.operators.MANAGE_NODE_OPERATOR_ROLE(), voting);

// Lido
perms[0] = _state.lido.PAUSE_ROLE();
Expand Down Expand Up @@ -736,7 +746,9 @@ contract LidoTemplate is IsContract {
}

function _resolveRepo(bytes32 _appId) private view returns (Repo) {
return Repo(PublicResolver(ens.resolver(_appId)).addr(_appId));
address resolverAddress = ens.resolver(_appId);
require(resolverAddress != address(0x0), "ZERO_RESOLVER_ADDRESS");
return Repo(PublicResolver(resolverAddress).addr(_appId));
}

/**
Expand Down
Loading

0 comments on commit 4995f0d

Please sign in to comment.