Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

feat: added voting delay, configurable delay, voting, and submission periods, and checkpoints for periods #66

Merged
merged 33 commits into from
Dec 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a3d9e07
added set quorum fns
dd0sxx Dec 12, 2023
af9c1ef
SetQuorumPct
dd0sxx Dec 12, 2023
2bb3f4e
SetQuorumPct 721
dd0sxx Dec 12, 2023
cbce3da
compiles without tests
dd0sxx Dec 13, 2023
b48750e
tests work
dd0sxx Dec 13, 2023
cccded6
fmt
dd0sxx Dec 13, 2023
8f59376
pushing changes
dd0sxx Dec 13, 2023
c16d10e
builds w no tests
dd0sxx Dec 14, 2023
264218e
got rid of hardcoded 1/3 / 2/3 periods
dd0sxx Dec 14, 2023
228f830
added internal fn
dd0sxx Dec 14, 2023
83825c6
init to default value
dd0sxx Dec 14, 2023
66d1bdc
Merge branch 'main' into theo/update-submission-period
dd0sxx Dec 14, 2023
62e48c6
uint48
dd0sxx Dec 14, 2023
8e06643
added view fns
dd0sxx Dec 14, 2023
69117cf
so close
dd0sxx Dec 15, 2023
1550514
5 MOORE
dd0sxx Dec 15, 2023
aba8341
CLOSER
dd0sxx Dec 15, 2023
d2e978c
YES
dd0sxx Dec 15, 2023
1f2823f
new tests added
dd0sxx Dec 15, 2023
abe2676
Merge branch 'main' into theo/update-submission-period
dd0sxx Dec 15, 2023
a109d5d
fix
dd0sxx Dec 15, 2023
6dd31ff
comment
dd0sxx Dec 15, 2023
f028e5f
Update PeriodPctCheckpoints.sol
dd0sxx Dec 15, 2023
6960a96
Update PeriodPctCheckpoints.sol
dd0sxx Dec 15, 2023
84b362f
Update src/lib/QuorumCheckpoints.sol
0xrajath Dec 15, 2023
448bc49
delayPeriodTimestamp weight
dd0sxx Dec 15, 2023
3a4c010
added weight test
dd0sxx Dec 15, 2023
88946da
tests
dd0sxx Dec 15, 2023
a000c44
test
dd0sxx Dec 15, 2023
4eaf6a1
test
dd0sxx Dec 15, 2023
0d50295
comments and insert return fn
dd0sxx Dec 15, 2023
8e546f6
comments
dd0sxx Dec 15, 2023
ddd9839
fixed
dd0sxx Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
got rid of hardcoded 1/3 / 2/3 periods
  • Loading branch information
dd0sxx committed Dec 14, 2023
commit 264218e6cb4e1dd3ba008a00c1b51c2a8dfe3edc
18 changes: 8 additions & 10 deletions src/token-voting/LlamaTokenCaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@ abstract contract LlamaTokenCaster is Initializable {
/// @dev Equivalent to 100%, but in basis points.
uint256 internal constant ONE_HUNDRED_IN_BPS = 10_000;

/// @dev Equivalent to 1/3, but in basis points.
uint256 internal constant ONE_THIRD_IN_BPS = 3333;

/// @dev Equivalent to 2/3, but in basis points.
uint256 internal constant TWO_THIRDS_IN_BPS = 6667;

/// @notice The core contract for this Llama instance.
ILlamaCore public llamaCore;

Expand Down Expand Up @@ -283,7 +277,8 @@ abstract contract LlamaTokenCaster is Initializable {
if (casts[actionInfo.id].approvalSubmitted) revert AlreadySubmittedApproval();
// check to make sure the casting period has ended
uint256 approvalPeriod = actionInfo.strategy.approvalPeriod();
if (block.timestamp < action.creationTime + (approvalPeriod * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS) {
(, uint16 castingPeriodPct,) = periodPctsCheckpoint.getAtProbablyRecentTimestamp(action.creationTime - 1);
if (block.timestamp < action.creationTime + (approvalPeriod * castingPeriodPct) / ONE_HUNDRED_IN_BPS) {
revert CannotSubmitYet();
}

Expand Down Expand Up @@ -319,8 +314,9 @@ abstract contract LlamaTokenCaster is Initializable {
if (casts[actionInfo.id].disapprovalSubmitted) revert AlreadySubmittedDisapproval();

uint256 queuingPeriod = actionInfo.strategy.queuingPeriod();
(,, uint16 submissionPeriodPct) = periodPctsCheckpoint.getAtProbablyRecentTimestamp(action.creationTime - 1);
// check to make sure the current timestamp is within the submitDisapprovalBuffer 9period
if (block.timestamp < action.minExecutionTime - (queuingPeriod * ONE_THIRD_IN_BPS) / ONE_HUNDRED_IN_BPS) {
if (block.timestamp < action.minExecutionTime - (queuingPeriod * submissionPeriodPct) / ONE_HUNDRED_IN_BPS) {
revert CannotSubmitYet();
}
if (block.timestamp >= action.minExecutionTime) revert SubmissionPeriodOver();
Expand Down Expand Up @@ -390,9 +386,10 @@ abstract contract LlamaTokenCaster is Initializable {
actionInfo.strategy.checkIfApprovalEnabled(actionInfo, address(this), role); // Reverts if not allowed.
if (llamaCore.getActionState(actionInfo) != uint8(ActionState.Active)) revert ActionNotActive();
if (casts[actionInfo.id].castVote[caster]) revert AlreadyCastedVote();
(, uint16 castingPeriodPct,) = periodPctsCheckpoint.getAtProbablyRecentTimestamp(action.creationTime - 1);
if (
block.timestamp
> action.creationTime + (actionInfo.strategy.approvalPeriod() * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS
> action.creationTime + (actionInfo.strategy.approvalPeriod() * castingPeriodPct) / ONE_HUNDRED_IN_BPS
) revert CastingPeriodOver();

uint256 balance = _getPastVotes(caster, action.creationTime - 1);
Expand All @@ -411,9 +408,10 @@ abstract contract LlamaTokenCaster is Initializable {
actionInfo.strategy.checkIfDisapprovalEnabled(actionInfo, address(this), role); // Reverts if not allowed.
if (llamaCore.getActionState(actionInfo) != uint8(ActionState.Queued)) revert ActionNotQueued();
if (casts[actionInfo.id].castVeto[caster]) revert AlreadyCastedVeto();
(,, uint16 submissionPeriodPct) = periodPctsCheckpoint.getAtProbablyRecentTimestamp(action.creationTime - 1);
if (
block.timestamp
> action.minExecutionTime - (actionInfo.strategy.queuingPeriod() * ONE_THIRD_IN_BPS) / ONE_HUNDRED_IN_BPS
> action.minExecutionTime - (actionInfo.strategy.queuingPeriod() * submissionPeriodPct) / ONE_HUNDRED_IN_BPS
) revert CastingPeriodOver();

uint256 balance = _getPastVotes(caster, action.creationTime - 1);
Expand Down