lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.21
/// @dev GoToken Contract constructor function sets GoToken dutch auction
/// contract address and assigns the tokens to the auction.
/// @param auction_address Address of dutch auction contract.
/// @param wallet_address Address of wallet.
/// @param initial_supply Number of initially provided token units (indivisible units).
function GoToken(address auction_address, address wallet_address, uint256 initial_supply) public
    {
        // Auction address should not be null.
        require(auction_address != 0x0);
        require(wallet_address != 0x0);

        // Initial supply is in indivisible units e.g. 50e24
        require(initial_supply > multiplier);

        // Total supply of indivisible GOT units at deployment
        totalSupply = initial_supply;

        // preallocation
        balances[auction_address] = initial_supply / 2;
        balances[wallet_address] = initial_supply / 2;

        // Record the events
        emit Transfer(0x0, auction_address, balances[auction_address]);
        emit Transfer(0x0, wallet_address, balances[wallet_address]);

        emit Deployed(totalSupply);

        assert(totalSupply == balances[auction_address] + balances[wallet_address]);
    }
// Solidity 0.4.21
/// @dev GoToken Contract constructor function sets the starting price,
/// price constant and price exponent for calculating the Dutch Auction price.
/// @param _wallet_address Wallet address to which all contributed ETH will be forwarded.
function GoTokenDutchAuction(
        address _wallet_address,
        address _whitelister_address,
        address _distributor_address,
        uint256 _price_start,
        uint256 _price_constant1,
        uint256 _price_exponent1,
        uint256 _price_constant2,
        uint256 _price_exponent2)
        public
    {
        // Address shouldn't be null
        require(_wallet_address != 0x0);
        require(_whitelister_address != 0x0);
        require(_distributor_address != 0x0);
        wallet_address = _wallet_address;
        whitelister_address = _whitelister_address;
        distributor_address = _distributor_address;

        owner_address = msg.sender;
        stage = Stages.AuctionDeployed;
        changePriceCurveSettings(_price_start, _price_constant1, _price_exponent1, _price_constant2, _price_exponent2);
        Deployed(_price_start, _price_constant1, _price_exponent1, _price_constant2, _price_exponent2);
    }
// Solidity 0.4.21
/// @notice Set "_token_address" as the token address to be used in the auction.
/// @dev Setup function sets external contracts addresses.
/// @param _token_address Token address.
function setup(address _token_address) public isOwner atStage(Stages.AuctionDeployed) {
        require(_token_address != 0x0);
        token = GoToken(_token_address);

        // Get number of GoToken indivisible tokens (GOT * token_multiplier)
        // to be auctioned from token auction balance
        num_tokens_auctioned = token.balanceOf(address(this));

        // Set the number of the token multiplier for its decimals
        token_multiplier = 10 ** (token.decimals());

        // State is set to Auction Setup
        stage = Stages.AuctionSetUp;
        Setup();
    }
// Solidity 0.4.21
/// @notice Set "_price_start", "_price_constant1" and "_price_exponent1"
///  "_price_constant2" and "_price_exponent2" as
/// the new starting price, price constant and price exponent for the auction price.
/// @dev Changes auction price function parameters before auction is started.
/// @param _price_start Updated start price.
/// @param _price_constant1 Updated price divisor constant.
/// @param _price_exponent1 Updated price divisor exponent.
/// @param _price_constant2 Updated price divisor constant.
/// @param _price_exponent2 Updated price divisor exponent.
function changePriceCurveSettings(
        uint256 _price_start,
        uint256 _price_constant1,
        uint256 _price_exponent1,
        uint256 _price_constant2,
        uint256 _price_exponent2)
        internal
    {
        // You can change the price curve settings only when either the auction is Deployed
        // or the auction is setup. You can't change during the auction is running or ended.
        require(stage == Stages.AuctionDeployed || stage == Stages.AuctionSetUp);
        require(_price_start > 0);
        require(_price_constant1 > 0);
        require(_price_constant2 > 0);

        price_start = _price_start;
        price_constant1 = _price_constant1;
        price_exponent1 = _price_exponent1;
        price_constant2 = _price_constant2;
        price_exponent2 = _price_exponent2;
    }
