Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
GalloDaSballo committed Oct 15, 2024
1 parent b692f5b commit 8e60ecb
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/Governance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance

emit RegisterInitiative(_initiative, msg.sender, currentEpoch);

// try IInitiative(_initiative).onRegisterInitiative(currentEpoch) {} catch {}
// Replaces try / catch | Enforces sufficient gas is passed
safeCallWithMinGas(_initiative, MIN_GAS_TO_HOOK, 0, abi.encodeCall(IInitiative.onRegisterInitiative, (currentEpoch)));
}
Expand Down Expand Up @@ -461,10 +460,6 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance
int88 deltaLQTYVotes = _deltaLQTYVotes[i];
int88 deltaLQTYVetos = _deltaLQTYVetos[i];

// TODO: Better assertion
/// Can remove or add
/// But cannot add or remove both

// only allow vetoing post the voting cutoff
require(
deltaLQTYVotes <= 0 || deltaLQTYVotes >= 0 && secondsWithinEpoch() <= EPOCH_VOTING_CUTOFF,
Expand All @@ -475,17 +470,12 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance
uint16 registeredAtEpoch = registeredInitiatives[initiative];
if(deltaLQTYVotes > 0 || deltaLQTYVetos > 0) {
require(currentEpoch > registeredAtEpoch && registeredAtEpoch != 0, "Governance: initiative-not-active");
} /// @audit TODO: We must allow removals for Proposals that are disabled | Should use the flag u16
}

if(registeredAtEpoch == UNREGISTERED_INITIATIVE) {
require(deltaLQTYVotes <= 0 && deltaLQTYVetos <= 0, "Must be a withdrawal");
}
}
// TODO: CHANGE
// Can add if active
// Can remove if inactive
// only allow allocations to initiatives that are active
// an initiative becomes active in the epoch after it is registered


(, InitiativeState memory initiativeState) = _snapshotVotesForInitiative(initiative);
Expand Down Expand Up @@ -537,8 +527,6 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance
);
state.countedVoteLQTY += initiativeState.voteLQTY;



// allocate the voting and vetoing LQTY to the initiative
Allocation memory allocation = lqtyAllocatedByUserToInitiative[msg.sender][initiative];
allocation.voteLQTY = add(allocation.voteLQTY, deltaLQTYVotes);
Expand All @@ -551,9 +539,6 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance

emit AllocateLQTY(msg.sender, initiative, deltaLQTYVotes, deltaLQTYVetos, currentEpoch);

// try IInitiative(initiative).onAfterAllocateLQTY(
// currentEpoch, msg.sender, userState, allocation, initiativeState
// ) {} catch {}
// Replaces try / catch | Enforces sufficient gas is passed
safeCallWithMinGas(initiative, MIN_GAS_TO_HOOK, 0, abi.encodeCall(IInitiative.onAfterAllocateLQTY, (currentEpoch, msg.sender, userState, allocation, initiativeState)));
}
Expand Down Expand Up @@ -598,15 +583,13 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance
globalState = state;

/// @audit removal math causes issues
// delete initiativeStates[_initiative];

/// @audit Should not delete this
/// weeks * 2^16 > u32 so the contract will stop working before this is an issue
registeredInitiatives[_initiative] = UNREGISTERED_INITIATIVE;

emit UnregisterInitiative(_initiative, currentEpoch);

// try IInitiative(_initiative).onUnregisterInitiative(currentEpoch) {} catch {}
// Replaces try / catch | Enforces sufficient gas is passed
safeCallWithMinGas(_initiative, MIN_GAS_TO_HOOK, 0, abi.encodeCall(IInitiative.onUnregisterInitiative, (currentEpoch)));
}
Expand Down Expand Up @@ -640,7 +623,7 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance

emit ClaimForInitiative(_initiative, claimableAmount, votesSnapshot_.forEpoch);

// try IInitiative(_initiative).onClaimForInitiative(votesSnapshot_.forEpoch, claimableAmount) {} catch {}

// Replaces try / catch | Enforces sufficient gas is passed
safeCallWithMinGas(_initiative, MIN_GAS_TO_HOOK, 0, abi.encodeCall(IInitiative.onClaimForInitiative, (votesSnapshot_.forEpoch, claimableAmount)));

Expand Down

0 comments on commit 8e60ecb

Please sign in to comment.