Address Contract Verified
Address
0xa52C7C7c0227957c2fBeb6d0f6B4223bd04ff3C2
Balance
0 ETH
Nonce
1
Code Size
8351 bytes
Creator
0x264c86DB...6b31 at tx 0xf3cf4cb9...6a0a7c
Indexed Transactions
0
Contract Bytecode
8351 bytes
0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c8063892de51d1161011a578063d8a8e03a116100ad578063e529780d1161007c578063e529780d14610570578063e7657e151461059b578063f3d34188146105a4578063f52981f4146105b7578063fc5a5b63146105ca57600080fd5b8063d8a8e03a146104e3578063db64ff8f146104f6578063dc2c788f14610509578063e054720f1461053c57600080fd5b8063bf8712c5116100e9578063bf8712c514610415578063c659cd451461045e578063cdf4349714610487578063d4e8fd2e146104b657600080fd5b8063892de51d146103a25780639c52a7f1146103cf578063bb7c46f3146103e2578063bf353dbb146103f557600080fd5b8063509aaa1d116101925780636a760b80116101615780636a760b801461032f5780637bd2bea7146103425780637d8d270214610369578063876908731461037c57600080fd5b8063509aaa1d146102eb57806353e8863d146102fe57806360fb494b1461031157806365fae35e1461031c57600080fd5b806326e027f1116101ce57806326e027f1146102a957806329ae8114146102bc578063355274ea146102cf5780633c433d5f146102d857600080fd5b806307079c24146102005780631a8d3a6c1461021557806321f6c0cf1461025957806324cada9114610296575b600080fd5b61021361020e366004611da8565b6106c0565b005b61023c7f000000000000000000000000f057afeec22e220f47ad4220871364e9e828b2e981565b6040516001600160a01b0390911681526020015b60405180910390f35b610288610267366004611da8565b600090815260026020526040902054600160a01b900465ffffffffffff1690565b604051908152602001610250565b6102886102a4366004611de6565b61079b565b6102136102b7366004611da8565b6107d7565b6102136102ca366004611e67565b6107e4565b61028860045481565b6102136102e6366004611da8565b6108db565b6102136102f9366004611e67565b6108e4565b61028861030c366004611da8565b6108f2565b610288632598060081565b61021361032a366004611e89565b6109de565b61021361033d366004611da8565b610a55565b61023c7f00000000000000000000000058d97b57bb95320f9a05dc918aef65434969c2b281565b610213610377366004611da8565b610a61565b61028861038a366004611da8565b60009081526002602052604090206003015460ff1690565b6102886103b0366004611da8565b600090815260026020819052604090912001546001600160801b031690565b6102136103dd366004611e89565b610b49565b6102136103f0366004611e67565b610bbd565b610288610403366004611e89565b60016020526000908152604090205481565b61044e610423366004611da8565b600090815260026020819052604090912001546001600160801b03808216600160801b909204161090565b6040519015158152602001610250565b61023c61046c366004611da8565b6000908152600260205260409020546001600160a01b031690565b610288610495366004611da8565b600090815260026020526040902054600160d01b900465ffffffffffff1690565b6102886104c4366004611da8565b600090815260026020526040902060010154600160d01b900460ff1690565b6102136104f1366004611ea4565b610bc7565b610288610504366004611ed0565b610d05565b61023c610517366004611da8565b600090815260026020526040902060010154600160301b90046001600160a01b031690565b61028861054a366004611da8565b60009081526002602081905260409091200154600160801b90046001600160801b031690565b61028861057e366004611da8565b60009081526002602052604090206001015465ffffffffffff1690565b61028860035481565b6102136105b2366004611da8565b610d20565b6102886105c5366004611da8565b610d29565b6106556105d8366004611da8565b600260208190526000918252604090912080546001820154928201546003909201546001600160a01b038083169465ffffffffffff600160a01b8504811695600160d01b9586900482169591831694600160301b84049094169360ff929093048216926001600160801b0380831693600160801b90930416911689565b604080516001600160a01b039a8b16815265ffffffffffff998a1660208201529789169088015296909416606086015295909116608084015260ff90811660a08401526001600160801b0394851660c0840152931660e0820152911661010082015261012001610250565b600054156106e95760405162461bcd60e51b81526004016106e090611f28565b60405180910390fd5b60016000908155818152600260205260409020546001600160a01b0316806107235760405162461bcd60e51b81526004016106e090611f57565b33600090815260016020819052604090912054146107535760405162461bcd60e51b81526004016106e090611f86565b600082815260026020526040808220600301805460ff191690555183917f028f3fd71c0ab977798420b1a28086f1c93daa66fdb9d3ba5b52ba1e94564d1391a2505060008055565b60006107ab898989898989610e04565b905082156107bc576107bc816112e5565b81156107cb576107cb816113d3565b98975050505050505050565b6107e181426114a8565b50565b33600090815260016020819052604090912054146108145760405162461bcd60e51b81526004016106e090611f86565b600054156108345760405162461bcd60e51b81526004016106e090611f28565b60016000556206361760ec1b829003610851576004819055610899565b60405162461bcd60e51b815260206004820152601f60248201527f447373566573742f66696c652d756e7265636f676e697a65642d706172616d0060448201526064016106e0565b817fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c7826040516108cb91815260200190565b60405180910390a2505060008055565b6107e1816112e5565b6108ee82826114a8565b5050565b600081815260026020818152604080842081516101208101835281546001600160a01b0380821680845265ffffffffffff600160a01b8404811697850197909752600160d01b9283900487169584019590955260018401549586166060840152600160301b860416608083015260ff9404841660a0820152938101546001600160801b0380821660c0870152600160801b9091041660e0850152600301549091166101008301526109b55760405162461bcd60e51b81526004016106e090611f57565b6109d7428260200151836040015184606001518560c001518660e00151611816565b9392505050565b3360009081526001602081905260409091205414610a0e5760405162461bcd60e51b81526004016106e090611f86565b6001600160a01b038116600081815260016020819052604080832091909155517fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a609190a250565b6107e181600019611857565b60005415610a815760405162461bcd60e51b81526004016106e090611f28565b60016000908155818152600260205260409020546001600160a01b031680610abb5760405162461bcd60e51b81526004016106e090611f57565b336000908152600160208190526040909120541480610ae257506001600160a01b03811633145b610afe5760405162461bcd60e51b81526004016106e090611f86565b600082815260026020526040808220600101805460ff60d01b191690555183917f3d1b575f06b2d660af77eec35d9b3ffcfa956b6c1fdbc840992d4b03b03e622b91a2505060008055565b3360009081526001602081905260409091205414610b795760405162461bcd60e51b81526004016106e090611f86565b6001600160a01b038116600081815260016020526040808220829055517f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b9190a250565b6108ee8282611857565b60005415610be75760405162461bcd60e51b81526004016106e090611f28565b60016000908155828152600260205260409020546001600160a01b03163314610c525760405162461bcd60e51b815260206004820152601a60248201527f447373566573742f6f6e6c792d757365722d63616e2d6d6f766500000000000060448201526064016106e0565b6001600160a01b038116610ca85760405162461bcd60e51b815260206004820152601c60248201527f447373566573742f7a65726f2d616464726573732d696e76616c69640000000060448201526064016106e0565b60008281526002602052604080822080546001600160a01b0319166001600160a01b0385169081179091559051909184917f8ceddd02f4fb8ef0d5d6212cf4c91d59d366e04b977e8b2b944168d2a6d850819190a3505060008055565b6000610d15878787878787610e04565b979650505050505050565b6107e1816113d3565b600081815260026020818152604080842081516101208101835281546001600160a01b0380821680845265ffffffffffff600160a01b8404811697850197909752600160d01b9283900487169584019590955260018401549586166060840152600160301b860416608083015260ff9404841660a0820152938101546001600160801b0380821660c0870152600160801b9091041660e085015260030154909116610100830152610dec5760405162461bcd60e51b81526004016106e090611f57565b6109d742826020015183606001518460c00151611a75565b33600090815260016020819052604082205414610e335760405162461bcd60e51b81526004016106e090611f86565b60005415610e535760405162461bcd60e51b81526004016106e090611f28565b60016000556001600160a01b038716610ea55760405162461bcd60e51b81526020600482015260146024820152732239b9ab32b9ba17b4b73b30b634b216bab9b2b960611b60448201526064016106e0565b60008611610ef55760405162461bcd60e51b815260206004820152601c60248201527f447373566573742f6e6f2d766573742d746f74616c2d616d6f756e740000000060448201526064016106e0565b610f03426325980600611b01565b8510610f475760405162461bcd60e51b81526020600482015260136024820152722239b9ab32b9ba17b133b716ba37b796b330b960691b60448201526064016106e0565b610f55426325980600611b5c565b8511610fa35760405162461bcd60e51b815260206004820152601860248201527f447373566573742f62676e2d746f6f2d6c6f6e672d61676f000000000000000060448201526064016106e0565b60008411610fe65760405162461bcd60e51b815260206004820152601060248201526f447373566573742f7461752d7a65726f60801b60448201526064016106e0565b600454610ff38588611fcc565b11156110395760405162461bcd60e51b8152602060048201526015602482015274088e6e6accae6e85ee4c2e8ca5ae8dede5ad0d2ced605b1b60448201526064016106e0565b63259806008411156110845760405162461bcd60e51b8152602060048201526014602482015273447373566573742f7461752d746f6f2d6c6f6e6760601b60448201526064016106e0565b838311156110cb5760405162461bcd60e51b8152602060048201526014602482015273447373566573742f6574612d746f6f2d6c6f6e6760601b60448201526064016106e0565b600019600354106111155760405162461bcd60e51b8152602060048201526014602482015273447373566573742f6964732d6f766572666c6f7760601b60448201526064016106e0565b60036000815461112490611fee565b9190508190559050604051806101200160405280886001600160a01b0316815260200161115087611bb2565b65ffffffffffff16815260200161116f61116a8887611b01565b611bb2565b65ffffffffffff16815260200161118961116a8888611b01565b65ffffffffffff1681526001600160a01b0384166020820152600060408201526060016111b588611c0f565b6001600160801b03908116825260006020808401829052604093840182905285825260028082528483208651815493880151888801516001600160a01b039283166001600160d01b031996871617600160a01b65ffffffffffff93841602176001600160d01b0316600160d01b918316820217845560608a015160018501805460808d015160a08e015193909516981697909717600160301b938516939093029290921760ff60d01b191660ff9283169091021790945560c088015160e0890151908716600160801b91909716029590951791810191909155610100909501516003909501805460ff1916959091169490941790935590519089169183917f2e3cc5298d3204a0f0fc2be0f6fdefcef002025f4c75caf950b23e6cfbfb78d09190a3600080559695505050505050565b600054156113055760405162461bcd60e51b81526004016106e090611f28565b60016000908155818152600260205260409020546001600160a01b03168061133f5760405162461bcd60e51b81526004016106e090611f57565b33600090815260016020819052604090912054148061136657506001600160a01b03811633145b6113825760405162461bcd60e51b81526004016106e090611f86565b600082815260026020526040808220600101805460ff60d01b1916600160d01b1790555183917f9247a2bf1b75bc397d4043d99b9cebce531548a01dbb56a5d4c5f5ca26051e8d91a2505060008055565b600054156113f35760405162461bcd60e51b81526004016106e090611f28565b60016000908155818152600260205260409020546001600160a01b03168061142d5760405162461bcd60e51b81526004016106e090611f57565b336000908152600160208190526040909120541461145d5760405162461bcd60e51b81526004016106e090611f86565b600082815260026020526040808220600301805460ff191660011790555183917f7f523e15b3feb7bbd0ee183627685fbe452b55efd91b1923a88f94abb36d362d91a2505060008055565b600054156114c85760405162461bcd60e51b81526004016106e090611f28565b600160008181553381526020829052604090205414806115085750600082815260026020526040902060010154600160301b90046001600160a01b031633145b6115245760405162461bcd60e51b81526004016106e090611f86565b60008281526002602081815260409283902083516101208101855281546001600160a01b0380821680845265ffffffffffff600160a01b8404811696850196909652600160d01b9283900486169784019790975260018401549485166060840152600160301b850416608083015260ff9304831660a0820152928101546001600160801b0380821660c0860152600160801b9091041660e08401526003015416610100820152906115e75760405162461bcd60e51b81526004016106e090611f57565b61010081015160ff161561163d5760405162461bcd60e51b815260206004820152601a60248201527f447373566573742f6e6f2d79616e6b696e672d626c657373656400000000000060448201526064016106e0565b42821015611649574291505b806060015165ffffffffffff168210156117d357600061166883611bb2565b6000858152600260209081526040909120600101805465ffffffffffff191665ffffffffffff8481169182179092559185015192935091909116111561170257600084815260026020819052604090912080546001600160a01b0316600160a01b65ffffffffffff85169081026001600160d01b031691909117600160d01b919091021781550180546001600160801b03191690556117d1565b816040015165ffffffffffff168165ffffffffffff16101561176057600084815260026020819052604090912080546001600160d01b0316600160d01b65ffffffffffff8516021781550180546001600160801b03191690556117d1565b6117a061179b611788858560200151866040015187606001518860c001518960e00151611816565b8460e001516001600160801b0316611b01565b611c0f565b60008581526002602081905260409091200180546001600160801b0319166001600160801b03929092169190911790555b505b827f6f2a3ed78a3066d89360b6c89e52bf3313f52e859401a3ea5fa0f033fd540c3c8360405161180591815260200190565b60405180910390a250506000805550565b60008465ffffffffffff16871061184a5761184561183688888787611a75565b836001600160801b0316611b5c565b610d15565b6000979650505050505050565b600054156118775760405162461bcd60e51b81526004016106e090611f28565b600160008181558381526002602081815260409283902083516101208101855281546001600160a01b03808216808452600160a01b830465ffffffffffff90811696850196909652600160d01b92839004861697840197909752968301549384166060830152600160301b840490961660808201529490910460ff90811660a0860152918101546001600160801b0380821660c0870152600160801b9091041660e085015260030154166101008301526119435760405162461bcd60e51b81526004016106e090611f57565b60a081015160ff161580611960575080516001600160a01b031633145b6119ac5760405162461bcd60e51b815260206004820152601b60248201527f447373566573742f6f6e6c792d757365722d63616e2d636c61696d000000000060448201526064016106e0565b60006119d0428360200151846040015185606001518660c001518760e00151611816565b90506119dc8184611c68565b90506119f861179b8360e001516001600160801b031683611b01565b60008581526002602081905260409091200180546001600160801b03928316600160801b0292169190911790558151611a319082611c7d565b837fa2906882572b0e9dfe893158bb064bc308eb1bd87d1da481850f9d17fc29384782604051611a6391815260200190565b60405180910390a25050600080555050565b60008365ffffffffffff16851015611a8f57506000611af9565b8265ffffffffffff168510611aae57506001600160801b038116611af9565b611ac88365ffffffffffff168565ffffffffffff16611b5c565b611aec836001600160801b0316611ae7888865ffffffffffff16611b5c565b611d41565b611af69190611fcc565b90505b949350505050565b600082611b0e8382612007565b9150811015611b565760405162461bcd60e51b8152602060048201526014602482015273447373566573742f6164642d6f766572666c6f7760601b60448201526064016106e0565b92915050565b600082611b69838261201a565b9150811115611b565760405162461bcd60e51b8152602060048201526015602482015274447373566573742f7375622d756e646572666c6f7760581b60448201526064016106e0565b8065ffffffffffff81168114611c0a5760405162461bcd60e51b815260206004820152601760248201527f447373566573742f75696e7434382d6f766572666c6f7700000000000000000060448201526064016106e0565b919050565b806001600160801b0381168114611c0a5760405162461bcd60e51b815260206004820152601860248201527f447373566573742f75696e743132382d6f766572666c6f77000000000000000060448201526064016106e0565b6000818311611c7757826109d7565b50919050565b6040516323b872dd60e01b81526001600160a01b037f000000000000000000000000f057afeec22e220f47ad4220871364e9e828b2e9811660048301528381166024830152604482018390527f00000000000000000000000058d97b57bb95320f9a05dc918aef65434969c2b216906323b872dd906064016020604051808303816000875af1158015611d14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d38919061202d565b6108ee57600080fd5b6000811580611d6557508282611d57818361204a565b9250611d639083611fcc565b145b611b565760405162461bcd60e51b8152602060048201526014602482015273447373566573742f6d756c2d6f766572666c6f7760601b60448201526064016106e0565b600060208284031215611dba57600080fd5b5035919050565b80356001600160a01b0381168114611c0a57600080fd5b80151581146107e157600080fd5b600080600080600080600080610100898b031215611e0357600080fd5b611e0c89611dc1565b975060208901359650604089013595506060890135945060808901359350611e3660a08a01611dc1565b925060c0890135611e4681611dd8565b915060e0890135611e5681611dd8565b809150509295985092959890939650565b60008060408385031215611e7a57600080fd5b50508035926020909101359150565b600060208284031215611e9b57600080fd5b6109d782611dc1565b60008060408385031215611eb757600080fd5b82359150611ec760208401611dc1565b90509250929050565b60008060008060008060c08789031215611ee957600080fd5b611ef287611dc1565b955060208701359450604087013593506060870135925060808701359150611f1c60a08801611dc1565b90509295509295509295565b602080825260159082015274111cdcd5995cdd0bdcde5cdd195b4b5b1bd8dad959605a1b604082015260600190565b602080825260159082015274111cdcd5995cdd0bda5b9d985b1a590b585dd85c99605a1b604082015260600190565b602080825260169082015275111cdcd5995cdd0bdb9bdd0b585d5d1a1bdc9a5e995960521b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082611fe957634e487b7160e01b600052601260045260246000fd5b500490565b60006001820161200057612000611fb6565b5060010190565b80820180821115611b5657611b56611fb6565b81810381811115611b5657611b56611fb6565b60006020828403121561203f57600080fd5b81516109d781611dd8565b600081600019048311821515161561206457612064611fb6565b50029056fea26469706673582212204a292a8dd3c156ae40fe24db4c12ca5fa9af9e70e5a4221776439c986e46808a64736f6c63430008100033
Verified Source Code Full Match
Compiler: v0.8.16+commit.07a7930e
EVM: london
Optimization: Yes (200 runs)
Vester.sol 8 lines
// SPDX-License-Identifier: GNU AGPLv3
pragma solidity 0.8.16;
import {DssVestTransferrable} from "dss-vest/DssVest.sol";
contract Vester is DssVestTransferrable {
constructor(address _czar, address _gem) DssVestTransferrable(_czar, _gem) {}
}
DssVest.sol 557 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 {
address usr_ = awards[_id].usr;
require(usr_ != address(0), "DssVest/invalid-award");
require(wards[msg.sender] == 1, "DssVest/not-authorized");
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 {
address usr_ = awards[_id].usr;
require(usr_ != address(0), "DssVest/invalid-award");
require(wards[msg.sender] == 1, "DssVest/not-authorized");
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