// Solidity 0.4.21
// @notice Finalize the auction - sets the final GoToken price and
// changes the auction stage after no bids are allowed. Only owner can finalize the auction.
// The owner can end the auction anytime after either the auction is deployed or started.
// @dev Finalize auction and set the final GOT token price.
function finalizeAuction() public isOwner
    {
        // The owner can end the auction anytime during the stages
        // AuctionSetUp and AuctionStarted
        require(stage == Stages.AuctionSetUp || stage == Stages.AuctionStarted);

        // Calculate the final price = WEI / (GOT / token_multiplier)
        final_price = token_multiplier * received_wei_with_bonus / num_tokens_auctioned;

        // End the auction
        end_time = now;
        stage = Stages.AuctionEnded;
        AuctionEnded(final_price);

        assert(final_price > 0);
    }
// Solidity 0.4.21
/// @notice Get the remaining funds needed to end the auction, calculated at
/// the current GOT price in WEI.
/// @dev The remaining funds necessary to end the auction at the current GOT price in WEI.
/// @return Returns the remaining funds to end the auction in WEI.
function remainingFundsToEndAuction() constant public returns (uint256) {

        // num_tokens_auctioned = total number of indivisible GOT (GOT * token_multiplier) that is auctioned
        uint256 required_wei_at_price = num_tokens_auctioned * price() / token_multiplier;
        if (required_wei_at_price <= received_wei) {
            return 0;
        }

        return required_wei_at_price - received_wei;
    }
// Solidity 0.4.21
// @dev Calculates the token price (WEI / GOT) at the current timestamp
// during the auction; elapsed time = 0 before auction starts.
// This is a composite exponentially decaying curve (two curves combined).
// The curve 1 is for the first 8 days and the curve 2 is for the remaining days.
// They are of the form:
//         current_price  = price_start * (1 + elapsed) / (1 + elapsed + decay_rate);
//          where, decay_rate = elapsed ** price_exponent / price_constant;
// Based on the provided parameters, the price does not change in the first
// price_constant^(1/price_exponent) seconds due to rounding.
// Rounding in `decay_rate` also produces values that increase instead of decrease
// in the beginning of the auction; these spikes decrease over time and are noticeable
// only in first hours. This should be calculated before usage.
// @return Returns the token price - WEI per GOT.
function calcTokenPrice() constant private returns (uint256) {
        uint256 elapsed;
        uint256 decay_rate1;
        uint256 decay_rate2;
        if (stage == Stages.AuctionDeployed || stage == Stages.AuctionSetUp){
          return price_start;
        }
        if (stage == Stages.AuctionStarted) {
            elapsed = now - auction_start_time;
            // The first eight days auction price curve
            if (now >= auction_start_time && now < auction_start_time + CURVE_CUTOFF_DURATION){
              decay_rate1 = elapsed ** price_exponent1 / price_constant1;
              return price_start * (1 + elapsed) / (1 + elapsed + decay_rate1);
            }
            // The remaining days auction price curve
            else if (now >= auction_start_time && now >= auction_start_time + CURVE_CUTOFF_DURATION){
              decay_rate2 = elapsed ** price_exponent2 / price_constant2;
              return price_start * (1 + elapsed) / (1 + elapsed + decay_rate2);
            }
            else {
              return price_start;
            }

        }
    }
// Solidity 0.8.1
// **********
// TOKEN SALE
// **********
function purchase(uint256 tokenId) external payable {
        if (sale[tokenId].buyer != address(0)) { // if buyer is preset, require caller match
            require(msg.sender == sale[tokenId].buyer, "!buyer");
        }
        uint256 price = sale[tokenId].price;
        require(price > 0, "!forSale"); // token price must be non-zero to be considered 'for sale'
        require(msg.value == price, "!price");
        address owner = ownerOf[tokenId];
        (bool success, ) = owner.call{value: msg.value}("");
        require(success, "!ethCall");
        balanceOf[owner]--; 
        balanceOf[msg.sender]++; 
        getApproved[tokenId] = address(0); // reset spender approval
        ownerOf[tokenId] = msg.sender;
        sale[tokenId].buyer = address(0); // reset buyer address
        sale[tokenId].price = 0; // reset sale price
        emit Transfer(owner, msg.sender, tokenId); 
    }
// Solidity 0.6.12
/// @dev Execute an arbitrary call. Only an authority can call this.
/// @param target The call target.
/// @param callData The call data.
/// @return resultData The data returned by the call.
function executeCall(
        address payable target,
        bytes calldata callData
    )
        override
        external
        onlySpender
        returns (bytes memory resultData)
    {
        bool success;
        (success, resultData) = target.call(callData);
        if (!success) {
            // Get the error message returned
            assembly {
                let ptr := mload(0x40)
                let size := returndatasize()
                returndatacopy(ptr, 0, size)
                revert(ptr, size)
            }
        }
    }
