lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.3.4
// DTHPool(address _daoAddress, address _delegate, uint _maxTimeBlocked, string _delegateName, string _delegateUrl, string _tokenSymbol);
function DTHPool(
        address _daoAddress,
        address _delegate,
        uint _maxTimeBlocked,
        string _delegateName,
        string _delegateUrl,
        string _tokenSymbol
    ) {
        daoAddress = _daoAddress;
        delegate = _delegate;
        delegateUrl = _delegateUrl;
        maxTimeBlocked = _maxTimeBlocked;
        name = _delegateName;
        symbol = _tokenSymbol;
        decimals = 16;
        oraclize_setNetwork(networkID_auto);
    }
// Solidity 0.4.21
//internal func
function burn (uint256 amount) internal
    {
        SafeMath.assert(amount >= 100000000000);
        if (amount >= 100000000000) {
            uint256 _value = amount / 100000000000;
            uint256 _tmp = _value * 100000000000;
            SafeMath.assert(_tmp == amount);
            vips[msg.sender] += amount / 100000000000;
            globalShares += amount / 100000000000;
            insert(msg.sender, vips[msg.sender]);
            balances[msg.sender] = balances[msg.sender].sub(amount);
            balances[burnAddress] = balances[burnAddress].add(amount);
            Transfer(msg.sender, burnAddress, amount);
        }
    }
// Solidity 0.4.21
//transfer shares
function transferShares(address _to, uint _value){
        SafeMath.assert(vips[msg.sender] >= _value && _value > 0);
        var _skey = msg.sender;
        uint _svalue = 0;
        var _tkey = _to;
        uint _tvalue = 0;
        for (var i = IterableMapping.iterate_start(data); IterableMapping.iterate_valid(data, i); i = IterableMapping.iterate_next(data, i))
        {
            var (key, value) = IterableMapping.iterate_get(data, i);
            if(key == msg.sender){
                _svalue = value;
            }
            if(key == _to){
                _tvalue = value;
            }
        }
        _svalue = _svalue.sub(_value);
        insert(msg.sender, _svalue);
        vips[msg.sender] = _svalue;
        if (_svalue == 0){
            remove(msg.sender);
        }
        vips[_to] = _tvalue + _value;
        insert(_to, _tvalue + _value);
        TransShare(msg.sender, _to, _value);
    }
// Solidity 0.4.21
//only ower exec,distribute dividends
function distributeDividends() onlyOwner public noEth(){
        for (var i = IterableMapping.iterate_start(data); IterableMapping.iterate_valid(data, i); i = IterableMapping.iterate_next(data, i))
        {
            var (key, value) = IterableMapping.iterate_get(data, i);
            uint tmp = balances[dividendAddress] / globalShares * value;
            balances[key] = balances[key].add(tmp);
            Dividends(dividendAddress, key, tmp);
        }
        balances[dividendAddress] = balances[dividendAddress].sub(balances[dividendAddress] / globalShares * globalShares);
    }
// Solidity 0.4.24
/**
 * If the user sends 0 ether, he receives 500tokens.
 * If he sends 0.001 ether, he receives 2000tokens
 * If he sends 0.005 ether he receives 22,000tokens
 * If he sends 0.01ether, he receives 48,000 tokens
 * If he sends 0.02ether he receives 100000tokens
 * If he sends 0.05ether, he receives 270,000tokens
 */
function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256) {
        uint256 amountOfTokens = 0;
        if(_weiAmount == 0){
            amountOfTokens = 500 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.001 ether){
            amountOfTokens = 2000 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.005 ether){
            amountOfTokens = 22 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.01 ether){
            amountOfTokens = 48 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.02 ether){
            amountOfTokens = 100 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.05 ether){
            amountOfTokens = 270 * 10**3 * (10**uint256(decimals));
        }
        return amountOfTokens;
    }
// Solidity 0.4.26
/// @dev increase the token's supply
function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        require (value + currentSupply <= totalSupply);
        require (balances[msg.sender] >= value && value>0);
        balances[msg.sender] -= value;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
// Solidity 0.4.26
/// buys the tokens
function () payable {
        require (isFunding);
        require(msg.value > 0);

        require(block.number >= fundingStartBlock);
        require(block.number <= fundingStopBlock);

        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        require(tokens + tokenRaised <= currentSupply);

        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;

        IssueToken(msg.sender, tokens);  // logs token issued
    }
