Skip to content

Commit

Permalink
chore: add double root push forge script function
Browse files Browse the repository at this point in the history
  • Loading branch information
jparklev committed May 7, 2024
1 parent 175a52c commit b66705d
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions contracts/script/PointTokenVault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ contract PointTokenVaultScripts is BatchScript {
function run(string memory version) public returns (PointTokenVault) {
PointTokenVault pointTokenVaultImplementation = new PointTokenVault{salt: keccak256(abi.encode(version))}();

PointTokenVault pointTokenVault = PointTokenVault(payable(
address(
new ERC1967Proxy{salt: keccak256(abi.encode(version))}(
address(pointTokenVaultImplementation),
abi.encodeCall(PointTokenVault.initialize, (msg.sender)) // msg.sender is admin
PointTokenVault pointTokenVault = PointTokenVault(
payable(
address(
new ERC1967Proxy{salt: keccak256(abi.encode(version))}(
address(pointTokenVaultImplementation),
abi.encodeCall(PointTokenVault.initialize, (msg.sender)) // msg.sender is admin
)
)
))
)
);

return pointTokenVault;
Expand Down Expand Up @@ -118,15 +120,30 @@ contract PointTokenVaultScripts is BatchScript {
vm.stopBroadcast();
}

// Useful for emergencies, where we need to override both the current and previous root at once
// For example, if minting for a specific pToken needs to be stopped, a root without any claim rights for the pToken would need to be pushed twice
function doublePushRoot(address pointTokenVaultAddress, bytes32 newRoot, address merkleUpdaterSafe) public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

bytes memory txn = abi.encodeWithSelector(PointTokenVault.updateRoot.selector, newRoot);
addToBatch(pointTokenVaultAddress, 0, txn);
addToBatch(pointTokenVaultAddress, 0, txn);

executeBatch(merkleUpdaterSafe, true);

vm.stopBroadcast();
}

function setCap() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

address pointTokenVault = 0xbff7Fb79efC49504afc97e74F83EE618768e63E9;
address pointTokenVaultAddress = 0xbff7Fb79efC49504afc97e74F83EE618768e63E9;

bytes memory txn =
abi.encodeWithSelector(PointTokenVault.setCap.selector, 0x791a051631c9c4cDf4E03Fb7Aec3163AE164A34B, 10e18);
addToBatch(pointTokenVault, 0, txn);
addToBatch(pointTokenVaultAddress, 0, txn);

executeBatch(SEOPLIA_ADMIN_SAFE, true);
vm.stopBroadcast();
Expand Down

0 comments on commit b66705d

Please sign in to comment.