Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0x702d770efd343f9727B42aCDd6336BFE51f02dB2
Balance 0 ETH
Nonce 1
Code Size 7977 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7977 bytes
0x608060405234801561001057600080fd5b50600436106101375760003560e01c80638da5cb5b116100b8578063d1ad17bf1161007c578063d1ad17bf146103cf578063dd128200146103e2578063f2fde38b146103f5578063fc0bf82514610408578063fc7448bd14610411578063fcff53a71461042457600080fd5b80638da5cb5b1461036857806392d3be791461038d578063b511edcb146103a0578063c28b16e2146103b3578063cadc1b71146103bc57600080fd5b80635c975abb116100ff5780635c975abb1461022357806368233eef14610240578063715018a614610249578063821bee73146102515780638779342d1461035557600080fd5b80631a0058f51461013c57806320f6b0a9146101c45780632c3ce5fa146101e45780633f6746ce146101fb57806359778bfd14610210575b600080fd5b61019961014a366004611890565b6040805180820190915260008082526020820152506000908152600960209081526040918290208251808401909352546001600160a01b0381168352600160a01b900460ff1615159082015290565b6040805182516001600160a01b03168152602092830151151592810192909252015b60405180910390f35b6101d76101d2366004611890565b610437565b6040516101bb91906118e4565b6101ed60075481565b6040519081526020016101bb565b61020e610209366004611a1c565b61064a565b005b61020e61021e366004611a1c565b610687565b600254600160a01b900460ff1660405190151581526020016101bb565b6101ed60065481565b61020e6106c4565b6102de61025f366004611890565b600a602052600090815260409020805460018201546002830154600384015460048501546005860154600687015460078801546008890154600b909901546001600160a01b03988916999789169896979596949593949293919281169060ff600160a01b8204811691600160a81b8104821691600160b01b909104168d565b604080516001600160a01b039e8f1681529c8e1660208e01528c019a909a5260608b019890985260808a019690965260a089019490945260c088019290925260e08701526101008601529094166101208401529215156101408301529115156101608201529015156101808201526101a0016101bb565b61020e610363366004611890565b6106d8565b6002546001600160a01b03165b6040516001600160a01b0390911681526020016101bb565b600154610375906001600160a01b031681565b6101ed6103ae366004611c38565b610745565b6101ed60055481565b61020e6103ca366004611d6c565b610b18565b600054610375906001600160a01b031681565b61020e6103f0366004611890565b610bde565b61020e610403366004611a1c565b610d26565b6101ed60085481565b61020e61041f366004611890565b610d61565b6101ed610432366004611de1565b610dcf565b6104d1604051806101e0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001606081526020016060815260200160006001600160a01b031681526020016000151581526020016000151581526020016000151581525090565b6000828152600a602090815260409182902082516101e08101845281546001600160a01b039081168252600183015416818401526002820154818501526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e0820152600882015461010082015260098201805485518186028101860190965280865291949293610120860193929083018282801561059b57602002820191906000526020600020905b815481526020019060010190808311610587575b50505050508152602001600a82018054806020026020016040519081016040528092919081815260200182805480156105f357602002820191906000526020600020905b8154815260200190600101908083116105df575b5050509183525050600b91909101546001600160a01b038116602083015260ff600160a01b8204811615156040840152600160a81b8204811615156060840152600160b01b90910416151560809091015292915050565b610652610dff565b6001600160a01b03811661066557600080fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b61068f610dff565b6001600160a01b0381166106a257600080fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6106cc610dff565b6106d66000610e2c565b565b6106e0610dff565b60648111156107405760405162461bcd60e51b815260206004820152602160248201527f457363726f77206665652070657263656e74206d757374206265203c3d2031306044820152600360fc1b60648201526084015b60405180910390fd5b600755565b600061074f610e7e565b610757610ea9565b8151516107b15760405162461bcd60e51b815260206004820152602260248201527f4d7573742070726f76696465206174206c65617374206f6e652072656365697660448201526132b960f11b6064820152608401610737565b81515160a0830151511480156107cd575081515160c083015151145b6108305760405162461bcd60e51b815260206004820152602e60248201527f436c696666206172726179206c656e67746820646f65736e74206d617463682060448201526d1c9958d95a5d995c8818dbdd5b9d60921b6064820152608401610737565b6006805490600061084083611e19565b919050555081610120015115610973578160e001516001600160a01b0316336001600160a01b0316146108c55760405162461bcd60e51b815260206004820152602760248201527f4f6e6c792070726f6a6563742077616c6c65742063616e2070617920757066726044820152666f6e742066656560c81b6064820152608401610737565b60006108d983604001518460800151610dcf565b90506000606460085460646108ee9190611e32565b6108f89084611e45565b6109029190611e5c565b60208501516001549192506109229133906001600160a01b031684610ed3565b600654602085810151604080516001600160a01b0390921682529181018490523392917f9eda2e8906c8cb89ee8ab3b536baa8cd7931792f59d00ca1e7317cd8ccb94fdc910160405180910390a350505b600061097e33610f40565b90506000818061099057508361012001515b60408051808201825260e08701516001600160a01b0390811682528315156020808401918252600654600090815260099091528481209351845492511515600160a01b026001600160a81b03199093169316929092171790915586515191870151929350916109ff9190611e5c565b905060005b855151811015610a9e57610a8c86600001518281518110610a2757610a27611e7e565b602002602001015187602001518489606001518a608001518b60a001518781518110610a5557610a55611e7e565b60200260200101518c60c001518881518110610a7357610a73611e7e565b60200260200101518d60e001518e61010001518c610f6d565b80610a9681611e19565b915050610a04565b508460e001516001600160a01b03166006547f68e8dd52363ad9cd763933cd4f1e47d756431b5f104927e2f2250467451a482b848860200151604051610af992919091151582526001600160a01b0316602082015260400190565b60405180910390a36006549350505050610b136001600355565b919050565b610b20610e7e565b6000546001600160a01b03163314610b895760405162461bcd60e51b815260206004820152602660248201527f43616c6c6572206973206e6f742074686520617574686f72697a65642073636860448201526532b23ab632b960d11b6064820152608401610737565b610b91610ea9565b60005b81811015610bcf57610bbd838383818110610bb157610bb1611e7e565b905060200201356112c8565b80610bc781611e19565b915050610b94565b50610bda6001600355565b5050565b610be6610dff565b610bee610ea9565b6000818152600a60205260409020600b810154600160a01b900460ff16610c4f5760405162461bcd60e51b815260206004820152601560248201527456657374696e67206973206e6f742061637469766560581b6044820152606401610737565b600b810154600160a81b900460ff16610caa5760405162461bcd60e51b815260206004820152601860248201527f56657374696e67206973206e6f74207265766f6361626c6500000000000000006044820152606401610737565b600b8101805460ff60a01b198116909155600682018054600090915560018301549091610ce4916001600160a01b0390811691168361168e565b6040518381527fd3dda1e90178815bfcce9e6835272f414b2353c6a301e4ea98e6a7935b74558d9060200160405180910390a15050610d236001600355565b50565b610d2e610dff565b6001600160a01b038116610d5857604051631e4fbdf760e01b815260006004820152602401610737565b610d2381610e2c565b610d69610dff565b6064811115610dca5760405162461bcd60e51b815260206004820152602760248201527f557066726f6e7420646973636f756e742070657263656e74206d7573742062656044820152660203c3d203130360cc1b6064820152608401610737565b600855565b600060648260075485610de29190611e45565b610dec9190611e45565b610df69190611e5c565b90505b92915050565b6002546001600160a01b031633146106d65760405163118cdaa760e01b8152336004820152602401610737565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600254600160a01b900460ff16156106d65760405163d93c066560e01b815260040160405180910390fd5b600260035403610ecc57604051633ee5aeb560e01b815260040160405180910390fd5b6002600355565b6040516001600160a01b038481166024830152838116604483015260648201839052610f3a9186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506116c4565b50505050565b6004546000906001600160a01b031615801590610df95750506004546001600160a01b0390811691161490565b60008611610fd25760405162461bcd60e51b815260206004820152602c60248201527f4e756d626572206f662072656c6561736573206d75737420626520677265617460448201526b6572207468616e207a65726f60a01b6064820152608401610737565b83518551146110345760405162461bcd60e51b815260206004820152602860248201527f436c6966662074696d657320616e642070657263656e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610737565b600060056000815461104590611e19565b918290555090506000611058888b611e5c565b9050604051806101e001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018b81526020018281526020018a4261109c9190611e94565b81526020018a81526020018b815260200160008152602001898152602001888152602001878152602001866001600160a01b031681526020016001151581526020018515158152602001841515815250600a600084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e0820151816007015561010082015181600801556101208201518160090190805190602001906111bd929190611830565b5061014082015180516111da91600a840191602090910190611830565b50610160820151600b90910180546101808401516101a08501516101c0909501511515600160b01b0260ff60b01b19951515600160a81b029590951661ffff60a81b19911515600160a01b026001600160a81b03199093166001600160a01b039095169490941791909117169190911791909117905561125985610f40565b611269576112698b86308d610ed3565b60408051838152602081018c90529081018990526001600160a01b03808d1691908e16907f0e5241d7ce8cb0f267850442bca27c37f22bf408fa47cf52d668cc6ba21354719060600160405180910390a3505050505050505050505050565b6000818152600a602052604090206009810154156113ba5760001960005b600983015481101561134e578183600901828154811061130857611308611e7e565b9060005260206000200154101561133c5782600901818154811061132e5761132e611e7e565b906000526020600020015491505b8061134681611e19565b9150506112e6565b50804210156113b85760405162461bcd60e51b815260206004820152603060248201527f43616e6e6f742072656c65617365206265666f7265207468652066697273742060448201526f18db1a5999881a5cc81c995858da195960821b6064820152608401610737565b505b80600401544210156114215760405162461bcd60e51b815260206004820152602a60248201527f546f6b656e73206e6f742079657420766573746564207065722072656c65617360448201526965207363686564756c6560b01b6064820152608401610737565b600081600601541161146b5760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e732072656d61696e696e6760681b6044820152606401610737565b600381015460005b60098301548110156115545782600901818154811061149457611494611e7e565b906000526020600020015442101580156114cd5750600083600a0182815481106114c0576114c0611e7e565b9060005260206000200154115b15611542576000606484600a0183815481106114eb576114eb611e7e565b906000526020600020015485600201546115059190611e45565b61150f9190611e5c565b905061151b8184611e94565b9250600084600a01838154811061153457611534611e7e565b600091825260209091200155505b8061154c81611e19565b915050611473565b508160060154811115611568575060068101545b81600501548260040160008282546115809190611e94565b925050819055508082600601600082825461159b9190611e32565b9091555050600b820154600160b01b900460ff166115ff5760006064600754836115c59190611e45565b6115cf9190611e5c565b90506115db8183611e32565b60018085015490549193506115fd916001600160a01b0391821691168361168e565b505b6001820154825461161d916001600160a01b0390811691168361168e565b60078201805490600061162f83611e19565b9190505550816006015460000361165057600b8201805460ff60a01b191690555b60408051848152602081018390527f06bfc9e66ca14afa6b27c5211d92e2453d2007b51cd69146f7d2b2b5654cf2b9910160405180910390a1505050565b6040516001600160a01b038381166024830152604482018390526116bf91859182169063a9059cbb90606401610f08565b505050565b60006116d96001600160a01b03841683611727565b905080516000141580156116fe5750808060200190518101906116fc9190611ea7565b155b156116bf57604051635274afe760e01b81526001600160a01b0384166004820152602401610737565b6060610df68383600084600080856001600160a01b0316848660405161174d9190611ec4565b60006040518083038185875af1925050503d806000811461178a576040519150601f19603f3d011682016040523d82523d6000602084013e61178f565b606091505b509150915061179f8683836117ab565b925050505b9392505050565b6060826117c0576117bb82611807565b6117a4565b81511580156117d757506001600160a01b0384163b155b1561180057604051639996b31560e01b81526001600160a01b0385166004820152602401610737565b50806117a4565b8051156118175780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b82805482825590600052602060002090810192821561186b579160200282015b8281111561186b578251825591602001919060010190611850565b5061187792915061187b565b5090565b5b80821115611877576000815560010161187c565b6000602082840312156118a257600080fd5b5035919050565b600081518084526020808501945080840160005b838110156118d9578151875295820195908201906001016118bd565b509495945050505050565b602081526118fe6020820183516001600160a01b03169052565b6000602083015161191a60408401826001600160a01b03169052565b506040830151606083015260608301516080830152608083015160a083015260a083015160c083015260c083015160e083015260e08301516101008181850152808501519150506101208181850152808501519150506101e061014081818601526119896102008601846118a9565b9250808601519050610160601f1986850301818701526119a984836118a9565b9350808701519150506101806119c9818701836001600160a01b03169052565b86015190506101a06119de8682018315159052565b86015190506101c06119f38682018315159052565b90950151151593019290925250919050565b80356001600160a01b0381168114610b1357600080fd5b600060208284031215611a2e57600080fd5b610df682611a05565b634e487b7160e01b600052604160045260246000fd5b604051610160810167ffffffffffffffff81118282101715611a7157611a71611a37565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611aa057611aa0611a37565b604052919050565b600067ffffffffffffffff821115611ac257611ac2611a37565b5060051b60200190565b600082601f830112611add57600080fd5b81356020611af2611aed83611aa8565b611a77565b82815260059290921b84018101918181019086841115611b1157600080fd5b8286015b84811015611b3357611b2681611a05565b8352918301918301611b15565b509695505050505050565b600082601f830112611b4f57600080fd5b81356020611b5f611aed83611aa8565b828152600592831b8501820192828201919087851115611b7e57600080fd5b8387015b85811015611c1257803567ffffffffffffffff811115611ba25760008081fd5b8801603f81018a13611bb45760008081fd5b858101356040611bc6611aed83611aa8565b82815291851b8301810191888101908d841115611be35760008081fd5b938201935b83851015611c0157843582529389019390890190611be8565b885250505093850193508401611b82565b5090979650505050505050565b8015158114610d2357600080fd5b8035610b1381611c1f565b600060208284031215611c4a57600080fd5b813567ffffffffffffffff80821115611c6257600080fd5b908301906101608286031215611c7757600080fd5b611c7f611a4d565b823582811115611c8e57600080fd5b611c9a87828601611acc565b825250611ca960208401611a05565b602082015260408301356040820152606083013560608201526080830135608082015260a083013582811115611cde57600080fd5b611cea87828601611b3e565b60a08301525060c083013582811115611d0257600080fd5b611d0e87828601611b3e565b60c083015250611d2060e08401611a05565b60e08201526101009150611d35828401611c2d565b828201526101209150611d49828401611c2d565b828201526101409150611d5d828401611a05565b91810191909152949350505050565b60008060208385031215611d7f57600080fd5b823567ffffffffffffffff80821115611d9757600080fd5b818501915085601f830112611dab57600080fd5b813581811115611dba57600080fd5b8660208260051b8501011115611dcf57600080fd5b60209290920196919550909350505050565b60008060408385031215611df457600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b600060018201611e2b57611e2b611e03565b5060010190565b81810381811115610df957610df9611e03565b8082028115828204841417610df957610df9611e03565b600082611e7957634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b80820180821115610df957610df9611e03565b600060208284031215611eb957600080fd5b81516117a481611c1f565b6000825160005b81811015611ee55760208186018101518583015201611ecb565b50600092019182525091905056fea26469706673582212202c0f97682613238202304cb9db211b65d5658cb55fbbd25d4dffaebbadabdd0a64736f6c63430008150033