// Solidity 0.8.9
/**
 @notice depositReward is a one-time function which deposits a set amount of VIRTUE token that
 can be claimed by airdrop recipients. The rewards are distributed over the duration of
 _rewardsDuration. The function requires the owner to first approve the VirtuousHourAirdrop
 contract to transfer the amount of VIRTUE token on its behalf.
 
 THIS FUNCTION CANNOT BE CALLED MORE THAN ONCE.
 @param _virtueAmount The amount of VIRTUE reward to distribute.
 @param _rewardsDuration The amount of time that the VIRTUE reward will distribute over.
 */
function depositReward(uint _virtueAmount, uint _rewardsDuration) external onlyOwner {
    require(!rewardDeposited, "Reward has already been deposited");
    rewardDeposited = true;
    totalVirtueReward = _virtueAmount;
    rewardsStartTime = block.timestamp;
    rewardsDuration = _rewardsDuration;
    require(virtueToken.transferFrom(msg.sender, address(this), _virtueAmount));
    emit AirdropRewardDeposited(_virtueAmount, msg.sender);
  }
// Solidity 0.8.9
/**
 @notice claimRewards will claim the VIRTUE rewards that an address is eligible to claim from the
 airdrop contract, based on how many NFTs they minted during the eligible window. The function
 must be called with the EXACT number of shares that the address is eligible to claim, i.e.
 if someone purchased 5 eligible NFTs and they try to claim with _numShares = 1, the
 transaction will be reverted -- they must claim exactly 5 shares.
 @param _to The address to claim rewards for.
 @param _numShares The number of shares (i.e. eligible NFTs purchased) of VIRTUE rewards to
 claim.
 @param _merkleProof The merkle proof used to authenticate the transaction against the Merkle
 root.
 */
function claimRewards(address _to, uint _numShares, bytes32[] calldata _merkleProof) external {
    require(rewardDeposited, "Reward has not yet been deposited into contract");

    // Verify against the Merkle tree that the transaction is authenticated for the user.
    bytes32 leaf = keccak256(abi.encodePacked(_to, _numShares));
    require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Failed to authenticate with merkle tree");

    uint rewardAmount = claimableReward(_to, _numShares);
    require(rewardAmount > 0, "No rewards available to claim");

    alreadyClaimed[_to] = alreadyClaimed[_to] + rewardAmount;
    require(virtueToken.transfer(_to, rewardAmount));
  }
// Solidity 0.5.17
// ------------------------------------------------------------------------
// Allow user to subscribe/extend access expiry through contract
// ------------------------------------------------------------------------
function subscribeViaToken(uint256 _value) public  returns (bool) {

        uint256 sentValue = _value.mul(1 ether);
        require(sentValue <= balances[msg.sender], "Insufficient balance");
        balances[msg.sender] = balances[msg.sender].sub(sentValue);
        balances[tokenReceivingAddress] = balances[tokenReceivingAddress].add(sentValue);
        emit Transfer(msg.sender, tokenReceivingAddress, sentValue);
        // To add new user or extend access expiry
        checkAndRegisterUser (msg.sender, _value);
        
        return true;
    }
// Solidity 0.5.17
// ------------------------------------------------------------------------
// Bulk buy tokens via ETH
// ------------------------------------------------------------------------
function buyTokens () public payable returns (bool) {
        require(pauseBuy == false,'Token buy currently unavailable.');
        require(msg.sender != address(0), "Invalid address");
        require(msg.value > 0, "Invalid amount");
        uint256 tokensToBuy;
        if (msg.value < 1 ether) {
            tokensToBuy = msg.value.mul(bronzePack).div(ethToToken);
        }
        else if (msg.value > 1 ether && msg.value <= 5 ether) {
            tokensToBuy = msg.value.mul(silverPack).div(ethToToken);
        }
        else if (msg.value > 5 ether && msg.value <= 15 ether) {
            tokensToBuy = msg.value.mul(goldPack).div(ethToToken);
        }
        else if (msg.value > 15 ether && msg.value <= 30 ether) {
            tokensToBuy = msg.value.mul(platinumPack).div(ethToToken);
        }
        else {
            tokensToBuy = msg.value.mul(diamondPack).div(ethToToken);
        }

        tokenSupply = tokenSupply.add(tokensToBuy);
        balances[msg.sender] = balances[msg.sender].add(tokensToBuy);
        ownerAddress.transfer(msg.value);
        emit Transfer(address(0), msg.sender, tokensToBuy);
        return true;
    }
