Address Contract Partially Verified
Address
0x25Aea8c84E138d2BAB058BcfBDCbd62d26544A18
Balance
0 ETH
Nonce
1
Code Size
1781 bytes
Creator
0xD5d935c2...2888 at tx 0x59a20c41...1b4a05
Indexed Transactions
0
Contract Bytecode
1781 bytes
0x5f3560e01c6002600d820660011b61069b01601e395f51565b63a7f0b3de811861064457346106975760206106b560403960206040f3610644565b6316f0115b811861005857346106975760206106d560403960206040f35b63c6e36a328118610644576044361034176106975760046004356020525f5260405f206024356020811161069757810190505460405260206040f3610644565b6388a8d60281186106445734610697575f5460405260206040f3610644565b63770817ec811861064457346106975760015460405260206040f3610644565b63efa9a1ad811861064457346106975760025460405260206040f3610644565b63661664068118610644576024361034176106975760036004356020525f5260405f205460405260206040f3610644565b63f3b4700d811861064457606436103417610697576004358060a01c6106975760405260056040516020525f5260405f20806024356020525f5260405f2090506044356020811161069757810190505460605260206060f3610644565b63c591aa9881186101cf57604436103417610697576004358060a01c6106975760405260066040516020525f5260405f20806024356020525f5260405f2090505460605260206060f35b63c764c59f811861064457602436103417610697576004358060a01c610697576040525f54331861069757604051156106975761020c606061066d565b606051610697576040516002556040517f602e8126584dd3551a170697ca62a8225945d42068a7ac49f200b7a60110aca95f6060a200610644565b63900cf0cf811861026757346106975760206102636040610648565b6040f35b63786370ba81186106445734610697576020610283604061066d565b6040f3610644565b63ce11f2bb811861059d5760443610341761069757600435600401602181351161069757803560208160051b0180836040375050506102cb6104a0610648565b6104a051610480526102de6104a061066d565b6104a05115610697576006336020525f5260405f2080610480516020525f5260405f209050546106975760206106d55f395f51630b36628d6104c05260206104c060046104dc845afa610333573d5f5f3e3d5ffd5b60203d10610697576104c09050516104a0526104a05115610697576104a05160018101818110610697579050604051116106975760025463f49ec3106104e052336105005260206104e060246104fc845afa610391573d5f5f3e3d5ffd5b60203d10610697576104e09050516104c0526104c05115610697576003610480516020525f5260405f2080546104c051808201828110610697579050905081555060016006336020525f5260405f2080610480516020525f5260405f209050555f6104e0525f6021905b8061050052604051610500511861041157610505565b610500516040518110156106975760051b6060015161042f576104fa565b610500516040518110156106975760051b606001516104c051808202811583838304141715610697579050905061271081049050610520526004610480516020525f5260405f20610500516020811161069757810190508054610520518082018281106106975790509050815550610520516005336020525f5260405f2080610480516020525f5260405f20905061050051602081116106975781019050556104e051610500516040518110156106975760051b6060015180820182811061069757905090506104e0525b6001018181186103fb575b50506127106104e051186106975733610480517fb24d2f234eb32f1ab65bfa873f22d4a592120770dad14bb7d817c6d12f60755360406104c05161050052806105205280610500015f6040518083528060051b5f826021811161069757801561058757905b8060051b606001518160051b60208801015260010181811861056a575b50508201602001915050905081019050610500a3005b63fd066ecc811861064457602436103417610697576004358060a01c610697576040525f543318610697576040516001556040517fe7b5cc087e6e47e33e86bdfe4720b7e849891938b18ff6e0c3f92299de79e60c5f6060a200610644565b63759be10c81186106445734610697576001543318610697575f600155335f55337fafe23f9e1f603b288748a507d5a993957e9f14313a5889d5a070851299939d595f6040a2005b5f5ffd5b4260206106b55f395f5180820382811161069757905090506224ea0081049050815250565b621baf7f4260206106b55f395f5180820382811161069757905090506224ea008106905011815250565b5f80fd018500b700d700180644064405fc009800f7028b0128003a02470000000000000000000000000000000000000000000000000000000064d428800000000000000000000000000ca1bd1301191576bea9b9afcfd4649dd1ba6822
Verified Source Code Partial Match
Compiler: v0.3.10+commit.91361694
Weightvote.vy 175 lines
# @version 0.3.10
"""
@title Weight vote
@author 0xkorin, Yearn Finance
@license GNU AGPLv3
@notice
Voting contract for weight redistribution.
Time is divided in 4 week epochs. In the final week of the epoch,
all users are able to vote on the current pool, as well as a 'blank' option,
indicating their desire to keep the composition unchanged.
A part of the weight of the assets in the pool is redistribution according to the vote distribution.
"""
interface Measure:
def vote_weight(_account: address) -> uint256: view
interface Pool:
def num_assets() -> uint256: view
genesis: public(immutable(uint256))
pool: public(immutable(address))
management: public(address)
pending_management: public(address)
measure: public(address)
total_votes: public(HashMap[uint256, uint256]) # epoch => total votes
votes: public(HashMap[uint256, uint256[33]]) # epoch => [blank vote, ..protocol votes..]
votes_user: public(HashMap[address, HashMap[uint256, uint256[33]]]) # user => epoch => [blank vote, ..protocol votes..]
voted: public(HashMap[address, HashMap[uint256, bool]]) # user => epoch => voted?
event Vote:
epoch: indexed(uint256)
account: indexed(address)
weight: uint256
votes: DynArray[uint256, 33]
event SetMeasure:
measure: indexed(address)
event PendingManagement:
management: indexed(address)
event SetManagement:
management: indexed(address)
WEEK: constant(uint256) = 7 * 24 * 60 * 60
EPOCH_LENGTH: constant(uint256) = 4 * WEEK
VOTE_LENGTH: constant(uint256) = WEEK
VOTE_START: constant(uint256) = EPOCH_LENGTH - VOTE_LENGTH
VOTE_SCALE: constant(uint256) = 10_000
@external
def __init__(_genesis: uint256, _pool: address, _measure: address):
"""
@notice Constructor
@param _genesis Timestamp of start of epoch 0
@param _pool Pool address
@param _measure Vote weight measure
"""
assert _genesis <= block.timestamp
assert _pool != empty(address)
assert _measure != empty(address)
genesis = _genesis
pool = _pool
self.management = msg.sender
self.measure = _measure
@external
@view
def epoch() -> uint256:
"""
@notice Get the current epoch
@return Current epoch
"""
return self._epoch()
@internal
@view
def _epoch() -> uint256:
"""
@notice Get the current epoch
"""
return (block.timestamp - genesis) / EPOCH_LENGTH
@external
@view
def vote_open() -> bool:
"""
@notice Query whether the vote period is currently open
@return True: vote period is open, False: vote period is closed
"""
return self._vote_open()
@internal
@view
def _vote_open() -> bool:
"""
@notice Query whether the vote period is currently open
"""
return (block.timestamp - genesis) % EPOCH_LENGTH >= VOTE_START
@external
def vote(_votes: DynArray[uint256, 33]):
"""
@notice
Vote for weight redistribution among the pool assets. The first entry
corresponds to a 'blank' vote, meaning no redistribution will be done.
Votes are in basispoints and must add to 100%
@param _votes List of votes in bps
"""
epoch: uint256 = self._epoch()
assert self._vote_open()
assert not self.voted[msg.sender][epoch]
n: uint256 = Pool(pool).num_assets()
assert n > 0
assert len(_votes) <= n + 1
weight: uint256 = Measure(self.measure).vote_weight(msg.sender)
assert weight > 0
self.total_votes[epoch] += weight
self.voted[msg.sender][epoch] = True
total: uint256 = 0
for i in range(33):
if i == len(_votes):
break
if _votes[i] == 0:
continue
votes: uint256 = _votes[i] * weight / VOTE_SCALE
self.votes[epoch][i] += votes
self.votes_user[msg.sender][epoch][i] = votes
total += _votes[i]
assert total == VOTE_SCALE
log Vote(epoch, msg.sender, weight, _votes)
@external
def set_measure(_measure: address):
"""
@notice Set vote weight measure contract
@param _measure New vote weight measure
"""
assert msg.sender == self.management
assert _measure != empty(address)
assert not self._vote_open()
self.measure = _measure
log SetMeasure(_measure)
@external
def set_management(_management: address):
"""
@notice
Set the pending management address.
Needs to be accepted by that account separately to transfer management over
@param _management New pending management address
"""
assert msg.sender == self.management
self.pending_management = _management
log PendingManagement(_management)
@external
def accept_management():
"""
@notice
Accept management role.
Can only be called by account previously marked as pending management by current management
"""
assert msg.sender == self.pending_management
self.pending_management = empty(address)
self.management = msg.sender
log SetManagement(msg.sender)
Read Contract
epoch 0x900cf0cf → uint256
genesis 0xa7f0b3de → uint256
management 0x88a8d602 → address
measure 0xefa9a1ad → address
pending_management 0x770817ec → address
pool 0x16f0115b → address
total_votes 0x66166406 → uint256
vote_open 0x786370ba → bool
voted 0xc591aa98 → bool
votes 0xc6e36a32 → uint256
votes_user 0xf3b4700d → uint256
Write Contract 4 functions
These functions modify contract state and require a wallet transaction to execute.
accept_management 0x759be10c
No parameters
set_management 0xfd066ecc
address _management
set_measure 0xc764c59f
address _measure
vote 0xce11f2bb
uint256[] _votes
Recent Transactions
No transactions found for this address