From 01b4047575da094ffbd885721b8dd84d67e156f8 Mon Sep 17 00:00:00 2001 From: MrDeadCe11 Date: Mon, 8 Jul 2024 23:27:45 -0500 Subject: [PATCH 1/6] added modifiablePerCollateral call to tax collector at end of GenerateAddCollateral call --- gov-input/mainnet/AddCollateralWETH.json | 5 ++++ gov-input/mainnet/new-AddCollateral.json | 7 ++++- gov-input/mainnet/new-AddGRT.json | 7 ++++- gov-input/mainnet/new-AddLINK.json | 7 ++++- .../GenerateAddCollateralProposal.s.sol | 28 +++++++++++++++++-- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/gov-input/mainnet/AddCollateralWETH.json b/gov-input/mainnet/AddCollateralWETH.json index c115cff..51842c5 100644 --- a/gov-input/mainnet/AddCollateralWETH.json +++ b/gov-input/mainnet/AddCollateralWETH.json @@ -19,6 +19,11 @@ "TaxCollectorCollateralParams": { "stabilityFee": "1000000000472114805215157978" }, + "TaxReceiver": { + "StabilityFeeTreasury_Address": "", + "canTakeBackTax": false, + "taxPercentage": "500000000000000000" + }, "LiquidationEngineCollateralParams": { "newCAHChild": "0x293b702362918e990Dd5f48a80fB139FeAd64263", "liquidationPenalty": "1050000000000000000", diff --git a/gov-input/mainnet/new-AddCollateral.json b/gov-input/mainnet/new-AddCollateral.json index 4d80206..03ab282 100644 --- a/gov-input/mainnet/new-AddCollateral.json +++ b/gov-input/mainnet/new-AddCollateral.json @@ -19,6 +19,11 @@ "TaxCollectorCollateralParams": { "stabilityFee": "1000000000000000000000000000" }, + "TaxReceiver": { + "receiver": "0x9C86C719Aa29D426C50Ee3BAEd40008D292b02CF", + "canTakeBackTax": true, + "taxPercentage": "200000000000000000" + }, "LiquidationEngineCollateralParams": { "newCAHChild": "0x293b702362918e990Dd5f48a80fB139FeAd64263", "liquidationPenalty": "1000000000000000000", @@ -35,4 +40,4 @@ "minDiscount": "3", "perSecondDiscountUpdateRate": "999998607628240538157433861" } -} +} \ No newline at end of file diff --git a/gov-input/mainnet/new-AddGRT.json b/gov-input/mainnet/new-AddGRT.json index 867feb7..4b979a5 100644 --- a/gov-input/mainnet/new-AddGRT.json +++ b/gov-input/mainnet/new-AddGRT.json @@ -19,6 +19,11 @@ "TaxCollectorCollateralParams": { "stabilityFee": "TBD" }, + "TaxReceiver": { + "StabilityFeeTreasury_Address": "", + "canTakeBackTax": false, + "taxPercentage": "" + }, "LiquidationEngineCollateralParams": { "newCAHChild": "", "liquidationPenalty": "TBD", @@ -35,4 +40,4 @@ "minDiscount": "TBD", "perSecondDiscountUpdateRate": "999998607628240538157433861" } -} +} \ No newline at end of file diff --git a/gov-input/mainnet/new-AddLINK.json b/gov-input/mainnet/new-AddLINK.json index eaba2ae..d85aa4e 100644 --- a/gov-input/mainnet/new-AddLINK.json +++ b/gov-input/mainnet/new-AddLINK.json @@ -19,6 +19,11 @@ "TaxCollectorCollateralParams": { "stabilityFee": "TBD" }, + "TaxReceiver": { + "StabilityFeeTreasury_Address": "", + "canTakeBackTax": false, + "taxPercentage": "" + }, "LiquidationEngineCollateralParams": { "newCAHChild": "", "liquidationPenalty": "TBD", @@ -35,4 +40,4 @@ "minDiscount": "TBD", "perSecondDiscountUpdateRate": "999998607628240538157433861" } -} +} \ No newline at end of file diff --git a/src/contracts/Generate/GenerateAddCollateralProposal.s.sol b/src/contracts/Generate/GenerateAddCollateralProposal.s.sol index 02db79b..30ecf2f 100644 --- a/src/contracts/Generate/GenerateAddCollateralProposal.s.sol +++ b/src/contracts/Generate/GenerateAddCollateralProposal.s.sol @@ -39,6 +39,7 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { ICollateralAuctionHouse.CollateralAuctionHouseParams internal _cahCParams; ISAFEEngine.SAFEEngineCollateralParams internal _SAFEEngineCollateralParams; ITaxCollector.TaxCollectorCollateralParams internal _taxCollectorCParams; + ITaxCollector.TaxReceiver internal _taxReceiver; ILiquidationEngine.LiquidationEngineCollateralParams internal _liquidationEngineCParams; IOracleRelayer.OracleRelayerCollateralParams internal _oracleCParams; @@ -54,6 +55,15 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { // uint256 /* RAY */ stabilityFee; // } + // struct TaxReceiver { + // // the secondary tax receiver. normally the StabilityFeeTreasury + // address receiver; + // // Whether this receiver can accept a negative rate (taking SF from it) + // bool /* bool */ canTakeBackTax; + // // Percentage of SF allocated to this receiver + // uint256 /* WAD % */ taxPercentage; + // } + // struct LiquidationEngineCollateralParams { // // Address of the collateral auction house handling liquidations for this collateral type // address /* */ collateralAuctionHouse; @@ -102,6 +112,10 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { _taxCollectorCParams.stabilityFee = json.readUint(string(abi.encodePacked('.TaxCollectorCollateralParams.stabilityFee'))); + _taxReceiver.receiver = json.readAddress(string(abi.encodePacked('.TaxReceiver.receiver'))); + _taxReceiver.canTakeBackTax = json.readBool(string(abi.encodePacked('.TaxReceiver.canTakeBackTax'))); + _taxReceiver.taxPercentage = json.readUint(string(abi.encodePacked('.TaxReceiver.taxPercentage'))); + _liquidationEngineCParams.collateralAuctionHouse = json.readAddress(string(abi.encodePacked('.LiquidationEngineCollateralParams.newCAHChild'))); _liquidationEngineCParams.liquidationPenalty = @@ -120,7 +134,7 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { ODGovernor gov = ODGovernor(payable(governanceAddress)); IGlobalSettlement globalSettlement = IGlobalSettlement(globalSettlementAddress); - address[] memory targets = new address[](6); + address[] memory targets = new address[](7); { targets[0] = address(globalSettlement.collateralJoinFactory()); targets[1] = address(globalSettlement.collateralAuctionHouseFactory()); @@ -128,9 +142,10 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { targets[3] = taxCollector; targets[4] = liquidationEngine; targets[5] = oracleRelayer; + targets[6] = taxCollector; } // No values needed - uint256[] memory values = new uint256[](6); + uint256[] memory values = new uint256[](7); { values[0] = 0; values[1] = 0; @@ -138,10 +153,11 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { values[3] = 0; values[4] = 0; values[5] = 0; + values[6] = 0; } // Get calldata for: - bytes[] memory calldatas = new bytes[](6); + bytes[] memory calldatas = new bytes[](7); calldatas[0] = abi.encodeWithSelector(ICollateralJoinFactory.deployCollateralJoin.selector, newCType, newCAddress); @@ -160,6 +176,12 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { calldatas[5] = abi.encodeWithSelector( IModifiablePerCollateral.initializeCollateralType.selector, newCType, abi.encode(_oracleCParams) ); + calldatas[6] = abi.encodeWithSelector( + IModifiablePerCollateral.modifyParameters.selector, + newCType, + bytes32(abi.encodePacked('secondaryTaxReceiver')), + abi.encode(_taxReceiver) + ); // Get the descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); From cb3c0cd977e30943916e7cba6849b9716fe3cc4f Mon Sep 17 00:00:00 2001 From: MrDeadCe11 Date: Tue, 9 Jul 2024 00:35:44 -0500 Subject: [PATCH 2/6] added date to the file name output, fixxed a stack too deep --- .../GenerateAddCollateralProposal.s.sol | 31 +++++++++++++--- .../GenerateAddNitroRewardsProposal.s.sol | 30 ++++++++++++--- ...erateDeployChainlinkRelayersProposal.s.sol | 29 ++++++++++++--- ...GenerateDeployDelayedOraclesProposal.s.sol | 27 +++++++++++--- ...rateDeployDenominatedOraclesProposal.s.sol | 27 +++++++++++--- .../GenerateERC20TransferProposal.s.sol | 30 ++++++++++++--- ...odifyParametersPerCollateralProposal.s.sol | 29 ++++++++++++--- .../GenerateModifyParametersProposal.s.sol | 31 +++++++++++++--- .../GenerateTargetsAndCalldataProposal.s.sol | 29 +++++++++++---- .../GenerateUpdateDelayProposal.s.sol | 31 ++++++++++++---- src/contracts/Generator.s.sol | 37 +++++++++++++++++++ src/contracts/helpers/JSONScript.s.sol | 4 +- 12 files changed, 275 insertions(+), 60 deletions(-) diff --git a/src/contracts/Generate/GenerateAddCollateralProposal.s.sol b/src/contracts/Generate/GenerateAddCollateralProposal.s.sol index 30ecf2f..a264f4a 100644 --- a/src/contracts/Generate/GenerateAddCollateralProposal.s.sol +++ b/src/contracts/Generate/GenerateAddCollateralProposal.s.sol @@ -186,16 +186,37 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { // Get the descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); + // stacc too dank + FileNameStrings memory fileNameStrings; + // Propose the action to add the collateral type - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); + + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { string memory objectKey = 'PROPOSE_ADD_COLLATERAL_KEY'; // Build the JSON output - string memory builtProp = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash); - vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/add-collateral-', stringProposalId, '.json')); + string memory builtProp = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, description, descriptionHash + ); + vm.writeJson( + builtProp, + string.concat( + './gov-output/', + _network, + '/add-collateral-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) + ); } } diff --git a/src/contracts/Generate/GenerateAddNitroRewardsProposal.s.sol b/src/contracts/Generate/GenerateAddNitroRewardsProposal.s.sol index b55b88e..8a7234c 100644 --- a/src/contracts/Generate/GenerateAddNitroRewardsProposal.s.sol +++ b/src/contracts/Generate/GenerateAddNitroRewardsProposal.s.sol @@ -71,17 +71,35 @@ contract GenerateAddNitroRewardsProposal is Generator, JSONScript { // Get the description and descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); - // Propose the action to add rewards to NitroPool - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + FileNameStrings memory fileNameStrings; + + // Propose the action + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); + + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { // Build the JSON output string memory objectKey = 'PROPOSE_ADD_NITROPOOL_REWARDS_KEY'; - string memory jsonOutput = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash); + string memory jsonOutput = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, description, descriptionHash + ); vm.writeJson( - jsonOutput, string.concat('./gov-output/', _network, '/add-nitro-rewards-', stringProposalId, '.json') + jsonOutput, + string.concat( + './gov-output/', + _network, + '/add-nitro-rewards-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) ); } } diff --git a/src/contracts/Generate/GenerateDeployChainlinkRelayersProposal.s.sol b/src/contracts/Generate/GenerateDeployChainlinkRelayersProposal.s.sol index 67e79b1..a485d28 100644 --- a/src/contracts/Generate/GenerateDeployChainlinkRelayersProposal.s.sol +++ b/src/contracts/Generate/GenerateDeployChainlinkRelayersProposal.s.sol @@ -66,18 +66,35 @@ contract GenerateDeployChainlinkRelayersProposal is Generator, JSONScript { // Get the description and descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); + FileNameStrings memory fileNameStrings; - // Propose the action - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + // Propose the action to add the collateral type + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); + + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { // Build the JSON output string memory objectKey = 'PROPOSE_DEPLOY_CHAINLINK_RELAYER_KEY'; - string memory jsonOutput = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash); + string memory jsonOutput = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, description, descriptionHash + ); vm.writeJson( - jsonOutput, string.concat('./gov-output/', _network, '/deploy-chainlink-relayer-', stringProposalId, '.json') + jsonOutput, + string.concat( + './gov-output/', + _network, + '/deploy-chainlink-relayer-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' '.json' + ) ); } } diff --git a/src/contracts/Generate/GenerateDeployDelayedOraclesProposal.s.sol b/src/contracts/Generate/GenerateDeployDelayedOraclesProposal.s.sol index c328e35..3e5e6fd 100644 --- a/src/contracts/Generate/GenerateDeployDelayedOraclesProposal.s.sol +++ b/src/contracts/Generate/GenerateDeployDelayedOraclesProposal.s.sol @@ -58,18 +58,35 @@ contract GenerateDeployDelayedOraclesProposal is Generator, JSONScript { // Get the description and descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); + FileNameStrings memory fileNameStrings; // Propose the action - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(abi.encodePacked(fileNameStrings.proposalIdUint)); + + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = vm.toString( + abi.encodePacked(uint8(fileNameStrings.month), '/', uint8(fileNameStrings.day), '/', uint8(fileNameStrings.year)) + ); { // Build the JSON output string memory objectKey = 'PROPOSE_DEPLOY_DELAYED_ORACLE_KEY'; - string memory jsonOutput = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash); + string memory jsonOutput = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, description, descriptionHash + ); vm.writeJson( - jsonOutput, string.concat('./gov-output/', _network, '/deploy-delayed-oracle-', stringProposalId, '.json') + jsonOutput, + string.concat( + './gov-output/', + _network, + '/deploy-delayed-oracle-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) ); } } diff --git a/src/contracts/Generate/GenerateDeployDenominatedOraclesProposal.s.sol b/src/contracts/Generate/GenerateDeployDenominatedOraclesProposal.s.sol index a6878a4..833f626 100644 --- a/src/contracts/Generate/GenerateDeployDenominatedOraclesProposal.s.sol +++ b/src/contracts/Generate/GenerateDeployDenominatedOraclesProposal.s.sol @@ -65,18 +65,35 @@ contract GenerateDeployDenominatedOraclesProposal is Generator, JSONScript { // Get the description and descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); + FileNameStrings memory fileNameStrings; // Propose the action - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); + + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { // Build the JSON output string memory objectKey = 'PROPOSE_DEPLOY_DENOMINATED_ORACLE_KEY'; - string memory jsonOutput = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash); + string memory jsonOutput = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, description, descriptionHash + ); vm.writeJson( - jsonOutput, string.concat('./gov-output/', _network, '/deploy-denominated-oracle-', stringProposalId, '.json') + jsonOutput, + string.concat( + './gov-output/', + _network, + '/deploy-denominated-oracle-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) ); } } diff --git a/src/contracts/Generate/GenerateERC20TransferProposal.s.sol b/src/contracts/Generate/GenerateERC20TransferProposal.s.sol index 37312cd..3371603 100644 --- a/src/contracts/Generate/GenerateERC20TransferProposal.s.sol +++ b/src/contracts/Generate/GenerateERC20TransferProposal.s.sol @@ -58,14 +58,34 @@ contract GenerateERC20TransferProposal is Generator, JSONScript { bytes32 descriptionHash = keccak256(bytes(description)); // Propose the action to add transfer the ERC20 token to the receiver - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + FileNameStrings memory fileNameStrings; + + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); + + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { string memory objectKey = 'PROPOSE_ERC20_TRANSFER_KEY'; - string memory jsonOutput = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash); - vm.writeJson(jsonOutput, string.concat('./gov-output/', _network, '/transfer-erc20', stringProposalId, '.json')); + string memory jsonOutput = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, description, descriptionHash + ); + vm.writeJson( + jsonOutput, + string.concat( + './gov-output/', + _network, + '/transfer-erc20', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) + ); } } diff --git a/src/contracts/Generate/GenerateModifyParametersPerCollateralProposal.s.sol b/src/contracts/Generate/GenerateModifyParametersPerCollateralProposal.s.sol index 3b231e8..e9228b3 100644 --- a/src/contracts/Generate/GenerateModifyParametersPerCollateralProposal.s.sol +++ b/src/contracts/Generate/GenerateModifyParametersPerCollateralProposal.s.sol @@ -65,18 +65,35 @@ contract GenerateModifyParametersPerCollateralProposal is Generator, JSONScript bytes32 descriptionHash = keccak256(bytes(_description)); - // Propose the action to add the collateral type - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + FileNameStrings memory fileNameStrings; + + // Propose the action + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); + + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { string memory objectKey = 'MODIFY_PARAMS_OBJECT_KEY'; // Build the JSON output - string memory builtProp = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash); + string memory builtProp = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, _description, descriptionHash + ); vm.writeJson( builtProp, - string.concat('./gov-output/', _network, '/modifyParameters-perCollateral-', stringProposalId, '.json') + string.concat( + './gov-output/', + _network, + '/modifyParameters-perCollateral-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) ); } } diff --git a/src/contracts/Generate/GenerateModifyParametersProposal.s.sol b/src/contracts/Generate/GenerateModifyParametersProposal.s.sol index 04fa3dc..6a80608 100644 --- a/src/contracts/Generate/GenerateModifyParametersProposal.s.sol +++ b/src/contracts/Generate/GenerateModifyParametersProposal.s.sol @@ -61,17 +61,36 @@ contract GenerateModifyParametersProposal is Generator, JSONScript { } bytes32 descriptionHash = keccak256(bytes(_description)); + FileNameStrings memory fileNameStrings; - // Propose the action to add the collateral type - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + // Propose the action + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); + + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { string memory objectKey = 'MODIFY_PARAMS_OBJECT_KEY'; // Build the JSON output - string memory builtProp = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash); - vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/modifyParameters-', stringProposalId, '.json')); + string memory builtProp = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, _description, descriptionHash + ); + vm.writeJson( + builtProp, + string.concat( + './gov-output/', + _network, + '/modifyParameters-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) + ); } } diff --git a/src/contracts/Generate/GenerateTargetsAndCalldataProposal.s.sol b/src/contracts/Generate/GenerateTargetsAndCalldataProposal.s.sol index 1725f39..5aef82a 100644 --- a/src/contracts/Generate/GenerateTargetsAndCalldataProposal.s.sol +++ b/src/contracts/Generate/GenerateTargetsAndCalldataProposal.s.sol @@ -38,20 +38,35 @@ contract GenerateTargetsAndCalldataProposal is Generator, JSONScript { } bytes32 descriptionHash = keccak256(bytes(_description)); + FileNameStrings memory fileNameStrings; - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); + // Propose the action + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); - // Propose the action to add the collateral type - - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { string memory objectKey = 'TARGETS-CALLDATA'; // Build the JSON output - string memory jsonOutput = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash); + string memory jsonOutput = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, _description, descriptionHash + ); vm.writeJson( - jsonOutput, string.concat('./gov-output/', _network, '/targetsAndCalldata-', stringProposalId, '.json') + jsonOutput, + string.concat( + './gov-output/', + _network, + '/targetsAndCalldata-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) ); } } diff --git a/src/contracts/Generate/GenerateUpdateDelayProposal.s.sol b/src/contracts/Generate/GenerateUpdateDelayProposal.s.sol index beec488..9003cca 100644 --- a/src/contracts/Generate/GenerateUpdateDelayProposal.s.sol +++ b/src/contracts/Generate/GenerateUpdateDelayProposal.s.sol @@ -38,19 +38,36 @@ contract GenerateUpdateDelayProposal is Generator, JSONScript { } bytes32 descriptionHash = keccak256(bytes(_description)); + FileNameStrings memory fileNameStrings; - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); + // Propose the action + fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash); + fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69); + fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint); - // Propose the action to add the collateral type - - string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + (fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp); + fileNameStrings.formattedDate = string.concat( + vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year) + ); { string memory objectKey = 'SCHEDULE-TIMELOCK-OBJECT'; // Build the JSON output - string memory jsonOutput = - _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash); - vm.writeJson(jsonOutput, string.concat('./gov-output/', _network, '/updateTimeDelay-', stringProposalId, '.json')); + string memory jsonOutput = _buildProposalParamsJSON( + fileNameStrings.proposalId, objectKey, targets, values, calldatas, _description, descriptionHash + ); + vm.writeJson( + jsonOutput, + string.concat( + './gov-output/', + _network, + '/updateTimeDelay-', + fileNameStrings.formattedDate, + '-', + fileNameStrings.shortProposalId, + '.json' + ) + ); } } diff --git a/src/contracts/Generator.s.sol b/src/contracts/Generator.s.sol index 02552fa..480785b 100644 --- a/src/contracts/Generator.s.sol +++ b/src/contracts/Generator.s.sol @@ -10,6 +10,16 @@ import 'forge-std/console2.sol'; contract Generator is ForkManagement { using stdJson for string; + struct FileNameStrings { + uint256 proposalIdUint; + string shortProposalId; + string proposalId; + string formattedDate; + uint256 year; + uint256 month; + uint256 day; + } + string public _version = 'version 0.1'; function _loadBaseData(string memory json) internal virtual { @@ -31,4 +41,31 @@ contract Generator is ForkManagement { function _generateProposal() internal virtual { // empty } + + function timestampToDate(uint256 timestamp) internal pure returns (uint256 year, uint256 month, uint256 day) { + unchecked { + (year, month, day) = _daysToDate(timestamp / (24 * 60 * 60)); + } + } + + function _daysToDate(uint256 _days) internal pure returns (uint256 year, uint256 month, uint256 day) { + unchecked { + int256 __days = int256(_days); + + int256 L = __days + 68_569 + 2_440_588; + int256 N = (4 * L) / 146_097; + L = L - (146_097 * N + 3) / 4; + int256 _year = (4000 * (L + 1)) / 1_461_001; + L = L - (1461 * _year) / 4 + 31; + int256 _month = (80 * L) / 2447; + int256 _day = L - (2447 * _month) / 80; + L = _month / 11; + _month = _month + 2 - 12 * L; + _year = 100 * (N - 49) + _year + L; + + year = uint256(_year); + month = uint256(_month); + day = uint256(_day); + } + } } diff --git a/src/contracts/helpers/JSONScript.s.sol b/src/contracts/helpers/JSONScript.s.sol index 48a5d08..1231444 100644 --- a/src/contracts/helpers/JSONScript.s.sol +++ b/src/contracts/helpers/JSONScript.s.sol @@ -10,7 +10,7 @@ contract JSONScript is Script { /// @dev This must be called after serializing proposal specific details /// @return jsonOutput the string JSON output to be written to file function _buildProposalParamsJSON( - uint256 proposalId, + string memory proposalId, string memory objectKey, address[] memory targets, uint256[] memory values, @@ -19,7 +19,7 @@ contract JSONScript is Script { bytes32 descriptionHash ) internal returns (string memory jsonOutput) { _serializeCurrentJson(objectKey); - vm.serializeUint(objectKey, 'proposalId', proposalId); + vm.serializeString(objectKey, 'proposalId', proposalId); vm.serializeAddress(objectKey, 'targets', targets); vm.serializeUint(objectKey, 'values', values); vm.serializeBytes(objectKey, 'calldatas', calldatas); From 6dc7908000433b7abccd49977102c3c6bf4c5451 Mon Sep 17 00:00:00 2001 From: MrDeadCe11 Date: Tue, 9 Jul 2024 00:48:56 -0500 Subject: [PATCH 3/6] added targetsAndCalldata generation for adding a secondary tax receiver for WETH --- gov-input/mainnet/AddCollateralWETH.json | 4 +-- gov-input/mainnet/new-AddGRT.json | 2 +- gov-input/mainnet/new-AddLINK.json | 2 +- gov-input/mainnet/new-TargetsAndCalldata.json | 18 ++++--------- .../targetsAndCalldata-7_9_2024-76864215.json | 25 +++++++++++++++++++ 5 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 gov-output/mainnet/targetsAndCalldata-7_9_2024-76864215.json diff --git a/gov-input/mainnet/AddCollateralWETH.json b/gov-input/mainnet/AddCollateralWETH.json index 51842c5..d1f929f 100644 --- a/gov-input/mainnet/AddCollateralWETH.json +++ b/gov-input/mainnet/AddCollateralWETH.json @@ -20,8 +20,8 @@ "stabilityFee": "1000000000472114805215157978" }, "TaxReceiver": { - "StabilityFeeTreasury_Address": "", - "canTakeBackTax": false, + "receiver": "0x9C86C719Aa29D426C50Ee3BAEd40008D292b02CF", + "canTakeBackTax": true, "taxPercentage": "500000000000000000" }, "LiquidationEngineCollateralParams": { diff --git a/gov-input/mainnet/new-AddGRT.json b/gov-input/mainnet/new-AddGRT.json index 4b979a5..9c14bce 100644 --- a/gov-input/mainnet/new-AddGRT.json +++ b/gov-input/mainnet/new-AddGRT.json @@ -20,7 +20,7 @@ "stabilityFee": "TBD" }, "TaxReceiver": { - "StabilityFeeTreasury_Address": "", + "receiver": "", "canTakeBackTax": false, "taxPercentage": "" }, diff --git a/gov-input/mainnet/new-AddLINK.json b/gov-input/mainnet/new-AddLINK.json index d85aa4e..493f10a 100644 --- a/gov-input/mainnet/new-AddLINK.json +++ b/gov-input/mainnet/new-AddLINK.json @@ -20,7 +20,7 @@ "stabilityFee": "TBD" }, "TaxReceiver": { - "StabilityFeeTreasury_Address": "", + "receiver": "", "canTakeBackTax": false, "taxPercentage": "" }, diff --git a/gov-input/mainnet/new-TargetsAndCalldata.json b/gov-input/mainnet/new-TargetsAndCalldata.json index 3f1fb41..6cc518a 100644 --- a/gov-input/mainnet/new-TargetsAndCalldata.json +++ b/gov-input/mainnet/new-TargetsAndCalldata.json @@ -1,22 +1,14 @@ { "chainid": 42161, - "description": "Random calldatas", + "description": "add secondary tax receiver for WETH", "network": "mainnet", "proposalType": "TargetsAndCalldata", - "ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F", + "ODGovernor_Address": "", "objectArray": [ { - "target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70", - "calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15" - }, - { - "target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70", - "calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15" - }, - { - "target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70", - "calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15" + "target": "0xc93F938A95488a03b976A15B20fAcFD52D087fB2", + "calldata": "0x12f3352657455448000000000000000000000000000000000000000000000000000000007365636f6e646172795461785265636569766572000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000009c86c719aa29d426c50ee3baed40008d292b02cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006f05b59d3b20000" } ], - "arrayLength": "3" + "arrayLength": "1" } \ No newline at end of file diff --git a/gov-output/mainnet/targetsAndCalldata-7_9_2024-76864215.json b/gov-output/mainnet/targetsAndCalldata-7_9_2024-76864215.json new file mode 100644 index 0000000..6e21a60 --- /dev/null +++ b/gov-output/mainnet/targetsAndCalldata-7_9_2024-76864215.json @@ -0,0 +1,25 @@ +{ + "ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F", + "arrayLength": "1", + "calldatas": [ + "0x12f3352657455448000000000000000000000000000000000000000000000000000000007365636f6e646172795461785265636569766572000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000009c86c719aa29d426c50ee3baed40008d292b02cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006f05b59d3b20000" + ], + "chainid": 42161, + "description": "add secondary tax receiver for WETH", + "descriptionHash": "0x42ba67fde5f25ce4c9185c3be6e859c5f2e4293c1321cfa063da8973c3b432c7", + "network": "mainnet", + "objectArray": [ + { + "target": "0xc93F938A95488a03b976A15B20fAcFD52D087fB2", + "calldata": "0x12f3352657455448000000000000000000000000000000000000000000000000000000007365636f6e646172795461785265636569766572000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000009c86c719aa29d426c50ee3baed40008d292b02cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006f05b59d3b20000" + } + ], + "proposalId": 76864215325714286555073332752783782717698752062872007843280380922333230264505, + "proposalType": "TargetsAndCalldata", + "targets": [ + "0xc93F938A95488a03b976A15B20fAcFD52D087fB2" + ], + "values": [ + 0 + ] +} \ No newline at end of file From f8664dba5792465d3d7757419da4ee05e285ef33 Mon Sep 17 00:00:00 2001 From: MrDeadCe11 Date: Thu, 11 Jul 2024 16:22:48 -0500 Subject: [PATCH 4/6] added delegatee param in gov input for add new colateral type. --- gov-input/mainnet/new-AddCollateral.json | 3 ++- gov-input/mainnet/new-TargetsAndCalldata.json | 2 +- .../Generate/GenerateAddCollateralProposal.s.sol | 12 +++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gov-input/mainnet/new-AddCollateral.json b/gov-input/mainnet/new-AddCollateral.json index 03ab282..b74e191 100644 --- a/gov-input/mainnet/new-AddCollateral.json +++ b/gov-input/mainnet/new-AddCollateral.json @@ -12,6 +12,7 @@ "LiquidationEngine_Address": "", "TaxCollector_Address": "", "GlobalSettlement_Address": "", + "Delegatee": "0x0000000000000000000000000000000000000000", "SAFEEngineCollateralParams": { "collateralDebtCeiling": "500000000000000000000000000000000000000000000000", "collateralDebtFloor": "100000000000000000000000000000000000000000000000" @@ -25,7 +26,7 @@ "taxPercentage": "200000000000000000" }, "LiquidationEngineCollateralParams": { - "newCAHChild": "0x293b702362918e990Dd5f48a80fB139FeAd64263", + "newCAHChild": "0xb043A91C26b79620aaa06C02Ddcd78F3649b27CF", "liquidationPenalty": "1000000000000000000", "liquidationQuantity": "1000000000000000000000000000000000000000000000" }, diff --git a/gov-input/mainnet/new-TargetsAndCalldata.json b/gov-input/mainnet/new-TargetsAndCalldata.json index 6cc518a..b062472 100644 --- a/gov-input/mainnet/new-TargetsAndCalldata.json +++ b/gov-input/mainnet/new-TargetsAndCalldata.json @@ -3,7 +3,7 @@ "description": "add secondary tax receiver for WETH", "network": "mainnet", "proposalType": "TargetsAndCalldata", - "ODGovernor_Address": "", + "ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F", "objectArray": [ { "target": "0xc93F938A95488a03b976A15B20fAcFD52D087fB2", diff --git a/src/contracts/Generate/GenerateAddCollateralProposal.s.sol b/src/contracts/Generate/GenerateAddCollateralProposal.s.sol index a264f4a..803324a 100644 --- a/src/contracts/Generate/GenerateAddCollateralProposal.s.sol +++ b/src/contracts/Generate/GenerateAddCollateralProposal.s.sol @@ -35,6 +35,7 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { address public liquidationEngine; address public oracleRelayer; address public newCAddress; + address public delegatee; ICollateralAuctionHouse.CollateralAuctionHouseParams internal _cahCParams; ISAFEEngine.SAFEEngineCollateralParams internal _SAFEEngineCollateralParams; @@ -97,6 +98,7 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { taxCollector = json.readAddress(string(abi.encodePacked('.TaxCollector_Address:'))); liquidationEngine = json.readAddress(string(abi.encodePacked('.LiquidationEngine_Address:'))); oracleRelayer = json.readAddress(string(abi.encodePacked('.OracleRelayer_Address:'))); + delegatee = json.readAddress(string(abi.encodePacked('.Delegatee'))); _cahCParams.minimumBid = json.readUint(string(abi.encodePacked('.CollateralAuctionHouseParams.minimumBid'))); _cahCParams.minDiscount = json.readUint(string(abi.encodePacked('.CollateralAuctionHouseParams.minDiscount'))); @@ -158,9 +160,13 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { // Get calldata for: bytes[] memory calldatas = new bytes[](7); - - calldatas[0] = abi.encodeWithSelector(ICollateralJoinFactory.deployCollateralJoin.selector, newCType, newCAddress); - + if (delegatee != address(0)) { + calldatas[0] = abi.encodeWithSelector( + ICollateralJoinFactory.deployDelegatableCollateralJoin.selector, newCType, newCAddress, delegatee + ); + } else { + calldatas[0] = abi.encodeWithSelector(ICollateralJoinFactory.deployCollateralJoin.selector, newCType, newCAddress); + } calldatas[1] = abi.encodeWithSelector( IModifiablePerCollateral.initializeCollateralType.selector, newCType, abi.encode(_cahCParams) ); From 0e8eeb0fb3872a4a1be8d35473567384e901cb6f Mon Sep 17 00:00:00 2001 From: MrDeadCe11 Date: Fri, 12 Jul 2024 22:04:50 -0500 Subject: [PATCH 5/6] fixed proposal id to be a string --- gov-input/mainnet/AddCollateralWETH.json | 5 --- gov-input/mainnet/new-AddCollateral.json | 5 ++- src/contracts/helpers/JSONScript.s.sol | 10 ++--- tasks/governanceManager.sh | 3 +- tasks/parseProposalOutputs.js | 54 +++++++++++++++++++++--- 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/gov-input/mainnet/AddCollateralWETH.json b/gov-input/mainnet/AddCollateralWETH.json index d1f929f..c115cff 100644 --- a/gov-input/mainnet/AddCollateralWETH.json +++ b/gov-input/mainnet/AddCollateralWETH.json @@ -19,11 +19,6 @@ "TaxCollectorCollateralParams": { "stabilityFee": "1000000000472114805215157978" }, - "TaxReceiver": { - "receiver": "0x9C86C719Aa29D426C50Ee3BAEd40008D292b02CF", - "canTakeBackTax": true, - "taxPercentage": "500000000000000000" - }, "LiquidationEngineCollateralParams": { "newCAHChild": "0x293b702362918e990Dd5f48a80fB139FeAd64263", "liquidationPenalty": "1050000000000000000", diff --git a/gov-input/mainnet/new-AddCollateral.json b/gov-input/mainnet/new-AddCollateral.json index b74e191..1c78de8 100644 --- a/gov-input/mainnet/new-AddCollateral.json +++ b/gov-input/mainnet/new-AddCollateral.json @@ -23,7 +23,7 @@ "TaxReceiver": { "receiver": "0x9C86C719Aa29D426C50Ee3BAEd40008D292b02CF", "canTakeBackTax": true, - "taxPercentage": "200000000000000000" + "taxPercentage": "500000000000000000" }, "LiquidationEngineCollateralParams": { "newCAHChild": "0xb043A91C26b79620aaa06C02Ddcd78F3649b27CF", @@ -40,5 +40,6 @@ "minimumBid": "2", "minDiscount": "3", "perSecondDiscountUpdateRate": "999998607628240538157433861" - } + }, + "proposalId": "" } \ No newline at end of file diff --git a/src/contracts/helpers/JSONScript.s.sol b/src/contracts/helpers/JSONScript.s.sol index 1231444..2294e56 100644 --- a/src/contracts/helpers/JSONScript.s.sol +++ b/src/contracts/helpers/JSONScript.s.sol @@ -48,9 +48,9 @@ contract JSONScript is Script { descriptionHash = vm.parseJsonBytes32(jsonFile, '.descriptionHash'); } - /// @notice Parses the params required for execution from a json file - /// @return proposalId the proposal to execute json output file - function _parseProposalId(string memory jsonFile) internal pure returns (uint256 proposalId) { - proposalId = vm.parseJsonUint(jsonFile, '.proposalId'); - } + // /// @notice Parses the params required for execution from a json file + // /// @return proposalId the proposal to execute json output file + // function _parseProposalId(string memory jsonFile) internal pure returns (uint256 proposalId) { + // proposalId = vm.parseJsonUint(jsonFile, '.proposalId'); + // } } diff --git a/tasks/governanceManager.sh b/tasks/governanceManager.sh index 0ad9509..4a72f4e 100755 --- a/tasks/governanceManager.sh +++ b/tasks/governanceManager.sh @@ -72,8 +72,7 @@ function generateProposal() { echo "$COMMAND_PATH" CALLDATA=$(cast calldata "run(string)" $CAST_PATH) forge script $COMMAND_PATH -s $CALLDATA --fork-url $ARB_MAINNET_RPC --unlocked 0x7a528ea3e06d85ed1c22219471cf0b1851943903 - # simulate $COMMAND_PATH $CALLDATA $RPC_ENDPOINT $PRIVATE_KEY - + echo "$(node tasks/parseProposalOutputs.js $NETWORK)" } function delegate() { diff --git a/tasks/parseProposalOutputs.js b/tasks/parseProposalOutputs.js index c6e09d1..a265fa1 100644 --- a/tasks/parseProposalOutputs.js +++ b/tasks/parseProposalOutputs.js @@ -1,14 +1,58 @@ const fs = require("fs"); const path = require("path"); - const args = process.argv.slice(2); const targetEnv = args[0].toLowerCase(); -const proposalType = args[1]; -const inputPath = path.join(__dirname, `../gov-input/${targetEnv}/new-${proposalType}-prop.json`); +const inputPath = path.join(__dirname, `../gov-output/${targetEnv}/`); + +const outputPath = getMostRecentWrittenFile(inputPath); + +const outputJson = require(outputPath); + +outputJson.proposalId = BigInt(outputJson.proposalId).toString(); + +// find most recently written json file in target env output folder + +function getMostRecentWrittenFile(targetPath) { + // Read the directory contents + const files = fs.readdirSync(targetPath); + + // Filter for JSON files + const jsonFiles = files.filter( + (file) => path.extname(file).toLowerCase() === ".json" + ); + + if (jsonFiles.length === 0) { + throw new Error("No JSON files found in the specified folder."); + } + + let mostRecentFile = null; + let mostRecentTime = 0; + + // Iterate through JSON files + for (const file of jsonFiles) { + const filePath = path.join(targetPath, file); + const stats = fs.statSync(filePath); + + if (stats.mtimeMs > mostRecentTime) { + mostRecentFile = filePath; + mostRecentTime = stats.mtimeMs; + } + } + + if (mostRecentFile) { + return mostRecentFile; + } else { + throw new Error("Unable to determine the most recent JSON file."); + } +} -const currentProp = require(inputPath); +fs.writeFile(outputPath, JSON.stringify(outputJson, null, 2), (err) => { + if (err) { + console.error(err); + return; + } +}); -currentProp ? console.log(JSON.stringify(currentProp, null, 2)) : console.log(''); return; From 0eaef61c8d75fce4b1cb46f1308e268ea1cb6515 Mon Sep 17 00:00:00 2001 From: MrDeadCe11 Date: Fri, 12 Jul 2024 22:05:46 -0500 Subject: [PATCH 6/6] added missing files --- .../add-collateral-7_13_2024-6286386.json | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 gov-output/mainnet/add-collateral-7_13_2024-6286386.json diff --git a/gov-output/mainnet/add-collateral-7_13_2024-6286386.json b/gov-output/mainnet/add-collateral-7_13_2024-6286386.json new file mode 100644 index 0000000..aff9ac4 --- /dev/null +++ b/gov-output/mainnet/add-collateral-7_13_2024-6286386.json @@ -0,0 +1,73 @@ +{ + "CollateralAuctionHouseParams": { + "maxDiscount": "1", + "minimumBid": "2", + "minDiscount": "3", + "perSecondDiscountUpdateRate": "999998607628240538157433861" + }, + "Delegatee": "0x0000000000000000000000000000000000000000", + "GlobalSettlement_Address": "0x1c6B7ab018be82ed6b5c63aE82D9f07bb7B231A2", + "LiquidationEngineCollateralParams": { + "newCAHChild": "0xb043A91C26b79620aaa06C02Ddcd78F3649b27CF", + "liquidationPenalty": "1000000000000000000", + "liquidationQuantity": "1000000000000000000000000000000000000000000000" + }, + "LiquidationEngine_Address": "0x17e546dDCE2EA8A74Bd667269457A2e80b309965", + "ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F", + "OracleRelayerCollateralParams": { + "delayedOracle": "0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9", + "safetyCRatio": "1000000000000000000000000000", + "liquidationCRatio": "1000000000000000000000000000" + }, + "OracleRelayer_Address": "0x7404fc1F3796748FAE17011b57Fad9713185c1d6", + "ProtocolToken_Address": "0x000D636bD52BFc1B3a699165Ef5aa340BEA8939c", + "SAFEEngineCollateralParams": { + "collateralDebtCeiling": "500000000000000000000000000000000000000000000000", + "collateralDebtFloor": "100000000000000000000000000000000000000000000000" + }, + "SAFEEngine_Address": "0xEff45E8e2353893BD0558bD5892A42786E9142F1", + "TaxCollectorCollateralParams": { + "stabilityFee": "1000000000000000000000000000" + }, + "TaxCollector_Address": "0xc93F938A95488a03b976A15B20fAcFD52D087fB2", + "TaxReceiver": { + "receiver": "0x9C86C719Aa29D426C50Ee3BAEd40008D292b02CF", + "canTakeBackTax": true, + "taxPercentage": "500000000000000000" + }, + "calldatas": [ + "0x26e166654e45574144440000000000000000000000000000000000000000000000000000000000000000000000000000a513e6e4b8f2a923d98304ec87f64353c4d5c853", + "0x34463c604e45574144440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000033b2df124c64e1bef3bc405", + "0x34463c604e45574144440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000005794c6828721caeb4b385895bfa0800000000000000000000000000000000000118427b3b4a05bc8a8a4de845986800000000000", + "0x34463c604e45574144440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000033b2e3c9fd0803ce8000000", + "0x34463c604e4557414444000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000b043a91c26b79620aaa06c02ddcd78f3649b27cf0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000002cd76fe086b93ce2f768a00b22a00000000000", + "0x34463c604e4557414444000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a783cdc72e34a174cca57a6d9a74904d0bec05a90000000000000000000000000000000000000000033b2e3c9fd0803ce80000000000000000000000000000000000000000000000033b2e3c9fd0803ce8000000", + "0x12f335264e455741444400000000000000000000000000000000000000000000000000007365636f6e646172795461785265636569766572000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000009c86c719aa29d426c50ee3baed40008d292b02cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006f05b59d3b20000" + ], + "chainid": "42161", + "description": "add NEWADD as a collateral type", + "descriptionHash": "0xb2cc6970c686cc6e9cbc9d95cc525cbcc1d11bf3c626e05f95069f77120cad40", + "network": "mainnet", + "newCollateralAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853", + "newCollateralType": "NEWADD", + "proposalId": "6286386367297697622524748526094319121591800364290862196749718428572157214720", + "proposalType": "AddCollateral", + "targets": [ + "0xa83c0f1e9eD8E383919Dde0fC90744ae370EB7B3", + "0x5dc1E86361faC018f24Ae0D1E5eB01D70AB32A82", + "0xEff45E8e2353893BD0558bD5892A42786E9142F1", + "0xc93F938A95488a03b976A15B20fAcFD52D087fB2", + "0x17e546dDCE2EA8A74Bd667269457A2e80b309965", + "0x7404fc1F3796748FAE17011b57Fad9713185c1d6", + "0xc93F938A95488a03b976A15B20fAcFD52D087fB2" + ], + "values": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] +} \ No newline at end of file