// Solidity 0.5.17
// ------------------------------------------------------------------------
// Register a new user
// ------------------------------------------------------------------------
function checkAndRegisterUser (address _account, uint256 _amount) private {
        require(_amount > 0, 'Amount can not be zero');
        if (!users[_account].isExist) {
            //Create temp instance of User struct
            Users_Details memory user;
            user.register_on = now;
            user.access_expiry = now + (_amount * tokenToTime);
            user.isExist = true;
            users[_account] = user;
            userCount += 1;
        }
        else {
            // Extend access expiry
            extendUserAccess(_account, _amount);
        }
    }
// Solidity 0.5.17
// ------------------------------------------------------------------------
// Check user access expiry
// ------------------------------------------------------------------------
function getUserAccessExpiry (address _account) public view returns(uint256) {
        //require(users[_account].isExist,'User does not exists');
        if (users[_account].isExist) {
            // Create temp instance of User struct
            Users_Details memory user;
            user = users[_account];
            return user.access_expiry;
        }
        else {
            return 0;
        }
    }
// Solidity 0.5.17
// ------------------------------------------------------------------------
// Extend user access expiry
// ------------------------------------------------------------------------
function extendUserAccess (address _account, uint256 _amount) private {
        require(users[_account].isExist,'User does not exists');
        // Create temp instance of User struct
        Users_Details memory user;
        uint256 currentExpiry = users[_account].access_expiry;
        uint256 extendedExpiry;
        if (currentExpiry > now) {
            extendedExpiry = currentExpiry + (_amount * tokenToTime);
        }
        else {
            extendedExpiry = now + (_amount * tokenToTime);
        }
        user.isExist = true;
        user.register_on = users[_account].register_on;
        user.access_expiry = extendedExpiry;
        users[_account] = user;
    }
// Solidity 0.5.17
// ------------------------------------------------------------------------
// Change ETH to VLT Rates
// ------------------------------------------------------------------------
function changePackRates (uint256 _bronzePack, uint256 _silverPack, uint256 _goldPack, uint256 _platinumPack, uint256 _diamondPack) public onlyOwner returns (bool) {
        require(_bronzePack > 0, 'Invalid bronze pack rate');
        require(_silverPack > 0, 'Invalid silver pack rate');
        require(_goldPack > 0, 'Invalid gold pack rate');
        require(_platinumPack > 0, 'Invalid platinum pack rate');
        require(_diamondPack > 0, 'Invalid diamond pack rate');

        bronzePack = _bronzePack;
        silverPack = _silverPack;
        goldPack = _goldPack;
        platinumPack = _platinumPack;
        diamondPack = _diamondPack;
        return true;
    }
// Solidity 0.5.16
/**
 * It adds a new token address to lastAmountsAddresses list
 *
 * @param _newToken : new interest bearing token address
 */
function setNewToken(address _newToken)
    external onlyOwner {
      require(_newToken != address(0), "New token should be != 0");
      for (uint256 i = 0; i < lastAmountsAddresses.length; i++) {
        if (lastAmountsAddresses[i] == _newToken) {
          return;
        }
      }

      lastAmountsAddresses.push(_newToken);
      lastAmounts.push(0);
  }
// Solidity 0.5.16
/**
 * Used by Rebalance manager to set the new allocations
 *
 * @param _allocations : array with allocations in percentages (100% => 100000)
 * @param _addresses : array with addresses of tokens used, should be equal to lastAmountsAddresses
 */
function setAllocations(uint256[] calldata _allocations, address[] calldata _addresses)
    external onlyRebalancerAndIdle
  {
    require(_allocations.length == lastAmounts.length, "Alloc lengths are different, allocations");
    require(_allocations.length == _addresses.length, "Alloc lengths are different, addresses");

    uint256 total;
    for (uint256 i = 0; i < _allocations.length; i++) {
      require(_addresses[i] == lastAmountsAddresses[i], "Addresses do not match");
      total = total.add(_allocations[i]);
      lastAmounts[i] = _allocations[i];
    }
    require(total == 100000, "Not allocating 100%");
  }
// Solidity 0.4.24
/* TODO: this is only for first pilots to avoid funds stuck in contract due to bugs.
 remove this function for higher volume pilots */
function withdraw(AugmintToken tokenAddress, address to, uint tokenAmount, uint weiAmount, string narrative)
    external restrict("StabilityBoard") {
        tokenAddress.transferWithNarrative(to, tokenAmount, narrative);
        if (weiAmount > 0) {
            to.transfer(weiAmount);
        }

        emit WithdrawFromSystemAccount(tokenAddress, to, tokenAmount, weiAmount, narrative);
    }
