Contract 0xC20129f1dd4DFeD023a6d6A8de9d54A7b61af5CC 11
My Name Tag:
Not Available
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Source Code Verified (Exact Match)
Contract Name:
Vyper_contract
Compiler Version
vyper:0.3.7
Contract Source Code (Vyper language format)
# @version 0.3.7 # @notice Wrapper contract for the Curve Liquidity Gauge. # @author bulbozaur <[email protected]> # @license MIT from vyper.interfaces import ERC20 struct Reward: distributor: address period_finish: uint256 rate: uint256 last_update: uint256 integral: uint256 interface LiquidityGauge: def reward_data(addr: address) -> Reward: view def deposit_reward_token(_reward_token: address, _amount: uint256): nonpayable def set_reward_distributor(_reward_token: address, _distributor: address): nonpayable event RewardsContractTransferred: newDistributor: indexed(address) event WeeklyRewardsAmountUpdated: newWeeklyRewardsAmount: uint256 event NewRewardsPeriodStarted: amount: uint256 event ERC20Recovered: token: indexed(address) amount: uint256 recipient: indexed(address) weekly_amount: public(uint256) rewards_iteration: public(uint256) min_rewards_amount: immutable(uint256) owner: immutable(address) rewards_contract: immutable(address) rewards_token: immutable(address) SECONDS_PER_WEEK: constant(uint256) = 7 * 24 * 60 * 60 WEEKS_PER_PERIOD: constant(uint256) = 4 @external def __init__( _owner: address, _min_rewards_amount: uint256, _rewards_contract: address, _rewards_token: address ): owner = _owner min_rewards_amount = _min_rewards_amount rewards_contract = _rewards_contract rewards_token = _rewards_token @view @external def owner() -> address: return owner @view @external def rewards_contract() -> address: return rewards_contract @view @external def rewards_token() -> address: return rewards_token @view @internal def _curve_period_finish() -> uint256: reward_data: Reward = LiquidityGauge(rewards_contract).reward_data(rewards_token) return reward_data.period_finish @view @internal def _is_curve_rewards_period_finished() -> bool: return block.timestamp >= self._curve_period_finish() @external def start_next_rewards_period(): """ @notice Starts the next rewards period of duration `rewards_contract.deposit_reward_token(address, uint256)`, distributing `self.weekly_amount` tokens throughout each week of the period. The current rewards period must be finished by this time and rewards token balance not lower than `self.weekly_amount`. Once per 4 calls recalculates `self.weekly_amount` based on self rewards token balance. Balance required not to be lower than `min_rewards_amount` """ amount: uint256 = ERC20(rewards_token).balanceOf(self) iteration: uint256 = self.rewards_iteration rewards_amount: uint256 = 0 assert self._is_curve_rewards_period_finished(), "manager: rewards period not finished" if iteration == 0: assert amount >= min_rewards_amount, "manager: low balance" rewards_amount = amount / WEEKS_PER_PERIOD self.weekly_amount = rewards_amount log WeeklyRewardsAmountUpdated(rewards_amount) else: rewards_amount = self.weekly_amount assert rewards_amount > 0, "manager: rewards disabled" assert amount >= rewards_amount, "manager: low balance" self.rewards_iteration = (iteration + 1) % WEEKS_PER_PERIOD ERC20(rewards_token).approve(rewards_contract, rewards_amount) LiquidityGauge(rewards_contract).deposit_reward_token(rewards_token, rewards_amount) log NewRewardsPeriodStarted(rewards_amount) @view @internal def _period_finish() -> uint256: return self._curve_period_finish() + \ ((WEEKS_PER_PERIOD - self.rewards_iteration) % WEEKS_PER_PERIOD) * SECONDS_PER_WEEK @view @external def period_finish() -> uint256: """ @notice Returns end of the rewards period of LiquidityGauge contract """ return self._period_finish() @view @external def is_rewards_period_finished() -> bool: """ @notice Whether the current rewards period has finished. """ return block.timestamp >= self._period_finish() @view @external def curve_period_finish() -> uint256: return self._curve_period_finish() @view @external def is_curve_rewards_period_finished() -> bool: return self._is_curve_rewards_period_finished() @external def replace_me_by_other_distributor(_to: address): """ @notice Changes the reward contracts distributor. Can only be called by the current owner. """ assert msg.sender == owner, "not permitted" assert _to != ZERO_ADDRESS, "zero address not allowed" LiquidityGauge(rewards_contract).set_reward_distributor(rewards_token, _to) log RewardsContractTransferred(_to) @internal def _safe_transfer(_token: address, _to: address, _value: uint256) -> bool: """ @notice Used to solve Vyper SafeERC20 issue https://github.com/vyperlang/vyper/issues/2202 """ _response: Bytes[32] = raw_call( _token, concat( method_id("transfer(address,uint256)"), convert(_to, bytes32), convert(_value, bytes32) ), max_outsize=32 ) if len(_response) > 0: assert convert(_response, bool), "Transfer failed!" return True @external def recover_erc20(_token: address, _amount: uint256, _recipient: address = msg.sender): """ @notice Transfers the given _amount of the given ERC20 token from self to the recipient. Can only be called by the owner. """ assert msg.sender == owner, "not permitted" assert _recipient != ZERO_ADDRESS, "zero address not allowed" if _amount != 0: self._safe_transfer(_token, _recipient, _amount) log ERC20Recovered(_token, _amount, _recipient)
[{"name":"RewardsContractTransferred","inputs":[{"name":"newDistributor","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"WeeklyRewardsAmountUpdated","inputs":[{"name":"newWeeklyRewardsAmount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"NewRewardsPeriodStarted","inputs":[{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"ERC20Recovered","inputs":[{"name":"token","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false},{"name":"recipient","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_owner","type":"address"},{"name":"_min_rewards_amount","type":"uint256"},{"name":"_rewards_contract","type":"address"},{"name":"_rewards_token","type":"address"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"rewards_contract","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"rewards_token","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"nonpayable","type":"function","name":"start_next_rewards_period","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"period_finish","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"is_rewards_period_finished","inputs":[],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"curve_period_finish","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"is_curve_rewards_period_finished","inputs":[],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"replace_me_by_other_distributor","inputs":[{"name":"_to","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_erc20","inputs":[{"name":"_token","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_recipient","type":"address"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"weekly_amount","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"rewards_iteration","inputs":[],"outputs":[{"name":"","type":"uint256"}]}]
Contract Creation Code
6020610b026000396000518060a01c610afd576040526020610b426000396000518060a01c610afd576060526020610b626000396000518060a01c610afd5760805234610afd57604051610aa0526020610b22600039600051610a8052606051610ac052608051610ae052610a8061007c61000039610b00610000f36003361161000c5761082b565b60003560e01c34610a6e57638da5cb5b811861003e5760043610610a6e576020610aa060003960005160405260206040f35b638d786e8781186100655760043610610a6e576020610ac060003960005160405260206040f35b63eaf71e00811861008c5760043610610a6e576020610ae060003960005160405260206040f35b63d8b3a01e81186104495760043610610a6e576020610ae06000396000516370a0823161028052306102a0526020610280602461029c845afa6100d4573d600060003e3d6000fd5b60203d10610a6e57610280905051610260526001546102805260006102a0526100fe6102c06108d7565b6102c0516101915760246102e0527f6d616e616765723a207265776172647320706572696f64206e6f742066696e69610300527f7368656400000000000000000000000000000000000000000000000000000000610320526102e0506102e0518061030001601f826000031636823750506308c379a06102a05260206102c052601f19601f6102e05101166044016102bcfd5b6102805161025d576020610a806000396000516102605110156102145760146102c0527f6d616e616765723a206c6f772062616c616e63650000000000000000000000006102e0526102c0506102c051806102e001601f826000031636823750506308c379a06102805260206102a052601f19601f6102c051011660440161029cfd5b610260518060021c90506102a0526102a0516000557f0d243350ade876635a8814de0509b3b8b3e6dffcd62061b1bed0953d7fb453d66102a0516102c05260206102c0a1610265565b6000546102a0525b6102a0516102d35760196102c0527f6d616e616765723a20726577617264732064697361626c6564000000000000006102e0526102c0506102c051806102e001601f826000031636823750506308c379a06102805260206102a052601f19601f6102c051011660440161029cfd5b6102a0516102605110156103475760146102c0527f6d616e616765723a206c6f772062616c616e63650000000000000000000000006102e0526102c0506102c051806102e001601f826000031636823750506308c379a06102805260206102a052601f19601f6102c051011660440161029cfd5b6102805160018101818110610a6e5790506003811690506001556020610ae060003960005163095ea7b36102c0526020610ac06000396000516102e0526102a0516103005260206102c060446102dc6000855af16103aa573d600060003e3d6000fd5b60203d10610a6e576102c0518060011c610a6e576103205261032050506020610ac06000396000516393f7aa676102c0526020610ae06000396000516102e0526102a05161030052803b15610a6e5760006102c060446102dc6000855af1610417573d600060003e3d6000fd5b507f103ebec0d13e01678ae654f7e3be6498829b977988ef5a9a6f1d8a9fff5ef08c6102a0516102c05260206102c0a1005b6390710647811861046e5760043610610a6e5760206104696102606108ee565b610260f35b6386ef0e5e811861049e5760043610610a6e5761048c6102606108ee565b61026051421015610280526020610280f35b6341ac365f81186104c35760043610610a6e5760206104be610240610831565b610240f35b632c129e8981186104e85760043610610a6e5760206104e36102606108d7565b610260f35b63463c6ad181186106525760243610610a6e576004358060a01c610a6e576040526020610aa060003960005133181561057857600d6060527f6e6f74207065726d69747465640000000000000000000000000000000000000060805260605060605180608001601f826000031636823750506308c379a06020526020604052601f19601f6060510116604401603cfd5b6040516105dc5760186060527f7a65726f2061646472657373206e6f7420616c6c6f776564000000000000000060805260605060605180608001601f826000031636823750506308c379a06020526020604052601f19601f6060510116604401603cfd5b6020610ac060003960005163058a3a246060526020610ae060003960005160805260405160a052803b15610a6e57600060606044607c6000855af1610626573d600060003e3d6000fd5b506040517ff4f0b3991cf2de2d32a1e5a8d0dfec953b7b10d7d938a78bb9a82b1341841b5760006060a2005b6323a50d3c811861066f5760443610610a6e573361020052610692565b63edd885b481186107eb5760643610610a6e576044358060a01c610a6e57610200525b6004358060a01c610a6e576101e0526020610aa060003960005133181561071957600d610220527f6e6f74207065726d6974746564000000000000000000000000000000000000006102405261022050610220518061024001601f826000031636823750506308c379a06101e052602061020052601f19601f6102205101166044016101fcfd5b61020051610787576018610220527f7a65726f2061646472657373206e6f7420616c6c6f77656400000000000000006102405261022050610220518061024001601f826000031636823750506308c379a06101e052602061020052601f19601f6102205101166044016101fcfd5b602435156107e9576101e051604052610200516060526024356080526107ae61022061093b565b61022050610200516101e0517f8619312ed4eff1cf9f0116e6db2f49d9570a86f0350d1c5ad1bd0f7b0cf9e132602435610220526020610220a35b005b632c71fc6f811861080a5760043610610a6e5760005460405260206040f35b63106f6b8d81186108295760043610610a6e5760015460405260206040f35b505b60006000fd5b6020610ac06000396000516348e9c65e60e0526020610ae06000396000516101005260a060e0602460fc845afa61086d573d600060003e3d6000fd5b60a03d10610a6e5760e0518060a01c610a6e576101a052610100516101c052610120516101e052610140516102005261016051610220526101a09050805160405260208101516060526040810151608052606081015160a052608081015160c05250606051815250565b6108e2610240610831565b61024051421015815250565b6108f9610240610831565b610240516001548060040360048111610a6e57905060038116905062093a8081028162093a80820418610a6e579050808201828110610a6e5790509050815250565b6000600460e0527fa9059cbb000000000000000000000000000000000000000000000000000000006101005260e08051602082018361014001815181525050808301925050506060518161014001526020810190506080518161014001526020810190508061012052610120505060206101c06101205161014060006040515af16109cb573d600060003e3d6000fd5b3d602081183d60201002186101a0526101a080518060a05260208201805160c05250505060a05115610a675760c05160a05160200360031b1c610a6757601060e0527f5472616e73666572206661696c656421000000000000000000000000000000006101005260e05060e0518061010001601f826000031636823750506308c379a060a052602060c052601f19601f60e051011660440160bcfd5b6001815250565b600080fda165767970657283000307000b005b600080fd0000000000000000000000008c2b8595ea1b627427efe4f29a64b145df439d160000000000000000000000000000000000000000000000a2a15d09519be00000000000000000000000000000098ef55011b6b8c99845128114a9d9159777d69700000000000000000000000013ad51ed4f1b7e9dc168d8a00cb3f4ddd85efa60
Deployed Bytecode
0x6003361161000c5761082b565b60003560e01c34610a6e57638da5cb5b811861003e5760043610610a6e576020610aa060003960005160405260206040f35b638d786e8781186100655760043610610a6e576020610ac060003960005160405260206040f35b63eaf71e00811861008c5760043610610a6e576020610ae060003960005160405260206040f35b63d8b3a01e81186104495760043610610a6e576020610ae06000396000516370a0823161028052306102a0526020610280602461029c845afa6100d4573d600060003e3d6000fd5b60203d10610a6e57610280905051610260526001546102805260006102a0526100fe6102c06108d7565b6102c0516101915760246102e0527f6d616e616765723a207265776172647320706572696f64206e6f742066696e69610300527f7368656400000000000000000000000000000000000000000000000000000000610320526102e0506102e0518061030001601f826000031636823750506308c379a06102a05260206102c052601f19601f6102e05101166044016102bcfd5b6102805161025d576020610a806000396000516102605110156102145760146102c0527f6d616e616765723a206c6f772062616c616e63650000000000000000000000006102e0526102c0506102c051806102e001601f826000031636823750506308c379a06102805260206102a052601f19601f6102c051011660440161029cfd5b610260518060021c90506102a0526102a0516000557f0d243350ade876635a8814de0509b3b8b3e6dffcd62061b1bed0953d7fb453d66102a0516102c05260206102c0a1610265565b6000546102a0525b6102a0516102d35760196102c0527f6d616e616765723a20726577617264732064697361626c6564000000000000006102e0526102c0506102c051806102e001601f826000031636823750506308c379a06102805260206102a052601f19601f6102c051011660440161029cfd5b6102a0516102605110156103475760146102c0527f6d616e616765723a206c6f772062616c616e63650000000000000000000000006102e0526102c0506102c051806102e001601f826000031636823750506308c379a06102805260206102a052601f19601f6102c051011660440161029cfd5b6102805160018101818110610a6e5790506003811690506001556020610ae060003960005163095ea7b36102c0526020610ac06000396000516102e0526102a0516103005260206102c060446102dc6000855af16103aa573d600060003e3d6000fd5b60203d10610a6e576102c0518060011c610a6e576103205261032050506020610ac06000396000516393f7aa676102c0526020610ae06000396000516102e0526102a05161030052803b15610a6e5760006102c060446102dc6000855af1610417573d600060003e3d6000fd5b507f103ebec0d13e01678ae654f7e3be6498829b977988ef5a9a6f1d8a9fff5ef08c6102a0516102c05260206102c0a1005b6390710647811861046e5760043610610a6e5760206104696102606108ee565b610260f35b6386ef0e5e811861049e5760043610610a6e5761048c6102606108ee565b61026051421015610280526020610280f35b6341ac365f81186104c35760043610610a6e5760206104be610240610831565b610240f35b632c129e8981186104e85760043610610a6e5760206104e36102606108d7565b610260f35b63463c6ad181186106525760243610610a6e576004358060a01c610a6e576040526020610aa060003960005133181561057857600d6060527f6e6f74207065726d69747465640000000000000000000000000000000000000060805260605060605180608001601f826000031636823750506308c379a06020526020604052601f19601f6060510116604401603cfd5b6040516105dc5760186060527f7a65726f2061646472657373206e6f7420616c6c6f776564000000000000000060805260605060605180608001601f826000031636823750506308c379a06020526020604052601f19601f6060510116604401603cfd5b6020610ac060003960005163058a3a246060526020610ae060003960005160805260405160a052803b15610a6e57600060606044607c6000855af1610626573d600060003e3d6000fd5b506040517ff4f0b3991cf2de2d32a1e5a8d0dfec953b7b10d7d938a78bb9a82b1341841b5760006060a2005b6323a50d3c811861066f5760443610610a6e573361020052610692565b63edd885b481186107eb5760643610610a6e576044358060a01c610a6e57610200525b6004358060a01c610a6e576101e0526020610aa060003960005133181561071957600d610220527f6e6f74207065726d6974746564000000000000000000000000000000000000006102405261022050610220518061024001601f826000031636823750506308c379a06101e052602061020052601f19601f6102205101166044016101fcfd5b61020051610787576018610220527f7a65726f2061646472657373206e6f7420616c6c6f77656400000000000000006102405261022050610220518061024001601f826000031636823750506308c379a06101e052602061020052601f19601f6102205101166044016101fcfd5b602435156107e9576101e051604052610200516060526024356080526107ae61022061093b565b61022050610200516101e0517f8619312ed4eff1cf9f0116e6db2f49d9570a86f0350d1c5ad1bd0f7b0cf9e132602435610220526020610220a35b005b632c71fc6f811861080a5760043610610a6e5760005460405260206040f35b63106f6b8d81186108295760043610610a6e5760015460405260206040f35b505b60006000fd5b6020610ac06000396000516348e9c65e60e0526020610ae06000396000516101005260a060e0602460fc845afa61086d573d600060003e3d6000fd5b60a03d10610a6e5760e0518060a01c610a6e576101a052610100516101c052610120516101e052610140516102005261016051610220526101a09050805160405260208101516060526040810151608052606081015160a052608081015160c05250606051815250565b6108e2610240610831565b61024051421015815250565b6108f9610240610831565b610240516001548060040360048111610a6e57905060038116905062093a8081028162093a80820418610a6e579050808201828110610a6e5790509050815250565b6000600460e0527fa9059cbb000000000000000000000000000000000000000000000000000000006101005260e08051602082018361014001815181525050808301925050506060518161014001526020810190506080518161014001526020810190508061012052610120505060206101c06101205161014060006040515af16109cb573d600060003e3d6000fd5b3d602081183d60201002186101a0526101a080518060a05260208201805160c05250505060a05115610a675760c05160a05160200360031b1c610a6757601060e0527f5472616e73666572206661696c656421000000000000000000000000000000006101005260e05060e0518061010001601f826000031636823750506308c379a060a052602060c052601f19601f60e051011660440160bcfd5b6001815250565b600080fda165767970657283000307000b0000000000000000000000000000000000000000000000a2a15d09519be000000000000000000000000000008c2b8595ea1b627427efe4f29a64b145df439d16000000000000000000000000098ef55011b6b8c99845128114a9d9159777d69700000000000000000000000013ad51ed4f1b7e9dc168d8a00cb3f4ddd85efa60
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000008c2b8595ea1b627427efe4f29a64b145df439d160000000000000000000000000000000000000000000000a2a15d09519be00000000000000000000000000000098ef55011b6b8c99845128114a9d9159777d69700000000000000000000000013ad51ed4f1b7e9dc168d8a00cb3f4ddd85efa60
-----Decoded View---------------
Arg [0] : _owner (address): 0x8C2b8595eA1b627427EFE4f29A64b145DF439d16
Arg [1] : _min_rewards_amount (uint256): 3000000000000000000000
Arg [2] : _rewards_contract (address): 0x098EF55011B6B8c99845128114A9D9159777d697
Arg [3] : _rewards_token (address): 0x13Ad51ed4F1B7e9Dc168d8a00cB3f4dDD85EfA60
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000008c2b8595ea1b627427efe4f29a64b145df439d16
Arg [1] : 0000000000000000000000000000000000000000000000a2a15d09519be00000
Arg [2] : 000000000000000000000000098ef55011b6b8c99845128114a9d9159777d697
Arg [3] : 00000000000000000000000013ad51ed4f1b7e9dc168d8a00cb3f4ddd85efa60
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.