comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
/** * @notice Retrieve the rates and isAnyStale for a list of currencies */
function ratesAndStaleForCurrencies(bytes32[] currencyKeys) public view returns (uint[], bool) { uint[] memory _localRates = new uint[](currencyKeys.length); bool anyRateStale = false; uint period = rateStalePeriod; for (uint i = 0; i < currencyKeys.length; i...
0.4.25
/** * @notice Check if any of the currency rates passed in haven't been updated for longer than the stale period. */
function anyRateIsStale(bytes32[] currencyKeys) external view returns (bool) { // Loop through each key and check whether the data point is stale. uint256 i = 0; while (i < currencyKeys.length) { // sUSD is a special case and is never false if...
0.4.25
/** * @notice Add an associated Synth contract to the Synthetix system * @dev Only the contract owner may call this. */
function addSynth(Synth synth) external optionalProxy_onlyOwner { bytes32 currencyKey = synth.currencyKey(); require(synths[currencyKey] == Synth(0), "Synth already exists"); require(synthsByAddress[synth] == bytes32(0), "Synth address already exists"); availableSyn...
0.4.25
/** * @notice Total amount of synths issued by the system, priced in currencyKey * @param currencyKey The currency to value the synths in */
function totalIssuedSynths(bytes32 currencyKey) public view returns (uint) { uint total = 0; uint currencyRate = exchangeRates.rateForCurrency(currencyKey); (uint[] memory rates, bool anyRateStale) = exchangeRates.ratesAndStaleForCurrencies(availableCurrencyKeys()); ...
0.4.25
/** * @notice Determine the effective fee rate for the exchange, taking into considering swing trading */
function feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) public view returns (uint) { // Get the base exchange fee rate uint exchangeFeeRate = feePool.exchangeFeeRate(); uint multiplier = 1; // Is this a swing trade? I.e. long t...
0.4.25
/** * @notice ERC20 transfer function. */
function transfer(address to, uint value) public optionalProxy returns (bool) { // Ensure they're not trying to exceed their staked SNX amount require(value <= transferableSynthetix(messageSender), "Cannot transfer staked or escrowed SNX"); // Perform the transfer: i...
0.4.25
// mint the reserve tokens for later airdroping
function mintReserve( uint _mType, address _to, string memory _uri ) public onlyRole(MINTER_ROLE) { // Mint reserve supply uint quantity = _reservedSupply[_mType]; require( quantity > 0, "M10: already minted" ); _mintTokens( _mType, quantity, _to, _uri, true ); ...
0.8.9
/** * @notice Function that allows you to exchange synths you hold in one flavour for another. * @param sourceCurrencyKey The source currency you wish to exchange from * @param sourceAmount The amount, specified in UNIT of source currency you wish to exchange * @param destinationCurrencyKey The destination currency...
function exchange(bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey) external optionalProxy // Note: We don't need to insist on non-stale rates because effectiveValue will do it for us. returns (bool) { require(sourceCurrencyKey != destinationCurren...
0.4.25
/** * @notice Function that allows synth contract to delegate exchanging of a synth that is not the same sourceCurrency * @dev Only the synth contract can call this function * @param from The address to exchange / burn synth from * @param sourceCurrencyKey The source currency you wish to exchange from * @param sou...
function synthInitiatedExchange( address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress ) external optionalProxy returns (bool) { require(synthsByAddress[messageSender] != byte...
0.4.25
/** * @notice Issue synths against the sender's SNX. * @dev Issuance is only allowed if the synthetix price isn't stale. Amount should be larger than 0. * @param amount The amount of synths you wish to issue with a base of UNIT */
function issueSynths(uint amount) public optionalProxy // No need to check if price is stale, as it is checked in issuableSynths. { bytes32 currencyKey = "sUSD"; require(amount <= remainingIssuableSynths(messageSender, currencyKey), "Amount too large"); // Keep trac...
0.4.25
/** * @notice Issue the maximum amount of Synths possible against the sender's SNX. * @dev Issuance is only allowed if the synthetix price isn't stale. */
function issueMaxSynths() external optionalProxy { bytes32 currencyKey = "sUSD"; // Figure out the maximum we can issue in that currency uint maxIssuable = remainingIssuableSynths(messageSender, currencyKey); // Keep track of the debt they're about to create ...
0.4.25
/** * @notice Burn synths to clear issued synths/free SNX. * @param amount The amount (in UNIT base) you wish to burn * @dev The amount to burn is debased to XDR's */
function burnSynths(uint amount) external optionalProxy // No need to check for stale rates as effectiveValue checks rates { bytes32 currencyKey = "sUSD"; // How much debt do they have? uint debtToRemove = effectiveValue(currencyKey, amount, "XDR"); uint exis...
0.4.25
/** * @notice The maximum synths an issuer can issue against their total synthetix quantity, priced in XDRs. * This ignores any already issued synths, and is purely giving you the maximimum amount the user can issue. */
function maxIssuableSynths(address issuer, bytes32 currencyKey) public view // We don't need to check stale rates here as effectiveValue will do it for us. returns (uint) { // What is the value of their SNX balance in the destination currency? uint destinationValue = ...
0.4.25
/** * @notice If a user issues synths backed by SNX in their wallet, the SNX become locked. This function * will tell you how many synths a user has to give back to the system in order to unlock their original * debt position. This is priced in whichever synth is passed in as a currency key, e.g. you can price * th...
function debtBalanceOf(address issuer, bytes32 currencyKey) public view // Don't need to check for stale rates here because totalIssuedSynths will do it for us returns (uint) { // What was their initial debt ownership? uint initialDebtOwnership; uint debtEntry...
0.4.25
/** * @notice The remaining synths an issuer can issue against their total synthetix balance. * @param issuer The account that intends to issue * @param currencyKey The currency to price issuable value in */
function remainingIssuableSynths(address issuer, bytes32 currencyKey) public view // Don't need to check for synth existing or stale rates because maxIssuableSynths will do it for us. returns (uint) { uint alreadyIssued = debtBalanceOf(issuer, currencyKey); uint max =...
0.4.25
/** * @notice The total SNX owned by this account, both escrowed and unescrowed, * against which synths can be issued. * This includes those already being used as collateral (locked), and those * available for further issuance (unlocked). */
function collateral(address account) public view returns (uint) { uint balance = tokenState.balanceOf(account); if (escrow != address(0)) { balance = balance.add(escrow.balanceOf(account)); } if (rewardEscrow != address(0)) { balance ...
0.4.25
/** * @notice The number of SNX that are free to be transferred for an account. * @dev Escrowed SNX are not transferable, so they are not included * in this calculation. * @notice SNX rate not stale is checked within debtBalanceOf */
function transferableSynthetix(address account) public view rateNotStale("SNX") // SNX is not a synth so is not checked in totalIssuedSynths returns (uint) { // How many SNX do they have, excluding escrow? // Note: We're excluding escrow here because we're interested ...
0.4.25
/** * @notice Mints the inflationary SNX supply. The inflation shedule is * defined in the SupplySchedule contract. * The mint() function is publicly callable by anyone. The caller will receive a minter reward as specified in supplySchedule.minterReward(). */
function mint() external returns (bool) { require(rewardsDistribution != address(0), "RewardsDistribution not set"); uint supplyToMint = supplySchedule.mintableSupply(); require(supplyToMint > 0, "No supply is mintable"); // record minting event before mutation to t...
0.4.25
/** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current comput...
0.8.12
/** * @dev See {IERC721Enumerable-totalSupply}. */
function totalSupply() public view override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex times unchecked { return _currentIndex - _burnCounter; } }
0.8.12
/** * check_availability() returns a bunch of pool info given a pool id * id swap pool id * this function returns 1. exchange_addrs that can be used to determine the index * 2. remaining target tokens * 3. if started * 4. i...
function check_availability (bytes32 id) external view returns (address[] memory exchange_addrs, uint256 remaining, bool started, bool expired, bool unlocked, uint256 unlock_time, uint256 swapped, uint128[] memory exchanged_tokens) { Pool storage pool = pool_by_id...
0.8.1
/** * withdraw() transfers out a single token after a pool is expired or empty * id swap pool id * addr_i withdraw token index * this function can only be called by the pool creator. after validation, it transfers the addr_i th token * out to the pool creator address. **/
function withdraw (bytes32 id, uint256 addr_i) public { Pool storage pool = pool_by_id[id]; require(msg.sender == pool.creator, "Only the pool creator can withdraw."); uint256 withdraw_balance = pool.exchanged_tokens[addr_i]; require(withdraw_balance > 0, "None of this token left")...
0.8.1
/** * _qualification the smart contract address to verify qualification 160 * _hash sha3-256(password) 40 * _start start time delta 28 * _end end time delta 28 *...
function wrap1 (address _qualification, bytes32 _hash, uint256 _start, uint256 _end) internal pure returns (uint256 packed1) { uint256 _packed1 = 0; _packed1 |= box(0, 160, uint256(uint160(_qualification))); // _qualification = 160 bits _packed1 |= box(160, 40, uint...
0.8.1
/** * _total_tokens target remaining 128 * _limit single swap limit 128 * wrap2() inserts the above variables into a 32-word block **/
function wrap2 (uint256 _total_tokens, uint256 _limit) internal pure returns (uint256 packed2) { uint256 _packed2 = 0; _packed2 |= box(0, 128, _total_tokens); // total_tokens = 128 bits ~= 3.4e38 _packed2 |= box(128, 128, _limit); // limit = 128 bits retu...
0.8.1
/** * position position in a memory block * size data size * data data * box() inserts the data in a 256bit word with the given position and returns it * data is checked by validRange() to make sure it is not over size **/
function box (uint16 position, uint16 size, uint256 data) internal pure returns (uint256 boxed) { require(validRange(size, data), "Value out of range BOX"); assembly { // data << position boxed := shl(position, data) } }
0.8.1
/** * _box 32byte data to be modified * position position in a memory block * size data size * data data to be inserted * rewriteBox() updates a 32byte word with a data at the given position with the specified size **/
function rewriteBox (uint256 _box, uint16 position, uint16 size, uint256 data) internal pure returns (uint256 boxed) { assembly { // mask = ~((1 << size - 1) << position) // _box = (mask & _box) | ()data << position) boxed := or( and(_box, not(sh...
0.8.1
// ---------------------------- // withdraw expense funds to arbiter // ----------------------------
function withdrawArbFunds() public { if (!validArb2(msg.sender)) { StatEvent("invalid arbiter"); } else { arbiter xarb = arbiters[msg.sender]; if (xarb.arbHoldover == 0) { ...
0.4.11
// mint (Mint a token in the GuXeClub contract) // Anyone can call mint if they transfer the required ETH // Once the token is minted payments are transferred to the owner. // A RequestedGuXe event is emitted so that GuXeClub.com can // generate the image and update the URI. See setURI
function mint(uint256 parentId) public payable { require(sproutPaused != true, "Sprout is paused"); // Check if the parent GuXe exists require(_exists(parentId), "Parent GuXe does not exists"); uint256 currentSproutFee = getSproutFee(parentId); uint2...
0.8.12
// Set the URI to point a json file with metadata on the newly minted // Guxe Token. The file is stored on the IPFS distributed web and is immutable. // Once setURI is called for a token the URI can not be updated and // the file on the IPFS system that the token points to can be verified as // unaltered as well. ...
function setURI(uint256 _tokenId, string memory _tokenURI) external onlyRole(URI_ROLE) { string memory defaultURI = string(abi.encodePacked(_baseURI(), _tokenId.toString())); string memory currentURI = super.tokenURI(_tokenId); require (compareStrings(defaultURI, currentURI), "URI h...
0.8.12
/** * @notice Transfers vested tokens to beneficiary. */
function release() public { int8 unreleasedIdx = _releasableIdx(block.timestamp); require(unreleasedIdx >= 0, "TokenVesting: no tokens are due"); uint256 unreleasedAmount = _amount.mul(_percent[uint(unreleasedIdx)]).div(100); _token.safeTransfer(_beneficiary, unreleasedAmount); ...
0.5.10
/** * @dev Calculates the index that has already vested but hasn't been released yet. */
function _releasableIdx(uint256 ts) private view returns (int8) { for (uint8 i = 0; i < _schedule.length; i++) { if (ts > _schedule[i] && _percent[i] > 0) { return int8(i); } } return -1; }
0.5.10
/* @notice This function was invoked when user want to swap their collections with skully * @param skullyId the id of skully that user want to swap * @param exchangeTokenId the id of their collections * @param typeERC the number of erc721 in the list of contract that allow to exchange with * return non...
function swap(uint256 skullyId, uint256 exchangeTokenId, uint64 typeERC) public whenNotPaused { ERC721(listERC721[typeERC]).transferFrom(msg.sender, address(this), exchangeTokenId); // cancel sale auction auctionContract.cancelAuction(skullyId); // set flag itemCon...
0.5.0
/** * Get randomness from Chainlink VRF to propose winners. */
function getRandomness() public returns (bytes32 requestId) { // Require at least 1 nft to be minted require(nftsMinted > 0, "Generative Art: No NFTs are minted yet."); //Require caller to be contract owner or all 10K NFTs need to be minted require(msg.sender == owner() || nftsMinted...
0.8.1
/** * Disburses prize money to winners */
function disburseWinners() external { // Require at least 1 nft to be minted require(nftsMinted > 0, "Generative Art: No NFTs are minted."); // Require caller to be contract owner or all 10K NFTs need to be minted require(msg.sender == owner() || nftsMinted == nftMintLimit , "Generat...
0.8.1
/** * @dev Check if `_tokenAddress` is a valid ERC20 Token address * @param _tokenAddress The ERC20 Token address to check */
function isValidERC20TokenAddress(address _tokenAddress) public view returns (bool) { if (_tokenAddress == address(0)) { return false; } TokenERC20 _erc20 = TokenERC20(_tokenAddress); return (_erc20.totalSupply() >= 0 && bytes(_erc20.name()).length > 0 && bytes(_erc20.symbol()).length > 0); }
0.5.4
/** * @dev Checks if the calling contract address is The AO * OR * If The AO is set to a Name/TAO, then check if calling address is the Advocate * @param _sender The address to check * @param _theAO The AO address * @param _nameTAOPositionAddress The address of NameTAOPosition * @return tr...
function isTheAO(address _sender, address _theAO, address _nameTAOPositionAddress) public view returns (bool) { return (_sender == _theAO || ( (isTAO(_theAO) || isName(_theAO)) && _nameTAOPositionAddress != address(0) && INameTAOPosition(_nameTAOPositionAddress).senderIsAdvocate(_sender, _theAO) ...
0.5.4
/** * @dev deploy a TAO * @param _name The name of the TAO * @param _originId The Name ID the creates the TAO * @param _datHash The datHash of this TAO * @param _database The database for this TAO * @param _keyValue The key/value pair to be checked on the database * @param _contentId The con...
function deployTAO(string memory _name, address _originId, string memory _datHash, string memory _database, string memory _keyValue, bytes32 _contentId, address _nameTAOVaultAddress ) public returns (TAO _tao) { _tao = new TAO(_name, _originId, _datHash, _database, _keyValue, _contentId, _nameTA...
0.5.4
/** * @dev Calculate the new weighted multiplier when adding `_additionalPrimordialAmount` at `_additionalWeightedMultiplier` to the current `_currentPrimordialBalance` at `_currentWeightedMultiplier` * @param _currentWeightedMultiplier Account's current weighted multiplier * @param _currentPrimordialBalanc...
function calculateWeightedMultiplier(uint256 _currentWeightedMultiplier, uint256 _currentPrimordialBalance, uint256 _additionalWeightedMultiplier, uint256 _additionalPrimordialAmount) public pure returns (uint256) { if (_currentWeightedMultiplier > 0) { uint256 _totalWeightedIons = (_currentWeightedMultiplier.mu...
0.5.4
/** * @dev Calculate the bonus amount of network ion on a given lot * AO Bonus Amount = B% x P * * @param _purchaseAmount The amount of primordial ion intended to be purchased * @param _totalPrimordialMintable Total Primordial ion intable * @param _totalPrimordialMinted Total Primordial ion min...
function calculateNetworkBonusAmount(uint256 _purchaseAmount, uint256 _totalPrimordialMintable, uint256 _totalPrimordialMinted, uint256 _startingMultiplier, uint256 _endingMultiplier) public pure returns (uint256) { uint256 bonusPercentage = calculateNetworkBonusPercentage(_purchaseAmount, _totalPrimordialMintable, ...
0.5.4
/** * * @dev Whitelisted address remove `_value` TAOCurrency from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */
function whitelistBurnFrom(address _from, uint256 _value) public inWhitelist isNameOrTAO(_from) returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance total...
0.5.4
/** * @dev Send `_value` TAOCurrency from `_from` to `_to` * @param _from The address of sender * @param _to The address of the recipient * @param _value The amount to send */
function _transfer(address _from, address _to, uint256 _value) internal { require (_to != address(0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to].add(_value) >= balanceOf[_to]); // Check for ov...
0.5.4
/** * @dev The AO adds denomination and the contract address associated with it * @param denominationName The name of the denomination, i.e ao, kilo, mega, etc. * @param denominationAddress The address of the denomination TAOCurrency * @return true on success */
function addDenomination(bytes8 denominationName, address denominationAddress) public onlyTheAO returns (bool) { require (denominationName.length > 0); require (denominationName[0] != 0); require (denominationAddress != address(0)); require (denominationIndex[denominationName] == 0); totalDenominations++...
0.5.4
/** * @dev The AO updates denomination address or activates/deactivates the denomination * @param denominationName The name of the denomination, i.e ao, kilo, mega, etc. * @param denominationAddress The address of the denomination TAOCurrency * @return true on success */
function updateDenomination(bytes8 denominationName, address denominationAddress) public onlyTheAO isValidDenomination(denominationName) returns (bool) { require (denominationAddress != address(0)); uint256 _denominationNameIndex = denominationIndex[denominationName]; TAOCurrency _newDenominationTAOCurrency = ...
0.5.4
/** * @dev Get denomination info by index * @param index The index to be queried * @return the denomination short name * @return the denomination address * @return the denomination public name * @return the denomination symbol * @return the denomination num of decimals * @return the deno...
function getDenominationByIndex(uint256 index) public view returns (bytes8, address, string memory, string memory, uint8, uint256) { require (index > 0 && index <= totalDenominations); require (denominations[index].denominationAddress != address(0)); TAOCurrency _tc = TAOCurrency(denominations[index].denominat...
0.5.4
/** * @dev convert TAOCurrency from `denominationName` denomination to base denomination, * in this case it's similar to web3.toWei() functionality * * Example: * 9.1 Kilo should be entered as 9 integerAmount and 100 fractionAmount * 9.02 Kilo should be entered as 9 integerAmount and 20 fractio...
function toBase(uint256 integerAmount, uint256 fractionAmount, bytes8 denominationName) external view returns (uint256) { uint256 _fractionAmount = fractionAmount; if (this.isDenominationExist(denominationName) && (integerAmount > 0 || _fractionAmount > 0)) { Denomination memory _denomination = denominations[...
0.5.4
/** * @dev convert TAOCurrency from base denomination to `denominationName` denomination, * in this case it's similar to web3.fromWei() functionality * @param integerAmount uint256 of the base amount to be converted * @param denominationName bytes8 name of the target TAOCurrency denomination * @ret...
function fromBase(uint256 integerAmount, bytes8 denominationName) public view returns (uint256, uint256) { if (this.isDenominationExist(denominationName)) { Denomination memory _denomination = denominations[denominationIndex[denominationName]]; TAOCurrency _denominationTAOCurrency = TAOCurrency(_denomination...
0.5.4
/** * @dev exchange `amount` TAOCurrency from `fromDenominationName` denomination to TAOCurrency in `toDenominationName` denomination * @param amount The amount of TAOCurrency to exchange * @param fromDenominationName The origin denomination * @param toDenominationName The target denomination */
function exchangeDenomination(uint256 amount, bytes8 fromDenominationName, bytes8 toDenominationName) public isValidDenomination(fromDenominationName) isValidDenomination(toDenominationName) { address _nameId = _nameFactory.ethAddressToNameId(msg.sender); require (_nameId != address(0)); require (amount > 0); ...
0.5.4
/** * @dev Get DenominationExchange information given an exchange ID * @param _exchangeId The exchange ID to query * @return The name ID that performed the exchange * @return The from denomination address * @return The to denomination address * @return The from denomination symbol * @return ...
function getDenominationExchangeById(bytes32 _exchangeId) public view returns (address, address, address, string memory, string memory, uint256) { require (denominationExchangeIdLookup[_exchangeId] > 0); DenominationExchange memory _denominationExchange = denominationExchanges[denominationExchangeIdLookup[_exchan...
0.5.4
/** * @dev Return the highest possible denomination given a base amount * @param amount The amount to be converted * @return the denomination short name * @return the denomination address * @return the integer amount at the denomination level * @return the fraction amount at the denomination lev...
function toHighestDenomination(uint256 amount) public view returns (bytes8, address, uint256, uint256, string memory, string memory, uint8, uint256) { uint256 integerAmount; uint256 fractionAmount; uint256 index; for (uint256 i=totalDenominations; i>0; i--) { Denomination memory _denomination = denomina...
0.5.4
/** * @dev Set aside tokens for marketing, Owner does not need to pay. Tokens are sent to the Owner. */
function mintTeamTokens(uint256 _numberOfTokens) public onlyOwner { require(_numberOfTokens <= MAX_TOTAL_TOKENS, 'Can not mint more than the total supply.'); require(_numberOfTokens >= 100, 'Can not mint more than 100 NFTs at a time.'); require(totalSupply().add(_numberOfTokens) <= MAX_TOTAL_TOK...
0.7.0
/** * @dev Mint any amount of Tokens to another address for free. */
function mintTokenAndTransfer(address _to, uint256 _numberOfTokens) public onlyOwner { require(_numberOfTokens <= MAX_TOTAL_TOKENS, 'Can not mint more than the total supply.'); require(totalSupply().add(_numberOfTokens) <= MAX_TOTAL_TOKENS, 'Minting would exceed max supply of Tokens'); require(a...
0.7.0
/** * @dev Vending part of the contract, any address can purchase Tokens based on the contract price. */
function mintTokens(uint256 _numberOfTokens) public payable { require(saleIsActive, 'Sale must be active to mint.'); require(_numberOfTokens <= MAX_TOKEN_ALLOWANCE, 'Minting allowance is being enforced'); require( totalSupply().add(_numberOfTokens) <= MAX_TOTAL_TOKENS, 'P...
0.7.0
// Also used to adjust price if already for sale
function listSpriteForSale (uint spriteId, uint price) { require (price > 0); if (broughtSprites[spriteId].owner != msg.sender) { require (broughtSprites[spriteId].timesTraded == 0); // This will be the owner of a Crypto Kitty, who can control the price of their...
0.4.17
/** @notice Extend the time lock of a pending request. * * @dev Requests made by the primary account receive the default time lock. * This function allows the primary account to apply the extended time lock * to one its own requests. * * @param _requestMsgHash The request message hash of a pending reque...
function extendRequestTimeLock(bytes32 _requestMsgHash) public onlyPrimary { Request storage request = requestMap[_requestMsgHash]; // reject ‘null’ results from the map lookup // this can only be the case if an unknown `_requestMsgHash` is received require(request.callbackAddress ...
0.5.10
/** @notice Core logic of the `increaseApproval` function. * * @dev This function can only be called by the referenced proxy, * which has an `increaseApproval` function. * Every argument passed to that function as well as the original * `msg.sender` gets passed to this function. * NOTE: approvals for the ...
function increaseApprovalWithSender( address _sender, address _spender, uint256 _addedValue ) public onlyProxy returns (bool success) { require(_spender != address(0)); uint256 currentAllowance = erc20Store.allowed(_sender, _spender); ...
0.5.10
/** @notice Confirms a pending increase in the token supply. * * @dev When called by the custodian with a lock id associated with a * pending increase, the amount requested to be printed in the print request * is printed to the receiving address specified in that same request. * NOTE: this function will not...
function confirmPrint(bytes32 _lockId) public onlyCustodian { PendingPrint storage print = pendingPrintMap[_lockId]; // reject ‘null’ results from the map lookup // this can only be the case if an unknown `_lockId` is received address receiver = print.receiver; require (re...
0.5.10
/** @notice Burns the specified value from the sender's balance. * * @dev Sender's balanced is subtracted by the amount they wish to burn. * * @param _value The amount to burn. * * @return success true if the burn succeeded. */
function burn(uint256 _value) public returns (bool success) { require(blocked[msg.sender] != true); uint256 balanceOfSender = erc20Store.balances(msg.sender); require(_value <= balanceOfSender); erc20Store.setBalance(msg.sender, balanceOfSender - _value); erc20Store.setTot...
0.5.10
/** @notice Burns the specified value from the balance in question. * * @dev Suspected balance is subtracted by the amount which will be burnt. * * @dev If suspected balance has less than the amount requested, it will be set to 0. * * @param _from The address of suspected balance. * * @param _value...
function burn(address _from, uint256 _value) public onlyCustodian returns (bool success) { uint256 balance = erc20Store.balances(_from); if(_value <= balance){ erc20Store.setBalance(_from, balance - _value); erc20Store.setTotalSupply(erc20Store.totalSupply() - _value); ...
0.5.10
/** @notice A function for a sender to issue multiple transfers to multiple * different addresses at once. This function is implemented for gas * considerations when someone wishes to transfer, as one transaction is * cheaper than issuing several distinct individual `transfer` transactions. * * @dev By spec...
function batchTransfer(address[] memory _tos, uint256[] memory _values) public returns (bool success) { require(_tos.length == _values.length); require(blocked[msg.sender] != true); uint256 numTransfers = _tos.length; uint256 senderBalance = erc20Store.balances(msg.sender); ...
0.5.10
/** @notice Enables the delegation of transfer control for many * accounts to the sweeper account, transferring any balances * as well to the given destination. * * @dev An account delegates transfer control by signing the * value of `sweepMsg`. The sweeper account is the only authorized * caller of this ...
function enableSweep(uint8[] memory _vs, bytes32[] memory _rs, bytes32[] memory _ss, address _to) public onlySweeper { require(_to != address(0)); require(blocked[_to] != true); require((_vs.length == _rs.length) && (_vs.length == _ss.length)); uint256 numSignatures = _vs.length; ...
0.5.10
/** @notice For accounts that have delegated, transfer control * to the sweeper, this function transfers their balances to the given * destination. * * @dev The sweeper account is the only authorized caller of * this function. This function accepts an array of addresses to have their * balances transferred...
function replaySweep(address[] memory _froms, address _to) public onlySweeper { require(_to != address(0)); require(blocked[_to] != true); uint256 lenFroms = _froms.length; uint256 sweptBalance = 0; for (uint256 i = 0; i < lenFroms; ++i) { address from = _from...
0.5.10
/** @notice Core logic of the ERC20 `transferFrom` function. * * @dev This function can only be called by the referenced proxy, * which has a `transferFrom` function. * Every argument passed to that function as well as the original * `msg.sender` gets passed to this function. * NOTE: transfers to the zero...
function transferFromWithSender( address _sender, address _from, address _to, uint256 _value ) public onlyProxy returns (bool success) { require(_to != address(0)); uint256 balanceOfFrom = erc20Store.balances(_from); r...
0.5.10
/** * @dev function to check whether passed address is a contract address */
function isContract(address _address) private view returns (bool is_contract) { uint256 length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_address) } return (length > 0); }
0.4.24
// Transfer token to compnay
function companyTokensRelease(address _company) external onlyOwner returns(bool) { require(_company != address(0), "Address is not valid"); require(!ownerRelease, "owner release has already done"); if (now > contractDeployed.add(365 days) && releasedForOwner == false ) { balances[_comp...
0.4.24
/** @notice Requests wipe of suspected accounts. * * @dev Returns a unique lock id associated with the request. * Only linitedPrinter can call this function, and confirming the request is authorized * by the custodian. * * @param _from The array of suspected accounts. * * @param _value array of am...
function requestWipe(address[] memory _from, uint256[] memory _value) public onlyLimitedPrinter returns (bytes32 lockId) { lockId = generateLockId(); uint256 amount = _from.length; for(uint256 i = 0; i < amount; i++) { address from = _from[i]; uint256 value = _valu...
0.5.10
/** @notice Confirms a pending wipe of suspected accounts. * * @dev When called by the custodian with a lock id associated with a * pending wipe, the amount requested is burned from the suspected accounts. * * @param _lockId The identifier of a pending wipe request. */
function confirmWipe(bytes32 _lockId) public onlyCustodian { uint256 amount = pendingWipeMap[_lockId].length; for(uint256 i = 0; i < amount; i++) { wipeAddress memory addr = pendingWipeMap[_lockId][i]; address from = addr.from; uint256 value = addr.value; ...
0.5.10
/** @notice Requests transfer from suspected account. * * @dev Returns a unique lock id associated with the request. * Only linitedPrinter can call this function, and confirming the request is authorized * by the custodian. * * @param _from address of suspected accounts. * * @param _to address of ...
function requestTransfer(address _from, address _to, uint256 _value) public onlyLimitedPrinter returns (bytes32 lockId) { lockId = generateLockId(); require (_value != 0); pendingTransferMap[lockId] = transfer(_value, _from, _to); emit TransferRequested(lockId, _from, _to, _value);...
0.5.10
/** @notice Confirms a pending increase in the token supply. * * @dev When called by the custodian with a lock id associated with a * pending ceiling increase, the amount requested is added to the * current supply ceiling. * NOTE: this function will not execute any raise that would overflow the * supply c...
function confirmCeilingRaise(bytes32 _lockId) public onlyCustodian { PendingCeilingRaise storage pendingRaise = pendingRaiseMap[_lockId]; // copy locals of references to struct members uint256 raiseBy = pendingRaise.raiseBy; // accounts for a gibberish _lockId require(rais...
0.5.10
// Transfer token to team
function transferToTeam(address _team) external onlyOwner returns(bool) { require(_team != address(0), "Address is not valid"); require(!teamRelease, "Team release has already done"); if (now > contractDeployed.add(365 days) && team_1_release == false) { balances[_team] = balance...
0.4.24
/** * @dev Function to Release Bounty and Bonus token to Bounty address after Locking period is over * @param _bounty The address of the Bounty * @return A boolean that indicates if the operation was successful. */
function transferToBounty(address _bounty) external onlyOwner returns(bool) { require(_bounty != address(0), "Address is not valid"); require(!bountyrelase, "Bounty release already done"); if (now > contractDeployed.add(180 days) && bounty_1_release == false) { balances[_bounty] ...
0.4.24
/** * @notice Get the current price of a supported cToken underlying * @param cToken The address of the market (token) * @return USD price mantissa or failure for unsupported markets */
function getUnderlyingPrice(address cToken) public view returns (uint256) { string memory cTokenSymbol = CTokenInterface(cToken).symbol(); if (compareStrings(cTokenSymbol, "sETH")) { return getETHUSDCPrice(); } else if (compareStrings(cTokenSymbol, "sUSDC")) { return...
0.6.6
//Init Parameter.
function initialParameter( // address _manager, address _secretSigner, address _erc20tokenAddress , address _refunder, uint _MIN_BET, uint _MAX_BET, uint _maxProfit, uint _MAX_AMOUNT, uint8 _platformFeePercentage, ...
0.4.24
// Funds withdrawal.
function withdrawFunds(address beneficiary, uint withdrawAmount) external onlyOwner { require (withdrawAmount <= address(this).balance && withdrawAmount > 0); uint safetyAmount = jackpotSize.add(lockedInBets).add(withdrawAmount); safetyAmount = safetyAmount.add(withdrawAmount); r...
0.4.24
//Bet by ether: Commits are signed with a block limit to ensure that they are used at most once.
function placeBet(uint8 _rotateTime , uint8 _machineMode , uint _commitLastBlock, uint _commit, bytes32 r, bytes32 s ) external payable { // Check that the bet is in 'clean' state. Bet storage bet = bets[_commit]; require (bet.gambler == address(0)); //Check Secr...
0.4.24
//Get deductedBalance
function getPossibleWinAmount(uint bonusPercentage,uint senderValue)public view returns (uint platformFee,uint jackpotFee,uint possibleWinAmount) { //Platform Fee uint prePlatformFee = (senderValue).mul(platformFeePercentage); platformFee = (prePlatformFee).div(1000); //Get jackp...
0.4.24
// Refund transaction
function refundBet(uint commit) external onlyRefunder{ // Check that bet is in 'active' state. Bet storage bet = bets[commit]; uint amount = bet.amount; uint8 machineMode = bet.machineMode; require (amount != 0, "Bet should be in an 'active' state"); /...
0.4.24
// Helper routine to move 'processed' bets into 'clean' state.
function clearProcessedBet(uint commit) private { Bet storage bet = bets[commit]; // Do not overwrite active bets with zeros if (bet.amount != 0 || block.number <= bet.placeBlockNumber + BetExpirationBlocks) { return; } // Zero out the remaining storage ...
0.4.24
/** * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation * @dev Admin function for new implementation to accept it's role as implementation * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */
function _acceptImplementation() public returns (uint) { // Check caller is pendingImplementation and pendingImplementation ≠ address(0) if (msg.sender != pendingWanFarmImplementation || pendingWanFarmImplementation == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDI...
0.5.16
// Suport the Peeny ICO! Thank you for your support of the Dick Chainy foundation. // If you've altready contributed, you can't contribute again until your coins have // been distributed.
function contribute() public payable { require(icoOpen, "The Peeny ICO has now ended."); require(msg.value >= minimumContributionWei, "Minimum contribution must be at least getMinimumContribution(). "); Funder storage funder = contributions[address(msg.sender)]; require(funder.number...
0.8.7
// If someone is generous and wants to add to pool
function addToPool() public payable { require(msg.value > 0); uint _lotteryPool = msg.value; // weekly and daily pool uint weeklyPoolFee = _lotteryPool.div(5); uint dailyPoolFee = _lotteryPool.sub(weeklyPoolFee); weeklyPool = weeklyPool.add(weeklyPoolFee); daily...
0.4.21
/** * @dev Delegates execution to an implementation contract. * It returns to the external caller whatever the implementation returns * or forwards reverts. */
function () payable external { // delegate all other functions to current implementation (bool success, ) = wanFarmImplementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) returndatacopy(free_mem_ptr, 0, returndatasize) ...
0.5.16
/** * @dev Initializes the data structure. This method is exposed publicly. * @param _stakesToken The ERC-20 token address to be used as stakes * token (GRO). * @param _sharesToken The ERC-20 token address to be used as shares * token (gToken). */
function init(Self storage _self, address _stakesToken, address _sharesToken) public { _self.stakesToken = _stakesToken; _self.sharesToken = _sharesToken; _self.state = State.Created; _self.liquidityPool = address(0); _self.burningRate = DEFAULT_BURNING_RATE; _self.lastBurningTime = 0; _sel...
0.6.12
/** * @dev Burns a portion of the liquidity pool according to the defined * burning rate. It must happen at most once every 7-days. This * method does not actually burn the funds, but it will redeem * the amounts from the pool to the caller contract, which is then * assumed to pe...
function burnPoolPortion(Self storage _self) public returns (uint256 _stakesAmount, uint256 _sharesAmount) { require(_self._hasPool(), "pool not available"); require(now >= _self.lastBurningTime + BURNING_INTERVAL, "must wait lock interval"); _self.lastBurningTime = now; return G.exitPool(_self.liquidityP...
0.6.12
/** * @dev Completes the liquidity pool migration by redeeming all funds * from the pool. This method does not actually transfer the * redemeed funds to the recipient, it assumes the caller contract * will perform that. This method is exposed publicly. * @return _migrationRecipient Th...
function completePoolMigration(Self storage _self) public returns (address _migrationRecipient, uint256 _stakesAmount, uint256 _sharesAmount) { require(_self.state == State.Migrating, "migration not initiated"); require(now >= _self.migrationUnlockTime, "must wait lock interval"); _migrationRecipient = _self...
0.6.12
/** * @dev Receives and executes a batch of function calls on this contract. */
function multicall(bytes[] calldata data) external returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), data[i]); } return results; }
0.8.6
/////////////////////////////////////////////////////////////////// ///// Owners Functions /////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
function registerUserForPreSale(address _erc20, LimitItem[] calldata _wanted, address _user) external onlyOwner { uint256 currLimit; for (uint256 i = 0; i < _wanted.length; i ++){ currLimit = _getUserLimitTotal(_user); require(priceForCard[_erc20][_wanted[i].tokenId].value > 0, ...
0.8.11
/** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - contract owner must have transfer globally allowed. * * Emits a {...
function _transfer(address from, address to, uint256 tokenId) private { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); require(_transferable == true, "ERC721 transfer not permitted by contract ...
0.6.12
/** * @dev Buys a token. Needs to be supplied the correct amount of ether. */
function buyToken() external payable returns (bool) { uint256 paidAmount = msg.value; require(paidAmount == _tokenPrice, "Invalid amount for token purchase"); address to = msg.sender; uint256 nextToken = nextTokenId(); uint256 remainingTokens = 1 + MAX_SUPPLY - nextToke...
0.6.12
/** * @dev Sets someBool for the specified token. Can only be used by the owner of the token (not an approved account). * Owner needs to also own a ticket token to set the someBool attribute. */
function setSomeBool(uint256 tokenId, bool newValue) external { require(_exists(tokenId), "Token ID does not exist"); require(ownerOf(tokenId) == msg.sender, "Only token owner can set attribute"); require(T2(_ticketContract).burnAnyFrom(msg.sender), "Token owner ticket could not be burned"); ...
0.6.12
/** * Executes the OTC deal. Sends the USDC from the beneficiary to Index Governance, and * locks the INDEX in the vesting contract. Can only be called once. */
function swap() external onlyOnce { require(IERC20(index).balanceOf(address(this)) >= indexAmount, "insufficient INDEX"); // Transfer expected USDC from beneficiary IERC20(usdc).safeTransferFrom(beneficiary, address(this), usdcAmount); // Create Vesting contract Vesting vestin...
0.6.10
// Overwrites ERC20._transfer. // If to = _entryCreditContract, sends tokens to the credit contract according to the // exchange rate in credit contract, destroys tokens locally
function _transfer(address from, address to, uint256 value) internal { if (to == _entryCreditContract) { _burn(from, value); IEntryCreditContract entryCreditContractInstance = IEntryCreditContract(to); require(entryCreditContractInstance.mint(from, value), "Failed to ...
0.5.2
// Run destroy for all entries
function batchDestroy(address[] calldata from, uint256[] calldata values) external onlyDestroyer whenPaused whenNotInBME returns (bool) { uint fromLength = from.length; require(fromLength == values.length, "Input arrays must have the same length"); for (uint256 i = ...
0.5.2
/// Update verifier's data
function updateVerifier(uint feeRate, uint baseFee) external { require(feeRate >= 0 && feeRate <= ((10 ** feeRateDecimals) * 100)); require(baseFee >= 0 && baseFee <= 100000000 * 1 ether); Verifier storage verifier = verifiers[msg.sender]; uint oldFeeRate = verifier.feeRate; ...
0.4.24
/// Make a bet
function makeBet(uint makerBetId, uint odds, address trustedVerifier, uint trustedVerifierFeeRate, uint trustedVerifierBaseFee, uint expiry) external payable { require(odds > (10 ** oddsDecimals) && odds < ((10 ** 8) * (10 ** oddsDecimals))); require(expiry > now); MakerBet storage makerBet...
0.4.24
/// Increase total fund of a bet
function addFund(uint makerBetId) external payable { MakerBet storage makerBet = makerBets[makerBetId][msg.sender]; require(makerBet.makerBetId != 0); require(now < makerBet.expiry); require(makerBet.status == BetStatus.Open || makerBet.status == BetStatus.Paused); req...
0.4.24
/// Update odds of a bet
function updateOdds(uint makerBetId, uint odds) external { require(odds > (10 ** oddsDecimals) && odds < ((10 ** 8) * (10 ** oddsDecimals))); MakerBet storage makerBet = makerBets[makerBetId][msg.sender]; require(makerBet.makerBetId != 0); require(now < makerBet.expiry); ...
0.4.24
/// Close a bet and withdraw unused fund
function closeBet(uint makerBetId) external { MakerBet storage makerBet = makerBets[makerBetId][msg.sender]; require(makerBet.makerBetId != 0); require(makerBet.status == BetStatus.Open || makerBet.status == BetStatus.Paused); require(msg.sender == makerBet.maker); mak...
0.4.24
/// Settle a bet by trusted verifier
function settleBet(uint makerBetId, address maker, uint outcome) external { require(outcome == 1 || outcome == 2 || outcome == 3 || outcome == 4); MakerBet storage makerBet = makerBets[makerBetId][maker]; require(makerBet.makerBetId != 0); require(msg.sender == makerBet.trustedVe...
0.4.24
/// Manual withdraw fund from a bet after outcome is set
function withdraw(uint makerBetId, address maker) external { MakerBet storage makerBet = makerBets[makerBetId][maker]; require(makerBet.makerBetId != 0); require(makerBet.outcome != BetOutcome.NotSettled); require(makerBet.status == BetStatus.Settled); bool fullyWithdr...
0.4.24
/// Payout to maker
function payMaker(MakerBet storage makerBet) private returns (bool fullyWithdrawn) { fullyWithdrawn = false; if (!makerBet.makerFundWithdrawn) { makerBet.makerFundWithdrawn = true; uint payout = 0; if (makerBet.outcome == BetOutcome.MakerWin) { ...
0.4.24