// Solidity 0.8.7
/**
 * @notice Requests randomness
 * @dev Warning: if the VRF response is delayed, avoid calling requestRandomness repeatedly
 * as that would give miners/VRF operators latitude about which VRF response arrives first.
 * @dev You must review your implementation details with extreme care.
 *
 * @return bytes32
 */
function rollDice() public onlyOwner returns (bytes32) {
        require(LINK.balanceOf(address(this)) >= s_fee, "Not enough LINK to pay fee");
        require(result == 0, "Already rolled");
        requestId = requestRandomness(s_keyHash, s_fee);
        result = BIG_PRIME;
        emit DiceRolled(requestId, msg.sender);
        return requestId;
    }
// Solidity 0.8.7
/**
 * @notice Get the random number of token with id tokenId
 * @param _offset uint256
 * @param _limit uint256
 * @return array of random number as a uint256[]
 */
function getBatchRandomNumbers(uint256 _offset, uint256 _limit) public view returns (uint256[] memory) {
        require(_offset + _limit <= GHOST_SUPPLY, "Exceeded total supply");
        uint256[] memory numbers = new uint[](_limit);
        for (uint256 i = 0; i < _limit; i++) {
            numbers[i] = getRandomNumber(_offset + i);
        }
        return numbers;
    }
// Solidity 0.6.12
/**
 * @notice Add credit to a job to be paid out for work
 * @param credit the credit being assigned to the job
 * @param job the job being credited
 * @param amount the amount of credit being added to the job
 */
function addCredit(address credit, address job, uint amount) external nonReentrant {
        require(jobs[job], "addCreditETH: !job");
        uint _before = IERC20(credit).balanceOf(address(this));
        IERC20(credit).safeTransferFrom(msg.sender, address(this), amount);
        uint _received = IERC20(credit).balanceOf(address(this)).sub(_before);
        uint _fee = _received.mul(FEE).div(BASE);
        credits[job][credit] = credits[job][credit].add(_received.sub(_fee));
        IERC20(credit).safeTransfer(governance, _fee);

        emit AddCredit(credit, job, msg.sender, block.number, _received);
    }
// Solidity 0.6.12
/**
 * @notice Allows liquidity providers to submit jobs
 * @param liquidity the liquidity being added
 * @param job the job to assign credit to
 * @param amount the amount of liquidity tokens to use
 */
function addLiquidityToJob(address liquidity, address job, uint amount) external nonReentrant {
        require(liquidityAccepted[liquidity], "addLiquidityToJob: !pair");
        IERC20(liquidity).safeTransferFrom(msg.sender, address(this), amount);
        liquidityProvided[msg.sender][liquidity][job] = liquidityProvided[msg.sender][liquidity][job].add(amount);

        liquidityApplied[msg.sender][liquidity][job] = now.add(LIQUIDITYBOND);
        liquidityAmount[msg.sender][liquidity][job] = liquidityAmount[msg.sender][liquidity][job].add(amount);

        if (!jobs[job] && jobProposalDelay[job] < now) {
            IGovernance(governance).proposeJob(job);
            jobProposalDelay[job] = now.add(UNBOND);
        }
        emit SubmitJob(job, liquidity, msg.sender, block.number, amount);
    }
// Solidity 0.6.12
/**
 * @notice Applies the credit provided in addLiquidityToJob to the job
 * @param provider the liquidity provider
 * @param liquidity the pair being added as liquidity
 * @param job the job that is receiving the credit
 */
function applyCreditToJob(address provider, address liquidity, address job) external {
        require(liquidityAccepted[liquidity], "addLiquidityToJob: !pair");
        require(liquidityApplied[provider][liquidity][job] != 0, "credit: no bond");
        require(liquidityApplied[provider][liquidity][job] < now, "credit: bonding");
        uint _liquidity = KperNetworkLibrary.getReserve(liquidity, address(this));
        uint _credit = _liquidity.mul(liquidityAmount[provider][liquidity][job]).div(IERC20(liquidity).totalSupply());
        _mint(address(this), _credit);
        credits[job][address(this)] = credits[job][address(this)].add(_credit);
        liquidityAmount[provider][liquidity][job] = 0;

        emit ApplyCredit(job, liquidity, provider, block.number, _credit);
    }
// Solidity 0.6.12
/**
 * @notice Unbond liquidity for a job
 * @param liquidity the pair being unbound
 * @param job the job being unbound from
 * @param amount the amount of liquidity being removed
 */
