Discover more of Etherscan's tools and services in one place.
Sponsored
Contract Source Code:
File 1 of 1 : VoteWeightRegistry.sol<i class='far fa-question-circle text-muted ms-2' data-bs-trigger='hover' data-bs-toggle='tooltip' data-bs-html='true' data-bs-title='Click on the check box to select individual contract to compare. Only 1 contract can be selected from each side.'></i>
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.20; contract VoteWeightRegistry { struct Vote { // User address address user; // Gauge address address[] gauges; // Weight to allocate - 0 to 100 uint256[] weights; bool killed; } mapping(string => mapping(uint256 => Vote)) public votes; // Index start to one mapping(string => uint256) public space_votes_index; mapping(address => mapping(string => uint256)) public user_vote_index; function set(string calldata space, address[] calldata _gauges, uint256[] calldata _weights) external { uint256 weightLength = _weights.length; require(_gauges.length == weightLength, "!Length"); uint256 sum = 0; uint256 i = 0; for(;i<weightLength;) { sum += _weights[i]; unchecked { ++i; } } require(sum == 10000, "Wrong weight"); uint256 userVoteIndex = user_vote_index[msg.sender][space]; if(userVoteIndex == 0) { // New vote uint256 currentIndex = space_votes_index[space]; userVoteIndex = currentIndex + 1; space_votes_index[space] = userVoteIndex; user_vote_index[msg.sender][space] = userVoteIndex; } votes[space][userVoteIndex] = Vote({ user: msg.sender, gauges: _gauges, weights: _weights, killed: false }); } function remove(string calldata space) public { uint256 index = user_vote_index[msg.sender][space]; require(index > 0, "No vote"); votes[space][index].killed = true; } function removeAll(string[] calldata spaces) public { for(uint256 i = 0; i < spaces.length; ++i) { remove(spaces[i]); } } function get(address user, string calldata space) external view returns(Vote memory) { uint256 index = user_vote_index[user][space]; return votes[space][index]; } }
Please enter a contract address above to load the contract details and source code.
Please DO NOT store any passwords or private keys here. A private note (up to 100 characters) can be saved and is useful for transaction tracking.
My Name Tag:
Private Note:
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.