Skip to content

Commit

Permalink
691 allow script gen (#705)
Browse files Browse the repository at this point in the history
* made generate run on a fork of mainnet or sepolia.  should no longer require a private key to generate a proposal

* linted

* added an open proposal generation script

* linted

* removed loading of private key from generator scripts

* removed generated test file

* Format output json

---------

Co-authored-by: Patrick Gallagher <[email protected]>
  • Loading branch information
MrDeadCe11 and pi0neerpat authored May 22, 2024
1 parent e31c215 commit 22d75d0
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 160 deletions.
39 changes: 1 addition & 38 deletions gov-input/anvil/new-AddCollateral.json
Original file line number Diff line number Diff line change
@@ -1,38 +1 @@
{
"chainid": "31337",
"description": "add NEWADD as a collateral type",
"network": "anvil",
"newCollateralAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"newCollateralType": "NEWADD",
"proposalType": "AddCollateral",
"ProtocolToken_Address": "",
"ODGovernor_Address": "",
"SAFEEngine_Address": "",
"OracleRelayer_Address": "",
"LiquidationEngine_Address": "",
"TaxCollector_Address": "",
"GlobalSettlement_Address": "",
"SAFEEngineCollateralParams": {
"collateralDebtCeiling": "500000000000000000000000000000000000000000000000",
"collateralDebtFloor": "100000000000000000000000000000000000000000000000"
},
"TaxCollectorCollateralParams": {
"stabilityFee": "1000000000000000000000000000"
},
"LiquidationEngineCollateralParams": {
"newCAHChild": "0xd468bF477c0c99095D508c3B0A60f39348d91ac0",
"liquidationPenalty": "1000000000000000000",
"liquidationQuantity": "1000000000000000000000000000000000000000000000"
},
"OracleRelayerCollateralParams": {
"delayedOracle": "0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9",
"safetyCRatio": "1000000000000000000000000000",
"liquidationCRatio": "1000000000000000000000000000"
},
"CollateralAuctionHouseParams": {
"maximumDiscount": "1",
"minimumBid": "2",
"minimumDiscount": "3",
"perSecondDiscountUpdateRate": "999998607628240538157433861"
}
}
{"chainid":"31337","description":"add NEWADDed as a collateral type","network":"anvil","newCollateralAddress":"0xa513E6E4b8f2a923D98304ec87F64353C4D5C853","newCollateralType":"NEWADD","proposalType":"AddCollateral","ProtocolToken_Address":"0xc6e7DF5E7b4f2A278906862b61205850344D4e7d","ODGovernor_Address":"0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f","SAFEEngine_Address":"0x67d269191c92Caf3cD7723F116c85e6E9bf55933","OracleRelayer_Address":"0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E","LiquidationEngine_Address":"0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9","TaxCollector_Address":"0x95401dc811bb5740090279Ba06cfA8fcF6113778","GlobalSettlement_Address":"0x5f3f1dBD7B74C6B46e8c44f98792A1dAf8d69154","SAFEEngineCollateralParams":{"collateralDebtCeiling":"500000000000000000000000000000000000000000000000","collateralDebtFloor":"100000000000000000000000000000000000000000000000"},"TaxCollectorCollateralParams":{"stabilityFee":"1000000000000000000000000000"},"LiquidationEngineCollateralParams":{"liquidationPenalty":"1000000000000000000","liquidationQuantity":"1000000000000000000000000000000000000000000000","newCAHChild":"0xf9b42E09Fd787d6864D6b2Cd8E1350fc93E6683D"},"OracleRelayerCollateralParams":{"delayedOracle":"0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9","safetyCRatio":"1000000000000000000000000000","liquidationCRatio":"1000000000000000000000000000"},"CollateralAuctionHouseParams":{"maximumDiscount":"1","minimumBid":"2","minimumDiscount":"3","perSecondDiscountUpdateRate":"999998607628240538157433861"}}
74 changes: 37 additions & 37 deletions gov-input/mainnet/new-AddCollateral.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"chainid": "42161",
"description": "add NEWADD as a collateral type",
"network": "mainnet",
"newCollateralAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"newCollateralType": "NEWADD",
"proposalType": "AddCollateral",
"ProtocolToken_Address": "",
"ODGovernor_Address": "",
"SAFEEngine_Address": "",
"OracleRelayer_Address": "",
"LiquidationEngine_Address": "",
"TaxCollector_Address": "",
"GlobalSettlement_Address": "",
"SAFEEngineCollateralParams": {
"collateralDebtCeiling": "500000000000000000000000000000000000000000000000",
"collateralDebtFloor": "100000000000000000000000000000000000000000000000"
},
"TaxCollectorCollateralParams": {
"stabilityFee": "1000000000000000000000000000"
},
"LiquidationEngineCollateralParams": {
"newCAHChild": "0x293b702362918e990Dd5f48a80fB139FeAd64263",
"liquidationPenalty": "1000000000000000000",
"liquidationQuantity": "1000000000000000000000000000000000000000000000"
},
"OracleRelayerCollateralParams": {
"delayedOracle": "0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9",
"safetyCRatio": "1000000000000000000000000000",
"liquidationCRatio": "1000000000000000000000000000"
},
"CollateralAuctionHouseParams": {
"maximumDiscount": "1",
"minimumBid": "2",
"minimumDiscount": "3",
"perSecondDiscountUpdateRate": "999998607628240538157433861"
}
}
"chainid": "42161",
"description": "add NEWADD as a collateral type",
"network": "mainnet",
"newCollateralAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"newCollateralType": "NEWADD",
"proposalType": "AddCollateral",
"ProtocolToken_Address": "",
"ODGovernor_Address": "",
"SAFEEngine_Address": "",
"OracleRelayer_Address": "",
"LiquidationEngine_Address": "",
"TaxCollector_Address": "",
"GlobalSettlement_Address": "",
"SAFEEngineCollateralParams": {
"collateralDebtCeiling": "500000000000000000000000000000000000000000000000",
"collateralDebtFloor": "100000000000000000000000000000000000000000000000"
},
"TaxCollectorCollateralParams": {
"stabilityFee": "1000000000000000000000000000"
},
"LiquidationEngineCollateralParams": {
"newCAHChild": "0x293b702362918e990Dd5f48a80fB139FeAd64263",
"liquidationPenalty": "1000000000000000000",
"liquidationQuantity": "1000000000000000000000000000000000000000000000"
},
"OracleRelayerCollateralParams": {
"delayedOracle": "0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9",
"safetyCRatio": "1000000000000000000000000000",
"liquidationCRatio": "1000000000000000000000000000"
},
"CollateralAuctionHouseParams": {
"maximumDiscount": "1",
"minimumBid": "2",
"minimumDiscount": "3",
"perSecondDiscountUpdateRate": "999998607628240538157433861"
}
}
22 changes: 22 additions & 0 deletions gov-input/mainnet/new-TargetsAndCalldata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"chainid": 42161,
"description": "Random calldatas",
"network": "mainnet",
"proposalType": "TargetsAndCalldata",
"ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F",
"objectArray": [
{
"target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70",
"calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15"
},
{
"target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70",
"calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15"
},
{
"target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70",
"calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15"
}
],
"arrayLength": "3"
}
18 changes: 9 additions & 9 deletions gov-input/mainnet/new-UpdateDelay.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"chainid": 42161,
"description": "update timelock controller delay",
"network": "mainnet",
"TimelockController_Address": "",
"ProtocolToken_Address": "",
"ODGovernor_Address": "",
"proposalType": "UpdateDelay",
"newDelay": 86400
}
"chainid": 42161,
"description": "update timelock controller delay",
"network": "mainnet",
"TimelockController_Address": "",
"ProtocolToken_Address": "",
"ODGovernor_Address": "",
"proposalType": "UpdateDelay",
"newDelay": 86400
}
39 changes: 1 addition & 38 deletions gov-input/sepolia/new-AddCollateral.json
Original file line number Diff line number Diff line change
@@ -1,38 +1 @@
{
"chainid": "421614",
"network": "sepolia",
"newCollateralAddress": "",
"newCollateralType": "",
"proposalType": "AddCollateral",
"description": "",
"ProtocolToken_Address": "",
"ODGovernor_Address": "",
"SAFEEngine_Address": "",
"OracleRelayer_Address": "",
"LiquidationEngine_Address": "",
"TaxCollector_Address": "",
"GlobalSettlement_Address": "",
"SAFEEngineCollateralParams": {
"collateralDebtCeiling": "",
"collateralDebtFloor": ""
},
"TaxCollectorCollateralParams": {
"stabilityFee": ""
},
"LiquidationEngineCollateralParams": {
"newCAHChild": "",
"liquidationPenalty": "",
"liquidationQuantity": ""
},
"OracleRelayerCollateralParams": {
"delayedOracle": "",
"safetyCRatio": "",
"liquidationCRatio": ""
},
"CollateralAuctionHouseParams": {
"maximumDiscount": "",
"minimumBid": "",
"minimumDiscount": "",
"perSecondDiscountUpdateRate": ""
}
}
{"chainid":"421614","network":"sepolia","newCollateralAddress":"0x1ebFA3a5074f74C1dE3d1bfd1e981ab89475Ef14","newCollateralType":"NEWEY","proposalType":"AddCollateral","description":"it's a new collateratl!","ProtocolToken_Address":"","ODGovernor_Address":"","SAFEEngine_Address":"","OracleRelayer_Address":"","LiquidationEngine_Address":"","TaxCollector_Address":"","GlobalSettlement_Address":"","SAFEEngineCollateralParams":{"collateralDebtCeiling":"1","collateralDebtFloor":"2"},"TaxCollectorCollateralParams":{"stabilityFee":"3"},"LiquidationEngineCollateralParams":{"newCAHChild":"0x1ebFA3a5074f74C1dE3d1bfd1e981ab89475Ef14","liquidationPenalty":"4","liquidationQuantity":"5"},"OracleRelayerCollateralParams":{"delayedOracle":"0x1ebFA3a5074f74C1dE3d1bfd1e981ab89475Ef14","safetyCRatio":"6","liquidationCRatio":"7"},"CollateralAuctionHouseParams":{"maximumDiscount":"8","minimumBid":"9","minimumDiscount":"10","perSecondDiscountUpdateRate":"11"}}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "@opendollar/contracts",
"version": "1.7.1",
"private": true,
"description": "Multicollateral ETH backed stablecoin",
"description": "Contracts for the Open Dollar protocol",
"homepage": "https://www.opendollar.com/",
"repository": {
"type": "git",
"url": "https://github.com/open-dollar/od-contracts"
},
"license": "MIT",
"license": "GNU AGPL",
"author": "OpenFi Foundation",
"contributors": [
"cupOJoseph (https://github.com/cupOJoseph)",
Expand Down
4 changes: 0 additions & 4 deletions script/gov/Generate/GenerateAddCollateralProposal.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ contract GenerateAddCollateralProposal is Generator, JSONScript {
// Get the descriptionHash
bytes32 descriptionHash = keccak256(bytes(description));

vm.startBroadcast(_privateKey);

// Propose the action to add the collateral type
uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash);
string memory stringProposalId = vm.toString(proposalId / 10 ** 69);
Expand All @@ -187,8 +185,6 @@ contract GenerateAddCollateralProposal is Generator, JSONScript {
_buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash);
vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/', stringProposalId, '-add-collateral.json'));
}

