CTOVoteTemplate
Minimal proxy template for Community Takeover voting. Cloned by the Hook for each CTO vote. Manages token-weighted voting with quorum and majority requirements.
Write Functions
initialize(_token, _hook_address, _initiator) externalInitialize the cloned vote. Called by Hook after cloning. Records initiator's token stake as YES vote. Vote ends in 3 days.
vote(amount: uint256, support: bool) externalCast a vote by depositing tokens. support = true for YES, false for NO. Tokens must be approved first. Each address can only vote once (use add_votes to add more).
add_votes(amount: uint256) externalAdd more tokens to an existing vote (same direction). Must have already voted.
end_vote() externalEnd voting after the 3-day period. Anyone can call.
end_vote_early() externalEnd voting early if quorum AND majority are already met. Anyone can call.
finalize() externalFinalize a successful vote. Calls Hook.finalize_cto() to transfer deployer rights. Anyone can call after vote ends successfully.
withdraw_tokens() externalWithdraw deposited tokens after vote ends. Available regardless of outcome. Both YES and NO voters can withdraw.
View Functions
| Function | Returns | Description |
|---|---|---|
get_vote_stats() | (uint256, uint256, uint256, uint256, bool) | (yes_votes, no_votes, total, circulating, would_pass) |
is_takeover_successful() | bool | Whether CTO would pass with current votes |
get_participation_percentage() | uint256 | Participation as percentage (0-100) |
get_yes_percentage() | uint256 | YES as percentage of total votes (0-100) |
time_remaining() | uint256 | Seconds remaining in vote period |
get_voter_info(voter) | (uint256, bool, bool) | (balance, choice, has_voted) |
get_circulating_supply() | uint256 | Total supply minus LP and burned |