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) external

Initialize 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) external

Cast 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) external

Add more tokens to an existing vote (same direction). Must have already voted.

end_vote() external

End voting after the 3-day period. Anyone can call.

end_vote_early() external

End voting early if quorum AND majority are already met. Anyone can call.

finalize() external

Finalize a successful vote. Calls Hook.finalize_cto() to transfer deployer rights. Anyone can call after vote ends successfully.

withdraw_tokens() external

Withdraw deposited tokens after vote ends. Available regardless of outcome. Both YES and NO voters can withdraw.

View Functions

FunctionReturnsDescription
get_vote_stats()(uint256, uint256, uint256, uint256, bool)(yes_votes, no_votes, total, circulating, would_pass)
is_takeover_successful()boolWhether CTO would pass with current votes
get_participation_percentage()uint256Participation as percentage (0-100)
get_yes_percentage()uint256YES as percentage of total votes (0-100)
time_remaining()uint256Seconds remaining in vote period
get_voter_info(voter)(uint256, bool, bool)(balance, choice, has_voted)
get_circulating_supply()uint256Total supply minus LP and burned