Address Contract Partially Verified
Address
0x731A2572B1Cf56cFB804c74555715C8c8B5E980b
Balance
0 ETH
Nonce
1
Code Size
9786 bytes
Creator
0x7cbB62Ea...FAa4 at tx 0x79331567...b791e9
Indexed Transactions
0
Contract Bytecode
9786 bytes
0x608060405234801561001057600080fd5b50600436106102925760003560e01c806378a2b08711610160578063c2e72954116100d8578063eea3cd851161008c578063f7c618c111610071578063f7c618c1146105f6578063fce5f8df1461061d578063ff4a768a1461062a57600080fd5b8063eea3cd85146105d0578063f2fde38b146105e357600080fd5b8063d6eb1bbf116100bd578063d6eb1bbf14610561578063dd62ed3e14610584578063e42f8dcc146105bd57600080fd5b8063c2e7295414610527578063c89039c51461053a57600080fd5b806395d89b411161012f578063a9059cbb11610114578063a9059cbb14610482578063b02c43d014610495578063b35611f41461051457600080fd5b806395d89b4114610467578063a457c2d71461046f57600080fd5b806378a2b0871461041f5780637a5f0f181461043257806388c0f32b1461043a5780638da5cb5b1461044257600080fd5b8063313ce5671161020e5780634dfc3ff5116101c25780635ca662a4116101a75780635ca662a4146103dc57806370a08231146103ee578063715018a61461041757600080fd5b80634dfc3ff5146103c057806358eb9700146103c957600080fd5b806340bd2e23116101f357806340bd2e2314610387578063441a3e701461039a57806346573115146103ad57600080fd5b8063313ce56714610365578063395093511461037457600080fd5b806318160ddd1161026557806325141d681161024a57806325141d68146103295780632d5f3faf1461033c5780632dfdf0b51461035c57600080fd5b806318160ddd1461030e57806323b872dd1461031657600080fd5b806306fdde0314610297578063095ea7b3146102b55780630ba49d87146102d85780630dc85ece146102f9575b600080fd5b61029f61064a565b6040516102ac919061224a565b60405180910390f35b6102c86102c33660046122b4565b6106dc565b60405190151581526020016102ac565b6102eb6102e63660046122de565b6106f6565b6040519081526020016102ac565b61030c6103073660046122de565b61072c565b005b6002546102eb565b6102c8610324366004612300565b610c2e565b61030c61033736600461233c565b610ca2565b6102eb61034a3660046123b1565b600b6020526000908152604090205481565b6102eb60075481565b604051601281526020016102ac565b6102c86103823660046122b4565b610d85565b61030c6103953660046123b1565b610dc4565b61030c6103a83660046122de565b610e68565b61030c6103bb3660046123de565b6111a5565b6102eb60085481565b61030c6103d73660046123b1565b611259565b6009546102c890610100900460ff1681565b6102eb6103fc3660046123f9565b6001600160a01b031660009081526020819052604090205490565b61030c611329565b61030c61042d366004612414565b61133d565b61030c6114ce565b61030c6114e5565b6005546001600160a01b03165b6040516001600160a01b0390911681526020016102ac565b61029f6114fe565b6102c861047d3660046122b4565b61150d565b6102c86104903660046122b4565b6115b7565b6104e06104a33660046123b1565b600660205260009081526040902080546001909101546001600160a01b0382169163ffffffff600160a01b8204811692600160c01b909204169084565b604080516001600160a01b0395909516855263ffffffff9384166020860152919092169083015260608201526080016102ac565b61030c610522366004612440565b61161d565b6102eb610535366004612463565b611701565b61044f7f00000000000000000000000082b8c7c6fb62d09cfd004309c1f353fb1a926edc81565b6102c861056f3660046123f9565b600a6020526000908152604090205460ff1681565b6102eb61059236600461249f565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6102eb6105cb3660046123b1565b6119a0565b61030c6105de3660046124d7565b6119c4565b61030c6105f13660046123f9565b611a44565b61044f7f00000000000000000000000097d0cfeb4fde54b430307c9482d6f79c761fe9b681565b6009546102c89060ff1681565b6102eb6106383660046123b1565b600f6020526000908152604090205481565b6060600380546106599061250e565b80601f01602080910402602001604051908101604052809291908181526020018280546106859061250e565b80156106d25780601f106106a7576101008083540402835291602001916106d2565b820191906000526020600020905b8154815290600101906020018083116106b557829003601f168201915b5050505050905090565b6000336106ea818585611ad4565b60019150505b92915050565b6000670de0b6b3a764000061071183650a86cc92e3db61255e565b61071b908561255e565b6107259190612575565b9392505050565b600082815260066020526040902080546001600160a01b031633146107845760405162461bcd60e51b81526020600482015260096024820152682727aa1027aba722a960b91b60448201526064015b60405180910390fd5b805442906107a89063ffffffff600160c01b8204811691600160a01b900416612597565b63ffffffff16116107fb5760405162461bcd60e51b815260206004820152601260248201527f4445504f534954204953204d4154555245440000000000000000000000000000604482015260640161077b565b805442600160a01b90910463ffffffff16036108595760405162461bcd60e51b815260206004820152601560248201527f4445504f53495420494e2053414d4520424c4f434b0000000000000000000000604482015260640161077b565b600181015460009061087384670de0b6b3a764000061255e565b61087d9190612575565b90508282600101600082825461089391906125bb565b9091555050600182015482546000916108b891600160c01b900463ffffffff166106f6565b6000868152600b6020526040812054919250906108d69083906125bb565b9050600081116109285760405162461bcd60e51b815260206004820152601a60248201527f494e53554646494349454e54205645504f4348204255524e4544000000000000604482015260640161077b565b6109323382611bf8565b61093b86611d2a565b6000868152600b6020526040812080548392906109599084906125bb565b90915550506000868152600f6020908152604080832054600e909252822054670de0b6b3a764000091869161098e91906125ce565b610998919061255e565b6109a29190612575565b6000888152600e6020526040902054909150811115610ac5576000878152600e60205260409020546109d490826125bb565b6000888152600f6020526040812080549091906109f29084906125bb565b90915550506000878152600e602052604081208190556001600160a01b037f00000000000000000000000097d0cfeb4fde54b430307c9482d6f79c761fe9b616906323b872dd9033903090610a4790866125bb565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015610a9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abf91906125e1565b50610ae9565b6000878152600e602052604081208054839290610ae39084906125bb565b90915550505b600254610afe82670de0b6b3a764000061255e565b610b089190612575565b600c6000828254610b1991906125ce565b90915550506040805188815260208101889052908101839052606081018290527fc6067ea67ec24f4c7f76df0eb4c7484b441758d5594133bbdeccf4cd9baa11f09060800160405180910390a18460010154600003610b9357600087815260066020526040812080546001600160e01b0319168155600101555b60405163a9059cbb60e01b8152336004820152602481018790527f00000000000000000000000082b8c7c6fb62d09cfd004309c1f353fb1a926edc6001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015610c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2491906125e1565b5050505050505050565b336000908152600a602052604081205460ff16610c805760405162461bcd60e51b815260206004820152601060248201526f4e4f4e205452414e5346455241424c4560801b604482015260640161077b565b33610c8c858285611d6b565b610c97858585611df7565b506001949350505050565b6000805b82811015610ced57610ccf848483818110610cc357610cc36125fe565b90506020020135611fca565b610cd990836125ce565b915080610ce581612614565b915050610ca6565b5060405163a9059cbb60e01b8152336004820152602481018290527f00000000000000000000000097d0cfeb4fde54b430307c9482d6f79c761fe9b66001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015610d5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7f91906125e1565b50505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906106ea9082908690610dbf9087906125ce565b611ad4565b6000610dcf82611fca565b60405163a9059cbb60e01b8152336004820152602481018290529091507f00000000000000000000000097d0cfeb4fde54b430307c9482d6f79c761fe9b66001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015610e3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6391906125e1565b505050565b600082815260066020526040902080546001600160a01b03163314610ebb5760405162461bcd60e51b81526020600482015260096024820152682727aa1027aba722a960b91b604482015260640161077b565b8054610edd9063ffffffff600160c01b8204811691600160a01b900416612597565b63ffffffff164211610f315760405162461bcd60e51b815260206004820152601360248201527f4445504f534954204e4f54204d41545552454400000000000000000000000000604482015260640161077b565b60018101548154600091610f5191600160c01b900463ffffffff166106f6565b9050610f5c84611d2a565b8160010154830361108657610f713382611bf8565b6000848152600b6020526040812055610f8984610dc4565b60008481526006602052604080822080546001600160e01b0319168155600101919091555163a9059cbb60e01b8152336004820152602481018490526001600160a01b037f00000000000000000000000082b8c7c6fb62d09cfd004309c1f353fb1a926edc169063a9059cbb906044015b6020604051808303816000875af1158015611019573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103d91906125e1565b5060408051858152602081018590529081018290527fabd2ab552bc04cdbfa4a54107fa44ac8c9cb06f6d21da11933ac05a653be19e9906060015b60405180910390a150505050565b6001820154670de0b6b3a76400009061109f858361255e565b6110a99190612575565b6110b3908361255e565b6110bd9190612575565b9050828260010160008282546110d391906125bb565b9091555050806111255760405162461bcd60e51b815260206004820152601a60248201527f494e53554646494349454e54205645504f4348204255524e4544000000000000604482015260640161077b565b61112f3382611bf8565b6000848152600b60205260408120805483929061114d9084906125bb565b909155505060405163a9059cbb60e01b8152336004820152602481018490527f00000000000000000000000082b8c7c6fb62d09cfd004309c1f353fb1a926edc6001600160a01b03169063a9059cbb90604401610ffa565b6111ad612098565b60095460ff16156111bd57600080fd5b6312cc03008163ffffffff1611156112175760405162461bcd60e51b815260206004820152600b60248201527f31302059454152204d4158000000000000000000000000000000000000000000604482015260640161077b565b63ffffffff811660088190556040519081527fd932d8a220c6041bd9b88f8cfa55322a14b6b6f3ba59b3a985adb548bbe934fe9060200160405180910390a150565b60025461126e82670de0b6b3a764000061255e565b6112789190612575565b600c600082825461128991906125ce565b90915550506040516323b872dd60e01b8152336004820152306024820152604481018290527f00000000000000000000000097d0cfeb4fde54b430307c9482d6f79c761fe9b66001600160a01b0316906323b872dd906064016020604051808303816000875af1158015611301573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132591906125e1565b5050565b611331612098565b61133b60006120f2565b565b600082815260066020526040902080546001600160a01b031633146113905760405162461bcd60e51b81526020600482015260096024820152682727aa1027aba722a960b91b604482015260640161077b565b80546113aa908390600160c01b900463ffffffff16612597565b63ffffffff1660085410156113f45760405162461bcd60e51b815260206004820152601060248201526f24a72b20a624a210222aa920aa24a7a760811b604482015260640161077b565b600061140a82600101548463ffffffff166106f6565b90506114163382612151565b61141f84611d2a565b6000848152600b60205260408120805483929061143d9084906125ce565b909155505060008481526006602052604090208054849190601890611470908490600160c01b900463ffffffff16612597565b92506101000a81548163ffffffff021916908363ffffffff1602179055507f61e931800ddbbbcef4fc390fe4ab5a75c116e106b21625647134a641e0e9b2dc848460405161107892919091825263ffffffff16602082015260400190565b6114d6612098565b6009805460ff19166001179055565b6114ed612098565b6009805461ff001916610100179055565b6060600480546106599061250e565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156115aa5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161077b565b610c978286868403611ad4565b336000908152600a602052604081205460ff166116095760405162461bcd60e51b815260206004820152601060248201526f4e4f4e205452414e5346455241424c4560801b604482015260640161077b565b611614338484611df7565b50600192915050565b600082815260066020526040902080546001600160a01b031633146116705760405162461bcd60e51b81526020600482015260096024820152682727aa1027aba722a960b91b604482015260640161077b565b6001810154815461169a913391859161169591600160c01b900463ffffffff166106f6565b611df7565b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03831690811782556040805185815260208101929092527f8721ce30cd03020e7cf768359849ce2ffc8d83c789ed81a7648fb85e6effd9ff910160405180910390a1505050565b6000610e0f8363ffffffff1611801561172257506008548363ffffffff1611155b6117615760405162461bcd60e51b815260206004820152601060248201526f24a72b20a624a210222aa920aa24a7a760811b604482015260640161077b565b60076000815461177090612614565b9182905550604080516080810182526001600160a01b03808616825263ffffffff4281166020808501918252898316858701818152606087018d815260008a8152600690945297832096518754945191518616600160c01b027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff92909616600160a01b027fffffffffffffffff000000000000000000000000000000000000000000000000909516961695909517929092179390931691909117835592516001909201919091559192506118459086906106f6565b9050600081116118975760405162461bcd60e51b815260206004820152601a60248201527f494e53554646494349454e54205645504f4348204d494e544544000000000000604482015260640161077b565b6118a18382612151565b6118aa82611d2a565b6000828152600b6020526040812080548392906118c89084906125ce565b90915550506040516323b872dd60e01b8152336004820152306024820152604481018690527f00000000000000000000000082b8c7c6fb62d09cfd004309c1f353fb1a926edc6001600160a01b0316906323b872dd906064016020604051808303816000875af1158015611940573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196491906125e1565b506040518281527f2a89b2e3d580398d6dc2db5e0f336b52602bbaa51afa9bb5cdf59239cf0d2bea9060200160405180910390a1509392505050565b60006119ab82612210565b6000838152600e60205260409020546106f091906125ce565b6119cc612098565b600954610100900460ff16156119e157600080fd5b6001600160a01b0382166000818152600a6020908152604091829020805460ff19168515159081179091558251938452908301527f705a90a56dc356e75fd01e05189928f674eedf386d3fef4d5d1866e89caf7271910160405180910390a15050565b611a4c612098565b6001600160a01b038116611ac85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161077b565b611ad1816120f2565b50565b6001600160a01b038316611b365760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161077b565b6001600160a01b038216611b975760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161077b565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038216611c585760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161077b565b6001600160a01b03821660009081526020819052604090205481811015611ccc5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161077b565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b611d3381612210565b6000828152600e602052604081208054909190611d519084906125ce565b9091555050600c546000918252600d602052604090912055565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610d7f5781811015611dea5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161077b565b610d7f8484848403611ad4565b6001600160a01b038316611e735760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161077b565b6001600160a01b038216611ed55760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161077b565b6001600160a01b03831660009081526020819052604090205481811015611f645760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161077b565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610d7f565b6000818152600660205260408120546001600160a01b0316331461201c5760405162461bcd60e51b81526020600482015260096024820152682727aa1027aba722a960b91b604482015260640161077b565b61202582611d2a565b506000818152600e60209081526040808320805490849055600f90925282208054919283926120559084906125ce565b909155505060408051838152602081018390527f47b0878030426a9511b1cd915a0ac34bd29f33d4f846616b55847303ff8ebcbe910160405180910390a1919050565b6005546001600160a01b0316331461133b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161077b565b600580546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166121a75760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161077b565b80600260008282546121b991906125ce565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6000818152600b6020908152604080832054600d909252822054600c54670de0b6b3a764000091612240916125bb565b61071b908361255e565b600060208083528351808285015260005b818110156122775785810183015185820160400152820161225b565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b03811681146122af57600080fd5b919050565b600080604083850312156122c757600080fd5b6122d083612298565b946020939093013593505050565b600080604083850312156122f157600080fd5b50508035926020909101359150565b60008060006060848603121561231557600080fd5b61231e84612298565b925061232c60208501612298565b9150604084013590509250925092565b6000806020838503121561234f57600080fd5b823567ffffffffffffffff8082111561236757600080fd5b818501915085601f83011261237b57600080fd5b81358181111561238a57600080fd5b8660208260051b850101111561239f57600080fd5b60209290920196919550909350505050565b6000602082840312156123c357600080fd5b5035919050565b803563ffffffff811681146122af57600080fd5b6000602082840312156123f057600080fd5b610725826123ca565b60006020828403121561240b57600080fd5b61072582612298565b6000806040838503121561242757600080fd5b82359150612437602084016123ca565b90509250929050565b6000806040838503121561245357600080fd5b8235915061243760208401612298565b60008060006060848603121561247857600080fd5b83359250612488602085016123ca565b915061249660408501612298565b90509250925092565b600080604083850312156124b257600080fd5b6124bb83612298565b915061243760208401612298565b8015158114611ad157600080fd5b600080604083850312156124ea57600080fd5b6124f383612298565b91506020830135612503816124c9565b809150509250929050565b600181811c9082168061252257607f821691505b60208210810361254257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176106f0576106f0612548565b60008261259257634e487b7160e01b600052601260045260246000fd5b500490565b63ffffffff8181168382160190808211156125b4576125b4612548565b5092915050565b818103818111156106f0576106f0612548565b808201808211156106f0576106f0612548565b6000602082840312156125f357600080fd5b8151610725816124c9565b634e487b7160e01b600052603260045260246000fd5b60006001820161262657612626612548565b506001019056fea164736f6c6343000811000a
Verified Source Code Partial Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (800 runs)
Vepoch.sol 366 lines
// SPDX-License-Identifier: BUSL-1.1
// Developed by Moai Labs LLC, owned by EPOCH DAO
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract VEpoch is ERC20, Ownable {
// @dev Unknown tokens will/must not be used with this contract
struct Deposit {
address owner;
uint32 depositTs;
uint32 lockDuration;
uint256 depositTokenBalance;
}
mapping(uint256 => Deposit) public deposits;
uint256 public depositCount;
uint256 public maxDepositDuration = 730 days;
IERC20 public immutable depositToken;
// Admin functionalities that can be locked forever
bool public maxDepositDurationLocked;
bool public authorisedLocked;
mapping(address => bool) public authorised;
event Deposited(uint256 depositId);
event DepositExtend(uint256 _depositId, uint32 _secondsExtended);
event WithdrawnForfeit(uint256 depositId, uint256 depositTokensReturned, uint256 veTokensBurned, uint256 rewardForfeit);
event Withdrawn(uint256 depositId, uint256 depositTokensReturned, uint256 veTokensBurned);
event Authorised(address authorisedAddress, bool newAuthorisationStatus);
event MaxDepositDurationSet(uint256 newMaxDepositDuration);
event DepositOwnershipTransferred(uint256 depositId, address newOwner);
event RewardClaimed(uint256 depositId, uint256 yieldTokenAmount);
event RewardForfeit(uint256 depositId, uint256 yieldTokenAmount);
// Yield earning related
IERC20Metadata public immutable rewardToken;
mapping(uint256 => uint256) public rewardStakingPower;
uint256 private rewardIndex;
mapping(uint256 => uint256) private rewardIndexOf;
mapping(uint256 => uint256) private earned;
mapping(uint256 => uint256) public rewardTokensClaimed;
constructor(address _depositToken, address _yieldToken, address _newOwner) ERC20("Vote Escrow Epoch", "vEPOCH") {
depositToken = IERC20(_depositToken);
rewardToken = IERC20Metadata(_yieldToken);
authorised[address(this)] = true;
_transferOwnership(_newOwner);
}
/// @notice Allows only authorised addresses to transfer tokens from their address
/// @dev Can only be called by anyone but will revert if caller is not authorised
/// @param to - The address to send veTokens to
/// @param amount - The amount of veTokens to send
/// @return boolean on success
function transfer(address to, uint256 amount) public override returns (bool) {
require(authorised[msg.sender], "NON TRANSFERABLE");
_transfer(msg.sender, to, amount);
return true;
}
/// @notice Allows only authorised addresses to transfer tokens from/to any address
/// @dev Note: Authorised addresses NEED approvals from users (allowance)
/// @param from - The address to send veTokens from
/// @param to - The address to send veTokens to
/// @param amount - The amount of veTokens to send
/// @return boolean on success
function transferFrom(address from, address to, uint256 amount) public override returns (bool) {
require(authorised[msg.sender], "NON TRANSFERABLE");
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/// @notice Allows anyone to add reward tokens (which will be distributed proportionally)
/// @param _tokenAmount - The number of reward tokens to deposit
function addRewardTokens(uint256 _tokenAmount) external {
rewardIndex += (_tokenAmount * 1e18) / totalSupply();
rewardToken.transferFrom(msg.sender, address(this), _tokenAmount);
}
/// @notice Computes reward tokens for a given depositId
/// @param _depositId - The depositId to calculate rewards for
/// @return The number of pending reward tokens
function _calculateRewards(uint256 _depositId) private view returns (uint256) {
uint256 shares = rewardStakingPower[_depositId];
return (shares * (rewardIndex - rewardIndexOf[_depositId])) / 1e18;
}
/// @notice Determine the total number of reward tokens earned for a given depositId
/// @param _depositId - The depositId you want information for
/// @return The number of unclaimed reward tokens
function calculateRewardsEarned(uint256 _depositId) external view returns (uint256) {
return earned[_depositId] + _calculateRewards(_depositId);
}
/// @notice Updates rewards earned for a given depositId
/// @param _depositId - The depositId you want to update rewards earned for
function _updateRewards(uint256 _depositId) private {
earned[_depositId] += _calculateRewards(_depositId);
rewardIndexOf[_depositId] = rewardIndex;
}
/// @notice Used internally to update state before reward transfer
/// @param _depositId - The depositId you want to update state for
/// @return reward - The number of reward tokens available to claim
function _claimYield(uint256 _depositId) private returns (uint256 reward) {
// Ensure the claimer owns the specified deposit
require(deposits[_depositId].owner == msg.sender, "NOT OWNER");
_updateRewards(_depositId);
reward = earned[_depositId];
earned[_depositId] = 0;
rewardTokensClaimed[_depositId] += reward;
emit RewardClaimed(_depositId, reward);
}
/// @notice Allows user to claim reward tokens earned for a given depositId
/// @param _depositId - The depositId you want to claim rewards from
function claimYield(uint256 _depositId) public {
uint256 reward = _claimYield(_depositId);
rewardToken.transfer(msg.sender, reward);
}
/// @notice Allows user to claim reward tokens earned for one to many depositId's
/// @param _depositIds - An array of depositIds you want to claim rewards from
function claimYield(uint256[] calldata _depositIds) public {
uint256 totalRewards;
for(uint256 i = 0; i < _depositIds.length; i++) {
totalRewards += _claimYield(_depositIds[i]);
}
rewardToken.transfer(msg.sender, totalRewards);
}
/// @notice Returns the veTokens minted for a given tokenAmount and duration
/// @dev This function will IGNORE the maximum deposit duration
/// @param _tokenAmount - The number of deposit tokens to lock
/// @param _duration - The duration in seconds to lock for
/// @return The number of veTokens that would be minted
function calculateVeTokens(uint256 _tokenAmount, uint256 _duration) public pure returns(uint256) {
// @dev 0.000011574074074075 veTokens per 1 deposit token for 1 second
// @dev 365 days lock = ~ 365
return (_tokenAmount * (11574074074075 * _duration)) / 1e18;
}
/// @notice Deposits depositToken for a given duration and mints veTokens
/// @dev Deposits can be made on behalf of another address
/// @param _tokenAmount - The number of deposit tokens to lock
/// @param _duration - The duration in seconds to lock for
/// @param _behalfOf - The address that will own this newly created deposit
/// @return _depositCount - The new newly created depositId
function deposit(uint256 _tokenAmount, uint32 _duration, address _behalfOf) external returns(uint256 _depositCount) {
require(_duration > 3599 && _duration <= maxDepositDuration, "INVALID DURATION");
_depositCount = ++depositCount;
deposits[_depositCount] = Deposit(
_behalfOf,
uint32(block.timestamp),
_duration,
_tokenAmount
);
uint256 veTokensMinted = calculateVeTokens(_tokenAmount, _duration);
require(veTokensMinted > 0, "INSUFFICIENT VEPOCH MINTED");
_mint(_behalfOf, veTokensMinted);
// Ensure this deposit is earning
_updateRewards(_depositCount);
rewardStakingPower[_depositCount] += veTokensMinted;
depositToken.transferFrom(msg.sender, address(this), _tokenAmount);
emit Deposited(_depositCount);
return _depositCount;
}
/// @notice Allows withdrawing of deposit tokens which will forfeit some number of reward tokens
/// @dev Users can withdraw in full or partially
/// @param _depositId - The depositId you want to withdrawForfeit from
/// @param _depositTokensToRemove - The number of deposit tokens to remove
function withdrawForfeit(uint256 _depositId, uint256 _depositTokensToRemove) external {
Deposit storage d = deposits[_depositId];
// Ensure the caller is the owner of said deposit
require(d.owner == msg.sender, "NOT OWNER");
// Ensure this function is only used for deposits where lock has not ended
require(
(d.depositTs + d.lockDuration) > block.timestamp,
"DEPOSIT IS MATURED"
);
require(d.depositTs != block.timestamp, "DEPOSIT IN SAME BLOCK");
// Compute what percentage of depositTokens user wants to remove
uint256 percentage = (_depositTokensToRemove * 1e18) / d.depositTokenBalance;
// Decrease deposit balance first, then compute new veToken balance
d.depositTokenBalance -= _depositTokensToRemove;
uint256 veEndTokenBalance = calculateVeTokens(d.depositTokenBalance, d.lockDuration);
// Determine veToken amount to burn
uint256 burnAmount = rewardStakingPower[_depositId] - veEndTokenBalance;
require(burnAmount > 0, "INSUFFICIENT VEPOCH BURNED");
_burn(msg.sender, burnAmount); // Burn them
// Update rewards, then reduce staking power
_updateRewards(_depositId);
rewardStakingPower[_depositId] -= burnAmount;
uint256 forfeitReward = ((earned[_depositId] + rewardTokensClaimed[_depositId]) * percentage) / 1e18;
// IF number of EPOCH to return is GREATER than pending unclaimed rewards
// Transfer the excess from the user's wallet
if(forfeitReward > earned[_depositId]) {
// Calculate diff and transfer this many tokens from the user
rewardTokensClaimed[_depositId] -= (forfeitReward - earned[_depositId]);
// Since the user didn't have enough earned and had to transfer tokens
// This means we can set this to 0
earned[_depositId] = 0;
rewardToken.transferFrom(msg.sender, address(this), forfeitReward - earned[_depositId]);
} else {
// The number of yield tokens the user has earned is greater than the number that needs to be forfeit
// we can therefore just deduct from their balance.
earned[_depositId] -= forfeitReward;
}
// Redistribute these forfeit rewards
rewardIndex += (forfeitReward * 1e18) / totalSupply();
emit WithdrawnForfeit(_depositId, _depositTokensToRemove, burnAmount, forfeitReward);
// If this deposit has no associated deposit tokens, delete the deposit (dust protection)
if(d.depositTokenBalance == 0) {
delete deposits[_depositId];
}
// Transfer the LP tokens back
depositToken.transfer(msg.sender, _depositTokensToRemove);
}
/// @notice Burns veTokens for matured deposits and returns deposited tokens
/// @dev Users can withdraw in full or partially
/// @param _depositId - The depositId you want to withdraw from
/// @param _tokenAmount - The number of deposit tokens to remove
function withdraw(uint256 _depositId, uint256 _tokenAmount) external {
Deposit storage d = deposits[_depositId];
require(d.owner == msg.sender, "NOT OWNER");
require(
block.timestamp > (d.depositTs + d.lockDuration),
"DEPOSIT NOT MATURED"
);
uint256 veTokensBurned = calculateVeTokens(d.depositTokenBalance, d.lockDuration);
_updateRewards(_depositId);
if(_tokenAmount == d.depositTokenBalance) {
_burn(msg.sender, veTokensBurned);
// Reduce staking power
rewardStakingPower[_depositId] = 0;
claimYield(_depositId);
delete deposits[_depositId];
depositToken.transfer(msg.sender, _tokenAmount);
emit Withdrawn(_depositId, _tokenAmount, veTokensBurned);
return;
}
veTokensBurned = (veTokensBurned * ((_tokenAmount * 1e18) / d.depositTokenBalance)) / 1e18;
d.depositTokenBalance -= _tokenAmount;
require(veTokensBurned > 0, "INSUFFICIENT VEPOCH BURNED");
_burn(msg.sender, veTokensBurned);
// Reduce staking power
rewardStakingPower[_depositId] -= veTokensBurned;
depositToken.transfer(msg.sender, _tokenAmount);
emit Withdrawn(_depositId, _tokenAmount, veTokensBurned);
}
/// @notice Allows deposit owner to extend deposit up to maximum deposit duration
/// @param _depositId - The depositId you want to extend
/// @param _secondsToExtend - The number of seconds to extend this deposit by
function extendDeposit(uint256 _depositId, uint32 _secondsToExtend) external {
Deposit storage d = deposits[_depositId];
require(d.owner == msg.sender, "NOT OWNER");
require(maxDepositDuration >= d.lockDuration + _secondsToExtend, "INVALID DURATION");
// Determine how many more veTokens should be minted
uint256 veTokenDiff = calculateVeTokens(d.depositTokenBalance, _secondsToExtend);
_mint(msg.sender, veTokenDiff);
// Update rewards
_updateRewards(_depositId);
rewardStakingPower[_depositId] += veTokenDiff;
deposits[_depositId].lockDuration += _secondsToExtend;
emit DepositExtend(_depositId, _secondsToExtend);
}
/// @notice Allows user to transfer ownership of their deposit
/// @param _depositId - The depositId you want to transfer
/// @param _newOwner - The address of the new owner
function transferDepositOwnership(uint256 _depositId, address _newOwner) external {
Deposit storage d = deposits[_depositId];
require(d.owner == msg.sender, "NOT OWNER");
// Transfer veTokens from old owner to new owner
_transfer(msg.sender, _newOwner, calculateVeTokens(d.depositTokenBalance, d.lockDuration));
// Transfer ownership of deposit
d.owner = _newOwner;
emit DepositOwnershipTransferred(_depositId, _newOwner);
}
/// @notice Allows Owner to disable veToken transfer authorised functionality forever
function setAuthorisedLocked() external onlyOwner {
authorisedLocked = true;
}
/// @notice Allows Owner to disable setMaxDepositDuration functionality forever
function setMaxDepositDurationLocked() external onlyOwner {
maxDepositDurationLocked = true;
}
/// @notice This allows the owner to determine which addresses are authorised for token transfers
/// @dev Can only be called by the owner of the contract
/// @param _address - The address you want to change authorisation status of
/// @param _newAuthorisationStatus - The new authorisation status
function setAuthorised(address _address, bool _newAuthorisationStatus) external onlyOwner {
require(!authorisedLocked);
authorised[_address] = _newAuthorisationStatus;
emit Authorised(_address, _newAuthorisationStatus);
}
/// @notice This allows the owner to set the maximum deposit duration
/// @dev Can only be called by the owner of the contract
/// @param _newMaxDepositDuration - The new maximum deposit duration in seconds
function setMaxDepositDuration(uint32 _newMaxDepositDuration) external onlyOwner {
require(!maxDepositDurationLocked);
require(_newMaxDepositDuration <= 3650 days, "10 YEAR MAX");
maxDepositDuration = _newMaxDepositDuration;
emit MaxDepositDurationSet(_newMaxDepositDuration);
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ERC20.sol 365 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
Read Contract
allowance 0xdd62ed3e → uint256
authorised 0xd6eb1bbf → bool
authorisedLocked 0x5ca662a4 → bool
balanceOf 0x70a08231 → uint256
calculateRewardsEarned 0xe42f8dcc → uint256
calculateVeTokens 0x0ba49d87 → uint256
decimals 0x313ce567 → uint8
depositCount 0x2dfdf0b5 → uint256
depositToken 0xc89039c5 → address
deposits 0xb02c43d0 → address, uint32, uint32, uint256
maxDepositDuration 0x4dfc3ff5 → uint256
maxDepositDurationLocked 0xfce5f8df → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
rewardStakingPower 0x2d5f3faf → uint256
rewardToken 0xf7c618c1 → address
rewardTokensClaimed 0xff4a768a → uint256
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 19 functions
These functions modify contract state and require a wallet transaction to execute.
addRewardTokens 0x58eb9700
uint256 _tokenAmount
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
claimYield 0x25141d68
uint256[] _depositIds
claimYield 0x40bd2e23
uint256 _depositId
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
deposit 0xc2e72954
uint256 _tokenAmount
uint32 _duration
address _behalfOf
returns: uint256
extendDeposit 0x78a2b087
uint256 _depositId
uint32 _secondsToExtend
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
renounceOwnership 0x715018a6
No parameters
setAuthorised 0xeea3cd85
address _address
bool _newAuthorisationStatus
setAuthorisedLocked 0x88c0f32b
No parameters
setMaxDepositDuration 0x46573115
uint32 _newMaxDepositDuration
setMaxDepositDurationLocked 0x7a5f0f18
No parameters
transfer 0xa9059cbb
address to
uint256 amount
returns: bool
transferDepositOwnership 0xb35611f4
uint256 _depositId
address _newOwner
transferFrom 0x23b872dd
address from
address to
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x441a3e70
uint256 _depositId
uint256 _tokenAmount
withdrawForfeit 0x0dc85ece
uint256 _depositId
uint256 _depositTokensToRemove
Recent Transactions
No transactions found for this address