vm.stopBroadcast();
}

function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) {
Expand Down
4 changes: 0 additions & 4 deletions script/gov/Generate/GenerateAddNitroRewardsProposal.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ contract GenerateAddNitroRewardsProposal is Generator, JSONScript {
// Get the description and descriptionHash
bytes32 descriptionHash = keccak256(bytes(description));

vm.startBroadcast(_privateKey);

// Propose the action to add rewards to NitroPool
uint256 proposalId = gov.propose(targets, values, calldatas, description);
string memory stringProposalId = vm.toString(proposalId / 10 ** 69);
Expand All @@ -88,8 +86,6 @@ contract GenerateAddNitroRewardsProposal is Generator, JSONScript {
jsonOutput, string.concat('./gov-output/', _network, '/', stringProposalId, '-add-nitro-rewards.json')
);
}

vm.stopBroadcast();
}

function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) {
Expand Down
4 changes: 0 additions & 4 deletions script/gov/Generate/GenerateERC20TransferProposal.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ contract GenerateERC20TransferProposal is Generator, JSONScript {
// Get the descriptionHash
bytes32 descriptionHash = keccak256(bytes(description));

vm.startBroadcast(_privateKey);

// Propose the action to add transfer the ERC20 token to the receiver
uint256 proposalId = gov.propose(targets, values, calldatas, description);
string memory stringProposalId = vm.toString(proposalId / 10 ** 69);
Expand All @@ -72,8 +70,6 @@ contract GenerateERC20TransferProposal is Generator, JSONScript {
_buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash);
vm.writeJson(jsonOutput, string.concat('./gov-output/', _network, '/', stringProposalId, '-transfer-erc20.json'));
}

vm.stopBroadcast();
}

