lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.4
// This must be called AFTER fundSendToDestinationGas has been executed
// for this txn to fund this send operation
function sendTokensToDestination(bytes32 _id) external returns (bytes32) {
        require(isActive, "this atomic swap instance is not active");

       Swap storage swap = swaps[_id];

        _confirmSwapExistsGasFundedAndSenderValid(swap);
        _token.transfer(swap.swapAddress, swap.amount);
        swap.currentTimestamp = block.timestamp;
        swap.isComplete = true;
        emit SendTokensToDestination(_id, swap.swapAddress, swap.amount);
        return _id;
    }
// Solidity 0.4.21
//transfers various amounts to the holders of the stalemate cards
function _stalemateTransfer() private{
        uint payout=this.balance;
        //pay the pot to holders of the stalemate cards
        for(uint i=9;i<12;i++){
            require(msg.sender != indexToAddress[i]);
            if(indexToAddress[i]!=address(this)){
                uint proportion=(i-8)*15;
                indexToAddress[i].transfer(uint256(SafeMath.div(SafeMath.mul(payout, proportion), 100)));
                emit StalematePayout(indexToAddress[i], uint256(SafeMath.div(SafeMath.mul(payout, proportion), 100)));
            }
        }
    }
// Solidity 0.4.23
/**
 * @dev Validation of an incoming purchase. Use require statemens to revert state when conditions are not met. Use super to concatenate validations.
 * @param _beneficiary Address performing the token purchase
 * @param _weiAmount Value in wei involved in the purchase
 */
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view {
        require(_beneficiary != address(0)); 
        require(_weiAmount != 0);
    
        require(_weiAmount > minInvestment); // Revert if payment is less than 0.40 ETH
        require(whitelistedAddr[_beneficiary]); // Revert if investor is not whitelisted
        require(totalInvestment[_beneficiary].add(_weiAmount) <= investmentUpperBounds); // Revert if the investor already spent over 2k ETH investment or payment is greater than 2k ETH
        require(weiRaised.add(_weiAmount) <= hardcap); // Revert if ICO campaign reached Hard Cap
    }
// Solidity 0.8.0
// collect any token send by mistake, collect target after 90 days
function collectDust(address _token) external {
    if (_token == address(0)) { // token address(0) = ETH
      payable(owner()).transfer(address(this).balance);
    } else {
      if (_token == token) {
        require(block.timestamp > deployedAt + 90 days, "WETHDistributor: Not ready");
      }
      uint256 balance = IERC20(_token).balanceOf(address(this));
      IERC20(_token).transfer(owner(), balance);
    }
  }
// Solidity 0.6.11
// Transfer control 
function canTransfer(address sender, uint256 amount) public view returns (bool) {
        // Control is scheduled wallet
        if (!frozenWallets[sender].scheduled) {
            return true;
        }

        uint256 balance = balanceOf(sender);
        uint256 restAmount = getRestAmount(sender);

        if (balance > frozenWallets[sender].totalAmount && balance.sub(frozenWallets[sender].totalAmount) >= amount) {
            return true;
        }

        if (!isStarted(frozenWallets[sender].startDay) || balance.sub(amount) < restAmount) {
            return false;
        }

        return true;
    }
// Solidity 0.4.25
/// Constructor function. This is only called on contract creation.
function SEEDDEX(address admin_, address manager_, address feeAccount_, uint feeTakeMaker_, uint feeTakeSender_, uint feeTakeMakerFic_, uint feeTakeSenderFic_, address predecessor_) public {
        admin = admin_;
        manager = manager_;
        feeAccount = feeAccount_;
        feeTakeMaker = feeTakeMaker_;
        feeTakeSender = feeTakeSender_;
        feeTakeMakerFic = feeTakeMakerFic_;
        feeTakeSenderFic = feeTakeSenderFic_;
        depositingTokenFlag = false;
        predecessor = predecessor_;

        if (predecessor != address(0)) {
            version = SEEDDEX(predecessor).version() + 1;
        } else {
            version = 1;
        }
    }