// Solidity 0.4.24
/* Locker requesting interest when locking funds. Enforcing LTD to stay within range allowed by LTD params
 NB: it does not know about min loan amount, it's the loan contract's responsibility to enforce it  */
function requestInterest(uint amountToLock, uint interestAmount) external {
        // only whitelisted Locker
        require(permissions[msg.sender]["Locker"], "msg.sender must have Locker permission");
        require(amountToLock <= getMaxLockAmountAllowedByLtd(), "amountToLock must be <= maxLockAmountAllowedByLtd");

        totalLockedAmount = totalLockedAmount.add(amountToLock);
        // next line would revert but require to emit reason:
        require(augmintToken.balanceOf(address(interestEarnedAccount)) >= interestAmount,
            "interestEarnedAccount balance must be >= interestAmount");
        interestEarnedAccount.transferInterest(augmintToken, msg.sender, interestAmount); // transfer interest to Locker
    }
// Solidity 0.4.24
/* Issue loan if LTD stays within range allowed by LTD params
 NB: it does not know about min loan amount, it's the loan contract's responsibility to enforce it */
function issueLoan(address borrower, uint loanAmount) external {
         // only whitelisted LoanManager contracts
        require(permissions[msg.sender]["LoanManager"],
            "msg.sender must have LoanManager permission");
        require(loanAmount <= getMaxLoanAmountAllowedByLtd(), "loanAmount must be <= maxLoanAmountAllowedByLtd");
        totalLoanAmount = totalLoanAmount.add(loanAmount);
        augmintToken.issueTo(borrower, loanAmount);
    }
// Solidity 0.4.24
/* User can request to convert their tokens from older AugmintToken versions in 1:1
 transferNotification is called from AugmintToken's transferAndNotify
 Flow for converting old tokens:
 1) user calls old token contract's transferAndNotify with the amount to convert,
 addressing the new MonetarySupervisor Contract
 2) transferAndNotify transfers user's old tokens to the current MonetarySupervisor contract's address
 3) transferAndNotify calls MonetarySupervisor.transferNotification
 4) MonetarySupervisor checks if old AugmintToken is permitted
 5) MonetarySupervisor issues new tokens to user's account in current AugmintToken
 6) MonetarySupervisor burns old tokens from own balance
 */
function transferNotification(address from, uint amount, uint /* data, not used */ ) external {
        AugmintTokenInterface legacyToken = AugmintTokenInterface(msg.sender);
        require(acceptedLegacyAugmintTokens[legacyToken], "msg.sender must be allowed in acceptedLegacyAugmintTokens");

        legacyToken.burn(amount);
        augmintToken.issueTo(from, amount);
        emit LegacyTokenConverted(msg.sender, from, amount);
    }
// Solidity 0.4.24
/* Helper function for UI.
 Returns max lock amount based on minLockAmount, interestPt, using LTD params & interestEarnedAccount balance */
function getMaxLockAmount(uint minLockAmount, uint interestPt) external view returns (uint maxLock) {
        uint allowedByEarning = augmintToken.balanceOf(address(interestEarnedAccount)).mul(PERCENT_100).div(interestPt);
        uint allowedByLtd = getMaxLockAmountAllowedByLtd();
        maxLock = allowedByEarning < allowedByLtd ? allowedByEarning : allowedByLtd;
        maxLock = maxLock < minLockAmount ? 0 : maxLock;
    }
// Solidity 0.4.24
/* returns maximum lockable token amount allowed by LTD params. */
function getMaxLockAmountAllowedByLtd() public view returns(uint maxLockByLtd) {
        uint allowedByLtdDifferencePt = totalLoanAmount.mul(PERCENT_100).div(PERCENT_100
                                            .sub(ltdParams.lockDifferenceLimit));
        allowedByLtdDifferencePt = totalLockedAmount >= allowedByLtdDifferencePt ?
                                        0 : allowedByLtdDifferencePt.sub(totalLockedAmount);

        uint allowedByLtdDifferenceAmount =
            totalLockedAmount >= totalLoanAmount.add(ltdParams.allowedDifferenceAmount) ?
                0 : totalLoanAmount.add(ltdParams.allowedDifferenceAmount).sub(totalLockedAmount);

        maxLockByLtd = allowedByLtdDifferencePt > allowedByLtdDifferenceAmount ?
                                        allowedByLtdDifferencePt : allowedByLtdDifferenceAmount;
    }