-
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.
refactor: update governance deployments
- Loading branch information
Showing
10 changed files
with
242 additions
and
49 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
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
133 changes: 133 additions & 0 deletions
133
patches/@venusprotocol+governance-contracts+1.3.0.patch
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,133 @@ | ||
diff --git a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha.sol b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha.sol | ||
index fca5350..4713034 100644 | ||
--- a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha.sol | ||
+++ b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha.sol | ||
@@ -27,8 +27,8 @@ contract GovernorAlpha { | ||
|
||
/// @notice The duration of voting on a proposal, in blocks | ||
function votingPeriod() public pure returns (uint) { | ||
- return (60 * 60 * 24 * 3) / 3; | ||
- } // ~3 days in blocks (assuming 3s blocks) | ||
+ return 100; | ||
+ } // A reasonable amount of block suitable for testing | ||
|
||
/// @notice The address of the Venus Protocol Timelock | ||
TimelockInterface public timelock; | ||
diff --git a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha2.sol b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha2.sol | ||
index c009718..0e8e8ec 100644 | ||
--- a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha2.sol | ||
+++ b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorAlpha2.sol | ||
@@ -27,8 +27,8 @@ contract GovernorAlpha2 { | ||
|
||
/// @notice The duration of voting on a proposal, in blocks | ||
function votingPeriod() public pure returns (uint) { | ||
- return (60 * 60 * 24 * 3) / 3; | ||
- } // ~3 days in blocks (assuming 3s blocks) | ||
+ return 100; | ||
+ } // A reasonable amount of block suitable for testing | ||
|
||
/// @notice The address of the Venus Protocol Timelock | ||
TimelockInterface public timelock; | ||
diff --git a/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorBravoDelegator.sol b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorBravoDelegator.sol | ||
new file mode 100644 | ||
index 0000000..4323517 | ||
--- /dev/null | ||
+++ b/node_modules/@venusprotocol/governance-contracts/contracts/legacy/GovernorBravoDelegator.sol | ||
@@ -0,0 +1,97 @@ | ||
+pragma solidity ^0.5.16; | ||
+pragma experimental ABIEncoderV2; | ||
+ | ||
+import "./GovernorBravoInterfaces.sol"; | ||
+ | ||
+/** | ||
+ * @title GovernorBravoDelegator | ||
+ * @author Venus | ||
+ * @notice The `GovernorBravoDelegator` contract. | ||
+ */ | ||
+contract GovernorBravoDelegatorV1 is GovernorBravoDelegatorStorage, GovernorBravoEventsV1 { | ||
+ constructor( | ||
+ address timelock_, | ||
+ address xvsVault_, | ||
+ address admin_, | ||
+ address implementation_, | ||
+ uint votingPeriod_, | ||
+ uint votingDelay_, | ||
+ uint proposalThreshold_, | ||
+ address guardian_ | ||
+ ) public { | ||
+ // Admin set to msg.sender for initialization | ||
+ admin = msg.sender; | ||
+ | ||
+ delegateTo( | ||
+ implementation_, | ||
+ abi.encodeWithSignature( | ||
+ "initialize(address,address,uint256,uint256,uint256,address)", | ||
+ timelock_, | ||
+ xvsVault_, | ||
+ votingPeriod_, | ||
+ votingDelay_, | ||
+ proposalThreshold_, | ||
+ guardian_ | ||
+ ) | ||
+ ); | ||
+ | ||
+ _setImplementation(implementation_); | ||
+ | ||
+ admin = admin_; | ||
+ } | ||
+ | ||
+ /** | ||
+ * @notice Called by the admin to update the implementation of the delegator | ||
+ * @param implementation_ The address of the new implementation for delegation | ||
+ */ | ||
+ function _setImplementation(address implementation_) public { | ||
+ require(msg.sender == admin, "GovernorBravoDelegator::_setImplementation: admin only"); | ||
+ require( | ||
+ implementation_ != address(0), | ||
+ "GovernorBravoDelegator::_setImplementation: invalid implementation address" | ||
+ ); | ||
+ | ||
+ address oldImplementation = implementation; | ||
+ implementation = implementation_; | ||
+ | ||
+ emit NewImplementation(oldImplementation, implementation); | ||
+ } | ||
+ | ||
+ /** | ||
+ * @notice Internal method to delegate execution to another contract | ||
+ * @dev It returns to the external caller whatever the implementation returns or forwards reverts | ||
+ * @param callee The contract to delegatecall | ||
+ * @param data The raw data to delegatecall | ||
+ */ | ||
+ function delegateTo(address callee, bytes memory data) internal { | ||
+ (bool success, bytes memory returnData) = callee.delegatecall(data); | ||
+ assembly { | ||
+ if eq(success, 0) { | ||
+ revert(add(returnData, 0x20), returndatasize) | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
+ /** | ||
+ * @dev Delegates execution to an implementation contract. | ||
+ * It returns to the external caller whatever the implementation returns | ||
+ * or forwards reverts. | ||
+ */ | ||
+ function() external payable { | ||
+ // delegate all other functions to current implementation | ||
+ (bool success, ) = implementation.delegatecall(msg.data); | ||
+ | ||
+ assembly { | ||
+ let free_mem_ptr := mload(0x40) | ||
+ returndatacopy(free_mem_ptr, 0, returndatasize) | ||
+ | ||
+ switch success | ||
+ case 0 { | ||
+ revert(free_mem_ptr, returndatasize) | ||
+ } | ||
+ default { | ||
+ return(free_mem_ptr, returndatasize) | ||
+ } | ||
+ } | ||
+ } | ||
+} |
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
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
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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { Address } from '@graphprotocol/graph-ts'; | ||
|
||
import { governorBravoDelegateAddress as governorBravoDelegateAddressString } from './config'; | ||
import { governorBravoDelegatorAddress as governorBravoDelegatorAddressString } from './config'; | ||
|
||
export const governorBravoDelegateAddress = Address.fromString(governorBravoDelegateAddressString); | ||
export const governorBravoDelegatorAddress = Address.fromString( | ||
governorBravoDelegatorAddressString, | ||
); | ||
|
||
export const nullAddress = Address.fromString('0x0000000000000000000000000000000000000000'); |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Use yarn prepare commands to generate config typescript file per env | ||
|
||
export const governorBravoDelegateAddress = '{{ governorBravoDelegateAddress }}'; | ||
export const governorBravoDelegatorAddress = '{{ governorBravoDelegatorAddress }}'; | ||
|
||
export const xvsVaultPid = '{{ xvsVaultPid }}'; | ||
|
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
Oops, something went wrong.