// Solidity 0.4.25
/**
 * This function handles deposits of Ethereum based tokens to the contract.
 * Does not allow Ether.
 * If token transfer fails, transaction is reverted and remaining gas is refunded.
 * Emits a Deposit event.
 * Note: Remember to call IERC20(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf.
 * @param token Ethereum contract address of the token or 0 for Ether
 * @param amount uint of the amount of the token the user wishes to deposit
 */
function depositToken(address token, uint amount) {
        //remember to call IERC20(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf.
        if (token == 0) throw;
        if (!IERC20(token).transferFrom(msg.sender, this, amount)) throw;
        tokens[token][msg.sender] = SafeMath.add(tokens[token][msg.sender], amount);
        Deposit(token, msg.sender, amount, tokens[token][msg.sender]);
    }
// Solidity 0.4.25
/**
 * This function provides a fallback solution as outlined in ERC223.
 * If tokens are deposited through depositToken(), the transaction will continue.
 * If tokens are sent directly to this contract, the transaction is reverted.
 * @param sender Ethereum address of the sender of the token
 * @param amount amount of the incoming tokens
 * @param data attached data similar to msg.data of Ether transactions
 */
function tokenFallback(address sender, uint amount, bytes data) public returns (bool ok) {
        if (depositingTokenFlag) {
            // Transfer was initiated from depositToken(). User token balance will be updated there.
            return true;
        } else {
            // Direct ECR223 Token.transfer into this contract not allowed, to keep it consistent
            // with direct transfers of ECR20 and ETH.
            revert();
        }
    }
// Solidity 0.4.25
/**
 * Stores the active order inside of the contract.
 * Emits an Order event.
 *
 *
 * Note: tokenGet & tokenGive can be the Ethereum contract address.
 * @param tokenGet Ethereum contract address of the token to receive
 * @param amountGet uint amount of tokens being received
 * @param tokenGive Ethereum contract address of the token to give
 * @param amountGive uint amount of tokens being given
 * @param expires uint of block number when this order should expire
 * @param nonce arbitrary random number
 */
function order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) public {
        bytes32 hash = keccak256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        uint amount;
        orders[msg.sender][hash] = true;
        Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, hash, amount);
    }
// Solidity 0.4.25
/**
 * Facilitates a trade from one user to another.
 * Requires that the transaction is signed properly, the trade isn't past its expiration, and all funds are present to fill the trade.
 * Calls tradeBalances().
 * Updates orderFills with the amount traded.
 * Emits a Trade event.
 * Note: tokenGet & tokenGive can be the Ethereum contract address.
 * Note: amount is in amountGet / tokenGet terms.
 * @param tokenGet Ethereum contract address of the token to receive
 * @param amountGet uint amount of tokens being received
 * @param tokenGive Ethereum contract address of the token to give
 * @param amountGive uint amount of tokens being given
 * @param expires uint of block number when this order should expire
 * @param nonce arbitrary random number
 * @param user Ethereum address of the user who placed the order
 * @param v part of signature for the order hash as signed by user
 * @param r part of signature for the order hash as signed by user
 * @param s part of signature for the order hash as signed by user
 * @param amount uint amount in terms of tokenGet that will be "buy" in the trade
 */
function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) public {
        bytes32 hash = keccak256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        require((
            (orders[user][hash] || ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) == user) &&
            block.number <= expires &&
            SafeMath.add(orderFills[user][hash], amount) <= amountGet
            ));
        tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount);
        orderFills[user][hash] = SafeMath.add(orderFills[user][hash], amount);
        Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender, now);
    }
// Solidity 0.4.25
/**
 * This is a private function and is only being called from trade().
 * Handles the movement of funds when a trade occurs.
 * Takes fees.
 * Updates token balances for both buyer and seller.
 * Note: tokenGet & tokenGive can be the Ethereum contract address.
 * Note: amount is in amountGet / tokenGet terms.
 * @param tokenGet Ethereum contract address of the token to receive
 * @param amountGet uint amount of tokens being received
 * @param tokenGive Ethereum contract address of the token to give
 * @param amountGive uint amount of tokens being given
 * @param user Ethereum address of the user who placed the order
 * @param amount uint amount in terms of tokenGet that will be "buy" in the trade
 */
