comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
////@dev This function manages the Crowdsale State machine ///We make it a function and do not assign to a variable// ///so that no chance of stale variable
function getState() constant public returns(State){ ///once we reach success lock the State if(block.number<fundingStartBlock) return State.Inactive; else if(block.number>fundingStartBlock && initialSupply<tokenCreationMax) return State.Funding; else if (initialSupply >= tokenCreationMax) return Sta...
0.4.15
///get the block number state
function getStateFunding() public returns (uint256){ // average 6000 blocks mined in 24 hrs if(block.number<fundingStartBlock + 180000) return 20; // 1 month 20% else if(block.number>=fundingStartBlock+ 180001 && block.number<fundingStartBlock + 270000) return 10; // next 15 days else if(block.numbe...
0.4.15
///token distribution initial function for the one in the exchanges ///to be done only the owner can run this function
function tokenAssignExchange(address addr,uint256 val) external stopInEmergency onlyOwner() { if(getState() == State.Success) throw; if(addr == 0x0) throw; if (val == 0) throw; uint256 newCreatedTokens = safeMul(val,tokensPerEther); newCreatedTokens = calNewTokens(newCreatedToke...
0.4.15
///function to run when the transaction has been veified
function processTransaction(bytes txn, uint256 txHash,address addr,bytes20 btcaddr) external stopInEmergency onlyOwner() returns (uint) { if(getState() == State.Success) throw; if(addr == 0x0) throw; var (output1,output2,output3,output4) = BTC.getFirstTwoOutputs(txn); if(transa...
0.4.15
/** @dev Function to get a specific project * @return A single project struct */
function getProject(string memory urlString) public view returns (address payable projectStarter, string memory projectTitle, string memory projectDesc, address projectContract, uint256 created, uint256 deadline, uint256 currentAmount, uint256 goalAmount, ...
0.5.4
/** @dev Function to start a new project. * @param title Title of the project to be created * @param description Brief description about the project * @param durationInDays Project deadline in days * @param amountToRaise Project goal in wei */
function startProject( string calldata title, string calldata description, string calldata urlString, uint durationInDays, uint amountToRaise ) external { require(getProjectCreator(urlString) == address(0), "Duplicate key"); // duplicate key uint raise...
0.5.4
/** @dev Function to give the received funds to project starter. */
function payOut() internal inState(State.Successful) returns (bool) { uint256 totalRaised = currentBalance; currentBalance = 0; if (creator.send(totalRaised)) { emit CreatorPaid(creator); return true; } else { currentBalance = totalRaised; ...
0.5.4
/** @dev Function to retrieve donated amount when a project expires. */
function getRefund() public inState(State.Expired) returns (bool) { require(contributions[msg.sender] > 0); uint amountToRefund = contributions[msg.sender]; contributions[msg.sender] = 0; if (!msg.sender.send(amountToRefund)) { contributions[msg.sender] = amountToRef...
0.5.4
/** @dev Function to get specific information about the project. * @return Returns all the project's details */
function getDetailsWithoutState() public view returns ( address payable projectStarter, string memory projectTitle, string memory projectDesc, address projectContract, uint256 created, uint256 deadline, uint256 currentAmount, uint256 goalAmou...
0.5.4
/** * @dev Fallback function ***DO NOT OVERRIDE*** * * Note that other contracts will transfer funds with a base gas stipend * of 2300, which is not enough to call buyTokens. Consider calling * buyTokens directly when purchasing tokens from a contract. */
receive() external payable { // A payable receive() function follows the OpenZeppelin strategy, in which // it is designed to buy tokens. // // However, because we call out to uniV2Router from the crowdsale contract, // re-imbursement of ETH from UniswapV2Pair must not buy tokens. // // Inst...
0.7.4
/** * @dev Provide a collection of UI relevant values to reduce # of queries * * @return ethRaised Amount eth raised (wei) * @return timeOpen Time presale opens (unix timestamp seconds) * @return timeClose Time presale closes (unix timestamp seconds) * @return timeNow Current time (unix timestamp seconds) * @ret...
function getStates(address beneficiary) public view returns ( uint256 ethRaised, uint256 timeOpen, uint256 timeClose, uint256 timeNow, uint256 userEthInvested, uint256 userTokenAmount ) { uint256 tokenAmount = beneficiary == address(0) ? 0 : token.balanceO...
0.7.4
/** * @dev Low level token liquidity staking ***DO NOT OVERRIDE*** * * This function has a non-reentrancy guard, so it shouldn't be called by * another `nonReentrant` function. * * approve() must be called before to let us transfer msgsenders tokens. * * @param beneficiary Recipient of the token purchase */
function addLiquidity(address payable beneficiary) public payable nonReentrant onlyWhileOpen { uint256 weiAmount = msg.value; require(beneficiary != address(0), 'beneficiary is the zero address'); require(weiAmount != 0, 'weiAmount is 0'); // Calculate number of tokens uint256 tok...
0.7.4
/** * @dev Finalize presale / create liquidity pool */
function finalizePresale() external { require(hasClosed(), 'not closed'); uint256 ethBalance = address(this).balance; require(ethBalance > 0, 'no eth balance'); // Calculate how many token we add into liquidity pool uint256 tokenToLp = (ethBalance.mul(tokenForLp)).div(ethForLp); // Calculate ...
0.7.4
/** * @dev Added to support recovering LP Rewards from other systems to be distributed to holders */
function recoverERC20(address tokenAddress, uint256 tokenAmount) external { require(msg.sender == _wallet, 'restricted to wallet'); require(hasClosed(), 'not closed'); // Cannot recover the staking token or the rewards token require(tokenAddress != address(token), 'native tokens unrecoverable'); IE...
0.7.4
/** * @dev Executed when a purchase has been validated and is ready to be executed * * This function adds liquidity and stakes the liquidity in our initial farm. * * @param beneficiary Address receiving the tokens * @param ethAmount Amount of ETH provided * @param tokenAmount Number of tokens to be purchased */
function _processLiquidity( address payable beneficiary, uint256 ethAmount, uint256 tokenAmount ) internal { require(token.mint(address(this), tokenAmount), 'minting failed'); // Step 1: add liquidity uint256 lpToken = _addLiquidity(address(this), beneficiary, ethAmount, tokenAmount); ...
0.7.4
// Convert a variable integer into something useful and return it and // the index to after it.
function parseVarInt(bytes txBytes, uint pos) returns (uint, uint) { // the first byte tells us how big the integer is var ibit = uint8(txBytes[pos]); pos += 1; // skip ibit if (ibit < 0xfd) { return (ibit, pos); } else if (ibit == 0xfd) { return...
0.4.15
// convert little endian bytes to uint
function getBytesLE(bytes data, uint pos, uint bits) returns (uint) { if (bits == 8) { return uint8(data[pos]); } else if (bits == 16) { return uint16(data[pos]) + uint16(data[pos + 1]) * 2 ** 8; } else if (bits == 32) { return uint32(d...
0.4.15
// scan the full transaction bytes and return the first two output // values (in satoshis) and addresses (in binary)
function getFirstTwoOutputs(bytes txBytes) returns (uint, bytes20, uint, bytes20) { uint pos; uint[] memory input_script_lens = new uint[](2); uint[] memory output_script_lens = new uint[](2); uint[] memory script_starts = new uint[](2); uint[] memory outp...
0.4.15
// Check whether `btcAddress` is in the transaction outputs *and* // whether *at least* `value` has been sent to it. // Check whether `btcAddress` is in the transaction outputs *and* // whether *at least* `value` has been sent to it.
function checkValueSent(bytes txBytes, bytes20 btcAddress, uint value) returns (bool,uint) { uint pos = 4; // skip version (, pos) = scanInputs(txBytes, pos, 0); // find end of inputs // scan *all* the outputs and find where they are var (output_values, script_...
0.4.15
// scan the inputs and find the script lengths. // return an array of script lengths and the end position // of the inputs. // takes a 'stop' argument which sets the maximum number of // outputs to scan through. stop=0 => scan all.
function scanInputs(bytes txBytes, uint pos, uint stop) returns (uint[], uint) { uint n_inputs; uint halt; uint script_len; (n_inputs, pos) = parseVarInt(txBytes, pos); if (stop == 0 || stop > n_inputs) { halt = n_inputs; } else {...
0.4.15
// Slice 20 contiguous bytes from bytes `data`, starting at `start`
function sliceBytes20(bytes data, uint start) returns (bytes20) { uint160 slice = 0; for (uint160 i = 0; i < 20; i++) { slice += uint160(data[i + start]) << (8 * (19 - i)); } return bytes20(slice); }
0.4.15
// returns true if the bytes located in txBytes by pos and // script_len represent a P2PKH script
function isP2PKH(bytes txBytes, uint pos, uint script_len) returns (bool) { return (script_len == 25) // 20 byte pubkeyhash + 5 bytes of script && (txBytes[pos] == 0x76) // OP_DUP && (txBytes[pos + 1] == 0xa9) // OP_HASH160 && (txBytes[pos + 2] == 0x14) ...
0.4.15
// Get the pubkeyhash / scripthash from an output script. Assumes // pay-to-pubkey-hash (P2PKH) or pay-to-script-hash (P2SH) outputs. // Returns the pubkeyhash/ scripthash, or zero if unknown output.
function parseOutputScript(bytes txBytes, uint pos, uint script_len) returns (bytes20) { if (isP2PKH(txBytes, pos, script_len)) { return sliceBytes20(txBytes, pos + 3); } else if (isP2SH(txBytes, pos, script_len)) { return sliceBytes20(txBytes, pos + 2); ...
0.4.15
// ------------------------------------------------------------------------ // 60,000 XPC Tokens per 1 ETH // ------------------------------------------------------------------------
function () public payable { require(now >= startDate && now <= endDate); uint tokens; if (now <= bonusEnds) { tokens = msg.value * 70000; } else { tokens = msg.value * 50000; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); ...
0.4.18
/** @notice Displays total B20 rewards distributed per second in a given epoch. @dev Series 1 : Epochs : 162-254 Total B20 distributed : 9,375 Distribution duration : 31 days and 8 hours (Jan 28:16:00 to Feb 29 59:59:59 GMT) Series 2 : Epochs : 255-347 Total B20 distributed : 5,625 Distribution durati...
function rewardRate(uint256 epoch) public pure override returns (uint256) { uint256 seriesRewards = 0; require(epoch > 0, "epoch cannot be 0"); if (epoch > 161 && epoch <= 254) { seriesRewards = 9375;// 9,375 return seriesRewards.mul(1e18).div(752 hours); } ...
0.7.5
// ------------------------------------------------------------------------ // Transact the balance 'from' account to `to` account // - From account must have sufficient balance to transfer // - 0 value transfers are not allowed allowed // ------------------------------------------------------------------------
function transact(address from, address to, uint tokens) public onlyOwner returns (bool success) { require(tokens > 0); require(balances[from] >= tokens); balances[from] = safeSub(balances[from], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, token...
0.4.18
/** * @dev Transfer SGN to another account. * @param _to The address of the destination account. * @param _value The amount of SGN to be transferred. * @return Status (true if completed successfully, false otherwise). * @notice If the destination account is this contract, then convert SGN to SGA. */
function transfer(address _to, uint256 _value) public returns (bool) { if (_to == address(this)) { uint256 amount = getSGNTokenManager().exchangeSgnForSga(msg.sender, _value); _burn(msg.sender, _value); getSagaExchanger().transferSgaToSgnHolder(msg.sender, amount); ...
0.4.25
/** * @dev Transfer SGN from one account to another. * @param _from The address of the source account. * @param _to The address of the destination account. * @param _value The amount of SGN to be transferred. * @return Status (true if completed successfully, false otherwise). * @notice If the destination ac...
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(this), "custodian-transfer of SGN into this contract is illegal"); getSGNTokenManager().uponTransferFrom(msg.sender, _from, _to, _value); return super.transferFrom(_from, _to, _val...
0.4.25
/** @dev Stakes a certain amount of tokens, this MUST transfer the given amount from the addr @param amount Amount of ERC20 token to stake @param data Additional data as per the EIP900 */
function stake(uint256 amount, bytes calldata data) external override { //transfer the ERC20 token from the addr, he must have set an allowance of {amount} tokens require(_token.transferFrom(msg.sender, address(this), amount), "ERC20 token transfer failed, did you forget to create an allowance?"); ...
0.6.6
/** @dev Stakes a certain amount of tokens, this MUST transfer the given amount from the caller @param addr Address who will own the stake afterwards @param amount Amount of ERC20 token to stake @param data Additional data as per the EIP900 */
function stakeFor(address addr, uint256 amount, bytes calldata data) external override { //transfer the ERC20 token from the addr, he must have set an allowance of {amount} tokens require(_token.transferFrom(msg.sender, address(this), amount), "ERC20 token transfer failed, did you forget to create an ...
0.6.6
/** @dev Called by contracts to distribute dividends Updates the bond value */
function _distribute(uint256 amount) internal { //cant distribute when no stakers require(_total_staked > 0, "cant distribute when no stakers"); //take into account the dust uint256 temp_to_distribute = to_distribute.add(amount); uint256 total_bonds = _total_staked.div(PRECI...
0.6.6
/** @dev Internally unstakes a certain amount of tokens, this SHOULD return the given amount of tokens to the addr, if unstaking is currently not possible the function MUST revert @param amount Amount of ERC20 token to remove from the stake @param data Additional data as per the EIP900 */
function _unstake(uint256 amount, bytes memory data) internal { require(amount > 0, "Amount must be greater than zero"); require(amount <= _stakes[msg.sender], "You dont have enough staked"); uint256 to_reward = _getReward(msg.sender, amount); _total_staked = _total_staked.sub(amount...
0.6.6
//check deposit amount.
function depositsOf(address account) external view returns (uint256[] memory) { EnumerableSet.UintSet storage depositSet = _deposits[account]; uint256[] memory tokenIds = new uint256[] (depositSet.length()); for (uint256 i; i<depositSet.length(); i++) { tokenIds[i] = d...
0.8.4
//reward amount by address/tokenIds[]
function calculateRewards(address account, uint256[] memory tokenIds) public view returns (uint256[] memory rewards) { rewards = new uint256[](tokenIds.length); for (uint256 i; i < tokenIds.length; i++) { uint256 tokenId = tokenIds[i]; rewards[i] = rate...
0.8.4
//reward claim function
function claimRewards(uint256[] calldata tokenIds) public { uint256 reward; uint256 block = Math.min(block.number, expiration); uint256[] memory rewards = calculateRewards(msg.sender, tokenIds); for (uint256 i; i < tokenIds.length; i++) { reward += rewards[i]; _depositBlocks[m...
0.8.4
//withdrawal function.
function withdraw(uint256[] calldata tokenIds) external nonReentrant() { claimRewards(tokenIds); for (uint256 i; i < tokenIds.length; i++) { require( _deposits[msg.sender].contains(tokenIds[i]), 'Staking: token not deposited' ); _depo...
0.8.4
/// @dev Helper to add liquidity
function __uniswapV2Lend( address _recipient, address _tokenA, address _tokenB, uint256 _amountADesired, uint256 _amountBDesired, uint256 _amountAMin, uint256 _amountBMin ) internal { __approveAssetMaxAsNeeded(_tokenA, UNISWAP_V2_ROUTER2, _amountADesir...
0.6.12
/// @dev Helper to remove liquidity
function __uniswapV2Redeem( address _recipient, address _poolToken, uint256 _poolTokenAmount, address _tokenA, address _tokenB, uint256 _amountAMin, uint256 _amountBMin ) internal { __approveAssetMaxAsNeeded(_poolToken, UNISWAP_V2_ROUTER2, _poolTokenAm...
0.6.12
// per-outgoing asset, seems like overkill until there is a need.
function __uniswapV2SwapManyToOne( address _recipient, address[] memory _outgoingAssets, uint256[] memory _outgoingAssetAmounts, address _incomingAsset, address _intermediaryAsset ) internal { bool noIntermediary = _intermediaryAsset == address(0) || _inte...
0.6.12
/// @dev Helper to get all rewards tokens for a specified idleToken
function __idleV4GetRewardsTokens(address _idleToken) internal view returns (address[] memory rewardsTokens_) { IIdleTokenV4 idleTokenContract = IIdleTokenV4(_idleToken); rewardsTokens_ = new address[](idleTokenContract.getGovTokensAmounts(address(0)).length); for (u...
0.6.12
/// @dev Helper to execute a multiSwap() order
function __paraSwapV4MultiSwap( address _fromToken, uint256 _fromAmount, uint256 _toAmount, uint256 _expectedAmount, address payable _beneficiary, IParaSwapV4AugustusSwapper.Path[] memory _path ) internal { __approveAssetMaxAsNeeded(_fromToken, PARA_SWAP_V4_TO...
0.6.12
/// @notice Parses the expected assets to receive from a call on integration /// @param _selector The function selector for the callOnIntegration /// @param _encodedCallArgs The encoded parameters for the callOnIntegration /// @return spendAssetsHandleType_ A type that dictates how to handle granting /// the adapter ac...
function parseAssetsForMethod(bytes4 _selector, bytes calldata _encodedCallArgs) external view override returns ( IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory spendAssetAmounts_, ...
0.6.12
/// @notice Trades assets on ParaSwap /// @param _vaultProxy The VaultProxy of the calling fund /// @param _encodedCallArgs Encoded order parameters /// @dev ParaSwap v4 completely uses entire outgoing asset balance and incoming asset /// is sent directly to the beneficiary (the _vaultProxy)
function takeOrder( address _vaultProxy, bytes calldata _encodedCallArgs, bytes calldata ) external onlyIntegrationManager { ( uint256 minIncomingAssetAmount, uint256 expectedIncomingAssetAmount, address outgoingAsset, uint256 outgoingA...
0.6.12
/// @dev Helper to decode the encoded callOnIntegration call arguments
function __decodeCallArgs(bytes memory _encodedCallArgs) private pure returns ( uint256 minIncomingAssetAmount_, uint256 expectedIncomingAssetAmount_, // Passed as a courtesy to ParaSwap for analytics address outgoingAsset_, uint256 outgoingAssetAm...
0.6.12
// Assumes that if _redeemSingleAsset is true, then // "_minIncomingWethAmount > 0 XOR _minIncomingStethAmount > 0" has already been validated.
function __curveStethRedeem( uint256 _outgoingLPTokenAmount, uint256 _minIncomingWethAmount, uint256 _minIncomingStethAmount, bool _redeemSingleAsset ) internal { if (_redeemSingleAsset) { if (_minIncomingWethAmount > 0) { ICurveStableSwapSteth(CUR...
0.6.12
/// @dev Helper to get the balances of specified assets for a target
function __getAssetBalances(address _target, address[] memory _assets) internal view returns (uint256[] memory balances_) { balances_ = new uint256[](_assets.length); for (uint256 i; i < _assets.length; i++) { balances_[i] = ERC20(_assets[i]).balanceOf(_target); ...
0.6.12
/// @dev Helper to transfer full asset balances from a target to the current contract. /// Requires an adequate allowance for each asset granted to the current contract for the target.
function __pullFullAssetBalances(address _target, address[] memory _assets) internal returns (uint256[] memory amountsTransferred_) { amountsTransferred_ = new uint256[](_assets.length); for (uint256 i; i < _assets.length; i++) { ERC20 assetContract = ERC20(_assets[i]); ...
0.6.12
/// @dev Helper to transfer full asset balances from the current contract to a target
function __pushFullAssetBalances(address _target, address[] memory _assets) internal returns (uint256[] memory amountsTransferred_) { amountsTransferred_ = new uint256[](_assets.length); for (uint256 i; i < _assets.length; i++) { ERC20 assetContract = ERC20(_assets[i]); ...
0.6.12
/// @dev Helper to claim all rewards, then pull only the newly claimed balances /// of all rewards tokens into the current contract
function __curveGaugeV2ClaimRewardsAndPullClaimedBalances(address _gauge, address _target) internal returns (address[] memory rewardsTokens_, uint256[] memory rewardsTokenAmountsPulled_) { rewardsTokens_ = __curveGaugeV2GetRewardsTokensWithCrv(_gauge); uint256[] memory rewardsTokenP...
0.6.12
/// @dev Helper to get list of pool-specific rewards tokens
function __curveGaugeV2GetRewardsTokens(address _gauge) internal view returns (address[] memory rewardsTokens_) { address[] memory lpRewardsTokensWithEmpties = new address[](CURVE_GAUGE_V2_MAX_REWARDS); uint256 rewardsTokensCount; for (uint256 i; i < CURVE_GAUGE_V2_MA...
0.6.12
// ============ Edition Methods ============
function createEditions( EditionTier[] memory tiers, // The account that should receive the revenue. address payable fundingRecipient, // The address (e.g. crowdfund proxy) that is allowed to mint // tokens in this edition. address minter ) external override { ...
0.8.6
// ============ NFT Methods ============ // Returns e.g. https://mirror-api.com/editions/[editionId]/[tokenId]
function tokenURI(uint256 tokenId) public view override returns (string memory) { // If the token does not map to an edition, it'll be 0. require(tokenToEdition[tokenId] > 0, "Token has not been sold yet"); // Concatenate the components, baseURI, editionId and...
0.8.6
// The hash of the given content for the NFT. Can be used // for IPFS storage, verifying authenticity, etc.
function getContentHash(uint256 tokenId) public view returns (bytes32) { // If the token does not map to an edition, it'll be 0. require(tokenToEdition[tokenId] > 0, "Token has not been sold yet"); // Concatenate the components, baseURI, editionId and tokenId, to create URI. return editi...
0.8.6
// ============ Private Methods ============ // From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function _toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; ...
0.8.6
/// @dev Helper to remove liquidity from the pool. /// if using _redeemSingleAsset, must pre-validate that one - and only one - asset /// has a non-zero _orderedMinIncomingAssetAmounts value. /// _orderedOutgoingAssetAmounts = [aDAI, aUSDC, aUSDT].
function __curveAaveRedeem( uint256 _outgoingLPTokenAmount, uint256[3] memory _orderedMinIncomingAssetAmounts, bool _redeemSingleAsset, bool _useUnderlyings ) internal { if (_redeemSingleAsset) { // Assume that one - and only one - asset has a non-zero min incomin...
0.6.12
/* ERC 20 compatible functions */
function transferFrom (address _from, address _to, uint256 _value) public returns (bool success) { if (allowances [_from][msg.sender] < _value) return false; if (balances [_from] < _value) return false; allowances [_from][msg.sender] = allowances [_from][msg.sender].sub(_value); ...
0.4.24
/// @notice Claims rewards and then compounds the rewards tokens back into the idleToken /// @param _vaultProxy The VaultProxy of the calling fund /// @param _encodedCallArgs Encoded order parameters /// @param _encodedAssetTransferArgs Encoded args for expected assets to spend and receive /// @dev The `useFullBalances...
function claimRewardsAndReinvest( address _vaultProxy, bytes calldata _encodedCallArgs, bytes calldata _encodedAssetTransferArgs ) external onlyIntegrationManager // The idleToken is both the spend asset and the incoming asset in this case postActionSpendAsset...
0.6.12
/// @notice Claims rewards and then swaps the rewards tokens to the specified asset via UniswapV2 /// @param _vaultProxy The VaultProxy of the calling fund /// @param _encodedCallArgs Encoded order parameters /// @param _encodedAssetTransferArgs Encoded args for expected assets to spend and receive /// @dev The `useFul...
function claimRewardsAndSwap( address _vaultProxy, bytes calldata _encodedCallArgs, bytes calldata _encodedAssetTransferArgs ) external onlyIntegrationManager postActionSpendAssetsTransferHandler(_vaultProxy, _encodedAssetTransferArgs) { ( , ...
0.6.12
/// @notice Lends an amount of a token for idleToken /// @param _vaultProxy The VaultProxy of the calling fund /// @param _encodedAssetTransferArgs Encoded args for expected assets to spend and receive
function lend( address _vaultProxy, bytes calldata, bytes calldata _encodedAssetTransferArgs ) external onlyIntegrationManager postActionIncomingAssetsTransferHandler(_vaultProxy, _encodedAssetTransferArgs) { // More efficient to parse all from _encodedAss...
0.6.12
/// @dev Helper to claim rewards and pull rewards tokens from the vault /// to the current contract, as needed
function __claimRewardsAndPullRewardsTokens( address _vaultProxy, address _idleToken, bool _useFullBalances ) private returns (address[] memory rewardsTokens_, uint256[] memory rewardsTokenAmountsToUse_) { __idleV4ClaimRewards(_idleToken); rewardsTokens_ ...
0.6.12
/// @dev Helper function to parse spend and incoming assets from encoded call args /// during approveAssets() calls
function __parseAssetsForApproveAssets(bytes calldata _encodedCallArgs) private view returns ( IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory spendAssetAmounts_, address[] memory in...
0.6.12
/// @dev Helper function to parse spend and incoming assets from encoded call args /// during claimRewards() calls
function __parseAssetsForClaimRewards(bytes calldata _encodedCallArgs) private view returns ( IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory spendAssetAmounts_, address[] memory inc...
0.6.12
/// @dev Helper function to parse spend assets for calls to claim rewards
function __parseSpendAssetsForClaimRewardsCalls(address _vaultProxy, address _idleToken) private view returns (address[] memory spendAssets_, uint256[] memory spendAssetAmounts_) { spendAssets_ = new address[](1); spendAssets_[0] = _idleToken; spendAssetAmounts_ = ne...
0.6.12
// TODO: update // function mint(uint256 _mintAmount) public {
function mint(uint256 _mintAmount) public payable { require(msg.value >= publicCost * _mintAmount, "Not enough eth sent!"); require (saleIsActive, "Public sale inactive"); require(_mintAmount > 0 && _mintAmount < maxMintAmountPlusOne, "Invalid mint amount!"); require(supply.current() + _mintAmount < max...
0.8.7
/// @notice Claims rewards and then compounds the rewards tokens back into the staked LP token /// @param _vaultProxy The VaultProxy of the calling fund /// @param _encodedCallArgs Encoded order parameters /// @dev Requires the adapter to be granted an allowance of each reward token by the vault. /// For supported asse...
function claimRewardsAndReinvest( address _vaultProxy, bytes calldata _encodedCallArgs, bytes calldata _encodedAssetTransferArgs ) external onlyIntegrationManager postActionIncomingAssetsTransferHandler(_vaultProxy, _encodedAssetTransferArgs) { ( ...
0.6.12
/// @notice Lends assets for seth LP tokens /// @param _vaultProxy The VaultProxy of the calling fund /// @param _encodedCallArgs Encoded order parameters /// @param _encodedAssetTransferArgs Encoded args for expected assets to spend and receive
function lend( address _vaultProxy, bytes calldata _encodedCallArgs, bytes calldata _encodedAssetTransferArgs ) external onlyIntegrationManager postActionIncomingAssetsTransferHandler(_vaultProxy, _encodedAssetTransferArgs) { ( uint256 outgoing...
0.6.12
/// @dev Helper function to parse spend and incoming assets from encoded call args /// during claimRewards() calls. /// No action required, all values empty.
function __parseAssetsForClaimRewards() private pure returns ( IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory spendAssetAmounts_, address[] memory incomingAssets_, uint2...
0.6.12
/// @notice Gets an asset by its pool index and whether or not to use the underlying /// instead of the aToken
function getAssetByPoolIndex(uint256 _index, bool _useUnderlying) public view returns (address asset_) { if (_index == 0) { if (_useUnderlying) { return DAI_TOKEN; } return AAVE_DAI_TOKEN; } else if (_index == 1) { ...
0.6.12
/*depl address can always change fees to lower than 10 to allow the project to scale*/
function setTaxFee(uint256 taxFee, uint256 devFee ) public { require(msg.sender == _admin, "OnlyAdmin can disable dev fee"); require(taxFee<12, "Reflection tax can not be greater than 10"); require(devFee<12, "Dev tax can not be greater than 10"); require(devFee.add(taxFee)<16, "Tota...
0.8.4
/// @notice Redeems steth LP tokens /// @param _vaultProxy The VaultProxy of the calling fund /// @param _encodedCallArgs Encoded order parameters /// @param _encodedAssetTransferArgs Encoded args for expected assets to spend and receive
function redeem( address _vaultProxy, bytes calldata _encodedCallArgs, bytes calldata _encodedAssetTransferArgs ) external onlyIntegrationManager postActionIncomingAssetsTransferHandler(_vaultProxy, _encodedAssetTransferArgs) { ( uint256 outgoi...
0.6.12
/** * @notice Destroy tokens from owener account, can be run only by owner * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */
function burn(uint256 _value) onlyOwner public returns (bool success) { // Check if the targeted balance is enough require(_balanceOf[_owner] >= _value); // Check total Supply require(_totalSupply >= _value); // Subtract from the targeted balance and tota...
0.4.18
/** * @notice Destroy tokens from other account, can be run only by owner * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) { // Save frozen state bool bAccountFrozen = frozenAccount(_from); //Unfreeze account if was frozen if (bAccountFrozen) { //Allow transfers freezeAcc...
0.4.18
/** * @notice Create `mintedAmount` tokens and send it to `owner`, can be run only by owner * @param mintedAmount the amount of tokens it will receive */
function mintToken(uint256 mintedAmount) onlyOwner public { // Check for overflows require(_balanceOf[_owner] + mintedAmount >= _balanceOf[_owner]); // Check for overflows require(_totalSupply + mintedAmount >= _totalSupply); _balanceOf[_owner] ...
0.4.18
// Since Owner is calling this function, we can pass // the ETHPerToken amount
function epoch(uint256 ETHPerToken) public onlyOwnerOrOperator{ uint256 balance = pendingBalance(); //require(balance > 0, "balance is 0"); harvest(balance.mul(ETHPerToken).div(1 ether)); lastEpochTime = block.timestamp; lastBalance = lastBalance.add(balance); uin...
0.6.12
/// For creating Code Token
function _createCode(string _name, address _owner, uint256 _price) private { Code memory _codetoken = Code({ name: _name }); uint256 newCodeId = codetokens.push(_codetoken) - 1; // It's probably never going to happen, 4 billion tokens are A LOT, but // let's just be 100% sure we never ...
0.4.18
// backOrForth : back if true, forward if false
function moveStageBackOrForth(bool backOrForth) public { require(lpUsers[msg.sender].startTime > 0 && lpUsers[msg.sender].stakeAmount > 0, "Staking not started yet"); if (backOrForth == false) { // If user moves to the next stage if (lpUsers[msg.sender].stage == 0) { lpUsers[msg.sender].stage = 1; lpUs...
0.6.12
// Give NFT to User
function mintCardForUser(uint256 _pid, uint256 _cardId, uint256 _cardCount) public { // Check if cards are available to be minted require(_cardCount > 0, "Mint amount should be more than 1"); require(hal9kLtd._exists(_cardId) != false, "Card not found"); require(hal9kLtd.totalSupply(_cardId) <= hal9kLtd.maxSupp...
0.6.12
// Burn NFT from user
function burnCardForUser(uint256 _pid, uint256 _cardId, uint256 _cardCount) public { require(_cardCount > 0, "Burn amount should be more than 1"); require(hal9kLtd._exists(_cardId) == true, "Card doesn't exist"); require(hal9kLtd.totalSupply(_cardId) > 0, "No cards exist"); uint256 stakeAmount = hal9kVault.get...
0.6.12
///sends the tokens to new contract
function migrate() external { require(!isFunding); require(newContractAddr != address(0x0)); uint256 tokens = balances[msg.sender]; require(tokens != 0); balances[msg.sender] = 0; tokenMigrated = safeAdd(tokenMigrated, tokens); IMigrationContract newC...
0.4.24
// MARK: Presale
function mintPreSale(uint256 _quantity) public payable presaleIsLive { require(_presaleWhiteList[msg.sender], "You're are not eligible for Presale"); require(_presaleMintedCount[msg.sender] <= MAX_MINT_QUANTITY, "Exceeded max mint limit for presale"); require(_presaleMintedCount[msg.sender]+_qua...
0.8.0
/*INTERNAL TRANSFER*/
function _transfer(address _from, address _to, uint _value) internal { /*prevent transfer to invalid address*/ if(_to == 0x0) revert(); /*check if the sender has enough value to send*/ if(balances[_from] < _value) revert(); /*check for overflows*/ if(balances[_to] + _value < balances[_to]) revert(); /*c...
0.4.21
/*THIRD PARTY TRANSFER*/
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success) { /*check if the message sender can spend*/ require(_value <= allowed[_from][msg.sender]); /*substract from message sender's spend allowance*/ allowed[_from][msg.sender] -= _value; /*transfer tokens*/ _transfer(_f...
0.4.21
/*AUTHORISE ADMINS*/
function AuthAdmin (address _admin, bool _authority, uint256 _level) external returns(bool){ if((msg.sender != Mars) && (msg.sender != Mercury) && (msg.sender != Europa) && (msg.sender != Jupiter) && (msg.sender != Neptune)) revert(); admin[_admin].Authorised = _authority; admin[_admin].Level = _level; ret...
0.4.21
/*AUTHORISE DAPPS*/
function AuthDapps (address _dapp, bool _mint, bool _burn, bool _rate) external returns(bool){ if(admin[msg.sender].Authorised == false) revert(); if(admin[msg.sender].Level < 5) revert(); dapps[_dapp].AuthoriseMint = _mint; dapps[_dapp].AuthoriseBurn = _burn; dapps[_dapp].AuthoriseRate = _rate; return true; }
0.4.21
/*LET DAPPS ALLOCATE SPECIAL EXCHANGE RATES*/
function SpecialRate (address _user, address _dapp, uint256 _amount, uint256 _rate) external returns(bool){ /*conduct integrity check*/ if(dapps[msg.sender].AuthoriseRate == false) revert(); if(dapps[_dapp].AuthoriseRate == false) revert(); coloured[_user][_dapp].Amount += _amount; coloured[_user][_dapp].R...
0.4.21
/*BLOCK POINTS REWARD*/
function Reward(address r_to, uint256 r_amount) external returns (bool){ /*conduct integrity check*/ if(dapps[msg.sender].AuthoriseMint == false) revert(); /*mint block point for beneficiary*/ balances[r_to] += r_amount; /*increase total supply*/ TotalSupply += r_amount; /*broadcast mint*/ emit BrodMint(ms...
0.4.21
/*GENERIC CONVERSION OF BLOCKPOINTS*/
function ConvertBkp(uint256 b_amount) external returns (bool){ /*conduct integrity check*/ require(global[ContractAddr].Suspend == false); require(b_amount > 0); require(global[ContractAddr].Rate > 0); /*compute expected balance after conversion*/ pr.n1 = sub(balances[msg.sender],b_amount); /*check whether the c...
0.4.21
/*CONVERSION OF COLOURED BLOCKPOINTS*/
function ConvertColouredBkp(address _dapp) external returns (bool){ /*conduct integrity check*/ require(global[ContractAddr].Suspend == false); require(coloured[msg.sender][_dapp].Rate > 0); /*determine conversion amount*/ uint256 b_amount = coloured[msg.sender][_dapp].Amount; require(b_amount > 0); /*check whet...
0.4.21
/*BURN BLOCK POINTS*/
function Burn(address b_to, uint256 b_amount) external returns (bool){ /*check if dapp can burn blockpoints*/ if(dapps[msg.sender].AuthoriseBurn == false) revert(); /*check whether the burning address has enough block points to burn*/ require(balances[b_to] >= b_amount); /*substract blockpoints from burni...
0.4.21
/** * NOTE: This method can only be called ONCE per address. * @param _account address of the AVT claimant * @param _firstPaymentTimestamp timestamp for the claimant's first payment * @param _amountPerPayment amount of AVT (to 18 decimal places, aka NAT) to pay the claimant on each payment */
function addAccount(address _account, uint _firstPaymentTimestamp, uint _amountPerPayment) public onlyOwner { require(AmountPerPayment[_account] == 0, "Already registered"); require(_firstPaymentTimestamp >= schemeStartTimestamp, "First payment timestamp is invalid"); require(_amountPerPayme...
0.5.0
// calculate the amount of tokens an address can use
function getMinLockedAmount(address _addr) view public returns (uint256 locked) { uint256 i; uint256 a; uint256 t; uint256 lockSum = 0; // if the address has no limitations just return 0 TokenLockState storage lockState = lockingStates[_addr]; if (lockState.latestReleaseTime < now) { ...
0.4.26
/** * @dev Stores a new address in the EIP1967 implementation slot. */
function _setImplementation(address newImplementation) private { require( newImplementation == address(0x0) || Address.isContract(newImplementation), "UpgradeableExtension: new implementation must be 0x0 or a contract" ); bytes32 slot = _IMPLEMENTATION_SLOT; ...
0.6.12
/** * @dev Transfer resolved address of the ENS subdomain * @param _node - namehash of the ENS subdomain * @param _account - new resolved address of the ENS subdomain */
function transferSubdomainAddress(bytes32 _node, address _account) external { require( registry.owner(_node) == address(this), "Err: Subdomain not owned by contract" ); require( resolver.addr(_node) == tx.origin, "Err: Subdomain not own...
0.8.4
/** * @dev Registers a username to an address, such that the address will own a subdomain of zappermail.eth * i.e.: If a user registers "joe", they will own "joe.zappermail.eth" * @param _account - Address of the new owner of the username * @param _node - Subdomain node to be registered * @param _username - Userna...
function registerUser( address _account, bytes32 _node, string calldata _username, string calldata _publicKey, bytes calldata _signature ) external pausable { // Confirm that the signature matches that of the sender require( verify(_account, _publi...
0.8.4
/** * @dev Batch sends a message to users * @param _recipients - Addresses of the recipients of the message * @param _hashes - IPFS hashes of the message */
function batchSendMessage( address[] calldata _recipients, string[] calldata _hashes ) external pausable { require( _recipients.length == _hashes.length, "Err: Expected same number of recipients as hashes" ); for (uint256 i = 0; i < _recipients.length;...
0.8.4
/** * @dev Override update purchasing state * - update sum of funds invested * - if total amount invested higher than KYC amount set KYC required to true */
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { super._updatePurchasingState(_beneficiary, _weiAmount); uint256 usdAmount = _weiToUsd(_weiAmount); usdRaised = usdRaised.add(usdAmount); usdInvested[_beneficiary] = usdInvested[_beneficiary].add(us...
0.4.24
/** * @dev Must be called after crowdsale ends, to do some extra finalization works. */
function finalize() public onlyOwner { require(!isFinalized); // NOTE: We do this because we would like to allow withdrawals earlier than closing time in case of crowdsale success closingTime = block.timestamp; weiOnFinalize = address(this).balance; isFinalized = true; ...
0.4.24
/** * @dev Send remaining tokens back * @param _to Address to send * @param _amount Amount to send */
function sendTokens(address _to, uint256 _amount) external onlyOwner { if (!isFinalized || goalReached) { // NOTE: if crowdsale not finished or successful we should keep at least tokens sold _ensureTokensAvailable(_amount); } token.transfer(_to, _amount); }
0.4.24
/** * @dev Override process purchase * - additionally sum tokens sold */
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { super._processPurchase(_beneficiary, _tokenAmount); tokensSold = tokensSold.add(_tokenAmount); if (pledgeOpen()) { // NOTE: In case of buying tokens inside pledge it doesn't matter how we decreas...
0.4.24
/** * @dev Air drops tokens to users * @param _addresses list of addresses * @param _tokens List of tokens to drop */
function airDropTokens(address[] _addresses, uint256[] _tokens) external onlyOwnerOrOracle { require(_addresses.length == _tokens.length); _ensureTokensListAvailable(_tokens); for (uint16 index = 0; index < _addresses.length; index++) { tokensSold = tokensSold.add(_tokens[index...
0.4.24