Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
Voting Adapter
Compiler Version
vyper:0.3.7
Contract Source Code (Vyper language format)
# @version 0.3.7 """ @title Voting Adapter @author Lido Finance @license GPL-3.0 @notice Used to allow voting with tokens under vesting """ from vyper.interfaces import ERC20 interface IDelegation: def setDelegate( _id: bytes32, _delegate: address, ): nonpayable interface IVoting: def vote( _voteId: uint256, _supports: bool, _executesIfDecided_deprecated: bool, ): nonpayable event ERC20Recovered: token: address amount: uint256 event ETHRecovered: amount: uint256 event OwnerChanged: owner: address VOTING_CONTRACT_ADDR: immutable(address) SNAPSHOT_DELEGATE_CONTRACT_ADDR: immutable(address) DELEGATION_CONTRACT_ADDR: immutable(address) owner: public(address) @external def __init__( voting_addr: address, snapshot_delegate_addr: address, delegation_addr: address, owner: address, ): """ @notice Initialize source contract implementation. @param voting_addr Address of the Voting contract @param snapshot_delegate_addr Address of the Shapshot Delegate contract @param delegation_addr Address of the voting power delegation contract @param owner Address to recover tokens and ether to """ assert owner != empty(address), "zero owner" assert voting_addr != empty(address), "zero voting_addr" assert snapshot_delegate_addr != empty( address ), "zero snapshot_delegate_addr" self.owner = owner VOTING_CONTRACT_ADDR = voting_addr SNAPSHOT_DELEGATE_CONTRACT_ADDR = snapshot_delegate_addr DELEGATION_CONTRACT_ADDR = delegation_addr @external @view def encode_aragon_vote_calldata(voteId: uint256, supports: bool) -> Bytes[1000]: """ @notice Encode calldata for use in VestingEscrow. Returns type is Bytes[1000] to be compatible with up to 30 agrs @param voteId Id of the vote @param supports Support flag true - yea, false - nay """ return _abi_encode(voteId, supports) @external def aragon_vote(abi_encoded_params: Bytes[1000]): """ @notice Cast vote on Aragon voting @param abi_encoded_params Abi encoded data for call. Can be obtained from encode_aragon_vote_calldata """ vote_id: uint256 = empty(uint256) supports: bool = empty(bool) vote_id, supports = _abi_decode (abi_encoded_params, (uint256, bool)) IVoting(VOTING_CONTRACT_ADDR).vote( vote_id, supports, False ) # dev: third arg is deprecated @external @view def encode_snapshot_set_delegate_calldata(delegate: address) -> Bytes[1000]: """ @notice Encode calldata for use in VestingEscrow. Returns type is Bytes[1000] to be compatible with up to 30 agrs @param delegate Address of the delegate """ return _abi_encode(delegate) @external def snapshot_set_delegate(abi_encoded_params: Bytes[1000]): """ @notice Delegate Snapshot voting power of all available tokens @param abi_encoded_params Abi encoded data for call. Can be obtained from encode_snapshot_set_delegate_calldata """ delegate: address = empty(address) delegate = _abi_decode (abi_encoded_params, (address)) IDelegation(SNAPSHOT_DELEGATE_CONTRACT_ADDR).setDelegate( empty(bytes32), delegate ) # dev: null id allows voting at any snapshot space @external @view def encode_delegate_calldata(delegate: address) -> Bytes[1000]: """ @notice Encode calldata for use in VestingEscrow. Returns type is Bytes[1000] to be compatible with up to 30 agrs @param delegate Address of the delegate """ return _abi_encode(delegate) @external def delegate(abi_encoded_params: Bytes[1000]): """ @notice Delegate voting power of all available tokens @param abi_encoded_params Abi encoded data for call. Can be obtained from encode_delegate_calldata """ assert False, "not implemented" @external @view def voting_contract_addr() -> address: return VOTING_CONTRACT_ADDR @external @view def snapshot_delegate_contract_addr() -> address: return SNAPSHOT_DELEGATE_CONTRACT_ADDR @external @view def delegation_contract_addr() -> address: return DELEGATION_CONTRACT_ADDR @external def change_owner(owner: address): """ @notice Change contract owner. @param owner Address of the new owner. Must be non-zero. """ self._check_sender_is_owner() assert owner != empty(address), "zero owner address" self.owner = owner log OwnerChanged(owner) @external def recover_erc20(token: address, amount: uint256): """ @notice Recover ERC20 tokens to owner @param token Address of the ERC20 token to be recovered """ if amount != 0: assert ERC20(token).transfer( self.owner, amount, default_return_value=True ), "transfer failed" log ERC20Recovered(token, amount) @external def recover_ether(): """ @notice Recover Ether to owner """ amount: uint256 = self.balance if amount != 0: self._safe_send_ether(self.owner, amount) log ETHRecovered(amount) @internal def _check_sender_is_owner(): assert msg.sender == self.owner, "msg.sender not owner" @internal def _safe_send_ether(_to: address, _value: uint256): """ @notice Overcome 2300 gas limit on simple send """ _response: Bytes[32] = raw_call( _to, empty(bytes32), value=_value, max_outsize=32 ) if len(_response) > 0: assert convert(_response, bool), "ETH transfer failed"
[{"name":"ERC20Recovered","inputs":[{"name":"token","type":"address","indexed":false},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"ETHRecovered","inputs":[{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"OwnerChanged","inputs":[{"name":"owner","type":"address","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"voting_addr","type":"address"},{"name":"snapshot_delegate_addr","type":"address"},{"name":"delegation_addr","type":"address"},{"name":"owner","type":"address"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"encode_aragon_vote_calldata","inputs":[{"name":"voteId","type":"uint256"},{"name":"supports","type":"bool"}],"outputs":[{"name":"","type":"bytes"}]},{"stateMutability":"nonpayable","type":"function","name":"aragon_vote","inputs":[{"name":"abi_encoded_params","type":"bytes"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"encode_snapshot_set_delegate_calldata","inputs":[{"name":"delegate","type":"address"}],"outputs":[{"name":"","type":"bytes"}]},{"stateMutability":"nonpayable","type":"function","name":"snapshot_set_delegate","inputs":[{"name":"abi_encoded_params","type":"bytes"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"encode_delegate_calldata","inputs":[{"name":"delegate","type":"address"}],"outputs":[{"name":"","type":"bytes"}]},{"stateMutability":"nonpayable","type":"function","name":"delegate","inputs":[{"name":"abi_encoded_params","type":"bytes"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"voting_contract_addr","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"snapshot_delegate_contract_addr","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"delegation_contract_addr","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"nonpayable","type":"function","name":"change_owner","inputs":[{"name":"owner","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"recover_erc20","inputs":[{"name":"token","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"recover_ether","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address"}]}]
Contract Creation Code
60206109596000396000518060a01c6109545760405260206109796000396000518060a01c6109545760605260206109996000396000518060a01c6109545760805260206109b96000396000518060a01c6109545760a052346109545760a0516100c057600a60c0527f7a65726f206f776e65720000000000000000000000000000000000000000000060e05260c05060c0518060e001601f826000031636823750506308c379a0608052602060a052601f19601f60c0510116604401609cfd5b60405161012457601060c0527f7a65726f20766f74696e675f616464720000000000000000000000000000000060e05260c05060c0518060e001601f826000031636823750506308c379a0608052602060a052601f19601f60c0510116604401609cfd5b60605161018857601b60c0527f7a65726f20736e617073686f745f64656c65676174655f61646472000000000060e05260c05060c0518060e001601f826000031636823750506308c379a0608052602060a052601f19601f60c0510116604401609cfd5b60a05160005560405161079e526060516107be526080516107de5261079e6101b5610000396107fe610000f36003361161000c5761065a565b60003560e01c3461078c57636038c001811861009a576044361061078c576024358060011c61078c5760405260208060c05260043560805260405160a052604060605260608160c001815180825260208301602083018281848460045afa505050508051806020830101601f82600003163682375050601f19601f82516020010116905090508101905060c0f35b63412f3121811861014c576044361061078c576004356004016103e881351161078c578035806040526020820181816060375050506040366104603760406040511861078c57606080516104605260208101518060011c61078c576104805250602061079e60003960005163df133bca6104a052610460516104c052610480516104e052600061050052803b1561078c5760006104a060646104bc6000855af1610149573d600060003e3d6000fd5b50005b630c4a0d0781186101c4576024361061078c576004358060a01c61078c5760405260208060a052604051608052602060605260608160a00181518082526020830160208301815181525050508051806020830101601f82600003163682375050601f19601f82516020010116905090508101905060a0f35b63862e69708118610262576044361061078c576004356004016103e881351161078c5780358060405260208201818160603750505060006104605260206040511861078c576060518060a01c61078c576104605260206107be60003960005163bd86e5086104805260006104a052610460516104c052803b1561078c576000610480604461049c6000855af161025f573d600060003e3d6000fd5b50005b63b2ac5c0381186102da576024361061078c576004358060a01c61078c5760405260208060a052604051608052602060605260608160a00181518082526020830160208301815181525050508051806020830101601f82600003163682375050601f19601f82516020010116905090508101905060a0f35b630ccfac9e8118610375576044361061078c576004356004016103e881351161078c57803580604052602082018181606037505050600f610460527f6e6f7420696d706c656d656e74656400000000000000000000000000000000006104805261046050610460518061048001601f826000031636823750506308c379a061042052602061044052601f19601f61046051011660440161043cfd5b63bdd2198d811861039c576004361061078c57602061079e60003960005160405260206040f35b63b4d10efe81186103c3576004361061078c5760206107be60003960005160405260206040f35b630d4f19e581186103ea576004361061078c5760206107de60003960005160405260206040f35b63253c8bd481186104ab576024361061078c576004358060a01c61078c57608052610413610660565b60805161047757601260a0527f7a65726f206f776e65722061646472657373000000000000000000000000000060c05260a05060a0518060c001601f826000031636823750506308c379a06060526020608052601f19601f60a0510116604401607cfd5b6080516000557fa2ea9883a321a3e97b8266c2b078bfeec6d50c711ed71f874a90d500ae2eaf3660805160a052602060a0a1005b6323a50d3c81186105d1576044361061078c576004358060a01c61078c57604052602435156105cf5760405163a9059cbb60605260005460805260243560a052602060606044607c6000855af1610507573d600060003e3d6000fd5b3d61051d57803b1561078c57600160c052610534565b60203d1061078c576060518060011c61078c5760c0525b60c090505161059c57600f60e0527f7472616e73666572206661696c656400000000000000000000000000000000006101005260e05060e0518061010001601f826000031636823750506308c379a060a052602060c052601f19601f60e051011660440160bcfd5b7f505b28e6941631badc363841ecbf8e1214b9379c643936458e87be718e15799960405160605260243560805260406060a15b005b63644613468118610639576004361061078c574761012052610120511561063757600054604052610120516060526106076106c9565b7f0296f2c4dbc8c0e53c0ffab63f84aeebd5c28aa143475a37346bf15ac003f32761012051610140526020610140a15b005b638da5cb5b8118610658576004361061078c5760005460405260206040f35b505b60006000fd5b6000543318156106c75760146040527f6d73672e73656e646572206e6f74206f776e657200000000000000000000000060605260405060405180606001601f826000031636823750506308c379a06000526020602052601f19601f6040510116604401601cfd5b565b600060c05260c050602061010060c05160e06060516040515af16106f2573d600060003e3d6000fd5b3d602081183d602010021860e05260e080518060805260208201805160a0525050506080511561078a5760a05160805160200360031b1c61078a57601360c0527f455448207472616e73666572206661696c65640000000000000000000000000060e05260c05060c0518060e001601f826000031636823750506308c379a0608052602060a052601f19601f60c0510116604401609cfd5b565b600080fda165767970657283000307000b005b600080fd000000000000000000000000da7d2573df555002503f29aa4003e398d28cc00f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e92329ec7ddb11d25e25b3c21eebf11f15eb325d
Deployed Bytecode
0x6003361161000c5761065a565b60003560e01c3461078c57636038c001811861009a576044361061078c576024358060011c61078c5760405260208060c05260043560805260405160a052604060605260608160c001815180825260208301602083018281848460045afa505050508051806020830101601f82600003163682375050601f19601f82516020010116905090508101905060c0f35b63412f3121811861014c576044361061078c576004356004016103e881351161078c578035806040526020820181816060375050506040366104603760406040511861078c57606080516104605260208101518060011c61078c576104805250602061079e60003960005163df133bca6104a052610460516104c052610480516104e052600061050052803b1561078c5760006104a060646104bc6000855af1610149573d600060003e3d6000fd5b50005b630c4a0d0781186101c4576024361061078c576004358060a01c61078c5760405260208060a052604051608052602060605260608160a00181518082526020830160208301815181525050508051806020830101601f82600003163682375050601f19601f82516020010116905090508101905060a0f35b63862e69708118610262576044361061078c576004356004016103e881351161078c5780358060405260208201818160603750505060006104605260206040511861078c576060518060a01c61078c576104605260206107be60003960005163bd86e5086104805260006104a052610460516104c052803b1561078c576000610480604461049c6000855af161025f573d600060003e3d6000fd5b50005b63b2ac5c0381186102da576024361061078c576004358060a01c61078c5760405260208060a052604051608052602060605260608160a00181518082526020830160208301815181525050508051806020830101601f82600003163682375050601f19601f82516020010116905090508101905060a0f35b630ccfac9e8118610375576044361061078c576004356004016103e881351161078c57803580604052602082018181606037505050600f610460527f6e6f7420696d706c656d656e74656400000000000000000000000000000000006104805261046050610460518061048001601f826000031636823750506308c379a061042052602061044052601f19601f61046051011660440161043cfd5b63bdd2198d811861039c576004361061078c57602061079e60003960005160405260206040f35b63b4d10efe81186103c3576004361061078c5760206107be60003960005160405260206040f35b630d4f19e581186103ea576004361061078c5760206107de60003960005160405260206040f35b63253c8bd481186104ab576024361061078c576004358060a01c61078c57608052610413610660565b60805161047757601260a0527f7a65726f206f776e65722061646472657373000000000000000000000000000060c05260a05060a0518060c001601f826000031636823750506308c379a06060526020608052601f19601f60a0510116604401607cfd5b6080516000557fa2ea9883a321a3e97b8266c2b078bfeec6d50c711ed71f874a90d500ae2eaf3660805160a052602060a0a1005b6323a50d3c81186105d1576044361061078c576004358060a01c61078c57604052602435156105cf5760405163a9059cbb60605260005460805260243560a052602060606044607c6000855af1610507573d600060003e3d6000fd5b3d61051d57803b1561078c57600160c052610534565b60203d1061078c576060518060011c61078c5760c0525b60c090505161059c57600f60e0527f7472616e73666572206661696c656400000000000000000000000000000000006101005260e05060e0518061010001601f826000031636823750506308c379a060a052602060c052601f19601f60e051011660440160bcfd5b7f505b28e6941631badc363841ecbf8e1214b9379c643936458e87be718e15799960405160605260243560805260406060a15b005b63644613468118610639576004361061078c574761012052610120511561063757600054604052610120516060526106076106c9565b7f0296f2c4dbc8c0e53c0ffab63f84aeebd5c28aa143475a37346bf15ac003f32761012051610140526020610140a15b005b638da5cb5b8118610658576004361061078c5760005460405260206040f35b505b60006000fd5b6000543318156106c75760146040527f6d73672e73656e646572206e6f74206f776e657200000000000000000000000060605260405060405180606001601f826000031636823750506308c379a06000526020602052601f19601f6040510116604401601cfd5b565b600060c05260c050602061010060c05160e06060516040515af16106f2573d600060003e3d6000fd5b3d602081183d602010021860e05260e080518060805260208201805160a0525050506080511561078a5760a05160805160200360031b1c61078a57601360c0527f455448207472616e73666572206661696c65640000000000000000000000000060e05260c05060c0518060e001601f826000031636823750506308c379a0608052602060a052601f19601f60c0510116604401609cfd5b565b600080fda165767970657283000307000b000000000000000000000000da7d2573df555002503f29aa4003e398d28cc00f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000da7d2573df555002503f29aa4003e398d28cc00f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e92329ec7ddb11d25e25b3c21eebf11f15eb325d
-----Decoded View---------------
Arg [0] : voting_addr (address): 0xdA7d2573Df555002503F29aA4003e398d28cc00f
Arg [1] : snapshot_delegate_addr (address): 0x0000000000000000000000000000000000000001
Arg [2] : delegation_addr (address): 0x0000000000000000000000000000000000000000
Arg [3] : owner (address): 0xE92329EC7ddB11D25e25b3c21eeBf11f15eB325d
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000da7d2573df555002503f29aa4003e398d28cc00f
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 000000000000000000000000e92329ec7ddb11d25e25b3c21eebf11f15eb325d
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.