function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private {
        if (tokenGet == FicAddress || tokenGive == FicAddress) {
            tokens[tokenGet][msg.sender] = SafeMath.sub(tokens[tokenGet][msg.sender], amount);
            tokens[tokenGet][user] = SafeMath.add(tokens[tokenGet][user], SafeMath.mul(amount, ((1 ether) - feeTakeMakerFic)) / (1 ether));
            tokens[tokenGet][feeAccount] = SafeMath.add(tokens[tokenGet][feeAccount], SafeMath.mul(amount, feeTakeMakerFic) / (1 ether));
            tokens[tokenGive][user] = SafeMath.sub(tokens[tokenGive][user], SafeMath.mul(amountGive, amount) / amountGet);
            tokens[tokenGive][msg.sender] = SafeMath.add(tokens[tokenGive][msg.sender], SafeMath.mul(SafeMath.mul(((1 ether) - feeTakeSenderFic), amountGive), amount) / amountGet / (1 ether));
            tokens[tokenGive][feeAccount] = SafeMath.add(tokens[tokenGive][feeAccount], SafeMath.mul(SafeMath.mul(feeTakeSenderFic, amountGive), amount) / amountGet / (1 ether));
        }
        else {
            tokens[tokenGet][msg.sender] = SafeMath.sub(tokens[tokenGet][msg.sender], amount);
            tokens[tokenGet][user] = SafeMath.add(tokens[tokenGet][user], SafeMath.mul(amount, ((1 ether) - feeTakeMaker)) / (1 ether));
            tokens[tokenGet][feeAccount] = SafeMath.add(tokens[tokenGet][feeAccount], SafeMath.mul(amount, feeTakeMaker) / (1 ether));
            tokens[tokenGive][user] = SafeMath.sub(tokens[tokenGive][user], SafeMath.mul(amountGive, amount) / amountGet);
            tokens[tokenGive][msg.sender] = SafeMath.add(tokens[tokenGive][msg.sender], SafeMath.mul(SafeMath.mul(((1 ether) - feeTakeSender), amountGive), amount) / amountGet / (1 ether));
            tokens[tokenGive][feeAccount] = SafeMath.add(tokens[tokenGive][feeAccount], SafeMath.mul(SafeMath.mul(feeTakeSender, amountGive), amount) / amountGet / (1 ether));
        }
    }
// Solidity 0.4.25
/**
 * This function is to test if a trade would go through.
 * Note: tokenGet & tokenGive can be the Ethereum contract address.
 * Note: amount is in amountGet / tokenGet terms.
 * @param tokenGet Ethereum contract address of the token to receive
 * @param amountGet uint amount of tokens being received
 * @param tokenGive Ethereum contract address of the token to give
 * @param amountGive uint amount of tokens being given
 * @param expires uint of block number when this order should expire
 * @param nonce arbitrary random number
 * @param user Ethereum address of the user who placed the order
 * @param v part of signature for the order hash as signed by user
 * @param r part of signature for the order hash as signed by user
 * @param s part of signature for the order hash as signed by user
 * @param amount uint amount in terms of tokenGet that will be "buy" in the trade
 * @param sender Ethereum address of the user taking the order
 * @return bool: true if the trade would be successful, false otherwise
 */
function testTrade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) public constant returns (bool) {
        if (!(
        tokens[tokenGet][sender] >= amount &&
        availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount
        )) {
            return false;
        } else {
            return true;
        }
    }
