Address Contract Verified
Address
0x370F850180FDDCdc521Ed11900a7a27D08B2d402
Balance
0 ETH
Nonce
1
Code Size
9711 bytes
Creator
0x5EC1213c...5BBe at tx 0xe276736c...0712bd
Indexed Transactions
0
Contract Bytecode
9711 bytes
0x608060405234801561001057600080fd5b506004361061020b5760003560e01c8063892de51d1161012a578063d8a8e03a116100bd578063e529780d1161008c578063f3d3418811610071578063f3d34188146105b7578063f52981f4146105ca578063fc5a5b63146105dd57600080fd5b8063e529780d14610583578063e7657e15146105ae57600080fd5b8063d8a8e03a146104f3578063db64ff8f14610506578063dc2c788f14610519578063e054720f1461054f57600080fd5b8063bf8712c5116100f9578063bf8712c514610425578063c659cd451461046e578063cdf4349714610497578063d4e8fd2e146104c657600080fd5b8063892de51d146103b25780639c52a7f1146103df578063bb7c46f3146103f2578063bf353dbb1461040557600080fd5b8063509aaa1d116101a25780636a760b80116101715780636a760b801461033f5780637bd2bea7146103525780637d8d270214610379578063876908731461038c57600080fd5b8063509aaa1d146102fb57806353e8863d1461030e57806360fb494b1461032157806365fae35e1461032c57600080fd5b806326e027f1116101de57806326e027f1146102b957806329ae8114146102cc578063355274ea146102df5780633c433d5f146102e857600080fd5b806307079c24146102105780631a8d3a6c1461022557806321f6c0cf1461026957806324cada91146102a6575b600080fd5b61022361021e36600461235b565b6106d6565b005b61024c7f0000000000000000000000000813ec5f3b54003197d8b40a36ed570e803cfbf781565b6040516001600160a01b0390911681526020015b60405180910390f35b61029861027736600461235b565b600090815260026020526040902054600160a01b900465ffffffffffff1690565b604051908152602001610260565b6102986102b4366004612399565b610822565b6102236102c736600461235b565b61085e565b6102236102da36600461241a565b61086b565b61029860045481565b6102236102f636600461235b565b6109cd565b61022361030936600461241a565b6109d6565b61029861031c36600461235b565b6109e4565b610298632598060081565b61022361033a36600461243c565b610afb565b61022361034d36600461235b565b610b9b565b61024c7f0000000000000000000000007777f41a060377b3640f8b5e3bb78e37bd48777781565b61022361038736600461235b565b610ba7565b61029861039a36600461235b565b60009081526002602052604090206003015460ff1690565b6102986103c036600461235b565b600090815260026020819052604090912001546001600160801b031690565b6102236103ed36600461243c565b610d23565b61022361040036600461241a565b610dc0565b61029861041336600461243c565b60016020526000908152604090205481565b61045e61043336600461235b565b600090815260026020819052604090912001546001600160801b03808216600160801b909204161090565b6040519015158152602001610260565b61024c61047c36600461235b565b6000908152600260205260409020546001600160a01b031690565b6102986104a536600461235b565b600090815260026020526040902054600160d01b900465ffffffffffff1690565b6102986104d436600461235b565b600090815260026020526040902060010154600160d01b900460ff1690565b610223610501366004612457565b610dca565b610298610514366004612483565b610f48565b61024c61052736600461235b565b600090815260026020526040902060010154660100000000000090046001600160a01b031690565b61029861055d36600461235b565b60009081526002602081905260409091200154600160801b90046001600160801b031690565b61029861059136600461235b565b60009081526002602052604090206001015465ffffffffffff1690565b61029860035481565b6102236105c536600461235b565b610f63565b6102986105d836600461235b565b610f6c565b61066b6105eb36600461235b565b600260208190526000918252604090912080546001820154928201546003909201546001600160a01b038083169465ffffffffffff600160a01b8504811695600160d01b9586900482169591831694660100000000000084049094169360ff929093048216926001600160801b0380831693600160801b90930416911689565b604080516001600160a01b039a8b16815265ffffffffffff998a1660208201529789169088015296909416606086015295909116608084015260ff90811660a08401526001600160801b0394851660c0840152931660e0820152911661010082015261012001610260565b600054156107235760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b60448201526064015b60405180910390fd5b60016000818155338152602082905260409020541461077d5760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b6000818152600260205260409020546001600160a01b0316806107da5760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604482015260640161071a565b600082815260026020526040808220600301805460ff191690555183917f028f3fd71c0ab977798420b1a28086f1c93daa66fdb9d3ba5b52ba1e94564d1391a2505060008055565b6000610832898989898989611072565b905082156108435761084381611630565b811561085257610852816117b2565b98975050505050505050565b61086881426118fc565b50565b33600090815260016020819052604090912054146108c45760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b6000541561090c5760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604482015260640161071a565b60016000557f636170000000000000000000000000000000000000000000000000000000000082900361094357600481905561098b565b60405162461bcd60e51b815260206004820152601f60248201527f447373566573742f66696c652d756e7265636f676e697a65642d706172616d00604482015260640161071a565b817fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c7826040516109bd91815260200190565b60405180910390a2505060008055565b61086881611630565b6109e082826118fc565b5050565b600081815260026020818152604080842081516101208101835281546001600160a01b0380821680845265ffffffffffff600160a01b8404811697850197909752600160d01b92839004871695840195909552600184015495861660608401526601000000000000860416608083015260ff9404841660a0820152938101546001600160801b0380821660c0870152600160801b9091041660e085015260030154909116610100830152610ad25760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604482015260640161071a565b610af4428260200151836040015184606001518560c001518660e00151611d43565b9392505050565b3360009081526001602081905260409091205414610b545760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b6001600160a01b038116600081815260016020819052604080832091909155517fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a609190a250565b61086881600019611d84565b60005415610bef5760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604482015260640161071a565b60016000908155818152600260205260409020546001600160a01b031680610c515760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604482015260640161071a565b336000908152600160208190526040909120541480610c7857506001600160a01b03811633145b610cbd5760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b60008281526002602052604080822060010180547fffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffff1690555183917f3d1b575f06b2d660af77eec35d9b3ffcfa956b6c1fdbc840992d4b03b03e622b91a2505060008055565b3360009081526001602081905260409091205414610d7c5760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b6001600160a01b038116600081815260016020526040808220829055517f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b9190a250565b6109e08282611d84565b60005415610e125760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604482015260640161071a565b60016000908155828152600260205260409020546001600160a01b03163314610e7d5760405162461bcd60e51b815260206004820152601a60248201527f447373566573742f6f6e6c792d757365722d63616e2d6d6f7665000000000000604482015260640161071a565b6001600160a01b038116610ed35760405162461bcd60e51b815260206004820152601c60248201527f447373566573742f7a65726f2d616464726573732d696e76616c696400000000604482015260640161071a565b60008281526002602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091559051909184917f8ceddd02f4fb8ef0d5d6212cf4c91d59d366e04b977e8b2b944168d2a6d850819190a3505060008055565b6000610f58878787878787611072565b979650505050505050565b610868816117b2565b600081815260026020818152604080842081516101208101835281546001600160a01b0380821680845265ffffffffffff600160a01b8404811697850197909752600160d01b92839004871695840195909552600184015495861660608401526601000000000000860416608083015260ff9404841660a0820152938101546001600160801b0380821660c0870152600160801b9091041660e08501526003015490911661010083015261105a5760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604482015260640161071a565b610af442826020015183606001518460c00151611ff5565b336000908152600160208190526040822054146110ca5760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b600054156111125760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604482015260640161071a565b60016000556001600160a01b03871661116d5760405162461bcd60e51b815260206004820152601460248201527f447373566573742f696e76616c69642d75736572000000000000000000000000604482015260640161071a565b600086116111bd5760405162461bcd60e51b815260206004820152601c60248201527f447373566573742f6e6f2d766573742d746f74616c2d616d6f756e7400000000604482015260640161071a565b6111cb426325980600612081565b85106112195760405162461bcd60e51b815260206004820152601360248201527f447373566573742f62676e2d746f6f2d66617200000000000000000000000000604482015260640161071a565b6112274263259806006120e5565b85116112755760405162461bcd60e51b815260206004820152601860248201527f447373566573742f62676e2d746f6f2d6c6f6e672d61676f0000000000000000604482015260640161071a565b600084116112c55760405162461bcd60e51b815260206004820152601060248201527f447373566573742f7461752d7a65726f00000000000000000000000000000000604482015260640161071a565b6004546112d2858861250a565b11156113205760405162461bcd60e51b815260206004820152601560248201527f447373566573742f726174652d746f6f2d686967680000000000000000000000604482015260640161071a565b63259806008411156113745760405162461bcd60e51b815260206004820152601460248201527f447373566573742f7461752d746f6f2d6c6f6e67000000000000000000000000604482015260640161071a565b838311156113c45760405162461bcd60e51b815260206004820152601460248201527f447373566573742f6574612d746f6f2d6c6f6e67000000000000000000000000604482015260640161071a565b600019600354106114175760405162461bcd60e51b815260206004820152601460248201527f447373566573742f6964732d6f766572666c6f77000000000000000000000000604482015260640161071a565b60036000815461142690612545565b9190508190559050604051806101200160405280886001600160a01b0316815260200161145287612143565b65ffffffffffff16815260200161147161146c8887612081565b612143565b65ffffffffffff16815260200161148b61146c8888612081565b65ffffffffffff1681526001600160a01b0384166020820152600060408201526060016114b7886121a0565b6001600160801b03908116825260006020808401829052604093840182905285825260028082528483208651815493880151888801516001600160a01b039283167fffffffffffff000000000000000000000000000000000000000000000000000096871617600160a01b65ffffffffffff938416021779ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b918316820217845560608a015160018501805460808d015160a08e015193909516981697909717660100000000000093851693909302929092177fffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffff1660ff9283169091021790945560c088015160e0890151908716600160801b91909716029590951791810191909155610100909501516003909501805460ff1916959091169490941790935590519089169183917f2e3cc5298d3204a0f0fc2be0f6fdefcef002025f4c75caf950b23e6cfbfb78d09190a3600080559695505050505050565b600054156116785760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604482015260640161071a565b60016000908155818152600260205260409020546001600160a01b0316806116da5760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604482015260640161071a565b33600090815260016020819052604090912054148061170157506001600160a01b03811633145b6117465760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b60008281526002602052604080822060010180547fffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b1790555183917f9247a2bf1b75bc397d4043d99b9cebce531548a01dbb56a5d4c5f5ca26051e8d91a2505060008055565b600054156117fa5760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604482015260640161071a565b6001600081815533815260208290526040902054146118545760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b6000818152600260205260409020546001600160a01b0316806118b15760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604482015260640161071a565b600082815260026020526040808220600301805460ff191660011790555183917f7f523e15b3feb7bbd0ee183627685fbe452b55efd91b1923a88f94abb36d362d91a2505060008055565b600054156119445760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604482015260640161071a565b600160008181553381526020829052604090205414806119875750600082815260026020526040902060010154660100000000000090046001600160a01b031633145b6119cc5760405162461bcd60e51b8152602060048201526016602482015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015260640161071a565b60008281526002602081815260409283902083516101208101855281546001600160a01b0380821680845265ffffffffffff600160a01b8404811696850196909652600160d01b92839004861697840197909752600184015494851660608401526601000000000000850416608083015260ff9304831660a0820152928101546001600160801b0380821660c0860152600160801b9091041660e0840152600301541661010082015290611aba5760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604482015260640161071a565b61010081015160ff1615611b105760405162461bcd60e51b815260206004820152601a60248201527f447373566573742f6e6f2d79616e6b696e672d626c6573736564000000000000604482015260640161071a565b42821015611b1c574291505b806060015165ffffffffffff16821015611d00576000611b3b83612143565b600085815260026020908152604090912060010180547fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001665ffffffffffff84811691821790925591850151929350919091161115611c0a57600084815260026020819052604090912080546001600160a01b0316600160a01b65ffffffffffff851690810279ffffffffffffffffffffffffffffffffffffffffffffffffffff1691909117600160d01b919091021781550180546fffffffffffffffffffffffffffffffff19169055611cfe565b816040015165ffffffffffff168165ffffffffffff161015611c84576000848152600260208190526040909120805479ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b65ffffffffffff8516021781550180546fffffffffffffffffffffffffffffffff19169055611cfe565b611cc4611cbf611cac858560200151866040015187606001518860c001518960e00151611d43565b8460e001516001600160801b0316612081565b6121a0565b60008581526002602081905260409091200180546fffffffffffffffffffffffffffffffff19166001600160801b03929092169190911790555b505b827f6f2a3ed78a3066d89360b6c89e52bf3313f52e859401a3ea5fa0f033fd540c3c83604051611d3291815260200190565b60405180910390a250506000805550565b60008465ffffffffffff168710611d7757611d72611d6388888787611ff5565b836001600160801b03166120e5565b610f58565b6000979650505050505050565b60005415611dcc5760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604482015260640161071a565b600160008181558381526002602081815260409283902083516101208101855281546001600160a01b03808216808452600160a01b830465ffffffffffff90811696850196909652600160d01b928390048616978401979097529683015493841660608301526601000000000000840490961660808201529490910460ff90811660a0860152918101546001600160801b0380821660c0870152600160801b9091041660e08501526003015416610100830152611ec35760405162461bcd60e51b8152602060048201526015602482015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604482015260640161071a565b60a081015160ff161580611ee0575080516001600160a01b031633145b611f2c5760405162461bcd60e51b815260206004820152601b60248201527f447373566573742f6f6e6c792d757365722d63616e2d636c61696d0000000000604482015260640161071a565b6000611f50428360200151846040015185606001518660c001518760e00151611d43565b9050611f5c81846121f9565b9050611f78611cbf8360e001516001600160801b031683612081565b60008581526002602081905260409091200180546001600160801b03928316600160801b0292169190911790558151611fb1908261220e565b837fa2906882572b0e9dfe893158bb064bc308eb1bd87d1da481850f9d17fc29384782604051611fe391815260200190565b60405180910390a25050600080555050565b60008365ffffffffffff1685101561200f57506000612079565b8265ffffffffffff16851061202e57506001600160801b038116612079565b6120488365ffffffffffff168565ffffffffffff166120e5565b61206c836001600160801b0316612067888865ffffffffffff166120e5565b6122eb565b612076919061250a565b90505b949350505050565b60008261208e838261255f565b91508110156120df5760405162461bcd60e51b815260206004820152601460248201527f447373566573742f6164642d6f766572666c6f77000000000000000000000000604482015260640161071a565b92915050565b6000826120f28382612572565b91508111156120df5760405162461bcd60e51b815260206004820152601560248201527f447373566573742f7375622d756e646572666c6f770000000000000000000000604482015260640161071a565b8065ffffffffffff8116811461219b5760405162461bcd60e51b815260206004820152601760248201527f447373566573742f75696e7434382d6f766572666c6f77000000000000000000604482015260640161071a565b919050565b806001600160801b038116811461219b5760405162461bcd60e51b815260206004820152601860248201527f447373566573742f75696e743132382d6f766572666c6f770000000000000000604482015260640161071a565b60008183116122085782610af4565b50919050565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000813ec5f3b54003197d8b40a36ed570e803cfbf7811660048301528381166024830152604482018390527f0000000000000000000000007777f41a060377b3640f8b5e3bb78e37bd48777716906323b872dd906064016020604051808303816000875af11580156122be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e29190612585565b6109e057600080fd5b600081158061230f5750828261230181836125a2565b925061230d908361250a565b145b6120df5760405162461bcd60e51b815260206004820152601460248201527f447373566573742f6d756c2d6f766572666c6f77000000000000000000000000604482015260640161071a565b60006020828403121561236d57600080fd5b5035919050565b80356001600160a01b038116811461219b57600080fd5b801515811461086857600080fd5b600080600080600080600080610100898b0312156123b657600080fd5b6123bf89612374565b9750602089013596506040890135955060608901359450608089013593506123e960a08a01612374565b925060c08901356123f98161238b565b915060e08901356124098161238b565b809150509295985092959890939650565b6000806040838503121561242d57600080fd5b50508035926020909101359150565b60006020828403121561244e57600080fd5b610af482612374565b6000806040838503121561246a57600080fd5b8235915061247a60208401612374565b90509250929050565b60008060008060008060c0878903121561249c57600080fd5b6124a587612374565b9550602087013594506040870135935060608701359250608087013591506124cf60a08801612374565b90509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082612540577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60006000198203612558576125586124db565b5060010190565b808201808211156120df576120df6124db565b818103818111156120df576120df6124db565b60006020828403121561259757600080fd5b8151610af48161238b565b80820281158282048414176120df576120df6124db56fea26469706673582212201d7f078b95c45f1e5d50312fa33e30d8ecb397853a8b7611f8b1cc791e2ea2b664736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (2000 runs)
DssVest.sol 555 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// DssVest - Token vesting contract
//
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.8.13;
interface MintLike {
function mint(address, uint256) external;
}
interface ChainlogLike {
function getAddress(bytes32) external view returns (address);
}
interface DaiJoinLike {
function exit(address, uint256) external;
}
interface VatLike {
function hope(address) external;
function suck(address, address, uint256) external;
}
interface TokenLike {
function transferFrom(address, address, uint256) external returns (bool);
}
abstract contract DssVest {
uint256 public constant TWENTY_YEARS = 20 * 365 days;
uint256 internal locked;
event Rely(address indexed usr);
event Deny(address indexed usr);
event Init(uint256 indexed id, address indexed usr);
event Vest(uint256 indexed id, uint256 amt);
event Move(uint256 indexed id, address indexed dst);
event File(bytes32 indexed what, uint256 data);
event Yank(uint256 indexed id, uint256 end);
event Restrict(uint256 indexed id);
event Unrestrict(uint256 indexed id);
event Bless(uint256 indexed id);
event Unbless(uint256 indexed id);
// --- Auth ---
mapping (address => uint256) public wards;
function rely(address _usr) external auth { wards[_usr] = 1; emit Rely(_usr); }
function deny(address _usr) external auth { wards[_usr] = 0; emit Deny(_usr); }
modifier auth {
require(wards[msg.sender] == 1, "DssVest/not-authorized");
_;
}
// --- Mutex ---
modifier lock {
require(locked == 0, "DssVest/system-locked");
locked = 1;
_;
locked = 0;
}
struct Award {
address usr; // Vesting recipient
uint48 bgn; // Start of vesting period [timestamp]
uint48 clf; // The cliff date [timestamp]
uint48 fin; // End of vesting period [timestamp]
address mgr; // A manager address that can yank
uint8 res; // Restricted
uint128 tot; // Total reward amount
uint128 rxd; // Amount of vest claimed
uint8 bls; // Blessed (uninterruptible)
}
mapping (uint256 => Award) public awards;
uint256 public ids;
uint256 public cap; // Maximum per-second issuance token rate
// Getters to access only to the value desired
function usr(uint256 _id) external view returns (address) {
return awards[_id].usr;
}
function bgn(uint256 _id) external view returns (uint256) {
return awards[_id].bgn;
}
function clf(uint256 _id) external view returns (uint256) {
return awards[_id].clf;
}
function fin(uint256 _id) external view returns (uint256) {
return awards[_id].fin;
}
function mgr(uint256 _id) external view returns (address) {
return awards[_id].mgr;
}
function res(uint256 _id) external view returns (uint256) {
return awards[_id].res;
}
function tot(uint256 _id) external view returns (uint256) {
return awards[_id].tot;
}
function rxd(uint256 _id) external view returns (uint256) {
return awards[_id].rxd;
}
function bls(uint256 _id) external view returns (uint256) {
return awards[_id].bls;
}
/**
@dev Base vesting logic contract constructor
*/
constructor() {
wards[msg.sender] = 1;
emit Rely(msg.sender);
}
/**
@dev (Required) Set the per-second token issuance rate.
@param what The tag of the value to change (ex. bytes32("cap"))
@param data The value to update (ex. cap of 1000 tokens/yr == 1000*WAD/365 days)
*/
function file(bytes32 what, uint256 data) external auth lock {
if (what == "cap") cap = data; // The maximum amount of tokens that can be streamed per-second per vest
else revert("DssVest/file-unrecognized-param");
emit File(what, data);
}
function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = x > y ? y : x;
}
function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x + y) >= x, "DssVest/add-overflow");
}
function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x - y) <= x, "DssVest/sub-underflow");
}
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
require(y == 0 || (z = x * y) / y == x, "DssVest/mul-overflow");
}
function toUint48(uint256 x) internal pure returns (uint48 z) {
require((z = uint48(x)) == x, "DssVest/uint48-overflow");
}
function toUint128(uint256 x) internal pure returns (uint128 z) {
require((z = uint128(x)) == x, "DssVest/uint128-overflow");
}
/**
@dev Govanance adds a vesting contract
@param _usr The recipient of the reward
@param _tot The total amount of the vest
@param _bgn The starting timestamp of the vest
@param _tau The duration of the vest (in seconds)
@param _eta The cliff duration in seconds (i.e. 1 years)
@param _mgr An optional manager for the contract. Can yank if vesting ends prematurely.
@return id The id of the vesting contract
*/
function _create(address _usr, uint256 _tot, uint256 _bgn, uint256 _tau, uint256 _eta, address _mgr) internal auth lock returns (uint256 id) {
require(_usr != address(0), "DssVest/invalid-user");
require(_tot > 0, "DssVest/no-vest-total-amount");
require(_bgn < add(block.timestamp, TWENTY_YEARS), "DssVest/bgn-too-far");
require(_bgn > sub(block.timestamp, TWENTY_YEARS), "DssVest/bgn-too-long-ago");
require(_tau > 0, "DssVest/tau-zero");
require(_tot / _tau <= cap, "DssVest/rate-too-high");
require(_tau <= TWENTY_YEARS, "DssVest/tau-too-long");
require(_eta <= _tau, "DssVest/eta-too-long");
require(ids < type(uint256).max, "DssVest/ids-overflow");
id = ++ids;
awards[id] = Award({
usr: _usr,
bgn: toUint48(_bgn),
clf: toUint48(add(_bgn, _eta)),
fin: toUint48(add(_bgn, _tau)),
tot: toUint128(_tot),
rxd: 0,
mgr: _mgr,
res: 0,
bls: 0
});
emit Init(id, _usr);
}
/**
@dev Govanance adds a vesting contract
@param _usr The recipient of the reward
@param _tot The total amount of the vest
@param _bgn The starting timestamp of the vest
@param _tau The duration of the vest (in seconds)
@param _eta The cliff duration in seconds (i.e. 1 years)
@param _mgr An optional manager for the contract. Can yank if vesting ends prematurely.
@return id The id of the vesting contract
*/
function create(address _usr, uint256 _tot, uint256 _bgn, uint256 _tau, uint256 _eta, address _mgr) external returns (uint256 id) {
return _create(_usr,_tot,_bgn,_tau,_eta,_mgr);
}
/**
@dev Govanance adds a vesting contract with all options customizable
@param _usr The recipient of the reward
@param _tot The total amount of the vest
@param _bgn The starting timestamp of the vest
@param _tau The duration of the vest (in seconds)
@param _eta The cliff duration in seconds (i.e. 1 years)
@param _mgr An optional manager for the contract. Can yank if vesting ends prematurely.
@param _res Whether the vesting can be claimed by the usr only
@param _bls Whether the vesting is uninterruptible
@return id The id of the vesting contract
*/
function create_custom(address _usr, uint256 _tot, uint256 _bgn, uint256 _tau, uint256 _eta, address _mgr, bool _res, bool _bls) external returns (uint256 id) {
id = _create(_usr,_tot,_bgn,_tau,_eta,_mgr);
if (_res) { _restrict(id); }
if (_bls) { _bless(id); }
return id;
}
/**
@dev Anyone (or only owner of a vesting contract if restricted) calls this to claim all available rewards
@param _id The id of the vesting contract
*/
function vest(uint256 _id) external {
_vest(_id, type(uint256).max);
}
/**
@dev Anyone (or only owner of a vesting contract if restricted) calls this to claim rewards
@param _id The id of the vesting contract
@param _maxAmt The maximum amount to vest
*/
function vest(uint256 _id, uint256 _maxAmt) external {
_vest(_id, _maxAmt);
}
/**
@dev Anyone (or only owner of a vesting contract if restricted) calls this to claim rewards
@param _id The id of the vesting contract
@param _maxAmt The maximum amount to vest
*/
function _vest(uint256 _id, uint256 _maxAmt) internal lock {
Award memory _award = awards[_id];
require(_award.usr != address(0), "DssVest/invalid-award");
require(_award.res == 0 || _award.usr == msg.sender, "DssVest/only-user-can-claim");
uint256 amt = unpaid(block.timestamp, _award.bgn, _award.clf, _award.fin, _award.tot, _award.rxd);
amt = min(amt, _maxAmt);
awards[_id].rxd = toUint128(add(_award.rxd, amt));
pay(_award.usr, amt);
emit Vest(_id, amt);
}
/**
@dev amount of tokens accrued, not accounting for tokens paid
@param _id The id of the vesting contract
@return amt The accrued amount
*/
function accrued(uint256 _id) external view returns (uint256 amt) {
Award memory _award = awards[_id];
require(_award.usr != address(0), "DssVest/invalid-award");
amt = accrued(block.timestamp, _award.bgn, _award.fin, _award.tot);
}
/**
@dev amount of tokens accrued, not accounting for tokens paid
@param _time The timestamp to perform the calculation
@param _bgn The start time of the contract
@param _fin The end time of the contract
@param _tot The total amount of the contract
@return amt The accrued amount
*/
function accrued(uint256 _time, uint48 _bgn, uint48 _fin, uint128 _tot) internal pure returns (uint256 amt) {
if (_time < _bgn) {
amt = 0;
} else if (_time >= _fin) {
amt = _tot;
} else {
amt = mul(_tot, sub(_time, _bgn)) / sub(_fin, _bgn); // 0 <= amt < _award.tot
}
}
/**
@dev return the amount of vested, claimable GEM for a given ID
@param _id The id of the vesting contract
@return amt The claimable amount
*/
function unpaid(uint256 _id) external view returns (uint256 amt) {
Award memory _award = awards[_id];
require(_award.usr != address(0), "DssVest/invalid-award");
amt = unpaid(block.timestamp, _award.bgn, _award.clf, _award.fin, _award.tot, _award.rxd);
}
/**
@dev amount of tokens accrued, not accounting for tokens paid
@param _time The timestamp to perform the calculation
@param _bgn The start time of the contract
@param _clf The timestamp of the cliff
@param _fin The end time of the contract
@param _tot The total amount of the contract
@param _rxd The number of gems received
@return amt The claimable amount
*/
function unpaid(uint256 _time, uint48 _bgn, uint48 _clf, uint48 _fin, uint128 _tot, uint128 _rxd) internal pure returns (uint256 amt) {
amt = _time < _clf ? 0 : sub(accrued(_time, _bgn, _fin, _tot), _rxd);
}
/**
@dev Allows governance or the owner to restrict vesting to the owner only
@param _id The id of the vesting contract
*/
function _restrict(uint256 _id) internal lock {
address usr_ = awards[_id].usr;
require(usr_ != address(0), "DssVest/invalid-award");
require(wards[msg.sender] == 1 || usr_ == msg.sender, "DssVest/not-authorized");
awards[_id].res = 1;
emit Restrict(_id);
}
/**
@dev Allows governance or the owner to restrict vesting to the owner only
@param _id The id of the vesting contract
*/
function restrict(uint256 _id) external {
_restrict(_id);
}
/**
@dev Make vesting uninterruptible
@param _id The id of the vesting contract
*/
function _bless(uint256 _id) internal lock auth {
address usr_ = awards[_id].usr;
require(usr_ != address(0), "DssVest/invalid-award");
awards[_id].bls = 1;
emit Bless(_id);
}
/**
@dev Make vesting uninterruptible
@param _id The id of the vesting contract
*/
function bless(uint256 _id) external {
_bless(_id);
}
/**
@dev Make vesting interruptible
@param _id The id of the vesting contract
*/
function unbless(uint256 _id) external lock auth {
address usr_ = awards[_id].usr;
require(usr_ != address(0), "DssVest/invalid-award");
awards[_id].bls = 0;
emit Unbless(_id);
}
/**
@dev Allows governance or the owner to enable permissionless vesting
@param _id The id of the vesting contract
*/
function unrestrict(uint256 _id) external lock {
address usr_ = awards[_id].usr;
require(usr_ != address(0), "DssVest/invalid-award");
require(wards[msg.sender] == 1 || usr_ == msg.sender, "DssVest/not-authorized");
awards[_id].res = 0;
emit Unrestrict(_id);
}
/**
@dev Allows governance or the manager to remove a vesting contract immediately
@param _id The id of the vesting contract
*/
function yank(uint256 _id) external {
_yank(_id, block.timestamp);
}
/**
@dev Allows governance or the manager to remove a vesting contract at a future time
@param _id The id of the vesting contract
@param _end A scheduled time to end the vest
*/
function yank(uint256 _id, uint256 _end) external {
_yank(_id, _end);
}
/**
@dev Allows governance or the manager to end pre-maturely a vesting contract
@param _id The id of the vesting contract
@param _end A scheduled time to end the vest
*/
function _yank(uint256 _id, uint256 _end) internal lock {
require(wards[msg.sender] == 1 || awards[_id].mgr == msg.sender, "DssVest/not-authorized");
Award memory _award = awards[_id];
require(_award.usr != address(0), "DssVest/invalid-award");
require(_award.bls == 0, "DssVest/no-yanking-blessed");
if (_end < block.timestamp) {
_end = block.timestamp;
}
if (_end < _award.fin) {
uint48 end = toUint48(_end);
awards[_id].fin = end;
if (end < _award.bgn) {
awards[_id].bgn = end;
awards[_id].clf = end;
awards[_id].tot = 0;
} else if (end < _award.clf) {
awards[_id].clf = end;
awards[_id].tot = 0;
} else {
awards[_id].tot = toUint128(
add(
unpaid(_end, _award.bgn, _award.clf, _award.fin, _award.tot, _award.rxd),
_award.rxd
)
);
}
}
emit Yank(_id, _end);
}
/**
@dev Allows owner to move a contract to a different address
@param _id The id of the vesting contract
@param _dst The address to send ownership of the contract to
*/
function move(uint256 _id, address _dst) external lock {
require(awards[_id].usr == msg.sender, "DssVest/only-user-can-move");
require(_dst != address(0), "DssVest/zero-address-invalid");
awards[_id].usr = _dst;
emit Move(_id, _dst);
}
/**
@dev Return true if a contract is valid
@param _id The id of the vesting contract
@return isValid True for valid contract
*/
function valid(uint256 _id) external view returns (bool isValid) {
isValid = awards[_id].rxd < awards[_id].tot;
}
/**
@dev Override this to implement payment logic.
@param _guy The payment target.
@param _amt The payment amount. [units are implementation-specific]
*/
function pay(address _guy, uint256 _amt) virtual internal;
}
contract DssVestMintable is DssVest {
MintLike public immutable gem;
/**
@dev This contract must be authorized to 'mint' on the token
@param _gem The contract address of the mintable token
*/
constructor(address _gem) DssVest() {
require(_gem != address(0), "DssVest/Invalid-token-address");
gem = MintLike(_gem);
}
/**
@dev Override pay to handle mint logic
@param _guy The recipient of the minted token
@param _amt The amount of token units to send to the _guy
*/
function pay(address _guy, uint256 _amt) override internal {
gem.mint(_guy, _amt);
}
}
contract DssVestSuckable is DssVest {
uint256 internal constant RAY = 10**27;
ChainlogLike public immutable chainlog;
VatLike public immutable vat;
DaiJoinLike public immutable daiJoin;
/**
@dev This contract must be authorized to 'suck' on the vat
@param _chainlog The contract address of the MCD chainlog
*/
constructor(address _chainlog) DssVest() {
require(_chainlog != address(0), "DssVest/Invalid-chainlog-address");
ChainlogLike chainlog_ = chainlog = ChainlogLike(_chainlog);
VatLike vat_ = vat = VatLike(chainlog_.getAddress("MCD_VAT"));
DaiJoinLike daiJoin_ = daiJoin = DaiJoinLike(chainlog_.getAddress("MCD_JOIN_DAI"));
vat_.hope(address(daiJoin_));
}
/**
@dev Override pay to handle suck logic
@param _guy The recipient of the ERC-20 Dai
@param _amt The amount of Dai to send to the _guy [WAD]
*/
function pay(address _guy, uint256 _amt) override internal {
vat.suck(chainlog.getAddress("MCD_VOW"), address(this), mul(_amt, RAY));
daiJoin.exit(_guy, _amt);
}
}
/*
Transferrable token DssVest. Can be used to enable streaming payments of
any arbitrary token from an address (i.e. CU multisig) to individual
contributors.
*/
contract DssVestTransferrable is DssVest {
address public immutable czar;
TokenLike public immutable gem;
/**
@dev This contract must be approved for transfer of the gem on the czar
@param _czar The owner of the tokens to be distributed
@param _gem The token to be distributed
*/
constructor(address _czar, address _gem) DssVest() {
require(_czar != address(0), "DssVest/Invalid-distributor-address");
require(_gem != address(0), "DssVest/Invalid-token-address");
czar = _czar;
gem = TokenLike(_gem);
}
/**
@dev Override pay to handle transfer logic
@param _guy The recipient of the ERC-20 Dai
@param _amt The amount of gem to send to the _guy (in native token units)
*/
function pay(address _guy, uint256 _amt) override internal {
require(gem.transferFrom(czar, _guy, _amt));
}
}
Read Contract
TWENTY_YEARS 0x60fb494b → uint256
accrued 0xf52981f4 → uint256
awards 0xfc5a5b63 → address, uint48, uint48, uint48, address, uint8, uint128, uint128, uint8
bgn 0x21f6c0cf → uint256
bls 0x87690873 → uint256
cap 0x355274ea → uint256
clf 0xcdf43497 → uint256
czar 0x1a8d3a6c → address
fin 0xe529780d → uint256
gem 0x7bd2bea7 → address
ids 0xe7657e15 → uint256
mgr 0xdc2c788f → address
res 0xd4e8fd2e → uint256
rxd 0xe054720f → uint256
tot 0x892de51d → uint256
unpaid 0x53e8863d → uint256
usr 0xc659cd45 → address
valid 0xbf8712c5 → bool
wards 0xbf353dbb → uint256
Write Contract 14 functions
These functions modify contract state and require a wallet transaction to execute.
bless 0xf3d34188
uint256 _id
create 0xdb64ff8f
address _usr
uint256 _tot
uint256 _bgn
uint256 _tau
uint256 _eta
address _mgr
returns: uint256
create_custom 0x24cada91
address _usr
uint256 _tot
uint256 _bgn
uint256 _tau
uint256 _eta
address _mgr
bool _res
bool _bls
returns: uint256
deny 0x9c52a7f1
address _usr
file 0x29ae8114
bytes32 what
uint256 data
move 0xd8a8e03a
uint256 _id
address _dst
rely 0x65fae35e
address _usr
restrict 0x3c433d5f
uint256 _id
unbless 0x07079c24
uint256 _id
unrestrict 0x7d8d2702
uint256 _id
vest 0x6a760b80
uint256 _id
vest 0xbb7c46f3
uint256 _id
uint256 _maxAmt
yank 0x26e027f1
uint256 _id
yank 0x509aaa1d
uint256 _id
uint256 _end
Recent Transactions
No transactions found for this address