function unbondLiquidityFromJob(address liquidity, address job, uint amount) external {
        require(liquidityAmount[msg.sender][liquidity][job] == 0, "credit: pending credit");
        liquidityUnbonding[msg.sender][liquidity][job] = now.add(UNBOND);
        liquidityAmountsUnbonding[msg.sender][liquidity][job] = liquidityAmountsUnbonding[msg.sender][liquidity][job].add(amount);
        require(liquidityAmountsUnbonding[msg.sender][liquidity][job] <= liquidityProvided[msg.sender][liquidity][job], "unbondLiquidityFromJob: insufficient funds");

        uint _liquidity = KperNetworkLibrary.getReserve(liquidity, address(this));
        uint _credit = _liquidity.mul(amount).div(IERC20(liquidity).totalSupply());
        if (_credit > credits[job][address(this)]) {
            _burn(address(this), credits[job][address(this)]);
            credits[job][address(this)] = 0;
        } else {
            _burn(address(this), _credit);
            credits[job][address(this)] = credits[job][address(this)].sub(_credit);
        }

        emit UnbondJob(job, liquidity, msg.sender, block.number, amount);
    }
// Solidity 0.6.12
/**
 * @notice Allows liquidity providers to remove liquidity
 * @param liquidity the pair being unbound
 * @param job the job being unbound from
 */
function removeLiquidityFromJob(address liquidity, address job) external {
        require(liquidityUnbonding[msg.sender][liquidity][job] != 0, "removeJob: unbond");
        require(liquidityUnbonding[msg.sender][liquidity][job] < now, "removeJob: unbonding");
        uint _amount = liquidityAmountsUnbonding[msg.sender][liquidity][job];
        liquidityProvided[msg.sender][liquidity][job] = liquidityProvided[msg.sender][liquidity][job].sub(_amount);
        liquidityAmountsUnbonding[msg.sender][liquidity][job] = 0;
        IERC20(liquidity).safeTransfer(msg.sender, _amount);

        emit RemoveJob(job, liquidity, msg.sender, block.number, _amount);
    }
// Solidity 0.6.12
/**
 * @notice Implemented by jobs to show that a keeper performed work
 * @param keeper address of the keeper that performed the work
 * @param amount the reward that should be allocated
 */
function workReceipt(address keeper, uint amount) public {
        require(jobs[msg.sender], "workReceipt: !job");
        require(amount <= KPRH.getQuoteLimit(_gasUsed.sub(gasleft())), "workReceipt: max limit");
        credits[msg.sender][address(this)] = credits[msg.sender][address(this)].sub(amount, "workReceipt: insuffient funds");
        lastJob[keeper] = now;
        _reward(keeper, amount);
        workCompleted[keeper] = workCompleted[keeper].add(amount);
        emit KeeperWorked(address(this), msg.sender, keeper, block.number, amount);
    }
// Solidity 0.6.12
/**
 * @notice confirms if the current keeper is registered and has a minimum bond, should be used for protected functions
 * @param keeper the keeper being investigated
 * @param minBond the minimum requirement for the asset provided in bond
 * @param earned the total funds earned in the keepers lifetime
 * @param age the age of the keeper in the system
 * @return true/false if the address is a keeper and has more than the bond
 */
function isMinKeeper(address keeper, uint minBond, uint earned, uint age) external returns (bool) {
        _gasUsed = gasleft();
        return keepers[keeper]
                && bonds[keeper][address(this)].add(votes[keeper]) >= minBond
                && workCompleted[keeper] >= earned
                && now.sub(firstSeen[keeper]) >= age;
    }
// Solidity 0.6.12
/**
 * @notice begin the bonding process for a new keeper
 * @param bonding the asset being bound
 * @param amount the amount of bonding asset being bound
 */
function bond(address bonding, uint amount) external nonReentrant {
        require(!blacklist[msg.sender], "bond: blacklisted");
        bondings[msg.sender][bonding] = now.add(BOND);
        if (bonding == address(this)) {
            _transferTokens(msg.sender, address(this), amount);
        } else {
            uint _before = IERC20(bonding).balanceOf(address(this));
            IERC20(bonding).safeTransferFrom(msg.sender, address(this), amount);
            amount = IERC20(bonding).balanceOf(address(this)).sub(_before);
        }
        pendingbonds[msg.sender][bonding] = pendingbonds[msg.sender][bonding].add(amount);
        emit KeeperBonding(msg.sender, block.number, bondings[msg.sender][bonding], amount);
    }
