comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
/** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * */
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address disallowed"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); ...
0.6.12
/// @dev get expected return and conversion rate
function getExpectedReturn(GetExpectedReturnParams calldata params) external view override onlyProxyContract returns (uint256 destAmount) { require(params.tradePath.length == 2, "kyber_invalidTradepath"); uint256 expectedRate = kyberProxy.getExpectedRateAfterF...
0.7.6
/// @dev swap token /// @notice for some tokens that are paying fee, for example: DGX /// contract will trade with received src token amount (after minus fee) /// for UniSwap, fee will be taken in src token
function swap(SwapParams calldata params) external payable override onlyProxyContract returns (uint256 destAmount) { require(params.tradePath.length == 2, "kyber_invalidTradepath"); safeApproveAllowance(address(kyberProxy), IERC20Ext(params.tradePath[0])); ...
0.7.6
// A function to get key info for investors.
function getInfo() public view returns(uint Deposit, uint Withdrawn, uint AmountToWithdraw) { // 1) Amount of invested money; Deposit = deposit[msg.sender]; // 2) Amount of withdrawn money; Withdrawn = withdrawn[msg.sender]; // 3) Amount of money which is available to withdr...
0.4.24
// A function to get available dividends of an investor.
function withdraw() public { // Amount of money which is available to withdraw. // Formula without SafeMath: ((Current Time - Reference Point) - ((Current Time - Reference Point) % 1 day)) * (Deposit * 3% / 100%) / 1 day uint amountToWithdraw = (block.timestamp.sub(lastTimeWithdraw[msg.sender...
0.4.24
/** * @dev converts all incoming ethereum to keys. * -functionhash- 0x8f38f309 (using ID for affiliate) * -functionhash- 0x98a0871d (using address for affiliate) * -functionhash- 0xa65b37a1 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee */
function buyXid(uint256 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); /...
0.4.24
/** * setAdmin(admin) * * Change the admin of this contract. This should be used shortly after * deployment and live testing to switch to a multi-sig contract. */
function setAdmin(address admin) { if (msg.sender != _admin) { throw; } adminChanged(_admin, admin); _admin = admin; // Give the admin access to the reverse entry ReverseRegistrar(_ens.owner(RR_NODE)).claim(admin); // Point the resolved addr to the new admin ...
0.4.10
/** * config() * * Get the configuration of this registrar. */
function config() constant returns (address ens, bytes32 nodeHash, address admin, uint256 fee, address defaultResolver) { ens = _ens; nodeHash = _nodeHash; admin = _admin; fee = _fee; defaultResolver = _defaultResolver; }
0.4.10
/** * @notice buy Land with SAND using the merkle proof associated with it * @param buyer address that perform the payment * @param to address that will own the purchased Land * @param reserved the reserved address (if any) * @param x x coordinate of the Land * @param y y coordinate of the Land * @param size siz...
function buyLandWithSand( address buyer, address to, address reserved, uint256 x, uint256 y, uint256 size, uint256 priceInSand, bytes32 salt, bytes32[] calldata proof ) external { require(_sandEnabled, "sand payments not enabled"); ...
0.5.9
/** This function detects whether a transfer should be restricted and not allowed. If the function returns SUCCESS_CODE (0) then it should be allowed. */
function detectTransferRestriction (address from, address to, uint256) public view returns (uint8) { // If the restrictions have been disabled by the owner, then just return success // Logic defined in Restrictable parent class if(!isRestrictionE...
0.5.0
/** This function allows a wallet or other client to get a human readable string to show a user if a transfer was restricted. It should return enough information for the user to know why it failed. */
function messageForTransferRestriction (uint8 restrictionCode) public view returns (string memory) { if (restrictionCode == SUCCESS_CODE) { return SUCCESS_MESSAGE; } if (restrictionCode == FAILURE_NON_WHITELIST) { return FAILURE_NON_...
0.5.0
// for mint to skakeholders from staking contract
function mint(address to, uint256 amount) external onlyAllowed { require(mintAble, "Mint disabled!"); if (totalSupply() + amount > 91250000 * 10 ** 18){ _mint(to, 91250000 * 10 ** 18 - (totalSupply())); mintAble = false; } else { _mint(to, amount); } }
0.8.4
/** @notice Zap out in to a single token with permit @param fromVault Vault from which to remove liquidity @param amountIn Quantity of vault tokens to remove @param toToken Address of desired token @param isAaveUnderlying True if vault contains aave token @param minToTokens Minimum quantity of tokens to receive, ...
function ZapOutWithPermit( address fromVault, uint256 amountIn, address toToken, bool isAaveUnderlying, uint256 minToTokens, bytes calldata permitSig, address swapTarget, bytes calldata swapData, address affiliate, bool shouldSellEntireBala...
0.8.4
/** @notice Utility function to determine the quantity of underlying tokens removed from vault @param fromVault Yearn vault from which to remove liquidity @param liquidity Quantity of vault tokens to remove @return Quantity of underlying LP or token removed */
function removeLiquidityReturn(address fromVault, uint256 liquidity) external view returns (uint256) { IYVault vault = IYVault(fromVault); address[] memory V1Vaults = V1Registry.getVaults(); for (uint256 i = 0; i < V1Registry.getVaultsLength(); i++) { if...
0.8.4
/** @notice Submit a request for a cross chain interaction @param _to The target to interact with on `_toChainID` @param _data The calldata supplied for the interaction with `_to` @param _fallback The address to call back on the originating chain if the cross chain interaction fails @param _toChainID The ta...
function anyCall( address _to, bytes calldata _data, address _fallback, uint256 _toChainID ) external { require(!blacklist[msg.sender]); // dev: caller is blacklisted require(whitelist[msg.sender][_to][_toChainID]); // dev: request denied emit LogAny...
0.8.7
/** @notice Execute a cross chain interaction @dev Only callable by the MPC @param _from The request originator @param _to The cross chain interaction target @param _data The calldata supplied for interacting with target @param _fallback The address to call on `_fromChainID` if the interaction fails @para...
function anyExec( address _from, address _to, bytes calldata _data, address _fallback, uint256 _fromChainID ) external charge(_from) onlyMPC { context = Context({sender: _from, fromChainID: _fromChainID}); (bool success, bytes memory result) = _to.call...
0.8.7
/** * public mint nfts (no signature required) */
function mintNFT(uint256 numberOfNfts) public payable nonReentrant { require(!salePaused && enablePublicSale, "Sale paused or public sale disabled"); require(block.timestamp > SALE_START_TIMESTAMP, "Sale has not started"); require(block.timestamp < SALE_END_TIMESTAMP, "Sale has ended"); ...
0.8.10
/** * mint nfts (signature required) */
function allowlistMintNFT(uint256 numberOfNfts, bytes memory signature) public payable nonReentrant { require(!salePaused, "Sale Paused"); require(isAllowlisted(msg.sender, signature), "Address not allowlisted"); uint256 allowance = allowancePerWallet; // ambassador minting ...
0.8.10
/// @notice Function to create assetpack /// @param _packCover is cover image for asset pack /// @param _attributes is array of attributes /// @param _ipfsHashes is array containing all ipfsHashes for assets we'd like to put in pack /// @param _packPrice is price for total assetPack (every asset will have average price...
function createAssetPack( bytes32 _packCover, uint[] _attributes, bytes32[] _ipfsHashes, uint _packPrice, string _ipfsHash) public { require(_ipfsHashes.length > 0); require(_ipfsHashes.length < 50); require(_attributes.length == _ipfs...
0.4.24
/// @notice Function which creates an asset /// @param _attributes is meta info for asset /// @param _ipfsHash is ipfsHash to image of asset
function createAsset(uint _attributes, bytes32 _ipfsHash, uint _packId) internal returns(uint) { uint id = numberOfAssets; require(isAttributesValid(_attributes), "Attributes are not valid."); assets.push(Asset({ id : id, packId: _packId, attributes:...
0.4.24
/// @notice Method to buy right to use specific asset pack /// @param _to is address of user who will get right on that asset pack /// @param _assetPackId is id of asset pack user is buying
function buyAssetPack(address _to, uint _assetPackId) public payable { require(!checkHasPermissionForPack(_to, _assetPackId)); AssetPack memory assetPack = assetPacks[_assetPackId]; require(msg.value >= assetPack.price); // if someone wants to pay more money for asset pack, we will...
0.4.24
/// @notice method that gets all unique packs from array of assets
function pickUniquePacks(uint[] assetIds) public view returns (uint[]) { require(assetIds.length > 0); uint[] memory packs = new uint[](assetIds.length); uint packsCount = 0; for (uint i = 0; i < assetIds.length; i++) { Asset memory asset = assets[assetIds[i]...
0.4.24
/// @notice Function to get array of ipfsHashes for specific assets /// @dev need for data parsing on frontend efficiently /// @param _ids is array of ids /// @return bytes32 array of hashes
function getIpfsForAssets(uint[] _ids) public view returns (bytes32[]) { bytes32[] memory hashes = new bytes32[](_ids.length); for (uint i = 0; i < _ids.length; i++) { Asset memory asset = assets[_ids[i]]; hashes[i] = asset.ipfsHash; } return hashes; ...
0.4.24
/// @notice method that returns attributes for many assets
function getAttributesForAssets(uint[] _ids) public view returns(uint[]) { uint[] memory attributes = new uint[](_ids.length); for (uint i = 0; i < _ids.length; i++) { Asset memory asset = assets[_ids[i]]; attributes[i] = asset.attributes; } return...
0.4.24
/// @notice Function to get ipfs hash and id for all assets in one asset pack /// @param _assetPackId is id of asset pack /// @return two arrays with data
function getAssetPackData(uint _assetPackId) public view returns(bytes32, address, uint, uint[], uint[], bytes32[], string, string, bytes32) { require(_assetPackId < numberOfAssetPacks); AssetPack memory assetPack = assetPacks[_assetPackId]; bytes32[] memory hashes = new bytes32[](ass...
0.4.24
/// @notice Function to get cover image for every assetpack /// @param _packIds is array of asset pack ids /// @return bytes32[] array of hashes
function getCoversForPacks(uint[] _packIds) public view returns (bytes32[]) { require(_packIds.length > 0); bytes32[] memory covers = new bytes32[](_packIds.length); for (uint i = 0; i < _packIds.length; i++) { AssetPack memory assetPack = assetPacks[_packIds[i]]; co...
0.4.24
/** * admin minting for reserved nfts (callable by Owner only) */
function giftNFT(uint256[] calldata quantity, address[] calldata recipient) external onlyOwner { require(quantity.length == recipient.length, "Invalid quantities and recipients (length mismatch)"); uint256 totalQuantity = 0; uint256 s = _owners.length; for (uint256 i = 0; i < quantit...
0.8.10
/** * @dev Moves tokens `_value` from `_from` to `_to`. * * Requirements: * * - `lockedStatus` cannot be the 1. * - `_to` cannot be the zero address. * - Unlocked Amount of `_from` must bigger than `_value`. */
function _transfer( address _from, address _to, uint256 _value ) internal { require(lockedStatus != 1); require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); require(getUnlockedAmount(_...
0.4.24
/** @dev Lockup `amount` of the token from `account` * * Requirements: * * - Balance of `account` has to be bigger than `amount`. */
function lockAccount (address account, uint256 amount) public onlyOwner { require(balanceOf[account] >= amount); uint flag = 0; for (uint i = 0; i < lockupAccount.length; i++) { if (lockupAccount[i].account == account) { lockupAccount[i].amount = amount; flag = flag +...
0.4.24
/** @dev Return amount of locked tokens from `account` * */
function getLockedAmount(address account) public view returns (uint256) { uint256 res = 0; for (uint i = 0; i < lockupAccount.length; i++) { if (lockupAccount[i].account == account) { res = lockupAccount[i].amount; break; } } return res; }
0.4.24
// dev team mint
function devMint(uint256 _mintAmount) public onlyEOA onlyOwner { require(!paused); // contract is not paused uint256 supply = totalSupply(); // get current mintedAmount require( supply + _mintAmount <= maxSupply, "SHOGUN: total mint amount exceeded supply, try lowering amount" ); for (ui...
0.8.0
/** * @dev External function to purchase tokens. * @param _amount Token amount to buy */
function purchase(uint256 _amount) external payable { require(price > 0, "BattleRoyale: Token price is zero"); require( battleState == BATTLE_STATE.STANDBY, "BattleRoyale: Current battle state is not ready to purchase tokens" ); require( maxSupply > 0 && totalSupply < maxSupply, ...
0.8.6
/** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */
function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "BattleRoyale: Battle is not started"); battleState = BATTLE_STATE.ENDED; uint256 tokenId = totalSupply + 1; address winnerAddress = ownerOf(_winnerTokenId); _safeMint(winnerAddress, tokenI...
0.8.6
/// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of ...
function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length ==...
0.8.7
/// @notice Transfers NFT from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the...
function safeTransferNFTFrom( address token, address from, address to, uint256 tokenId ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC721.transferFrom.selector, from, to, tokenId)); require(success && (data.l...
0.8.7
/** * @dev Calls multiple functions on the contract deployed in `target` address. Only callable by owner of BatchRelayer. * @param target the destination contract. * @param data encoded method calls with arguments. * @return results of the method calls. */
function relay(address target, bytes[] calldata data) external onlyOwner() returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionCall(target, data[i]); } return results; }
0.8.9
/** * Mint CMoons */
function mintCMoons(uint256 numberOfTokens) public payable { require(saleIsActive, "Sorry, but the minting is not available now."); require( numberOfTokens <= MAX_PURCHASE, "Sorry, but you can only mint 5 tokens total." ); require( totalSupply()...
0.8.0
/** * registe a pool */
function addPool(address poolAddr, address rewardToken) external { require(msg.sender == _governance || msg.sender == factoryAddress, "not governance or factory"); require( _pools[poolAddr] == address(0), "derp, that pool already been registered"); _pools[poolAddr] = rewardToken; ...
0.5.16
/** * @dev set refer reward rate */
function setReferRewardRate(address poolAddr, uint256 refer1Rate, uint256 refer2Rate ) public { require(msg.sender == _governance || msg.sender == _poolOwner[poolAddr], "not governance or owner"); require(_pools[poolAddr] != address(0),"invalid pool address!"); _refer1RewardRate[pool...
0.5.16
/** * @notice Transfer tokens from one address to another or sell them if _to is this contract or zero address * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if( (_to == address(this)) || (_to == 0) ){ var _allowance = allowed[_from][msg.sender]; require (_value <= _allowance); allowed[_from][msg.sender] = _allowance.sub(_value); ...
0.4.18
/** * @dev Fuction called when somebody is buying tokens * @param who The address of buyer (who will own bought tokens) * @param amount The amount to be transferred. */
function buy(address who, uint256 amount) canBuyAndSell internal returns(bool){ require(amount >= minBuyAmount); currentPeriodEtherCollected = currentPeriodEtherCollected.add(amount); receivedEther[who] = receivedEther[who].add(amount); //if this is first operation from this address, initial...
0.4.18
/** * @dev Fuction called when somebody is selling his tokens * @param who The address of seller (whose tokens are sold) * @param amount The amount to be transferred. */
function sell(address who, uint256 amount) canBuyAndSell internal returns(bool){ require(amount >= minSellAmount); currentPeriodTokenCollected = currentPeriodTokenCollected.add(amount); soldTokens[who] = soldTokens[who].add(amount); //if this is first operation from this address, initial val...
0.4.18
/** * @notice Start distribution phase * @param _currentPeriodRate exchange rate for current distribution */
function startDistribution(uint256 _currentPeriodRate) onlyOwner public { require(currentState != State.Distribution); //owner should not be able to change rate after distribution is started, ensures that everyone have the same rate require(_currentPeriodRate != 0); //something has t...
0.4.18
/** * @notice Distribute tokens to buyers * @param buyers an array of addresses to pay tokens for their ether. Should be composed from outside by reading Sale events */
function distributeTokens(address[] buyers) onlyOwner public { require(currentState == State.Distribution); require(currentPeriodRate > 0); for(uint256 i=0; i < buyers.length; i++){ address buyer = buyers[i]; require(buyer != address(0)); uint256 etherAm...
0.4.18
/** * @notice Distribute ether to sellers * If not enough ether is available on contract ballance * @param sellers an array of addresses to pay ether for their tokens. Should be composed from outside by reading Redemption events */
function distributeEther(address[] sellers) onlyOwner payable public { require(currentState == State.Distribution); require(currentPeriodRate > 0); for(uint256 i=0; i < sellers.length; i++){ address seller = sellers[i]; require(seller != address(0)); uin...
0.4.18
/** * Accepts required payment and mints a specified number of tokens to an address. * This method also checks if direct purchase is enabled. */
function purchase(uint256 count) public payable nonReentrant { require(!msg.sender.isContract(), 'BASE_COLLECTION/CONTRACT_CANNOT_CALL'); requireMintingConditions(msg.sender, count); require(isPurchaseEnabled, 'BASE_COLLECTION/PURCHASE_DISABLED'); require( (_publicSaleTime != 0 && _pub...
0.8.9
/// @inheritdoc IHistoryERC721
function eventData(uint eventId) external view override returns( uint totalMintFee, string memory _name, string memory contentHash, string memory contentDomain, uint firstMintTime ){ EventMeta memory meta = eventMeta[eventId]; totalMintFee = meta.total...
0.8.7
/// @inheritdoc IERC721Metadata
function tokenURI(uint256 tokenId) public view override(IERC721Metadata, ERC721) returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); (uint evtId, uint reportId) = _tokenIdSplit(tokenId); EventMeta memory meta = eventMeta[evtId]; str...
0.8.7
/// @notice Checks if the join address is one of the Ether coll. types /// @param _joinAddr Join address to check
function isEthJoinAddr(address _joinAddr) internal view returns (bool) { // if it's dai_join_addr don't check gem() it will fail if (_joinAddr == 0x9759A6Ac90977b93B58547b4A71c78317f391A28) return false; // if coll is weth it's and eth type coll if (address(Join(_joinAddr).gem()) == 0xC...
0.6.12
/// @notice Takes a src amount of tokens and converts it into the dest token /// @dev Takes fee from the _srcAmount before the exchange /// @param exData [srcAddr, destAddr, srcAmount, destAmount, minPrice, exchangeType, exchangeAddr, callData, price0x] /// @param _user User address who called the exchange
function sell(ExchangeData memory exData, address payable _user) public payable burnGas(burnAmount) { exData.dfsFeeDivider = SERVICE_FEE; exData.user = _user; // Perform the exchange (address wrapper, uint destAmount) = _sell(exData); // send back any leftover ether or tokens ...
0.6.12
/// @notice Takes a dest amount of tokens and converts it from the src token /// @dev Send always more than needed for the swap, extra will be returned /// @param exData [srcAddr, destAddr, srcAmount, destAmount, minPrice, exchangeType, exchangeAddr, callData, price0x] /// @param _user User address who called the excha...
function buy(ExchangeData memory exData, address payable _user) public payable burnGas(burnAmount){ exData.dfsFeeDivider = SERVICE_FEE; exData.user = _user; // Perform the exchange (address wrapper, uint srcAmount) = _buy(exData); // send back any leftover ether or tokens ...
0.6.12
/// @notice User deposits tokens to the Aave protocol /// @dev User needs to approve the DSProxy to pull the _tokenAddr tokens /// @param _tokenAddr The address of the token to be deposited /// @param _amount Amount of tokens to be deposited
function deposit(address _tokenAddr, uint256 _amount) public burnGas(5) payable { address lendingPoolCore = ILendingPoolAddressesProvider(AAVE_LENDING_POOL_ADDRESSES).getLendingPoolCore(); address lendingPool = ILendingPoolAddressesProvider(AAVE_LENDING_POOL_ADDRESSES).getLendingPool(); uint et...
0.6.12
/// @dev User needs to approve the DSProxy to pull the _tokenAddr tokens /// @notice User paybacks tokens to the Aave protocol /// @param _tokenAddr The address of the token to be paybacked /// @param _aTokenAddr ATokens to be paybacked /// @param _amount Amount of tokens to be payed back /// @param _wholeDebt If true ...
function payback(address _tokenAddr, address _aTokenAddr, uint256 _amount, bool _wholeDebt) public burnGas(3) payable { address lendingPoolCore = ILendingPoolAddressesProvider(AAVE_LENDING_POOL_ADDRESSES).getLendingPoolCore(); address lendingPool = ILendingPoolAddressesProvider(AAVE_LENDING_POOL_ADDRESS...
0.6.12
/// @notice Helper method to withdraw tokens from the DSProxy /// @param _tokenAddr Address of the token to be withdrawn
function withdrawTokens(address _tokenAddr) public { uint256 amount = _tokenAddr == ETH_ADDR ? address(this).balance : ERC20(_tokenAddr).balanceOf(address(this)); if (amount > 0) { if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeTransfer(msg.sender, amount); ...
0.6.12
/// @notice Withdraws collateral, converts to borrowed token and repays debt /// @dev Called through the DSProxy /// @param _exData Exchange data /// @param _cAddresses Coll/Debt addresses [cCollAddress, cBorrowAddress] /// @param _gasCost Gas cost for specific transaction
function repay( ExchangeData memory _exData, address[2] memory _cAddresses, // cCollAddress, cBorrowAddress uint256 _gasCost ) public payable { enterMarket(_cAddresses[0], _cAddresses[1]); address payable user = payable(getUserAddress()); uint maxColl = getMaxCollat...
0.6.12
/// @notice Borrows token, converts to collateral, and adds to position /// @dev Called through the DSProxy /// @param _exData Exchange data /// @param _cAddresses Coll/Debt addresses [cCollAddress, cBorrowAddress] /// @param _gasCost Gas cost for specific transaction
function boost( ExchangeData memory _exData, address[2] memory _cAddresses, // cCollAddress, cBorrowAddress uint256 _gasCost ) public payable { enterMarket(_cAddresses[0], _cAddresses[1]); address payable user = payable(getUserAddress()); uint maxBorrow = getMaxBorr...
0.6.12
// Wind down pool exists just in case one of the pools is broken
function wind_down_pool(uint256 pool, uint256 epoch) external { require(msg.sender == team_address || msg.sender == governance, "must be team or governance"); require(epoch == 15, "v1.15: only epoch 15"); uint256 current_epoch = get_current_epoch(); require(epoch < current_epoch, "cannot wind down f...
0.7.4
// Deploy all capital in pool (funnel 100% of pooled base assets into best adapter)
function deploy_all_capital() external override { require(block.timestamp >= last_deploy + (deploy_interval), "deploy call too soon" ); last_deploy = block.timestamp; // DAI/Compound ISaffronPool pool = ISaffronPool(pools[0]); IERC20 base_asset = IERC20(pool.get_base_asset_address()); if...
0.7.4
/// @notice Repays the position with it's own fund or with FL if needed /// @param _exData Exchange data /// @param _cAddresses cTokens addreses and exchange [cCollAddress, cBorrowAddress, exchangeAddress] /// @param _gasCost Gas cost for specific transaction
function repayWithLoan( ExchangeData memory _exData, address[2] memory _cAddresses, // cCollAddress, cBorrowAddress uint256 _gasCost ) public payable burnGas(25) { uint maxColl = getMaxCollateral(_cAddresses[0], address(this)); uint availableLiquidity = getAvailableLiquidity(...
0.6.12
/// @dev Buys votes for an option, each vote costs voteCost. /// @param _id Which side gets the vote
function buyVotes(uint8 _id) public payable { // Ensure at least one vote can be purchased require(msg.value >= voteCost); // Ensure vote is only for listed Ivys require(_id >= 0 && _id <= 7); // Calculate number of votes uint256 votes = msg.value / voteCost; voteCounts[...
0.4.18
// Insert functions
function addMasterWithSlave(address payable _master, address payable _slave, uint256 _masterPercent, uint256 _slavePercent , string memory _investorCode ) public onlyOwner { require(getMasterWithSlaveIndexByInvestorCode(_investorCode) == 0 && getMasterIndexByInvestorCode(_investorCode) == 0 ); ...
0.5.0
/** * @notice create automation order * @param _otoken the address of otoken (only holders) * @param _amount amount of otoken (only holders) * @param _vaultId the id of specific vault to settle (only writers) * @param _toToken token address for custom token settlement */
function createOrder( address _otoken, uint256 _amount, uint256 _vaultId, address _toToken ) public override { uint256 fee; bool isSeller; if (_otoken == address(0)) { require( _amount == 0, "AutoGamma::createOrder: ...
0.8.0
/** * @notice cancel automation order * @param _orderId the id of specific order to be cancelled */
function cancelOrder(uint256 _orderId) public override { Order storage order = orders[_orderId]; require( order.owner == msg.sender, "AutoGamma::cancelOrder: Sender is not order owner" ); require( !order.finished, "AutoGamma::cancelOrder: O...
0.8.0
/** * @notice check if processing order is profitable * @param _orderId the id of specific order to be processed * @return true if settling vault / redeeming returns more than 0 amount */
function shouldProcessOrder(uint256 _orderId) public view override returns (bool) { Order memory order = orders[_orderId]; if (order.finished) return false; if (order.isSeller) { bool shouldSettle = shouldSettleVault(order.owner, order.vaultId); ...
0.8.0
/** * @notice process an order * @dev only automator allowed * @param _orderId the id of specific order to process */
function processOrder(uint256 _orderId, ProcessOrderArgs calldata orderArgs) public override onlyAuthorized { Order storage order = orders[_orderId]; require( shouldProcessOrder(_orderId), "AutoGamma::processOrder: Order should not be processed" ...
0.8.0
/** * @notice process multiple orders * @param _orderIds array of order ids to process */
function processOrders( uint256[] calldata _orderIds, ProcessOrderArgs[] calldata _orderArgs ) public override { require( _orderIds.length == _orderArgs.length, "AutoGamma::processOrders: Params lengths must be same" ); for (uint256 i = 0; i < _orderId...
0.8.0
/** * Mints PixelToros */
function mintPixelToros(uint numberOfPixelToros) public payable { require(isSaleActive, "Sale must be active to mint PixelToros"); require(numberOfPixelToros <= maxPixelTorosPurchase, "Can only mint 10 PixelToros at a time"); require(totalSupply().add(numberOfPixelToros) <= MAX_PIXEL_TOROS, "Purchase would exc...
0.8.7
/// @dev Owner reserve
function reserve(address to, uint256 amount) external onlyOwner { uint256 newTokenId = totalSupply(); require(newTokenId + amount <= MAX_SUPPLY, "exceed max supply"); for (uint256 i = 0; i < amount; i++) { _safeMint(to, newTokenId); newTokenId++; } }
0.8.4
/** Function to freeze the tokens */
function freezeTokens(uint256 _value) public returns(bool){ address callingUser = msg.sender; address contractAddress = address(this); //LOGIC TO WITHDRAW ANY OUTSTANDING MAIN DIVIDENDS //we want this current call to complete if we return true from withdrawDividendsEverything, ot...
0.5.11
//To air drop
function airDrop(address[] memory recipients,uint[] memory tokenAmount) public onlyOwner returns (bool) { uint reciversLength = recipients.length; require(reciversLength <= 150); for(uint i = 0; i < reciversLength; i++) { if (gasleft() < 100000) { ...
0.5.11
/** * @dev Gets current TheRestorian Price */
function getNFTPrice() public view returns (uint256) { require(minted < MAX_NFT_MINTED, "Sale has already ended"); require(block.timestamp >= saleStartTimestamp, "Sale has not started"); if (minted >= 3584) { return 255000000000000000; } else if (minted >= 3072) { ...
0.7.1
/** * @dev Mints TheRestorian */
function mintNFT(uint256 numberOfNfts) public payable { require(numberOfNfts > 0, "numberOfNfts cannot be 0"); require(numberOfNfts <= 20, "You may not buy more than 20 NFTs at once"); require(minted.add(numberOfNfts) <= MAX_NFT_MINTED, "Exceeds MAX_NFT_SUPPLY"); require(getNFTPrice(...
0.7.1
// ============ SUPPORTING FUNCTIONS ============
function getPrice(uint256 _numberOfDrivers, bool _whitelistActive) internal pure returns (uint256) { if (_whitelistActive) { if (_numberOfDrivers == 1) { return PRICE_PER_DRIVER; } else if (_numberOfDrivers == 4) { retu...
0.8.11
/** * @dev Allows the current owner to change the minter. * @param _newMinter The address of the new minter. * @return True if the operation was successful. */
function setMinter(address _newMinter) external canMint onlyOwner returns(bool) { require(_newMinter != address(0), "New minter must be a valid non-null address"); require(_newMinter != minter, "New minter has to differ from previous minter"); emit MinterT...
0.4.24
/** * @dev Allows the current owner to change the assigner. * @param _newAssigner The address of the new assigner. * @return True if the operation was successful. */
function setAssigner(address _newAssigner) external onlyOwner canMint returns(bool) { require(_newAssigner != address(0), "New assigner must be a valid non-null address"); require(_newAssigner != assigner, "New assigner has to differ from previous assigner"); ...
0.4.24
/** * @dev Allows the current owner to change the burner. * @param _newBurner The address of the new burner. * @return True if the operation was successful. */
function setBurner(address _newBurner) external onlyOwner returns(bool) { require(_newBurner != address(0), "New burner must be a valid non-null address"); require(_newBurner != burner, "New burner has to differ from previous burner"); emit BurnerTransferred(burner...
0.4.24
/** * @dev Function to batch mint tokens. * @param _to An array of addresses that will receive the minted tokens. * @param _amounts An array with the amounts of tokens each address will get minted. * @param _batchMintId Identifier for the batch in order to synchronize with internal (off-chain) processes. * @r...
function batchMint(address[] _to, uint256[] _amounts, uint256 _batchMintId) external canMint hasMintPermission returns (bool) { require(_to.length == _amounts.length, "Input arrays must have the same length"); uint256 totalMintedTokens = 0; for (uint...
0.4.24
/** * @dev Function to assign a list of numbers of tokens to a given list of addresses. * @param _to The addresses that will receive the assigned tokens. * @param _amounts The amounts of tokens to assign. * @param _batchAssignId Identifier for the batch in order to synchronize with internal (off-chain) processe...
function batchAssign(address[] _to, uint256[] _amounts, uint256 _batchAssignId) external canMint hasAssignPermission returns (bool) { require(_to.length == _amounts.length, "Input arrays must have the same length"); uint256 totalAssignedTokens = 0; f...
0.4.24
/** * @dev Transfer tokens from one address to several others when minting is finished. * @param _to addresses The addresses which you want to transfer to * @param _amounts uint256 the amounts of tokens to be transferred * @param _batchTransferId Identifier for the batch in order to synchronize with internal (o...
function transferInBatches(address[] _to, uint256[] _amounts, uint256 _batchTransferId) public whenMintingFinished whenNotPaused returns (bool) { require(_to.length == _amounts.length, "Input arrays must have the same length"); uint256 totalTransferredTokens ...
0.4.24
/** * @dev Initialize the ICO contract */
function SelfllerySaleFoundation( address _token, address _selflleryManagerWallet, uint _tokenCents, uint _tokenPriceWei, uint _saleTokensCents, uint _startDate, uint _bonusEndDate, uint _endDate, uint _hardCapTokens, uint _minimu...
0.4.18
/** * @dev Purchase tokens for the amount of ether sent to this contract for custom address * @param _participant The address of the participant * @return A boolean that indicates if the operation was successful. */
function purchaseFor(address _participant) public payable onlyDuringICODates() returns(bool) { require(_participant != 0x0); require(paidEther[_participant].add(msg.value) >= minimumPurchaseAmount); selflleryManagerWallet.transfer(msg.value); uint currentBonusPercent = getCurrent...
0.4.18
/** * @dev Add pre-sale purchased tokens only owner * @param _participant The address of the participant * @param _totalTokens Total tokens amount for pre-sale participant * @return A boolean that indicates if the operation was successful. */
function addPreSalePurchaseTokens(address _participant, uint _totalTokens) public onlyOwner returns(bool) { require(_participant != 0x0); require(_totalTokens > 0); require(currentCapTokens.add(_totalTokens) <= saleTokensCents); require(token.transferFrom(owner, _participant, _tota...
0.4.18
/* actions */
function _collectPatronage() public { // determine patronage to pay if (state == StewardState.Owned) { uint256 collection = patronageOwed(); // should foreclose and stake stewardship if (collection >= deposit) { // up to when was it...
0.5.8
/** * Change the upgrade master. * * This allows us to set a new owner for the upgrade mechanism. */
function setUpgradeMaster(address master) public { require(master != address(0), "The provided upgradeMaster is required to be a non-empty address when setting upgrade master."); require(msg.sender == upgradeMaster, "Message sender is required to be the original upgradeMaster when setting (new) upgr...
0.4.22
/** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * Approve with a value of `MAX_UINT = 2 ** 256 - 1` will symbolize * an approval of infinite value. * * IMPORTANT:to prevent the risk that someone ma...
function approve(address spender, uint256 value) public returns (bool) { require( value == 0 || _allowances[msg.sender][spender] == 0, "ERC20: approve only to or from 0 value" ); _approve(msg.sender, spender, value); return true; }
0.5.8
///@dev Withdraws staked waTokens from the transmuter /// /// This function reverts if you try to draw more tokens than you deposited /// ///@param amount the amount of waTokens to unstake
function unstake(uint256 amount) public updateAccount(msg.sender) { // by calling this function before transmuting you forfeit your gained allocation address sender = msg.sender; require(depositedWaTokens[sender] >= amount,"TransmuterD8: unstake amount exceeds deposited amount"); dep...
0.6.12
///@dev Deposits waTokens into the transmuter /// ///@param amount the amount of waTokens to stake
function stake(uint256 amount) public runPhasedDistribution() updateAccount(msg.sender) checkIfNewUser() { // requires approval of waToken first address sender = msg.sender; //require tokens transferred in; IERC20Burnable(WaToken).safeTransfer...
0.6.12
/// @dev Converts the staked waTokens to the base tokens in amount of the sum of pendingdivs and tokensInBucket /// /// once the waToken has been converted, it is burned, and the base token becomes realisedTokens which can be recieved using claim() /// /// reverts if there are no pendingdivs or tokensInBucket
function transmute() public runPhasedDistribution() updateAccount(msg.sender) { address sender = msg.sender; uint256 pendingz = tokensInBucket[sender]; uint256 diff; require(pendingz > 0, "need to have pending in bucket"); tokensInBucket[sender] = 0; // check ...
0.6.12
/// @dev Executes transmute() on another account that has had more base tokens allocated to it than waTokens staked. /// /// The caller of this function will have the surlus base tokens credited to their tokensInBucket balance, rewarding them for performing this action /// /// This function reverts if the address to tr...
function forceTransmute(address toTransmute) public runPhasedDistribution() updateAccount(msg.sender) updateAccount(toTransmute) { //load into memory address sender = msg.sender; uint256 pendingz = tokensInBucket[toTransmute]; // check restric...
0.6.12
/// @dev Gets the status of a user's staking position. /// /// The total amount allocated to a user is the sum of pendingdivs and inbucket. /// /// @param user the address of the user you wish to query. /// /// returns user status
function userInfo(address user) public view returns ( uint256 depositedAl, uint256 pendingdivs, uint256 inbucket, uint256 realised ) { uint256 _depositedAl = depositedWaTokens[user]; uint256 _toDistribute = bu...
0.6.12
/// @dev Gets the status of multiple users in one call /// /// This function is used to query the contract to check for /// accounts that have overfilled positions in order to check /// who can be force transmuted. /// /// @param from the first index of the userList /// @param to the last index of the userList /// /// ...
function getMultipleUserInfo(uint256 from, uint256 to) public view returns (address[] memory theUserList, uint256[] memory theUserData) { uint256 i = from; uint256 delta = to - from; address[] memory _theUserList = new address[](delta); //user uint256[...
0.6.12
// Note: Order creation happens off-chain but the orders are signed by creators, // we validate the contents and the creator address in the logic below
function trade(address _tokenGet, uint _amountGet, address _tokenGive, uint _amountGive, uint _expires, uint _nonce, address _user, uint8 _v, bytes32 _r, bytes32 _s, uint _amount) { bytes32 hash = sha256(this, _tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce); // Check order signatures ...
0.4.24
// User-triggered (!) fund migrations in case contract got updated // Similar to withdraw but we use a successor account instead // As we don't store user tokens list on chain, it has to be passed from the outside
function migrateFunds(address[] _tokens) { // Get the latest successor in the chain require(successor != address(0)); TokenStore newExchange = TokenStore(successor); for (uint16 n = 0; n < 20; n++) { // We will look past 20 contracts in the future address nextSuccessor = newExchange.succes...
0.4.24
// This is used for migrations only. To be called by previous exchange only, // user-triggered, on behalf of the user called the migrateFunds method. // Note that it does exactly the same as depositToken, but as this is called // by a previous generation of exchange itself, we credit internally not the // previous exch...
function depositForUser(address _user) payable deprecable { require(_user != address(0)); require(msg.value > 0); TokenStore caller = TokenStore(msg.sender); require(caller.version() > 0); // Make sure it's an exchange account tokens[0][_user] = safeAdd(tokens[0][_user], msg.value); }
0.4.24
// Have that someone else spend your tokens
function transferFrom(address payable from, address payable to, uint value) public returns(bool success) { uint256 allowance = allowances[from][msg.sender]; require(allowance > 0, "Not approved"); require(allowance >= value, "Over spending limit"); allowances[from][msg.sender] = allowance.sub(value); act...
0.5.1
// The fallback function
function() payable external{ // Only accept free ETH from the bitx and from our child slave. if (msg.sender != address(bitx) && msg.sender != address(refHandler)) { // Now, sending ETH increases the balance _before_ the transaction has been fully processed. // We don't want to distribute the entire purcha...
0.5.1
// Throw your money at this thing with a referrer specified by their Ethereum address. // Returns the amount of tokens created.
function buy(address referrerAddress) payable public returns(uint256) { // Now, sending ETH increases the balance _before_ the transaction has been fully processed. // We don't want to distribute the entire purchase order as dividends. if (msg.value > 0) { lastTotalBalance += msg.value; distributeDivid...
0.5.1
// Use all the ETH you earned hodling BXTG to buy more BXTG. // Returns the amount of tokens created.
function reinvest() public returns(uint256) { address accountHolder = msg.sender; distributeDividends(0, NULL_ADDRESS); // Just in case BITX-only transactions happened. uint256 payout; uint256 bonusPayout; (payout, bonusPayout) = clearDividends(accountHolder); emit onWithdraw(accountHolder, payout, bo...
0.5.1
// Use some of the ETH you earned hodling BXTG to buy more BXTG. // You can withdraw the rest or keep it in here allocated for you. // Returns the amount of tokens created.
function reinvestPartial(uint256 ethToReinvest, bool withdrawAfter) public returns(uint256 tokensCreated) { address payable accountHolder = msg.sender; distributeDividends(0, NULL_ADDRESS); // Just in case BITX-only transactions happened. uint256 payout = dividendsOf(accountHolder, false); uint256 bonusPa...
0.5.1
// There's literally no reason to call this function
function sell(uint256 amount, bool withdrawAfter) public returns(uint256) { require(amount > 0, "You have to sell something"); uint256 sellAmount = destroyTokens(msg.sender, amount); if (withdrawAfter && dividendsOf(msg.sender, true) > 0) { withdrawDividends(msg.sender); } return sellAmount; }
0.5.1