// Solidity 0.4.25
/**
 * This function checks the available volume for a given order.
 * Note: tokenGet & tokenGive can be the Ethereum contract address.
 * @param tokenGet Ethereum contract address of the token to receive
 * @param amountGet uint amount of tokens being received
 * @param tokenGive Ethereum contract address of the token to give
 * @param amountGive uint amount of tokens being given
 * @param expires uint of block number when this order should expire
 * @param nonce arbitrary random number
 * @param user Ethereum address of the user who placed the order
 * @param v part of signature for the order hash as signed by user
 * @param r part of signature for the order hash as signed by user
 * @param s part of signature for the order hash as signed by user
 * @return uint: amount of volume available for the given order in terms of amountGet / tokenGet
 */
function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) public constant returns (uint) {
        bytes32 hash = keccak256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        if (!(
        (orders[user][hash] || ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) == user) &&
        block.number <= expires
        )) {
            return 0;
        }
        uint[2] memory available;
        available[0] = SafeMath.sub(amountGet, orderFills[user][hash]);
        available[1] = SafeMath.mul(tokens[tokenGive][user], amountGet) / amountGive;
        if (available[0] < available[1]) {
            return available[0];
        } else {
            return available[1];
        }
    }
// Solidity 0.4.25
/**
 * This function checks the amount of an order that has already been filled.
 * Note: tokenGet & tokenGive can be the Ethereum contract address.
 * @param tokenGet Ethereum contract address of the token to receive
 * @param amountGet uint amount of tokens being received
 * @param tokenGive Ethereum contract address of the token to give
 * @param amountGive uint amount of tokens being given
 * @param expires uint of block number when this order should expire
 * @param nonce arbitrary random number
 * @param user Ethereum address of the user who placed the order
 * @param v part of signature for the order hash as signed by user
 * @param r part of signature for the order hash as signed by user
 * @param s part of signature for the order hash as signed by user
 * @return uint: amount of the given order that has already been filled in terms of amountGet / tokenGet
 */
function amountFilled(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) public constant returns (uint) {
        bytes32 hash = keccak256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        return orderFills[user][hash];
    }
// Solidity 0.4.25
/**
 * This function cancels a given order by editing its fill data to the full amount.
 * Requires that the transaction is signed properly.
 * Updates orderFills to the full amountGet
 * Emits a Cancel event.
 * Note: tokenGet & tokenGive can be the Ethereum contract address.
 * @param tokenGet Ethereum contract address of the token to receive
 * @param amountGet uint amount of tokens being received
 * @param tokenGive Ethereum contract address of the token to give
 * @param amountGive uint amount of tokens being given
 * @param expires uint of block number when this order should expire
 * @param nonce arbitrary random number
 * @param v part of signature for the order hash as signed by user
 * @param r part of signature for the order hash as signed by user
 * @param s part of signature for the order hash as signed by user
 * @return uint: amount of the given order that has already been filled in terms of amountGet / tokenGet
 */
function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) public {
        bytes32 hash = keccak256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        require((orders[msg.sender][hash] || ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) == msg.sender));
        orderFills[msg.sender][hash] = amountGet;
        Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s);
    }
// Solidity 0.4.25
/**
 * User triggered function to migrate funds into a new contract to ease updates.
 * Emits a FundsMigrated event.
 * @param newContract Contract address of the new contract we are migrating funds to
 * @param tokens_ Array of token addresses that we will be migrating to the new contract
 */
function migrateFunds(address newContract, address[] tokens_) public {

        require(newContract != address(0));

        SEEDDEX newExchange = SEEDDEX(newContract);

        // Move Ether into new exchange.
        uint etherAmount = tokens[0][msg.sender];
        if (etherAmount > 0) {
            tokens[0][msg.sender] = 0;
            newExchange.depositForUser.value(etherAmount)(msg.sender);
        }

        // Move Tokens into new exchange.
        for (uint16 n = 0; n < tokens_.length; n++) {
            address token = tokens_[n];
            require(token != address(0));
            // Ether is handled above.
            uint tokenAmount = tokens[token][msg.sender];

            if (tokenAmount != 0) {
                if (!IERC20(token).approve(newExchange, tokenAmount)) throw;
                tokens[token][msg.sender] = 0;
                newExchange.depositTokenForUser(token, tokenAmount, msg.sender);
            }
        }

        FundsMigrated(msg.sender, newContract);
    }