// Solidity 0.6.12
/**
 * @notice withdraw funds after unbonding has finished
 * @param bonding the asset to withdraw from the bonding pool
 */
function withdraw(address bonding) external nonReentrant {
        require(unbondings[msg.sender][bonding] != 0 && unbondings[msg.sender][bonding] < now, "withdraw: unbonding");
        require(!disputes[msg.sender], "withdraw: disputes");

        if (bonding == address(this)) {
            _transferTokens(address(this), msg.sender, partialUnbonding[msg.sender][bonding]);
        } else {
            IERC20(bonding).safeTransfer(msg.sender, partialUnbonding[msg.sender][bonding]);
        }
        emit KeeperUnbound(msg.sender, block.number, block.timestamp, partialUnbonding[msg.sender][bonding]);
        partialUnbonding[msg.sender][bonding] = 0;
    }
// Solidity 0.6.12
/**
 * @notice allows governance to slash a keeper based on a dispute
 * @param bonded the asset being slashed
 * @param keeper the address being slashed
 * @param amount the amount being slashed
 */
function slash(address bonded, address keeper, uint amount) public nonReentrant {
        require(msg.sender == governance, "slash: !gov");
        if (bonded == address(this)) {
            _transferTokens(address(this), governance, amount);
        } else {
            IERC20(bonded).safeTransfer(governance, amount);
        }
        _unbond(bonded, keeper, amount);
        disputes[keeper] = false;
        emit KeeperSlashed(keeper, msg.sender, block.number, amount);
    }
// Solidity 0.6.12
/// @dev overrides transfer function to meet tokenomics of COINAGE
function _transfer(address sender, address recipient, uint256 amount) internal virtual override {
        // swap and liquify
        if (
            swapAndLiquifyEnabled == true
            && _inSwapAndLiquify == false
            && address(coinageFinanceRouter) != address(0)
            && coinageFinancePair != address(0)
            && sender != coinageFinancePair
            && sender != owner()
        ) {
            swapAndLiquify();
        }
      
        if (whitelistTaxFee[sender] || whitelistTaxFee[recipient] || transferTaxRate == 0) {
            super._transfer(sender, recipient, amount);
        } else {
          
            uint256 taxAmount = amount.mul(transferTaxRate).div(10000);
            uint256 burnAmount = taxAmount.mul(burnRate).div(100);
            uint256 liquidityAmount = taxAmount.sub(burnAmount);
            require(taxAmount == burnAmount + liquidityAmount, "COINAGE::transfer: Burn value invalid");

      
            uint256 sendAmount = amount.sub(taxAmount);
            require(amount == sendAmount + taxAmount, "COINAGE::transfer: Tax value invalid");

            super._transfer(sender, BURN_ADDRESS, burnAmount);
            super._transfer(sender, address(this), liquidityAmount);
            super._transfer(sender, recipient, sendAmount);
            amount = sendAmount;
        }
    }
// Solidity 0.6.12
/// @dev Swap and liquify
function swapAndLiquify() private lockTheSwap transferTaxFree {
        uint256 contractTokenBalance = balanceOf(address(this));
        uint256 maxTransferAmount = maxTransferAmount();
        contractTokenBalance = contractTokenBalance > maxTransferAmount ? maxTransferAmount : contractTokenBalance;

        if (contractTokenBalance >= minAmountToLiquify) {
            // only min amount to liquify
            uint256 liquifyAmount = minAmountToLiquify;

            // split the liquify amount into halves
            uint256 half = liquifyAmount.div(2);
            uint256 otherHalf = liquifyAmount.sub(half);

            // capture the contract's current ETH balance.
            // this is so that we can capture exactly the amount of ETH that the
            // swap creates, and not make the liquidity event include any ETH that
            // has been manually sent to the contract
            uint256 initialBalance = address(this).balance;

            // swap tokens for ETH
            swapTokensForEth(half);

            // how much ETH did we just swap into?
            uint256 newBalance = address(this).balance.sub(initialBalance);

            // add liquidity
            addLiquidity(otherHalf, newBalance);

            emit SwapAndLiquify(half, newBalance, otherHalf);
        }
    }
