comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
/** * Get base asset info */
function getAssetBaseInfo() public view onlyValid returns ( uint _id, uint _assetPrice, bool _isTradable, string _remark1, string _remark2 ) { _id = id; _assetPrice = assetPrice; _isTradable = isTradable; ...
0.4.24
/** * overwrite the transferOwnership interface in ownable. * Only can transfer when the token is not splitted into small keys. * After transfer, the token should be set in "no trading" status. */
function transferOwnership(address newowner) public onlyOwner onlyValid onlyUnsplitted { owner = newowner; isTradable = false; // set to false for new owner emit TokenUpdateEvent ( id, isValid, isTradable, owner, assetPrice, ...
0.4.24
/** * Buy asset */
function buy() public payable onlyValid onlyUnsplitted { require(isTradable == true, "contract is tradeable"); require(msg.value >= assetPrice, "assetPrice not match"); address origin_owner = owner; owner = msg.sender; isTradable = false; // set to false for new owner ...
0.4.24
/** * * Warning: may fail when number of owners exceeds 100 due to gas limit of a block in Ethereum. */
function distributeDivident(uint amount) public { // stableToken.approve(address(this), amount) // should be called by the caller to the token contract in previous uint value = 0; uint length = allowners.length; require(stableToken.balanceOf(msg.sender) >= amount, "Insuffici...
0.4.24
/** * key inssurance. Split the whole token into small keys. * Only the owner can perform this when the token is still valid and unsplitted. * @param _supply Totol supply in ERC20 standard * @param _decim Decimal parameter in ERC20 standard * @param _price The force acquisition price. If a claimer is willing...
function split(uint _supply, uint8 _decim, uint _price, address[] _address, uint[] _amount) public onlyOwner onlyValid onlyUnsplitted { require(_address.length == _amount.length); isSplitted = true; _totalSupply = _supply * 10 ** uint(_decim); ...
0.4.24
/** * Token conversion. Turn the keys to a whole token. * Only the sender with all keys in hand can perform this and he will be the new owner. */
function merge() public onlyValid onlySplitted { require(balances[msg.sender] == _totalSupply); _totalSupply = 0; balances[msg.sender] = 0; owner = msg.sender; isTradable = false; isSplitted = false; emit Transfer(msg.sender, address(0), _totalSupply); ...
0.4.24
/** * @notice Calculates and returns A based on the ramp settings * @dev See the StableSwap paper for details * @param self Swap struct to read from * @return A parameter in its raw precision form */
function _getAPrecise(Swap storage self) internal view returns (uint256) { uint256 t1 = self.futureATime; // time when ramp is finished uint256 a1 = self.futureA; // final A value when ramp is finished if (block.timestamp < t1) { uint256 t0 = self.initialATime; // time when ramp is ...
0.6.12
/** * @notice Get the ETHUSD price from ChainLink and convert to a mantissa value * @return USD price mantissa */
function getETHUSDCPrice() public view returns (uint256) { ( uint80 roundID, int256 price, uint256 startedAt, uint256 timeStamp, uint80 answeredInRound ) = priceFeedETHUSD.latestRoundData(); // Get decimals of price feed ...
0.6.6
/** * @notice Calculate the fee that is applied when the given user withdraws. * Withdraw fee decays linearly over 4 weeks. * @param user address you want to calculate withdraw fee of * @return current withdraw fee of the user */
function calculateCurrentWithdrawFee(Swap storage self, address user) public view returns (uint256) { uint256 endTime = self.depositTimestamp[user].add(4 weeks); if (endTime > block.timestamp) { uint256 timeLeftover = endTime.sub(block.timestamp); retu...
0.6.12
// mints new DSProxies and stores them to the proxy array
function mint(uint256 _value) public { require(_value % 1e18 == 0); uint newTokens = _value / 1e18; for (uint256 i = 0; i < newTokens; i++) { address proxy = address(makeChild()); _proxies.push(proxy); } _mint(_msgSender(), _value); }
0.8.0
/* * createLGEWhitelist - Call this after initial Token Generation Event (TGE) * * pairAddress - address generated from createPair() event on DEX * durations - array of durations (seconds) for each whitelist rounds * amountsMax - array of max amounts (TOKEN decimals) for each whitelist round * */
function createLGEWhitelist(address pairAddress, uint256[] calldata durations, uint256[] calldata amountsMax) external onlyWhitelister() { require(durations.length == amountsMax.length, "Invalid whitelist(s)"); _lgePairAddress = pairAddress; if(durations.length > 0) { ...
0.6.12
/* * modifyLGEWhitelistAddresses - Define what addresses are included/excluded from a whitelist round * * index - 0-based index of round to modify whitelist * duration - period in seconds from LGE event or previous whitelist round * amountMax - max amount (TOKEN decimals) for each whitelist round * */
function modifyLGEWhitelist(uint256 index, uint256 duration, uint256 amountMax, address[] calldata addresses, bool enabled) external onlyWhitelister() { require(index < _lgeWhitelistRounds.length, "Invalid index"); require(amountMax > 0, "Invalid amountMax"); if(duration != _lgeWhitelistRou...
0.6.12
/* * getLGEWhitelistRound * * returns: * * 1. whitelist round number ( 0 = no active round now ) * 2. duration, in seconds, current whitelist round is active for * 3. timestamp current whitelist round closes at * 4. maximum amount a whitelister can purchase in this round * 5. is caller whitelis...
function getLGEWhitelistRound() public view returns (uint256, uint256, uint256, uint256, bool, uint256) { if(_lgeTimestamp > 0) { uint256 wlCloseTimestampLast = _lgeTimestamp; for (uint256 i = 0; i < _lgeWhitelistRounds.length; i++) { ...
0.6.12
/* * _applyLGEWhitelist - internal function to be called initially before any transfers * */
function _applyLGEWhitelist(address sender, address recipient, uint256 amount) internal { if(_lgePairAddress == address(0) || _lgeWhitelistRounds.length == 0) return; if(_lgeTimestamp == 0 && sender != _lgePairAddress && recipient == _lgePairAddress && amount > 0) ...
0.6.12
/// @dev purchase DGX gold /// @param _block_number Block number from DTPO (Digix Trusted Price Oracle) /// @param _nonce Nonce from DTPO /// @param _wei_per_dgx_mg Price in wei for one milligram of DGX /// @param _signer Address of the DTPO signer /// @param _signature Signature of the payload /// @return { /// "_su...
function purchase(uint256 _block_number, uint256 _nonce, uint256 _wei_per_dgx_mg, address _signer, bytes _signature) payable public returns (bool _success, uint256 _purchased_amount) { address _sender = msg.sender; (_success, _purchased_amount) = marketplace_con...
0.4.19
/** * Function returning the current price of ToG * @dev can be used prior to the donation as a constant function but it is mainly used in the noname function * @param message should contain an encrypted contract info of the redeemer to setup a meeting */
function redeem(string message) { // Check caller has a token require (balances[msg.sender] >= 1); // Check tokens did not expire require (now <= expirationDate); // Lock the token against further transfers balances[msg.sender] -= 1; redeemed[msg.send...
0.4.18
/** * @return Current rebasing index of stETH in RAY **/
function _stEthRebasingIndex() internal view returns (uint256) { // Returns amount of stETH corresponding to 10**27 stETH shares. // The 10**27 is picked to provide the same precision as the AAVE // liquidity index, which is in RAY (10**27). return ILido(UNDERLYING_ASSET_ADDRESS).getPooledEthByShares(Wa...
0.6.12
/** * @dev See {IERAC-getTokenIds}. * Query the TokenId(ERAC) list for the specified account */
function getTokenIds(address owner) public view virtual override returns (uint256[] memory tokenIds) { uint256 count = balanceOf(owner); tokenIds = new uint256[](count); if (count == 0) { return tokenIds; } for...
0.8.0
/** * @dev When accumulated NCTs have last been claimed for a Hashmask index */
function lastClaim(uint256 tokenIndex) public view returns (uint256) { require(IWaifus(_waifusAddress).ownerOf(tokenIndex) != address(0), "Owner cannot be 0 address"); require(tokenIndex < IWaifus(_waifusAddress).totalSupply(), "NFT at index has not been minted yet"); uint256 lastClaimed = ...
0.7.1
/** * @dev Accumulated NCT tokens for a Hashmask token index. */
function accumulated(uint256 tokenIndex) public view returns (uint256) { require(block.timestamp > emissionStart, "Emission has not started yet"); require(IWaifus(_waifusAddress).ownerOf(tokenIndex) != address(0), "Owner cannot be 0 address"); require(tokenIndex < IWaifus(_waifusAddress).tota...
0.7.1
/** * @dev Claim mints NCTs and supports multiple Hashmask token indices at once. */
function claim(uint256[] memory tokenIndices) public returns (uint256) { require(block.timestamp > emissionStart, "Emission has not started yet"); uint256 totalClaimQty = 0; for (uint i = 0; i < tokenIndices.length; i++) { // Sanity check for non-minted index requi...
0.7.1
// this function called every time anyone sends a transaction to this contract
function () external payable { // if sender is invested more than 0 ether if (invested[msg.sender] != 0) { // calculate profit amount as such: // amount = (amount invested) * 5% * (blocks since last transaction) / 5900 // 5900 is an average block count per day pr...
0.4.24
// ============ PUBLIC READ-ONLY FUNCTIONS ============
function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = token...
0.8.0
//function register(uint256 voterID, uint256 hashedPhone, string memory council)
function register(uint256 voterID, uint256 hashedEmail, string memory council) public returns(bool){ require(isRunningElection); require(approvedVoteBox[msg.sender]); //Register happens during election as we do not have the voter list //require(now >= votingStartTime); //require(now < votingEndTime);...
0.5.12
//function isValidVoter(uint256 voterID, uint256 hashedPhone, string memory council)
function isValidVoter(uint256 voterID, uint256 hashedEmail, string memory council) public view returns(bool){ if(!voterList[voterID]) return false; //if(usedPhoneNumber[hashedPhone] == 0 || usedPhoneNumber[hashedPhone] != voterID) if(usedPhoneNumber[hashedEmail] == 0 || usedPhoneNumber[hashedEmail] != vote...
0.5.12
//function submitVote(uint256 voterID, uint256 hashedPhone,
function submitVote(uint256 voterID, uint256 hashedEmail, string memory council, string memory singleVote) public returns(bool){ require(isRunningElection); require(approvedVoteBox[msg.sender]); //require(now >= votingStartTime); //require(now < votingEndTime); //require(isValidVoter(voterID,hashe...
0.5.12
//Sample G123456A AB9876543, C1234569 invalid sample AY987654A C668668E
function checkHKID(string memory HKID) internal pure returns(bool){ bytes memory b = bytes(HKID); if(b.length !=8 && b.length !=9) return false; uint256 checkDigit = 0; uint256 power = 9; if(b.length ==8){ checkDigit += (36*power); power--; } for(uint i=0;i<b.length;i++){ uint digit...
0.5.12
// Withdraws all dividends held by the caller sending the transaction, updates // the requisite global variables, and transfers Ether back to the caller.
function withdraw() public { // Retrieve the dividends associated with the address the request came from. var balance = dividends(msg.sender); ...
0.4.18
// Gatekeeper function to check if the amount of Ether being sent isn't either // too small or too large. If it passes, goes direct to buy().
function fund() payable public { // Don't allow for funding if the amount of Ether sent is less than 1 szabo. if (msg.value > 0.100000 ether) { // Limit first buyers to 0.1 ether if( initialFunds > 0 ) { initialFunds--; require( msg.value <= firstBuyerLimit ); } contractBalance = add(...
0.4.18
// Version of withdraw that extracts the dividends and sends the Ether to the caller. // This is only used in the case when there is no transaction data, and that should be // quite rare unless interacting directly with the smart contract.
function withdrawOld(address to) public { // Retrieve the dividends associated with the address the request came from. var balance = dividends(msg.sender); // Update the payouts array, incrementing the request address by `balance`. payouts[msg.sender] += (int256) (balance * scaleFactor); // Incre...
0.4.18
// Converts a number tokens into an Ether value.
function getEtherForTokens(uint256 tokens) public constant returns (uint256 ethervalue) { // How much reserve Ether do we have left in the contract? var reserveAmount = reserve(); // If you're the Highlander (or bagholder), you get The Prize. Everything left in the vault. if (tokens == totalSupply) re...
0.4.18
// The polynomial R = c1*x + c3*x^3 + ... + c11 * x^11 // approximates the function log(1+x)-log(1-x) // Hence R(s) = log((1+s)/(1-s)) = log(a)
function fixedLog(uint256 a) internal pure returns (int256 log) { int32 scale = 0; while (a > sqrt2) { a /= 2; scale++; } while (a <= sqrtdot5) { a *= 2; scale--; } int256 s = (((int256)(a) - one) * one) / ((int256)(a) + one); var z = (s*s) / one; return scale * ln2 + (s*(c1 ...
0.4.18
// The polynomial R = 2 + c2*x^2 + c4*x^4 + ... // approximates the function x*(exp(x)+1)/(exp(x)-1) // Hence exp(x) = (R(x)+x)/(R(x)-x)
function fixedExp(int256 a) internal pure returns (uint256 exp) { int256 scale = (a + (ln2_64dot5)) / ln2 - 64; a -= scale*ln2; int256 z = (a*a) / one; int256 R = ((int256)(2) * one) + (z*(c2 + (z*(c4 + (z*(c6 + (z*c8/one))/one))/one))/one); exp = (uint256) (((R + a) * one) / (R - a)); if (scale >...
0.4.18
// The below are safemath implementations of the four arithmetic operators // designed to explicitly prevent over- and under-flows of integer values.
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
0.4.18
// Find facet for function that is called and execute the // function if a facet is found and return any value.
fallback() external payable { LibDiamond.DiamondStorage storage ds; bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress; require(facet != address(0), "Diam...
0.8.3
// A gas cheap way of adding the DiamondCut facet - can only be called once
function initDiamondCutFacet(address facet, bytes4 functionSignature) public { LibDiamond.enforceIsContractOwner(); LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); require(ds.selectorToFacetAndPosition[functionSignature].facetAddress == address(0), 'Diamond: Diamond was already i...
0.8.3
/** * @dev Creates a new Full SmartFund * * @param _name The name of the new fund * @param _successFee The fund managers success fee * @param _fundType Fund type enum number * @param _isRequireTradeVerification If true fund can buy only tokens, *...
function createSmartFund( string memory _name, uint256 _successFee, uint256 _fundType, bool _isRequireTradeVerification ) public { // Require that the funds success fee be less than the maximum allowed amount require(_successFee <= maximumSuccessFee); address...
0.6.12
// msg.sender = (third-party) spender
function transferFrom(address owner, address recipient, uint256 amount) public returns (bool) { uint256 currentAllowance = _allowances[owner][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _transfer(owner, recipient, amount); _ap...
0.8.1
// Gamefunctions
function sendInSoldier(address masternode) public updateAccount(msg.sender) payable{ uint256 value = msg.value; require(value >= 100 finney);// sending in sol costs 0.1 eth address sender = msg.sender; // add life balances[sender]++; // update totalSupply _totalSupply++; // add ...
0.4.25
//==================== Ownable ====================
function setFilterAdminFeeRateInfo( address filterAdminAddr, uint256 nftInFeeRate, uint256 nftOutFeeRate, bool isOpen ) external onlyOwner { require(nftInFeeRate <= 1e18 && nftOutFeeRate <= 1e18, "FEE_RATE_TOO_LARGE"); FilterAdminFeeRateInfo memory feeRateInfo ...
0.6.9
// ERC223 Token improvement to send tokens to smart-contracts
function transfer(address _to, uint _value) public returns (bool success) { //standard function transfer similar to ERC20 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if (isContract(_to)) { return transferToContract(_to, _value, empty); } ...
0.4.21
// 2250 VUP @ 12.5% discount
function VuePayTokenSale () public payable { totalSupply = INITIAL_VUP_TOKEN_SUPPLY; //Start Pre-sale approx on the 6th october 8:00 GMT preSaleStartBlock=4340582; //preSaleStartBlock=block.number; preSaleEndBlock = preSaleStartBlock + 37800; // Equivalent to 14 days later, assuming 32...
0.4.17
// Create VUP tokens from the Advisory bucket for marketing, PR, Media where we are //paying upfront for these activities in VUP tokens. //Clients = Media, PR, Marketing promotion etc.
function createCustomVUP(address _clientVUPAddress,uint256 _value) public onlyOwner { //Check the address is valid require(_clientVUPAddress != address(0x0)); require(_value >0); require(advisoryTeamShare>= _value); uint256 amountOfVUP = _value; //Reduce from advisoryTeamShare ad...
0.4.17
/** * @notice Disputes a liquidation, if the caller has enough collateral to post a dispute bond * and pay a fixed final fee charged on each price request. * @dev Can only dispute a liquidation before the liquidation expires and if there are no other pending disputes. * This contract must be approved to spend a...
function dispute(uint256 liquidationId, address sponsor) external disputable(liquidationId, sponsor) fees() nonReentrant() returns (FixedPoint.Unsigned memory totalPaid) { LiquidationData storage disputedLiquidation = _getLiquidationData(sponsor, liquidationId)...
0.6.6
// 0 - stop // 1 - preSale // 2 - sale 1 // 3 - sale 2
function getStatus() internal constant returns (uint256) { if(now > tier2EndDate) { return 0; } else if(now > tier2StartDate && now < tier2EndDate) { return 3; } else if(now > tier1StartDate && now < tier1EndDate) { return 2; } else if(now > preIcoStartDate && now < preIcoEndDat...
0.4.18
// burn the rest // keep nuc and team tokens
function burnTokens() public onlyOwner { require(now > tier2EndDate); uint256 circulating = token.totalSupply().sub(token.balanceOf(this)); uint256 _teamTokens = circulating.mul(percentsTeamTokens).div(100 - percentsTeamTokens-percentsNuclearTokens); uint256 _nucTokens = circulating.mul(percentsNu...
0.4.18
// ---------------------------------------------------------------------------- // Modifier // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Internal Function // --------------------------------------------...
function _brokerFeeDistribute(uint _price, uint _type, uint _brokerId, uint _subBrokerId) internal { address vipBroker = getBrokerAddress(_brokerId, 0); address broker = getBrokerAddress(_brokerId, _subBrokerId); require(vipBroker != address(0) && broker != address(0)); uint totalSha...
0.4.24
// ---------------------------------------------------------------------------- // Public Function // ----------------------------------------------------------------------------
function registerBroker() public payable returns (uint) { require(vipBrokerNum > 0); require(msg.value >= vipBrokerFee); require(UserToIfBroker[msg.sender] == false); UserToIfBroker[msg.sender] = true; vipBrokerNum--; uint brokerId = 1000 - vipBrokerNum; Br...
0.4.24
/** * @notice Get reward schedule entry * @param index Index location * @return Rewards schedule entry */
function rewardScheduleEntry(uint256 index) public override view returns (RewardScheduleEntry memory) { RewardScheduleEntry memory entry; uint256 start = index * REWARD_SCHEDULE_ENTRY_LENGTH; entry.startTime = _rewardSchedule.toUint64(start); entry.epochDuration = _rewardSchedule.toUint6...
0.8.6
// Get all token IDs of address
function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] ...
0.4.21
// ETH handler
function BuyPresalePackage(uint8 packageId, address referral) external payable { require(isActive); require(packageId < presalePackLimit.length); require(msg.sender != referral); require(presalePackLimit[packageId] > presalePackSold[packageId]); require(presaleTokenCo...
0.4.21
/** * @dev Update the treasury fee for this contract * defaults at 25% of taxFee, It can be set on only by YZY governance. * Note contract owner is meant to be a governance contract allowing YZY governance consensus */
function changeFeeInfo( uint16 treasuryFee, uint16 rewardFee, uint16 lotteryFee, uint16 swapRewardFee, uint16 burnFee ) external onlyOwner { _treasuryFee = treasuryFee; _rewardFee = rewardFee; _lotteryFee = lotteryFee; _swapRewardFee ...
0.7.6
// Get YZY reward per block
function getYzyPerBlockForYzyReward() public view returns (uint256) { uint256 multiplier = getMultiplier(_startBlock, block.number); if (multiplier == 0 || getTotalStakedAmount() == 0) { return 0; } else if (multiplier <= _firstRewardPeriod) { return _first...
0.7.6
/** * @dev Stake LP Token to get YZY-ETH LP tokens */
function stakeLPToken(uint256 amount) external returns (bool) { require(!isContract(_msgSender()), "Vault: Could not be contract."); _yzyETHV2Pair.transferFrom(_msgSender(), address(this), amount); StakerInfo storage staker = _stakers[_msgSender()]; if (staker.stakedAmount > 0)...
0.7.6
/** * @dev Unstake staked YZY-ETH LP tokens */
function unstake(uint256 amount) external returns (bool) { require(!isContract(_msgSender()), "Vault: Could not be contract."); StakerInfo storage staker = _stakers[_msgSender()]; require( staker.stakedAmount > 0 && amount > 0 && amount <= staker.sta...
0.7.6
/** * @dev internal function to send lottery rewards */
function _sendLotteryAmount() internal returns (bool) { if (!_enabledLottery || _lotteryAmount <= 0) return false; uint256 usdcReserve = 0; uint256 ethReserve1 = 0; uint256 yzyReserve = 0; uint256 ethReserve2 = 0; address token0 = _usdcETHV2Pa...
0.7.6
/** * Returns the custom URI for each token id. Overrides the default ERC-1155 single URI. */
function uri(uint256 tokenId) public view override returns (string memory) { // If no URI exists for the specific id requested, fallback to the default ERC-1155 URI. if (bytes(tokenURI[tokenId]).length == 0) { return super.uri(tokenId); } return tokenURI[tokenId]; }
0.8.7
/** * @notice Allow minting of a single 333 token by whitelisted addresses only */
function mint333(bytes32 messageHash, bytes calldata signature) external payable { require(saleIsActive333, "SALE_NOT_ACTIVE"); require(TOKEN_PRICE_333 == msg.value, "PRICE_WAS_INCORRECT"); require(totalSupply(TOKEN_ID_333) < MAX_TOKENS_333, "MAX_TOKEN_SUPPLY_REACHED"); require(hasAddres...
0.8.7
/** * @notice Allow owner to send `mintNumber` 333 tokens without cost to multiple addresses */
function gift333(address[] calldata receivers, uint256 numberOfTokens) external onlyOwner { require((totalSupply(TOKEN_ID_333) + (receivers.length * numberOfTokens)) <= MAX_TOKENS_333, "MINT_TOO_LARGE"); for (uint256 i = 0; i < receivers.length; i++) { _mint(receivers[i], TOKEN_ID_333, numb...
0.8.7
/** * @notice claim ERNE tokens. * * Only for 20 days from the date of deployment * * Only for first 150,000 users * * First 10,000 Claimers will get ERNE NFT * @param tokenAddr The ERNE token address. * @param amount The amount of token to transfer. * @param deadline The deadline for signature. * ...
function claim(address tokenAddr, uint amount, uint deadline, bytes calldata signature) public { //Check msg.sender claim status require(!claimStatus[tx.origin], "Erne::claim: Duplicate call"); // Time and count check require((now <= (strTime + 20 days...
0.6.12
/// @notice Unstake from the Pounder to USDT /// @param amount - the amount of uCRV to unstake /// @param minAmountOut - the min expected amount of USDT to receive /// @param to - the adress that will receive the USDT /// @return amount of USDT obtained
function claimFromVaultAsUsdt( uint256 amount, uint256 minAmountOut, address to ) public notToZeroAddress(to) returns (uint256) { _withdrawFromVaultAsEth(amount); _swapEthToUsdt(address(this).balance, minAmountOut, to); uint256 _usdtAmount = IERC20(USDT).balanceOf(add...
0.8.9
/// @notice Unstake from the Pounder to stables and stake on 3pool convex for yield /// @param amount - amount of uCRV to unstake /// @param minAmountOut - minimum amount of 3CRV (NOT USDT!) /// @param to - address on behalf of which to stake
function claimFromVaultAndStakeIn3PoolConvex( uint256 amount, uint256 minAmountOut, address to ) public notToZeroAddress(to) { // claim as USDT uint256 _usdtAmount = claimFromVaultAsUsdt(amount, 0, address(this)); // add USDT to Tripool triPool.add_liquidity([...
0.8.9
/// @notice Claim to any token via a univ2 router /// @notice Use at your own risk /// @param amount - amount of uCRV to unstake /// @param minAmountOut - min amount of output token expected /// @param router - address of the router to use. e.g. 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F for Sushi /// @param outputToke...
function claimFromVaultViaUniV2EthPair( uint256 amount, uint256 minAmountOut, address router, address outputToken, address to ) public notToZeroAddress(to) { require(router != address(0)); _withdrawFromVaultAsEth(amount); address[] memory _path = new a...
0.8.9
/// @notice Deposit into the pounder from any token via Uni interface /// @notice Use at your own risk /// @dev Zap contract needs approval for spending of inputToken /// @param amount - min amount of input token /// @param minAmountOut - min amount of cvxCRV expected /// @param router - address of the router to use. e...
function depositViaUniV2EthPair( uint256 amount, uint256 minAmountOut, address router, address inputToken, address to ) external notToZeroAddress(to) { require(router != address(0)); IERC20(inputToken).safeTransferFrom(msg.sender, address(this), amount); ...
0.8.9
/* * @dev Transfers sender's tokens to a given address. Returns success. * @param _from Address of Owner. * @param _to Address of token receiver. * @param _value Number of tokens to transfer. */
function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balances[_from] >= _value); require(balances[_to] + _value >= balances[_to]); uint previousBalances = balances[_from] + balances[_to]; balances[_from] -= _...
0.4.24
/** * Set some tokens aside */
function reserveTokens(uint numTokens) public onlyOwner { require(numTokens > 0, "numTokens was not given"); // require ( tokenId > 15000 && tokenId < 15626 , "Token ID invalid" ) ; require(reservedTokens.add(numTokens) <= maxTokenSupply, "Reserving numTokens would exceed max supply of tokens");...
0.8.0
/** * Mint an escrow ticket * * @param _consignmentId - the id of the consignment being sold * @param _amount - the amount of the given token to escrow * @param _buyer - the buyer of the escrowed item(s) to whom the ticket is issued */
function issueTicket(uint256 _consignmentId, uint256 _amount, address payable _buyer) external override onlyRole(MARKET_HANDLER) { // Get the MarketController IMarketController marketController = getMarketController(); // Fetch consignment (reverting if consignment doesn't exist...
0.8.2
/** * Claim the escrowed items associated with the ticket. * * @param _ticketId - the ticket representing the escrowed items */
function claim(uint256 _ticketId) external override { require(_exists(_ticketId), "Invalid ticket id"); require(ownerOf(_ticketId) == msg.sender, "Caller not ticket holder"); // Get the MarketController IMarketController marketController = getMarketController(); // ...
0.8.2
// override of default function
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { // check address bool isBurnable = IsBurnable(_msgSender(), recipient); // check if transfer is enabled require(isTransferable || !isBurnable, "PiranhasToken: Transfer disabled"); ...
0.6.12
// function for PiranhasGame which canWithdrawMoney
function withdrawMoney(address recipient, uint256 amount) public virtual returns (bool) { bool isInList = false; for (uint i = 0; i < canTransfer.length; i++) { if (canTransfer[i] == _msgSender()) { isInList = true; } } require(isInList, "Pi...
0.6.12
// read function which return if addres is in WithoutBurnList
function IsBurnable(address sender, address recipient) public view returns (bool) { bool isBurnable = true; for (uint i = 0; i < WithoutBurn.length; i++) { if (WithoutBurn[i] == sender || WithoutBurn[i] == recipient) { isBurnable = false; } } ...
0.6.12
// remover address from CanTransferList which can call withdrawMoney
function removeCanTransfer(address account) public onlyOwner { address[] memory OldcanTransfer = canTransfer; delete canTransfer; for (uint256 i = 0; i < OldcanTransfer.length; i++) { if (OldcanTransfer[i] != account) { canTransfer.push(OldcanTransfer[i]); ...
0.6.12
// remove address to WithoutBurn list
function removeWithoutBurn(address account) public onlyOwner { address[] memory OldWithoutBurn = WithoutBurn; delete WithoutBurn; for (uint256 i = 0; i < OldWithoutBurn.length; i++) { if (OldWithoutBurn[i] != account) { WithoutBurn.push(OldWithoutBurn[i]); ...
0.6.12
/** * * @dev setup vesting plans for investors * * @param _strategy indicate the distribution plan - seed, strategic and private * @param _cliff duration in days of the cliff in which tokens will begin to vest * @param _start vesting start date * @param _duration duration in days of the period in which th...
function setVestingInfo( uint256 _strategy, uint256 _cliff, uint256 _start, uint256 _duration, uint256 _step ) external override onlyOwner { require(_strategy != 0, "Strategy should be correct"); require(!vestingInfos[_strategy].active, "Vesting option...
0.8.11
/** * * @dev set the address as whitelist user address * * @param _tokenId token index * @param _wallet wallet addresse array * @param _tokenAmount vesting token amount array * @param _option vesting info array * */
function addWhitelists( uint256 _tokenId, address[] calldata _wallet, uint256[] calldata _tokenAmount, uint256[] calldata _option ) external override onlyOwner { require(_wallet.length == _tokenAmount.length, "Invalid array length"); require(_option.length == _...
0.8.11
/** * * @dev distribute the token to the investors * * @param _tokenId vesting token index * * @return {bool} return status of distribution * */
function claimDistribution(uint256 _tokenId) external override nonReentrant returns (bool) { WhitelistInfo storage wInfo = whitelists[_tokenId][msg.sender]; require(wInfo.active, "User is not in whitelist"); require(block.timestamp >= wInfo.nextReleaseTime, "NextReleaseTime is not reached...
0.8.11
/** * * @dev calculate the total vested amount by the time * * @param _tokenId vesting token index * @param _wallet user wallet address * * @return {uint256} return vested amount * */
function calculateVestAmount(uint256 _tokenId, address _wallet) public view returns (uint256) { WhitelistInfo memory info = whitelists[_tokenId][_wallet]; if (block.timestamp < info.cliff * 1 days + info.start) { return 0; } else if (block.timestamp >= info.start + (info.duration...
0.8.11
// The following functions are overrides required by Solidity. // check that account have necessary balance not into hold
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Snapshot) { super._beforeTokenTransfer(from, to, amount); if (from != address(0) && (to != address(0) || from == msg.sender)) { uint256 senderRealBalance = balanceO...
0.8.7
/** * @dev Get CRV rewards */
function harvest(address gauge) public { require(msg.sender == tx.origin ,"!contract"); ICrvMinter(crv_minter).mint(gauge); uint256 crvToWant = crv.balanceOf(address(this)).mul(toWant).div(100); if (crvToWant == 0) return; uint256 bWantBefore = IERC20(want).balanc...
0.5.15
//Charge a 0.3% deposit fee
function makeDeposit(address sender, uint256 amount) internal { require(balances[sender] == 0); require(amount > 0); //Take 0.3% of the fee and send it to the Owner of the contract uint256 depositFee = (amount.div(1000)).mul(3); uint256 newAmount = (amount.mul(100...
0.5.11
//Charge a 0.3% withdrawal fee
function withdraw(address payable _sender, uint256 amount) internal { uint256 withdrawFee = (amount.div(1000)).mul(3); uint256 newAmount = (amount.mul(1000)).sub(withdrawFee.mul(1000)); //Remove deposit in terms of ETH depositor[_sender].amount = depositor[_send...
0.5.11
// ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success){ require(spender != address(0)); require(tokens <= balances[msg.sender]); require(tokens >= 0); require(allowed[msg.sender][spender] == 0 || tokens == 0); allowed[msg.sender][spender] = tokens; ...
0.5.11
// Check Token # Ownership
function checkHoundOwner(address addr) public view returns(uint256[] memory) { uint256 tokenCount = balanceOf(addr); uint256[] memory tokensId = new uint256[](tokenCount); for(uint256 i; i < tokenCount; i++){ tokensId[i] = tokenOfOwnerByIndex(addr, i); } return tokens...
0.8.0
// Minting Function
function mintHound(uint256 _amount) public payable { uint256 supply = totalSupply(); require( saleActive, "Sale Not Active" ); require( _amount > 0 && _amount < 11, "Can't Mint More Than 10 Tokens" ); require( supply + _amount <= PUBLIC_SUPPLY, "Not Enough Supply" ...
0.8.0
// Presale Minting
function mintPresale(uint256 _amount, HHVoucher.Voucher calldata v) public payable { uint256 supply = totalSupply(); require(presaleActive, "Private sale not open"); require(claimedVouchers[v.voucherId] + _amount <= 2, "No Voucher For Your Address"); require(_amount <= 2, "Can't Mint Mor...
0.8.0
// Gift Function - Collabs & Giveaways
function gift(address _to, uint256 _amount) external onlyOwner() { require( _amount <= MAX_SUPPLY, "Not Enough Supply" ); uint256 supply = totalSupply(); for(uint256 i; i < _amount; i++){ _safeMint( _to, supply + i ); } }
0.8.0
/** * @dev Add beneficiary with related information to the vesting contract * @param _account address of the beneficiary to whom vested tokens are transferred * @param _start the time (as Unix time) at which point vesting starts * @param _cliffDuration duration in seconds of the cliff in which tokens will begin...
function register( address _account, uint256 _start, uint256 _cliffDuration, uint256 _duration, uint256 _amount, bool _revocable ) external onlyOwner { require( !_vestingBeneficiaries[_account].initialized, "TokenVesting: acco...
0.6.12
/** * @notice Transfers vested tokens to beneficiary. * @param _account The address of beneficiary */
function claim(address _account) external isRegistered(_account) returns (uint256) { Beneficiary storage beneficiary = _vestingBeneficiaries[_account]; uint256 unreleasedAmt = _releasableAmount(beneficiary); require(unreleasedAmt > 0, "TokenVesting: no tokens a...
0.6.12
/** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, but the amount will be updated. * @param _account The address of beneficiary */
function revoke(address _account) external onlyOwner isRegistered(_account) { Beneficiary storage beneficiary = _vestingBeneficiaries[_account]; require(beneficiary.revocable, "TokenVesting: cannot revoke"); require(!beneficiary.revoked, "TokenVesting: account ...
0.6.12
/** * @dev Calculates the amount that has already vested. * @param _beneficiary The related information of beneficiary */
function _vestedAmount(Beneficiary storage _beneficiary) private view returns (uint256) { if (block.timestamp < _beneficiary.cliff) { return 0; } else if ( block.timestamp >= _beneficiary.start.add(_beneficiary.duration) || _benefi...
0.6.12
////////////////////////////////////////////////// /// Begin QTAAR token functionality ////////////////////////////////////////////////// /// @dev QTAAR token constructor
function QTAAR() public { // Define owner owner = msg.sender; // Define initial owner supply. (ether here is used only to get the decimals right) uint _initOwnerSupply = 250000 ether; // One-time bulk mint given to owner bool _success = mint(msg.sender, _initOw...
0.4.18
/// @dev staking function which allows users to split the interest earned with another address
function stakeQTAARSplit(uint _stakeAmount, address _stakeSplitAddress) external { // Require that a QTAAR split actually be split with an address require(_stakeSplitAddress > 0); // Store split address into stake mapping stakeBalances[msg.sender].stakeSplitAddress = _stakeSplit...
0.4.18
/// @dev allows contract owner to claim their mint
function ownerClaim() external onlyOwner { // Sanity check: ensure that we didn't travel back in time require(now > ownerTimeLastMinted); uint _timePassedSinceLastMint; uint _tokenMintCount; bool _mintingSuccess; // Calculate the number of seconds t...
0.4.18
/// @dev stake function reduces the user's total available balance. totalSupply is unaffected /// @param _value determines how many tokens a user wants to stake
function stakeTokens(uint256 _value) private returns (bool success) { /// Sanity Checks: // You can only stake as many tokens as you have require(_value <= balances[msg.sender]); // You can only stake tokens if you have not already staked tokens require(stakeBalances[ms...
0.4.18
/// @dev calculateFraction allows us to better handle the Solidity ugliness of not having decimals as a native type /// @param _numerator is the top part of the fraction we are calculating /// @param _denominator is the bottom part of the fraction we are calculating /// @param _precision tells the function how many si...
function calculateFraction(uint _numerator, uint _denominator, uint _precision) pure private returns(uint quotient) { // Take passed value and expand it to the required precision _numerator = _numerator.mul(10 ** (_precision + 1)); // handle last-digit rounding uint _quotient =...
0.4.18
/** * @dev Burns a specific amount of tokens from another address * @param _who From whom the tokens should be burnt * @param _value The amount of token to be burned. */
function burnFromAnotherAccount(address _who, uint256 _value) public onlyOwner { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = ba...
0.4.24
/// @notice Claim Deaf Gold for a given Deaf ID /// @param tokenId The tokenId of the Deaf NFT
function claimById(uint256 tokenId) external { // Follow the Checks-Effects-Interactions pattern to prevent reentrancy // attacks // Checks // Check that the msgSender owns the token that is being claimed require( _msgSender() == DeafContract.ownerOf(tokenId...
0.8.0
/// @notice Claim Deaf Gold for all tokens owned by the sender /// @notice This function will run out of gas if you have too much Deaf! If /// this is a concern, you should use claimRangeForOwner and claim Deaf /// Gold in batches.
function claimAllForOwner() external { uint256 tokenBalanceOwner = DeafContract.balanceOf(_msgSender()); // Checks require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED"); // i < tokenBalanceOwner because tokenBalanceOwner is 1-indexed for (uint256 i = 0; i < tokenBalanceOwner...
0.8.0
/// @notice Claim Deaf Gold for all tokens owned by the sender within a /// given range /// @notice This function is useful if you own too much Deaf to claim all at /// once or if you want to leave some Deaf unclaimed. If you leave Deaf /// unclaimed, however, you cannot claim it once the next season starts.
function claimRangeForOwner(uint256 ownerIndexStart, uint256 ownerIndexEnd) external { uint256 tokenBalanceOwner = DeafContract.balanceOf(_msgSender()); // Checks require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED"); // We use < for ownerIndexEnd and tokenBalanceOwner ...
0.8.0
/// @dev Internal function to mint Deaf upon claiming
function _claim(uint256 tokenId, address tokenOwner) internal { // Checks // Check that the token ID is in range // We use >= and <= to here because all of the token IDs are 0-indexed require( tokenId >= tokenIdStart && tokenId <= tokenIdEnd, "TOKEN_ID_OUT_O...
0.8.0