-
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.
- Loading branch information
Showing
1 changed file
with
98 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,98 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "forge-std/Script.sol"; | ||
import { BaseScript } from "script/BaseScript.s.sol"; | ||
import { AccessManager } from "@openzeppelin/contracts/access/manager/AccessManager.sol"; | ||
import { ValidatorTicketPricer } from "../src/ValidatorTicketPricer.sol"; | ||
import { PufferOracleV2 } from "../src/PufferOracleV2.sol"; | ||
import { BaseScript } from "script/BaseScript.s.sol"; | ||
import { stdJson } from "forge-std/StdJson.sol"; | ||
import { Multicall } from "@openzeppelin/contracts/utils/Multicall.sol"; | ||
import { | ||
ROLE_ID_VT_PRICER, | ||
ROLE_ID_OPERATIONS_COORDINATOR, | ||
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/DeployVTPricer.s.sol:DeployVTPricer --rpc-url $RPC_URL --account puffer --broadcast | ||
* | ||
* forge cache clean | ||
* | ||
* forge script script/DeployVTPricer.s.sol:DeployVTPricer --rpc-url $RPC_URL --account puffer | ||
*/ | ||
contract DeployVTPricer is Script { | ||
ValidatorTicketPricer validatorTicketPricer; | ||
|
||
address ACCCESS_MANAGER = 0x8c1686069474410E6243425f4a10177a94EBEE11; | ||
address ORACLE = 0x0BE2aE0edbeBb517541DF217EF0074FC9a9e994f; | ||
|
||
function run() public { | ||
vm.startBroadcast(); | ||
|
||
validatorTicketPricer = | ||
new ValidatorTicketPricer({ oracle: PufferOracleV2(address(ORACLE)), accessManager: ACCCESS_MANAGER }); | ||
|
||
console.log("Deployed VT Pricer:", address(validatorTicketPricer)); | ||
|
||
_generateAccessManagerCallData(); | ||
} | ||
|
||
function _generateAccessManagerCallData() internal view { | ||
bytes[] memory calldatas = new bytes[](5); | ||
|
||
bytes4[] memory operationsSelectors = new bytes4[](2); | ||
operationsSelectors[0] = ValidatorTicketPricer.setDailyMevPayoutsChangeToleranceBps.selector; | ||
operationsSelectors[1] = ValidatorTicketPricer.setDailyConsensusRewardsChangeToleranceBps.selector; | ||
|
||
calldatas[0] = abi.encodeWithSelector( | ||
AccessManager.setTargetFunctionRole.selector, | ||
address(validatorTicketPricer), | ||
operationsSelectors, | ||
ROLE_ID_OPERATIONS_MULTISIG | ||
); | ||
|
||
bytes4[] memory daoSelectors = new bytes4[](1); | ||
daoSelectors[0] = ValidatorTicketPricer.setDiscountRate.selector; | ||
|
||
calldatas[1] = abi.encodeWithSelector( | ||
AccessManager.setTargetFunctionRole.selector, validatorTicketPricer, daoSelectors, ROLE_ID_DAO | ||
); | ||
|
||
bytes4[] memory vtPricerSelectors = new bytes4[](3); | ||
vtPricerSelectors[0] = ValidatorTicketPricer.setDailyMevPayouts.selector; | ||
vtPricerSelectors[1] = ValidatorTicketPricer.setDailyConsensusRewards.selector; | ||
vtPricerSelectors[2] = ValidatorTicketPricer.setDailyRewardsAndPostMintPrice.selector; | ||
|
||
calldatas[2] = abi.encodeWithSelector( | ||
AccessManager.setTargetFunctionRole.selector, | ||
address(validatorTicketPricer), | ||
vtPricerSelectors, | ||
ROLE_ID_VT_PRICER | ||
); | ||
|
||
bytes4[] memory publicSelectors = new bytes4[](1); | ||
publicSelectors[0] = ValidatorTicketPricer.postMintPrice.selector; | ||
|
||
calldatas[3] = abi.encodeWithSelector( | ||
AccessManager.setTargetFunctionRole.selector, address(validatorTicketPricer), publicSelectors, PUBLIC_ROLE | ||
); | ||
|
||
// ROLE_ID_OPERATIONS_COORDINATOR is the only role allowed to call Oracle.setMintPrice(), we need to give this role | ||
// to this newly deployed contract | ||
calldatas[4] = abi.encodeWithSelector( | ||
AccessManager.grantRole.selector, ROLE_ID_OPERATIONS_COORDINATOR, address(validatorTicketPricer), 0 | ||
); | ||
|
||
bytes memory multicallData = abi.encodeCall(Multicall.multicall, (calldatas)); | ||
|
||
console.log("AccessManager multicall calldata:"); | ||
console.logBytes(multicallData); | ||
} | ||
} |