// Solidity 0.6.12
/// @dev Swap tokens for eth
function swapTokensForEth(uint256 tokenAmount) private {
        // generate the coinageFinance pair path of token -> weth
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = coinageFinanceRouter.WETH();

        _approve(address(this), address(coinageFinanceRouter), tokenAmount);

        // make the swap
        coinageFinanceRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount,
            0, // accept any amount of ETH
            path,
            address(this),
            block.timestamp
        );
    }
// Solidity 0.6.12
/// @dev Add liquidity
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
        // approve token transfer to cover all possible scenarios
        _approve(address(this), address(coinageFinanceRouter), tokenAmount);

        // add the liquidity
        coinageFinanceRouter.addLiquidityETH{value: ethAmount}(
            address(this),
            tokenAmount,
            0, // slippage is unavoidable
            0, // slippage is unavoidable
            BURN_ADDRESS,
            block.timestamp
        );
    }
// Solidity 0.8.4
/** mint */
function _mintSeed(uint256 num, address to) internal {
        require(totalSupply() + num <= totalLimit, "exceed limit");
        for(uint256 i = 0; i < num; i++) {
            uint256 tokenIndex = totalSupply();
            _safeMint(to, tokenIndex);
        }
    }
// Solidity 0.8.4
// claim for dao holder
function claimDAO() public nonReentrant {
        require(!msg.sender.isContract(), "contract not allowed");
        require(onClaim, "not on claim");
        require(
            rally.balanceOf(msg.sender) >= rallyBalance || 
            bank.balanceOf(msg.sender) >= bankBalance ||
            fwb.balanceOf(msg.sender) >= fwbBalance ||
            ff.balanceOf(msg.sender) >= ffBalance,
            "low balance"
        );
        require(!daoClaimed[msg.sender], "already claimed");
        require(limit > 0, "out of supply");
        limit = limit.sub(1);
        daoClaimed[msg.sender] = true;
        _mintSeed(1, msg.sender);
    }
// Solidity 0.8.4
// mint for whitelist
function mintWhiteList(uint256 id, bytes32[] calldata proof) external nonReentrant {
        require(!minted[id][msg.sender], "already minted");
        require(supply > 0, "out of supply");
        require(
            MerkleProof.verify(
                proof, roots[id], keccak256(abi.encodePacked(msg.sender))
            ), 
            "invalid proof");
        supply = supply.sub(1);
        minted[id][msg.sender] = true;
        _mintSeed(1, msg.sender);
    }
// Solidity 0.5.11
/**
 @dev Initialize the contract, preventing any more changes not made through slate governance
 */
function init() public {
        require(msg.sender == owner, "Only the owner can initialize the ParameterStore");
        require(initialized == false, "Contract has already been initialized");

        initialized = true;

        // Do not allow initialization unless the gatekeeperAddress is set
        // Check after setting initialized so we can use the getter
        require(getAsAddress("gatekeeperAddress") != address(0), "Missing gatekeeper");

        emit Initialized();
    }
// Solidity 0.5.11
/**
 @dev Create multiple proposals to set values.
 @param keys The keys to set
 @param values The values to set for the keys
 @param metadataHashes Metadata hashes describing the proposals
 */
function createManyProposals(
        string[] calldata keys,
        bytes32[] calldata values,
        bytes[] calldata metadataHashes
    ) external {
        require(initialized, "Contract has not yet been initialized");
        require(
            keys.length == values.length && values.length == metadataHashes.length,
            "All inputs must have the same length"
        );

        Gatekeeper gatekeeper = _gatekeeper();
        for (uint i = 0; i < keys.length; i++) {
            string memory key = keys[i];
            bytes32 value = values[i];
            bytes memory metadataHash = metadataHashes[i];
            _createProposal(gatekeeper, key, value, metadataHash);
        }
    }
// Solidity 0.5.11
/**
 @dev Execute a proposal to set a parameter. The proposal must have been included in an
 accepted governance slate.
 @param proposalID The proposal
 */
function setValue(uint256 proposalID) public returns(bool) {
        require(proposalID < proposalCount(), "Invalid proposalID");
        require(initialized, "Contract has not yet been initialized");

        Proposal memory p = proposals[proposalID];
        Gatekeeper gatekeeper = Gatekeeper(p.gatekeeper);

        require(gatekeeper.hasPermission(p.requestID), "Proposal has not been approved");
        require(p.executed == false, "Proposal already executed");

        proposals[proposalID].executed = true;

        set(p.key, p.value);

        emit ProposalAccepted(proposalID, p.key, p.value);
        return true;
    }