// Solidity 0.4.25
/**
 * This function handles deposits of Ethereum based tokens into the contract, but allows specification of a user.
 * Does not allow Ether.
 * If token transfer fails, transaction is reverted and remaining gas is refunded.
 * Note: This is generally used in migration of funds.
 * Note: Remember to call Token(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf.
 * @param token Ethereum contract address of the token
 * @param amount uint of the amount of the token the user wishes to deposit
 */
function depositTokenForUser(address token, uint amount, address user) public {
        require(token != address(0));
        require(user != address(0));
        require(amount > 0);
        depositingTokenFlag = true;
        if (!IERC20(token).transferFrom(msg.sender, this, amount)) throw;
        depositingTokenFlag = false;
        tokens[token][user] = SafeMath.add(tokens[token][user], (amount));
    }
// Solidity 0.7.3
/**
 * @dev Main sale function. Mints Pizzas
 */
function mintNFT(uint256 numberOfPizzas) public payable {
        require(hasSaleStarted, "sale hasn't started");
        require(
            supremePizzas.totalSupply().add(numberOfPizzas) <= MAX_SUPPLY,
            "Exceeds MAX_SUPPLY"
        );
        require(
            price.mul(numberOfPizzas) == msg.value,
            "Ether value sent is not correct"
        );

        for (uint256 i; i < numberOfPizzas; i++) {
            supremePizzas.mint(msg.sender);
        }
    }
// Solidity 0.6.7
/**
 @dev Returns the smallest integer larger than or equal to _x.
 @param _x   number _x
 @return ret    value ret
 */
function ceil(uint _x)public pure returns(uint ret){
		ret = (_x / 1 ether) * 1 ether;
		if((_x % 1 ether) == 0){
			return ret;
		}else{
			return ret + 1 ether;
		}
	}
// Solidity 0.6.7
/**
 @dev removes tokens from an account and decreases the token supply
 can be called by the contract creator to destroy tokens from any account or by any holder to destroy tokens from his/her own account
 
 @param _from       account to remove the amount from
 @param _amount     amount to decrease the supply by
 */
function destroy(address _from, uint256 _amount) virtual override internal {
        //require(msg.sender == _from || msg.sender == creator); // validate input

        m_balanceOf[_from] = safeSub(m_balanceOf[_from], _amount);
        m_totalSupply = safeSub(m_totalSupply, _amount);

        emit Transfer(_from, address(0), _amount);
        emit Destruction(_amount);
    }
// Solidity 0.6.7
/**
 @dev given a token supply, connector balance, weight and a deposit amount (in the connector token),
 calculates the return for a given conversion (in the main token)
 
 Formula:
 Return = _supply * ((1 + _depositAmount / _connectorBalance) ^ (_connectorWeight / 1000000) - 1)
 
 @param _supply              token total supply
 @param _connectorBalance    total connector balance
 @param _connectorWeight     connector weight, represented in ppm, 1-1000000
 @param _depositAmount       deposit amount, in connector token
 
 @return purchase return amount
 */
function calculatePurchaseReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _depositAmount) public view returns (uint256) {
        // validate input
        require(_supply > 0 && _connectorBalance > 0 && _connectorWeight > 0 && _connectorWeight <= MAX_WEIGHT);

        // special case for 0 deposit amount
        if (_depositAmount == 0)
            return 0;

        // special case if the weight = 100%
        if (_connectorWeight == MAX_WEIGHT)
            return safeMul(_supply, _depositAmount) / _connectorBalance;

        uint256 result;
        uint8 precision;
        uint256 baseN = safeAdd(_depositAmount, _connectorBalance);
        (result, precision) = power(baseN, _connectorBalance, _connectorWeight, MAX_WEIGHT);
        uint256 temp = safeMul(_supply, result) >> precision;
        return temp - _supply;
    }