function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ contract GenerateModifyParametersPerCollateralProposal is Generator, JSONScript

bytes32 descriptionHash = keccak256(bytes(_description));

vm.startBroadcast(_privateKey);

// Propose the action to add the collateral type
uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash);
string memory stringProposalId = vm.toString(proposalId / 10 ** 69);
Expand All @@ -77,8 +75,6 @@ contract GenerateModifyParametersPerCollateralProposal is Generator, JSONScript
_buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash);
vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/', stringProposalId, '-modifyParameters.json'));
}

vm.stopBroadcast();
}

function _readData(
Expand Down
4 changes: 0 additions & 4 deletions script/gov/Generate/GenerateModifyParametersProposal.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ contract GenerateModifyParametersProposal is Generator, JSONScript {

bytes32 descriptionHash = keccak256(bytes(_description));

vm.startBroadcast(_privateKey);

// Propose the action to add the collateral type
uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash);
string memory stringProposalId = vm.toString(proposalId / 10 ** 69);
Expand All @@ -75,8 +73,6 @@ contract GenerateModifyParametersProposal is Generator, JSONScript {
_buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash);
vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/', stringProposalId, '-modifyParameters.json'));
}

vm.stopBroadcast();
}

function _readData(
Expand Down
62 changes: 62 additions & 0 deletions script/gov/Generate/GenerateTargetsAndCalldataProposal.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import {JSONScript} from '@script/gov/helpers/JSONScript.s.sol';
import {ODGovernor} from '@contracts/gov/ODGovernor.sol';
import {TimelockController} from '@openzeppelin/governance/TimelockController.sol';
import {Generator} from '@script/gov/Generator.s.sol';
import {Strings} from '@openzeppelin/utils/Strings.sol';
import 'forge-std/StdJson.sol';

contract GenerateTargetsAndCalldataProposal is Generator, JSONScript {
using stdJson for string;

address public _odGovernor;
string public _description;
address[] public targets;
bytes[] public calldatas;

function _loadBaseData(string memory json) internal override {
_description = json.readString(string(abi.encodePacked('.description')));
_odGovernor = json.readAddress(string(abi.encodePacked('.ODGovernor_Address:')));
uint256 len = json.readUint(string(abi.encodePacked('.arrayLength')));
for (uint256 i; i < len; i++) {
string memory index = Strings.toString(i);
address target = json.readAddress(string(abi.encodePacked('.objectArray[', index, '].target')));
bytes memory callData = json.readBytes(string(abi.encodePacked('.objectArray[', index, '].calldata')));
targets.push(target);
calldatas.push(callData);
}
}

function _generateProposal() internal override {
ODGovernor gov = ODGovernor(payable(_odGovernor));

uint256[] memory values = new uint256[](targets.length);
for (uint256 i; i < targets.length; i++) {
values[i] = 0;
}

bytes32 descriptionHash = keccak256(bytes(_description));

uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash);

// Propose the action to add the collateral type

string memory stringProposalId = vm.toString(proposalId / 10 ** 69);

{
string memory objectKey = 'TARGETS-CALLDATA';
// Build the JSON output
string memory jsonOutput =
_buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash);
vm.writeJson(
jsonOutput, string.concat('./gov-output/', _network, '/', stringProposalId, '-targetsAndCalldata.json')
);
}
}

function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) {
_serializedInput = vm.serializeJson(_objectKey, json);
}
}
4 changes: 0 additions & 4 deletions script/gov/Generate/GenerateUpdateDelayProposal.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ contract GenerateUpdateDelayProposal is Generator, JSONScript {

bytes32 descriptionHash = keccak256(bytes(_description));

vm.startBroadcast(_privateKey);

uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash);

// Propose the action to add the collateral type
Expand All @@ -54,8 +52,6 @@ contract GenerateUpdateDelayProposal is Generator, JSONScript {
_buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash);
vm.writeJson(jsonOutput, string.concat('./gov-output/', _network, '/', stringProposalId, '-updateTimeDelay.json'));
}

vm.stopBroadcast();
}

function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) {
Expand Down
Loading

0 comments on commit 22d75d0

Please sign in to comment.