Verified Source Code Full Match

Compiler: v0.8.21+commit.d9974bed EVM: paris Optimization: Yes (200 runs)
CoreVesting.sol 303 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ICoreVesting} from "./interfaces/ICoreVesting.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

// @title: PB&J Core Vesting
// @author: Tyler Martin
// @website: https://pbandjweb3.com/ 
contract CoreVesting is ICoreVesting, Ownable, Pausable, ReentrancyGuard {
    address otcMarketplace;
    uint256 public vestingCounter;
    uint256 public batchCounter;
    uint256 public escrowFeePercent = 1; // 1% fee
    uint256 public upfrontDiscountPercent = 25; // 25% discount for upfront payment

    mapping(uint256 => Batch) private batches;
    mapping(uint256 => Vesting) public vestings;

    event VestingCreated(uint256 vestingId, address indexed receiver, address indexed projectToken, uint256 totalTokens, uint256 numReleases);
    event TokensReleased(uint256 vestingId, uint256 tokensReleased);
    event VestingRevoked(uint256 vestingId);
    event BatchCreated(uint256 indexed batchId, address indexed projectWallet, bool paidUpfront, address projectToken);
    event UpfrontFeePaid(uint256 indexed batchId, address indexed projectWallet, address projectToken, uint256 amount);

    struct Vesting {
        address receiver;
        address projectToken;
        uint256 totalTokens;
        uint256 tokensPerRelease;
        uint256 nextReleaseTime;
        uint256 releaseInterval;
        uint256 remainingTokens;
        uint256 paymentsMade;
        uint256 totalPayments;
        uint256[] cliffTimes;
        uint256[] cliffPercents;
        address projectWallet;
        bool active;
        bool revocable;
        bool feeExempt;
    }

    struct Batch {
        address projectWallet;
        bool paidUpfront;
    }

    // CONSTRUCTOR
    constructor(address _escrowWallet) Ownable(msg.sender) {
        require(_escrowWallet != address(0));
        escrowWallet = _escrowWallet;
    }

    // MODIFIERS
    modifier canCreateVesting() {
        require(msg.sender == owner() || 
        (msg.sender != address(0) && msg.sender == otcMarketplace), "Caller can not create vesting");
        _;
    }

    modifier onlyScheduler() {
        require(msg.sender == scheduler, "Caller is not the authorized scheduler");
        _;
    }

    function batchCreateVesting(
        VestingParams memory params
    ) external override whenNotPaused nonReentrant returns (uint256) {
        require(params.receivers.length > 0, "Must provide at least one receiver");
        require(params.cliffTimes.length == params.receivers.length && params.cliffPercents.length == params.receivers.length, "Cliff array length doesnt match receiver count");

        batchCounter++;

        if (params.payUpFront) {
            require(msg.sender == params.projectWallet, "Only project wallet can pay upfront fee");
            uint256 totalFee = calculateTotalFee(params.totalTokens, params.numReleases);
            uint256 feeAmount = (totalFee * (100 - upfrontDiscountPercent)) / 100;
            SafeERC20.safeTransferFrom(IERC20(params.projectToken), msg.sender, escrowWallet, feeAmount);
            emit UpfrontFeePaid(batchCounter, msg.sender, params.projectToken, feeAmount);
        }

        bool isOtcDeal = isOtc(msg.sender);
        bool isFeeExempt = isOtcDeal || params.payUpFront;

        batches[batchCounter] = Batch({
            projectWallet: params.projectWallet,
            paidUpfront: isFeeExempt
        });

        uint256 tokensPerReceiver = params.totalTokens / params.receivers.length;

        for (uint256 i = 0; i < params.receivers.length; i++) { 
            _createVesting(
                params.receivers[i],
                params.projectToken,
                tokensPerReceiver,
                params.releaseInterval,
                params.numReleases,
                params.cliffTimes[i],
                params.cliffPercents[i],
                params.projectWallet,
                params.revocable,
                isFeeExempt // feeExempt if OTC or paid upfront
            );
        }

        emit BatchCreated(batchCounter, params.projectWallet, isFeeExempt, params.projectToken);

        return batchCounter;
    }

    function batchReleaseTokens(uint256[] calldata _vestingIds) external whenNotPaused onlyScheduler nonReentrant {
        for (uint256 i = 0; i < _vestingIds.length; i++) {
            releaseTokens(_vestingIds[i]);
        }
    }

    function _createVesting(
        address _receiver,
        address _projectToken,
        uint256 _totalTokens,
        uint256 _releaseInterval,
        uint256 _numReleases,
        uint256[] memory _cliffTimes,
        uint256[] memory _cliffPercents,
        address _projectWallet,
        bool _revocable,
        bool _feeExempt
    ) internal {
        require(_numReleases > 0, "Number of releases must be greater than zero");
        require(_cliffTimes.length == _cliffPercents.length, "Cliff times and percents length mismatch");

        uint newVestingId = ++vestingCounter;
        uint256 tokensPerRelease = _totalTokens / _numReleases;

        vestings[newVestingId] = Vesting({
            receiver: _receiver,
            projectToken: _projectToken,
            totalTokens: _totalTokens,
            tokensPerRelease: tokensPerRelease,
            nextReleaseTime: block.timestamp + _releaseInterval,
            releaseInterval: _releaseInterval,
            remainingTokens: _totalTokens,
            paymentsMade: 0,
            totalPayments: _numReleases,
            cliffTimes: _cliffTimes,
            cliffPercents: _cliffPercents,
            projectWallet: _projectWallet,
            active: true,
            revocable: _revocable,
            feeExempt: _feeExempt
        });

        if(!isOtc(_projectWallet)) {
            SafeERC20.safeTransferFrom(IERC20(_projectToken), _projectWallet, address(this), _totalTokens);
        }

        emit VestingCreated(newVestingId, _receiver, _projectToken, _totalTokens, _numReleases);
    }

  function releaseTokens(uint256 _vestingId) internal {
    Vesting storage vesting = vestings[_vestingId];

    // -----------------------------------------
    // 1. Block release until earliest cliff is hit (if any)
    // -----------------------------------------
    if (vesting.cliffTimes.length > 0) {
        // Find the earliest cliff time
        uint256 earliestCliff = type(uint256).max;
        for (uint256 i = 0; i < vesting.cliffTimes.length; i++) {
            if (vesting.cliffTimes[i] < earliestCliff) {
                earliestCliff = vesting.cliffTimes[i];
            }
        }
        // Revert if we have not reached the earliest cliff yet
        require(
            block.timestamp >= earliestCliff,
            "Cannot release before the first cliff is reached"
        );
    }

    // -----------------------------------------
    // 2. Also enforce the normal vesting schedule
    // -----------------------------------------
    require(
        block.timestamp >= vesting.nextReleaseTime,
        "Tokens not yet vested per release schedule"
    );
    require(vesting.remainingTokens > 0, "No tokens remaining");

    // -----------------------------------------
    // 3. Calculate regular release + any cliffs
    // -----------------------------------------
    uint256 tokensToRelease = vesting.tokensPerRelease;

    // Include any cliff tokens that have not been released yet
    for (uint256 i = 0; i < vesting.cliffTimes.length; i++) {
        if (
            block.timestamp >= vesting.cliffTimes[i] &&
            vesting.cliffPercents[i] > 0
        ) {
            uint256 cliffTokens =
                (vesting.totalTokens * vesting.cliffPercents[i]) / 100;
            tokensToRelease += cliffTokens;
            // Mark that cliff as released, so it's not released again
            vesting.cliffPercents[i] = 0;
        }
    }

    // -----------------------------------------
    // 4. Do not exceed the remaining tokens
    // -----------------------------------------
    if (tokensToRelease > vesting.remainingTokens) {
        tokensToRelease = vesting.remainingTokens;
    }

    // -----------------------------------------
    // 5. Update vesting schedule
    // -----------------------------------------
    vesting.nextReleaseTime += vesting.releaseInterval;
    vesting.remainingTokens -= tokensToRelease;

    // -----------------------------------------
    // 6. Deduct fee if applicable, then transfer
    // -----------------------------------------
    if (!vesting.feeExempt) {
        uint256 feeAmount = (tokensToRelease * escrowFeePercent) / 100;
        tokensToRelease -= feeAmount;
        SafeERC20.safeTransfer(IERC20(vesting.projectToken), escrowWallet, feeAmount);
    }

    // Transfer to the receiver
    SafeERC20.safeTransfer(IERC20(vesting.projectToken), vesting.receiver, tokensToRelease);
    vesting.paymentsMade++;

    // -----------------------------------------
    // 7. If no tokens remain, mark vesting inactive
    // -----------------------------------------
    if (vesting.remainingTokens == 0) {
        vesting.active = false;
    }

    emit TokensReleased(_vestingId, tokensToRelease);
}

    function revokeVesting(uint256 _vestingId) external onlyOwner nonReentrant {
        Vesting storage vesting = vestings[_vestingId];
        require(vesting.active, "Vesting is not active");
        require(vesting.revocable, "Vesting is not revocable");

        vesting.active = false;
        uint256 remainingTokens = vesting.remainingTokens;
        vesting.remainingTokens = 0;

        SafeERC20.safeTransfer(IERC20(vesting.projectToken), vesting.projectWallet, remainingTokens);

        emit VestingRevoked(_vestingId);
    }

    // SETTERS
    function setEscrowFeePercent(uint256 _escrowFeePercent) external onlyOwner {
        require(_escrowFeePercent <= 100, "Escrow fee percent must be <= 100");
        escrowFeePercent = _escrowFeePercent;
    }

    function setOtcMarketplace(address _otcMarketplaceAddress) external onlyOwner {
        require(_otcMarketplaceAddress != address(0));
        otcMarketplace = _otcMarketplaceAddress;
    }

    function setUpfrontDiscountPercent(uint256 _upfrontDiscountPercent) external onlyOwner {
        require(_upfrontDiscountPercent <= 100, "Upfront discount percent must be <= 100");
        upfrontDiscountPercent = _upfrontDiscountPercent;
    }

    function setScheduler(address _scheduler) external onlyOwner {
        require(_scheduler != address(0));
        scheduler = _scheduler;
    }

    // GETTERS 
    function getBatchInfo(uint256 _batchId) external view returns (Batch memory) {
        return batches[_batchId];
    }

    function getVestingInfo(uint256 _vestingId) external view returns (Vesting memory) {
        return vestings[_vestingId];
    }

    // PRIVATE
    function isOtc(address sender) private view returns (bool) {
        return otcMarketplace != address(0) && sender == otcMarketplace;
    }

    function calculateTotalFee(uint256 totalTokens, uint256 numReleases) public view override returns (uint256) {
        return (totalTokens * escrowFeePercent * numReleases) / 100;
    }
}
ICoreVesting.sol 27 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
abstract contract ICoreVesting {
    address public scheduler;
    address public escrowWallet;

    struct VestingParams {
        address[] receivers;
        address projectToken;
        uint256 totalTokens;
        uint256 releaseInterval;
        uint256 numReleases;
        uint256[][] cliffTimes;
        uint256[][] cliffPercents;
        address projectWallet;
        bool revocable;
        bool payUpFront;
        address stablecoin;
    }

    function batchCreateVesting(
        VestingParams memory params
    ) external virtual returns (uint256);

    function calculateTotalFee(uint256 totalTokens, uint256 numReleases) public virtual returns (uint256);

}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}
Pausable.sol 119 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
SafeERC20.sol 118 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Address.sol 159 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

Read Contract

batchCounter 0x68233eef → uint256
calculateTotalFee 0xfcff53a7 → uint256
escrowFeePercent 0x2c3ce5fa → uint256
escrowWallet 0x92d3be79 → address
getBatchInfo 0x1a0058f5 → tuple
getVestingInfo 0x20f6b0a9 → tuple
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
scheduler 0xd1ad17bf → address
upfrontDiscountPercent 0xfc0bf825 → uint256
vestingCounter 0xc28b16e2 → uint256
vestings 0x821bee73 → address, address, uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bool, bool, bool

Write Contract 9 functions

These functions modify contract state and require a wallet transaction to execute.

batchCreateVesting 0x45f3c562
tuple params
returns: uint256
batchReleaseTokens 0xcadc1b71
uint256[] _vestingIds
renounceOwnership 0x715018a6
No parameters
revokeVesting 0xdd128200
uint256 _vestingId
setEscrowFeePercent 0x8779342d
uint256 _escrowFeePercent
setOtcMarketplace 0x59778bfd
address _otcMarketplaceAddress
setScheduler 0x3f6746ce
address _scheduler
setUpfrontDiscountPercent 0xfc7448bd
uint256 _upfrontDiscountPercent
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address