Skip to content

Commit

Permalink
Optimistic token voting adaptations
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed May 14, 2024
1 parent 1899fae commit 55bd327
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/OptimisticTokenVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {ProposalUpgradeable} from "@aragon/osx/core/plugin/proposal/ProposalUpgr
import {PluginUUPSUpgradeable} from "@aragon/osx/core/plugin/PluginUUPSUpgradeable.sol";
import {RATIO_BASE, _applyRatioCeiled, RatioOutOfBounds} from "@aragon/osx/plugins/utils/Ratio.sol";
import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {EssentialContract as TaikoEssentialContract} from "@taikoxyz/taiko-mono/common/EssentialContract.sol";
import {IEssentialContract as ITaikoEssentialContract} from "./interfaces/ITaikoEssentialContract.sol";
// import {EssentialContract as TaikoEssentialContract} from "@taikoxyz/taiko-mono/common/EssentialContract.sol";

uint64 constant L2_AGGREGATION_PERIOD = 3 days;

Expand Down Expand Up @@ -80,10 +81,6 @@ contract OptimisticTokenVotingPlugin is
bytes32 public constant UPDATE_OPTIMISTIC_GOVERNANCE_SETTINGS_PERMISSION_ID =
keccak256("UPDATE_OPTIMISTIC_GOVERNANCE_SETTINGS_PERMISSION");

/// @notice The [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface ID of the contract.
bytes4 public constant OPTIMISTIC_GOVERNANCE_INTERFACE_ID =
this.initialize.selector ^ this.getProposal.selector ^ this.updateOptimisticGovernanceSettings.selector;

/// @notice An [OpenZeppelin `Votes`](https://docs.openzeppelin.com/contracts/4.x/api/governance#Votes) compatible contract referencing the token being used for voting.
IVotesUpgradeable public votingToken;

Expand All @@ -94,7 +91,7 @@ contract OptimisticTokenVotingPlugin is
OptimisticGovernanceSettings public governanceSettings;

/// @notice Taiko L1 contract to check for paused() status when a proposal is created.
TaikoEssentialContract public taikoL1;
ITaikoEssentialContract public taikoL1;

/// @notice A mapping between proposal IDs and proposal information.
mapping(uint256 => Proposal) internal proposals;
Expand Down Expand Up @@ -149,7 +146,7 @@ contract OptimisticTokenVotingPlugin is
IDAO _dao,
OptimisticGovernanceSettings calldata _governanceSettings,
IVotesUpgradeable _token,
TaikoEssentialContract _taikoL1,
ITaikoEssentialContract _taikoL1,
address _taikoBridge
) external initializer {
__PluginUUPSUpgradeable_init(_dao);
Expand Down Expand Up @@ -231,7 +228,7 @@ contract OptimisticTokenVotingPlugin is
return false;
}
// Check if L2 bridged vetoes are still possible
else if (_canReceiveL2Vetoes(_proposalId)) {
else if (_canReceiveL2Vetoes(proposal_)) {
return false;
}
// Check that not enough voters have vetoed the proposal
Expand All @@ -245,10 +242,10 @@ contract OptimisticTokenVotingPlugin is
/// @inheritdoc IOptimisticTokenVoting
function isMinVetoRatioReached(uint256 _proposalId) public view virtual returns (bool) {
Proposal storage proposal_ = proposals[_proposalId];
uint256 totalVotingPower_ = totalVotingPower(proposal_.snapshotTimestamp);
uint256 totalVotingPower_ = totalVotingPower(proposal_.parameters.snapshotTimestamp);
if (_isOnlyL1(proposal_)) {
// L2 tokens won't be fully accountable. Subtracting the bridged supply to compute relative to L1 only.
totalVotingPower_ -= votingToken.balanceOf(taikoBridge);
totalVotingPower_ -= IERC20Upgradeable(address(votingToken)).balanceOf(taikoBridge);
}

uint256 _minVetoPower = _applyRatioCeiled(totalVotingPower_, proposal_.parameters.minVetoRatio);
Expand Down Expand Up @@ -313,7 +310,7 @@ contract OptimisticTokenVotingPlugin is
bool isTaikoL1Paused = taikoL1.paused();

if (isTaikoL1Paused) {
totalVotingPower_ -= votingToken.balanceOf(taikoBridge);
totalVotingPower_ -= IERC20Upgradeable(address(votingToken)).balanceOf(taikoBridge);
}

if (totalVotingPower_ == 0) {
Expand Down Expand Up @@ -495,8 +492,8 @@ contract OptimisticTokenVotingPlugin is
}

/// @notice Determines whether the proposal is considered L1 only or not
/// @param _proposalId The proposal ID
function _isOnlyL1(Proposal storage proposal_) internal pure returns (bool) {
/// @param proposal_ The proposal
function _isOnlyL1(Proposal storage proposal_) internal view returns (bool) {
if (proposal_.parameters.taikoL1PausedOnCreation) {
return true;
} else if (!_canReceiveL2Vetoes(proposal_)) {
Expand Down

0 comments on commit 55bd327

Please sign in to comment.