-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add script for xpufETH on apechain (#97)
* feat: add script for xpufETH on apechain * forge fmt * add values to deployer helper * forge fmt --------- Co-authored-by: Benjamin <benjaminxh+github@gmail.com> Co-authored-by: bxmmm1 <28648109+bxmmm1@users.noreply.github.com>
- Loading branch information
1 parent
036fd96
commit 44fc130
Showing
2 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "forge-std/Script.sol"; | ||
import { AccessManager } from "@openzeppelin/contracts/access/manager/AccessManager.sol"; | ||
import { stdJson } from "forge-std/StdJson.sol"; | ||
import { Multicall } from "@openzeppelin/contracts/utils/Multicall.sol"; | ||
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import { xPufETH } from "src/l2/xPufETH.sol"; | ||
import { Timelock } from "../src/Timelock.sol"; | ||
import { DeployerHelper } from "script/DeployerHelper.s.sol"; | ||
import { ROLE_ID_OPERATIONS_MULTISIG, ROLE_ID_DAO, PUBLIC_ROLE } from "./Roles.sol"; | ||
|
||
/** | ||
* // Check that the simulation | ||
* add --slow if deploying to a mainnet fork like tenderly (its buggy sometimes) | ||
* | ||
* forge script script/DeployApechainXpufETH.s.sol:DeployApechainXpufETH --rpc-url $RPC_URL --account puffer | ||
* | ||
* forge cache clean | ||
* | ||
* forge script script/DeployApechainXpufETH.s.sol:DeployApechainXpufETH --rpc-url $RPC_URL --account puffer --broadcast | ||
*/ | ||
contract DeployApechainXpufETH is DeployerHelper { | ||
uint256 MINTING_LIMIT = 100 ether; | ||
uint256 BURNING_LIMIT = 100 ether; | ||
|
||
Timelock timelock; | ||
AccessManager accessManager; | ||
|
||
xPufETH public xPufETHProxy; | ||
|
||
function run() public { | ||
vm.startBroadcast(); | ||
|
||
accessManager = new AccessManager(_getPufferDeployer()); | ||
|
||
timelock = new Timelock({ | ||
accessManager: address(accessManager), | ||
communityMultisig: _getCommunityMultisig(), | ||
operationsMultisig: _getOPSMultisig(), | ||
pauser: _getPauserMultisig(), | ||
initialDelay: 7 days | ||
}); | ||
|
||
xPufETH xpufETHImplementation = new xPufETH(); | ||
|
||
xPufETHProxy = xPufETH( | ||
address( | ||
new ERC1967Proxy{ salt: bytes32("xPufETH") }( | ||
address(xpufETHImplementation), abi.encodeCall(xPufETH.initialize, (address(accessManager))) | ||
) | ||
) | ||
); | ||
console.log("Timelock:", address(timelock)); | ||
console.log("AccessManager:", address(accessManager)); | ||
console.log("xpufETHProxy:", address(xPufETHProxy)); | ||
console.log("xpufETH implementation:", address(xpufETHImplementation)); | ||
|
||
// setup the limits for the bridge | ||
bytes memory setLimitsCalldata = | ||
abi.encodeWithSelector(xPufETH.setLimits.selector, _getEverclear(), MINTING_LIMIT, BURNING_LIMIT); | ||
|
||
accessManager.execute(address(xPufETHProxy), setLimitsCalldata); | ||
|
||
// setup all access manager roles | ||
bytes[] memory calldatas = _generateAccessManagerCallData(); | ||
accessManager.multicall(calldatas); | ||
} | ||
|
||
function _generateAccessManagerCallData() internal view returns (bytes[] memory) { | ||
bytes[] memory calldatas = new bytes[](6); | ||
|
||
calldatas[0] = abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_DAO, _getOPSMultisig(), 0); | ||
|
||
calldatas[1] = | ||
abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_OPERATIONS_MULTISIG, _getOPSMultisig(), 0); | ||
|
||
bytes4[] memory daoSelectors = new bytes4[](2); | ||
daoSelectors[0] = xPufETH.setLockbox.selector; | ||
daoSelectors[1] = xPufETH.setLimits.selector; | ||
|
||
calldatas[2] = abi.encodeWithSelector( | ||
AccessManager.setTargetFunctionRole.selector, address(xPufETHProxy), daoSelectors, ROLE_ID_DAO | ||
); | ||
|
||
bytes4[] memory publicSelectors = new bytes4[](2); | ||
publicSelectors[0] = xPufETH.mint.selector; | ||
publicSelectors[1] = xPufETH.burn.selector; | ||
|
||
calldatas[3] = abi.encodeWithSelector( | ||
AccessManager.setTargetFunctionRole.selector, address(xPufETHProxy), publicSelectors, PUBLIC_ROLE | ||
); | ||
|
||
calldatas[4] = | ||
abi.encodeWithSelector(AccessManager.grantRole.selector, accessManager.ADMIN_ROLE(), address(timelock), 0); | ||
|
||
calldatas[5] = | ||
abi.encodeWithSelector(AccessManager.revokeRole.selector, accessManager.ADMIN_ROLE(), _getPufferDeployer()); | ||
|
||
return calldatas; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters