Contract Overview
Balance:
0 Ether
More Info
My Name Tag:
Not Available
TokenTracker:
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0xd7ea011478abc120c47a3795e0d1f9e93bb6f679be423fa347b01a77c6513055 | 0x60806040 | 6805636 | 726 days 4 hrs ago | 0xe010ac6e0248790e08f42d5f697160dedf97e024 | IN | Create: Tellor | 0 Ether | 0.01088807 |
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
This contract contains unverified libraries: TellorTransfer, TellorDispute, TellorStake, TellorLibrary
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
Tellor
Compiler Version
v0.5.16+commit.9c3226ce
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2020-07-09 */ pragma solidity >=0.5.0 <0.7.0; /** * @title Tellor Transfer * @dev Contains the methods related to transfers and ERC20. Tellor.sol and TellorGetters.sol * reference this library for function's logic. */ library TellorTransfer { using SafeMath for uint256; event Approval(address indexed _owner, address indexed _spender, uint256 _value); //ERC20 Approval event event Transfer(address indexed _from, address indexed _to, uint256 _value); //ERC20 Transfer Event /*Functions*/ /** * @dev Allows for a transfer of tokens to _to * @param _to The address to send tokens to * @param _amount The amount of tokens to send * @return true if transfer is successful */ function transfer(TellorStorage.TellorStorageStruct storage self, address _to, uint256 _amount) public returns (bool success) { doTransfer(self, msg.sender, _to, _amount); return true; } /** * @notice Send _amount tokens to _to from _from on the condition it * is approved by _from * @param _from The address holding the tokens being transferred * @param _to The address of the recipient * @param _amount The amount of tokens to be transferred * @return True if the transfer was successful */ function transferFrom(TellorStorage.TellorStorageStruct storage self, address _from, address _to, uint256 _amount) public returns (bool success) { require(self.allowed[_from][msg.sender] >= _amount, "Allowance is wrong"); self.allowed[_from][msg.sender] -= _amount; doTransfer(self, _from, _to, _amount); return true; } /** * @dev This function approves a _spender an _amount of tokens to use * @param _spender address * @param _amount amount the spender is being approved for * @return true if spender appproved successfully */ function approve(TellorStorage.TellorStorageStruct storage self, address _spender, uint256 _amount) public returns (bool) { require(_spender != address(0), "Spender is 0-address"); self.allowed[msg.sender][_spender] = _amount; emit Approval(msg.sender, _spender, _amount); return true; } /** * @param _user address of party with the balance * @param _spender address of spender of parties said balance * @return Returns the remaining allowance of tokens granted to the _spender from the _user */ function allowance(TellorStorage.TellorStorageStruct storage self, address _user, address _spender) public view returns (uint256) { return self.allowed[_user][_spender]; } /** * @dev Completes POWO transfers by updating the balances on the current block number * @param _from address to transfer from * @param _to addres to transfer to * @param _amount to transfer */ function doTransfer(TellorStorage.TellorStorageStruct storage self, address _from, address _to, uint256 _amount) public { require(_amount > 0, "Tried to send non-positive amount"); require(_to != address(0), "Receiver is 0 address"); //allowedToTrade checks the stakeAmount is removed from balance if the _user is staked require(allowedToTrade(self, _from, _amount), "Stake amount was not removed from balance"); uint256 previousBalance = balanceOfAt(self, _from, block.number); updateBalanceAtNow(self.balances[_from], previousBalance - _amount); previousBalance = balanceOfAt(self, _to, block.number); require(previousBalance + _amount >= previousBalance, "Overflow happened"); // Check for overflow updateBalanceAtNow(self.balances[_to], previousBalance + _amount); emit Transfer(_from, _to, _amount); } /** * @dev Gets balance of owner specified * @param _user is the owner address used to look up the balance * @return Returns the balance associated with the passed in _user */ function balanceOf(TellorStorage.TellorStorageStruct storage self, address _user) public view returns (uint256) { return balanceOfAt(self, _user, block.number); } /** * @dev Queries the balance of _user at a specific _blockNumber * @param _user The address from which the balance will be retrieved * @param _blockNumber The block number when the balance is queried * @return The balance at _blockNumber specified */ function balanceOfAt(TellorStorage.TellorStorageStruct storage self, address _user, uint256 _blockNumber) public view returns (uint256) { if ((self.balances[_user].length == 0) || (self.balances[_user][0].fromBlock > _blockNumber)) { return 0; } else { return getBalanceAt(self.balances[_user], _blockNumber); } } /** * @dev Getter for balance for owner on the specified _block number * @param checkpoints gets the mapping for the balances[owner] * @param _block is the block number to search the balance on * @return the balance at the checkpoint */ function getBalanceAt(TellorStorage.Checkpoint[] storage checkpoints, uint256 _block) public view returns (uint256) { if (checkpoints.length == 0) return 0; if (_block >= checkpoints[checkpoints.length - 1].fromBlock) return checkpoints[checkpoints.length - 1].value; if (_block < checkpoints[0].fromBlock) return 0; // Binary search of the value in the array uint256 min = 0; uint256 max = checkpoints.length - 1; while (max > min) { uint256 mid = (max + min + 1) / 2; if (checkpoints[mid].fromBlock <= _block) { min = mid; } else { max = mid - 1; } } return checkpoints[min].value; } /** * @dev This function returns whether or not a given user is allowed to trade a given amount * and removing the staked amount from their balance if they are staked * @param _user address of user * @param _amount to check if the user can spend * @return true if they are allowed to spend the amount being checked */ function allowedToTrade(TellorStorage.TellorStorageStruct storage self, address _user, uint256 _amount) public view returns (bool) { if (self.stakerDetails[_user].currentStatus > 0 && self.stakerDetails[_user].currentStatus < 4) { //Removes the stakeAmount from balance if the _user is staked if (balanceOf(self, _user).sub(self.uintVars[keccak256("stakeAmount")]).sub(_amount) >= 0) { return true; } } else if (balanceOf(self, _user).sub(_amount) >= 0) { return true; } return false; } /** * @dev Updates balance for from and to on the current block number via doTransfer * @param checkpoints gets the mapping for the balances[owner] * @param _value is the new balance */ function updateBalanceAtNow(TellorStorage.Checkpoint[] storage checkpoints, uint256 _value) public { if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) { TellorStorage.Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++]; newCheckPoint.fromBlock = uint128(block.number); newCheckPoint.value = uint128(_value); } else { TellorStorage.Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length - 1]; oldCheckPoint.value = uint128(_value); } } } /** * @title Tellor Dispute * @dev Contains the methods related to disputes. Tellor.sol references this library for function's logic. */ library TellorDispute { using SafeMath for uint256; using SafeMath for int256; //emitted when a new dispute is initialized event NewDispute(uint256 indexed _disputeId, uint256 indexed _requestId, uint256 _timestamp, address _miner); //emitted when a new vote happens event Voted(uint256 indexed _disputeID, bool _position, address indexed _voter); //emitted upon dispute tally event DisputeVoteTallied(uint256 indexed _disputeID, int256 _result, address indexed _reportedMiner, address _reportingParty, bool _active); event NewTellorAddress(address _newTellor); //emmited when a proposed fork is voted true /*Functions*/ /** * @dev Helps initialize a dispute by assigning it a disputeId * when a miner returns a false on the validate array(in Tellor.ProofOfWork) it sends the * invalidated value information to POS voting * @param _requestId being disputed * @param _timestamp being disputed * @param _minerIndex the index of the miner that submitted the value being disputed. Since each official value * requires 5 miners to submit a value. */ function beginDispute(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _timestamp, uint256 _minerIndex) public { TellorStorage.Request storage _request = self.requestDetails[_requestId]; //require that no more than a day( (24 hours * 60 minutes)/10minutes=144 blocks) has gone by since the value was "mined" //require(now - _timestamp <= 1 days, "The value was mined more than a day ago"); require(_request.minedBlockNum[_timestamp] > 0, "Mined block is 0"); require(_minerIndex < 5, "Miner index is wrong"); //_miner is the miner being disputed. For every mined value 5 miners are saved in an array and the _minerIndex //provided by the party initiating the dispute address _miner = _request.minersByValue[_timestamp][_minerIndex]; bytes32 _hash = keccak256(abi.encodePacked(_miner, _requestId, _timestamp)); //Increase the dispute count by 1 self.uintVars[keccak256("disputeCount")] = self.uintVars[keccak256("disputeCount")] + 1; //Sets the new disputeCount as the disputeId uint256 disputeId = self.uintVars[keccak256("disputeCount")]; //Ensures that a dispute is not already open for the that miner, requestId and timestamp if(self.disputeIdByDisputeHash[_hash] > 0){ self.disputesById[disputeId].disputeUintVars[keccak256("origID")] = self.disputeIdByDisputeHash[_hash]; } else{ self.disputeIdByDisputeHash[_hash] = disputeId; } uint256 origID = self.disputeIdByDisputeHash[_hash]; self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]++; self.disputesById[origID].disputeUintVars[keccak256(abi.encodePacked(self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]))] = disputeId; if(disputeId != origID){ uint256 lastID = self.disputesById[origID].disputeUintVars[keccak256(abi.encodePacked(self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]-1))]; require(self.disputesById[lastID].disputeUintVars[keccak256("minExecutionDate")] < now, "Dispute is already open"); if(self.disputesById[lastID].executed){ require(now - self.disputesById[lastID].disputeUintVars[keccak256("tallyDate")] <= 1 days, "Time for voting haven't elapsed"); } } uint256 _fee = self.uintVars[keccak256("disputeFee")] * self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]; //maps the dispute hash to the disputeId //maps the dispute to the Dispute struct self.disputesById[disputeId] = TellorStorage.Dispute({ hash: _hash, isPropFork: false, reportedMiner: _miner, reportingParty: msg.sender, proposedForkAddress: address(0), executed: false, disputeVotePassed: false, tally: 0 }); //Saves all the dispute variables for the disputeId self.disputesById[disputeId].disputeUintVars[keccak256("requestId")] = _requestId; self.disputesById[disputeId].disputeUintVars[keccak256("timestamp")] = _timestamp; self.disputesById[disputeId].disputeUintVars[keccak256("value")] = _request.valuesByTimestamp[_timestamp][_minerIndex]; self.disputesById[disputeId].disputeUintVars[keccak256("minExecutionDate")] = now + 2 days * self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]; self.disputesById[disputeId].disputeUintVars[keccak256("blockNumber")] = block.number; self.disputesById[disputeId].disputeUintVars[keccak256("minerSlot")] = _minerIndex; self.disputesById[disputeId].disputeUintVars[keccak256("fee")] = _fee; TellorTransfer.doTransfer(self, msg.sender, address(this),_fee); //Values are sorted as they come in and the official value is the median of the first five //So the "official value" miner is always minerIndex==2. If the official value is being //disputed, it sets its status to inDispute(currentStatus = 3) so that users are made aware it is under dispute if (_minerIndex == 2) { _request.inDispute[_timestamp] = true; _request.finalValues[_timestamp] = 0; } if (self.stakerDetails[_miner].currentStatus != 4){ self.stakerDetails[_miner].currentStatus = 3; } emit NewDispute(disputeId, _requestId, _timestamp, _miner); } /** * @dev Allows token holders to vote * @param _disputeId is the dispute id * @param _supportsDispute is the vote (true=the dispute has basis false = vote against dispute) */ function vote(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId, bool _supportsDispute) public { TellorStorage.Dispute storage disp = self.disputesById[_disputeId]; //Get the voteWeight or the balance of the user at the time/blockNumber the disupte began uint256 voteWeight = TellorTransfer.balanceOfAt(self, msg.sender, disp.disputeUintVars[keccak256("blockNumber")]); //Require that the msg.sender has not voted require(disp.voted[msg.sender] != true, "Sender has already voted"); //Requre that the user had a balance >0 at time/blockNumber the disupte began require(voteWeight > 0, "User balance is 0"); //ensures miners that are under dispute cannot vote require(self.stakerDetails[msg.sender].currentStatus != 3, "Miner is under dispute"); //Update user voting status to true disp.voted[msg.sender] = true; //Update the number of votes for the dispute disp.disputeUintVars[keccak256("numberOfVotes")] += 1; //If the user supports the dispute increase the tally for the dispute by the voteWeight //otherwise decrease it if (_supportsDispute) { disp.tally = disp.tally.add(int256(voteWeight)); } else { disp.tally = disp.tally.sub(int256(voteWeight)); } //Let the network know the user has voted on the dispute and their casted vote emit Voted(_disputeId, _supportsDispute, msg.sender); } /** * @dev tallies the votes. * @param _disputeId is the dispute id */ function tallyVotes(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId) public { TellorStorage.Dispute storage disp = self.disputesById[_disputeId]; //Ensure this has not already been executed/tallied require(disp.executed == false, "Dispute has been already executed"); require(now > disp.disputeUintVars[keccak256("minExecutionDate")], "Time for voting haven't elapsed"); require(disp.reportingParty != address(0)); //If the vote is not a proposed fork if (disp.isPropFork == false) { //Ensure the time for voting has elapsed TellorStorage.StakeInfo storage stakes = self.stakerDetails[disp.reportedMiner]; //If the vote for disputing a value is succesful(disp.tally >0) then unstake the reported // miner and transfer the stakeAmount and dispute fee to the reporting party if (disp.tally > 0) { //Set the dispute state to passed/true disp.disputeVotePassed = true; } if(stakes.currentStatus == 3){ stakes.currentStatus = 4; } } else { if (disp.tally > 0 && uint(disp.tally) >= ((self.uintVars[keccak256("total_supply")] * 10) / 100)) { disp.disputeVotePassed = true; emit NewTellorAddress(disp.proposedForkAddress); } } disp.disputeUintVars[keccak256("tallyDate")] = now; disp.executed = true; emit DisputeVoteTallied(_disputeId, disp.tally, disp.reportedMiner, disp.reportingParty, disp.disputeVotePassed); } /** * @dev Allows for a fork to be proposed * @param _propNewTellorAddress address for new proposed Tellor */ function proposeFork(TellorStorage.TellorStorageStruct storage self, address _propNewTellorAddress) public { bytes32 _hash = keccak256(abi.encodePacked(_propNewTellorAddress)); TellorTransfer.doTransfer(self, msg.sender, address(this), 100e18); //This is the fork fee (just 100 tokens flat, no refunds) self.uintVars[keccak256("disputeCount")]++; uint256 disputeId = self.uintVars[keccak256("disputeCount")]; if(self.disputeIdByDisputeHash[_hash] > 0){ self.disputesById[disputeId].disputeUintVars[keccak256("origID")] = self.disputeIdByDisputeHash[_hash]; } else{ self.disputeIdByDisputeHash[_hash] = disputeId; } uint256 origID = self.disputeIdByDisputeHash[_hash]; self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]++; self.disputesById[origID].disputeUintVars[keccak256(abi.encodePacked(self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]))] = disputeId; if(disputeId != origID){ uint256 lastID = self.disputesById[origID].disputeUintVars[keccak256(abi.encodePacked(self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]-1))]; require(self.disputesById[lastID].disputeUintVars[keccak256("minExecutionDate")] < now, "Dispute is already open"); if(self.disputesById[lastID].executed){ require(now - self.disputesById[lastID].disputeUintVars[keccak256("tallyDate")] <= 1 days, "Time for voting haven't elapsed"); } } self.disputesById[disputeId] = TellorStorage.Dispute({ hash: _hash, isPropFork: true, reportedMiner: msg.sender, reportingParty: msg.sender, proposedForkAddress: _propNewTellorAddress, executed: false, disputeVotePassed: false, tally: 0 }); self.disputesById[disputeId].disputeUintVars[keccak256("blockNumber")] = block.number; self.disputesById[disputeId].disputeUintVars[keccak256("minExecutionDate")] = now + 7 days; } /** * @dev Updates the Tellor address after a proposed fork has * passed the vote and day has gone by without a dispute * @param _disputeId the disputeId for the proposed fork */ function updateTellor(TellorStorage.TellorStorageStruct storage self, uint _disputeId) public { bytes32 _hash = self.disputesById[_disputeId].hash; uint256 origID = self.disputeIdByDisputeHash[_hash]; uint256 lastID = self.disputesById[origID].disputeUintVars[keccak256(abi.encodePacked(self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]))]; TellorStorage.Dispute storage disp = self.disputesById[lastID]; require(disp.disputeVotePassed == true, "vote needs to pass"); require(now - disp.disputeUintVars[keccak256("tallyDate")] > 1 days, "Time for voting for further disputes has not passed"); self.addressVars[keccak256("tellorContract")] = disp.proposedForkAddress; } /** * @dev Allows disputer to unlock the dispute fee * @param _disputeId to unlock fee from */ function unlockDisputeFee (TellorStorage.TellorStorageStruct storage self, uint _disputeId) public { bytes32 _hash = self.disputesById[_disputeId].hash; uint256 origID = self.disputeIdByDisputeHash[_hash]; uint256 lastID = self.disputesById[origID].disputeUintVars[keccak256(abi.encodePacked(self.disputesById[origID].disputeUintVars[keccak256("disputeRounds")]))]; if(lastID == 0){ lastID = origID; } TellorStorage.Dispute storage disp = self.disputesById[origID]; TellorStorage.Dispute storage last = self.disputesById[lastID]; if(disp.disputeUintVars[keccak256("disputeRounds")] == 0){ disp.disputeUintVars[keccak256("disputeRounds")] = 1; } require(disp.disputeUintVars[keccak256("paid")] == 0,"already paid out"); require(now - last.disputeUintVars[keccak256("tallyDate")] > 1 days, "Time for voting haven't elapsed"); TellorStorage.StakeInfo storage stakes = self.stakerDetails[disp.reportedMiner]; disp.disputeUintVars[keccak256("paid")] = 1; if (last.disputeVotePassed == true){ //Changing the currentStatus and startDate unstakes the reported miner and transfers the stakeAmount stakes.startDate = now - (now % 86400); //Reduce the staker count self.uintVars[keccak256("stakerCount")] -= 1; //Update the minimum dispute fee that is based on the number of stakers updateMinDisputeFee(self); //Decreases the stakerCount since the miner's stake is being slashed if(stakes.currentStatus == 4){ TellorTransfer.doTransfer(self,disp.reportedMiner,disp.reportingParty,self.uintVars[keccak256("stakeAmount")]); stakes.currentStatus =0 ; } for(uint i = 0; i < disp.disputeUintVars[keccak256("disputeRounds")];i++){ uint256 _id = disp.disputeUintVars[keccak256(abi.encodePacked(disp.disputeUintVars[keccak256("disputeRounds")]-i))]; if(_id == 0){ _id = origID; } TellorStorage.Dispute storage disp2 = self.disputesById[_id]; TellorTransfer.doTransfer(self,address(this),disp2.reportingParty,disp2.disputeUintVars[keccak256("fee")]); } } else { stakes.currentStatus = 1; TellorStorage.Request storage _request = self.requestDetails[disp.disputeUintVars[keccak256("requestId")]]; if(disp.disputeUintVars[keccak256("minerSlot")] == 2) { //note we still don't put timestamp back into array (is this an issue? (shouldn't be)) _request.finalValues[disp.disputeUintVars[keccak256("timestamp")]] = disp.disputeUintVars[keccak256("value")]; } if (_request.inDispute[disp.disputeUintVars[keccak256("timestamp")]] == true) { _request.inDispute[disp.disputeUintVars[keccak256("timestamp")]] = false; } for(uint i = 0; i < disp.disputeUintVars[keccak256("disputeRounds")];i++){ uint256 _id = disp.disputeUintVars[keccak256(abi.encodePacked(disp.disputeUintVars[keccak256("disputeRounds")]-i))]; if(_id != 0){ last = self.disputesById[_id];//handling if happens during an upgrade } TellorTransfer.doTransfer(self,address(this),last.reportedMiner,self.disputesById[_id].disputeUintVars[keccak256("fee")]); } } } /** * @dev This function upates the minimun dispute fee as a function of the amount * of staked miners */ function updateMinDisputeFee(TellorStorage.TellorStorageStruct storage self) public { self.uintVars[keccak256("disputeFee")] = SafeMath.max(15e18, (self.uintVars[keccak256("stakeAmount")]- (self.uintVars[keccak256("stakeAmount")]* (SafeMath.min(self.uintVars[keccak256("targetMiners")],self.uintVars[keccak256("stakerCount")])*1000)/ self.uintVars[keccak256("targetMiners")])/1000)); } } /** * itle Tellor Stake * @dev Contains the methods related to miners staking and unstaking. Tellor.sol * references this library for function's logic. */ library TellorStake { event NewStake(address indexed _sender); //Emits upon new staker event StakeWithdrawn(address indexed _sender); //Emits when a staker is now no longer staked event StakeWithdrawRequested(address indexed _sender); //Emits when a staker begins the 7 day withdraw period /*Functions*/ /** * @dev This function stakes the five initial miners, sets the supply and all the constant variables. * This function is called by the constructor function on TellorMaster.sol */ function init(TellorStorage.TellorStorageStruct storage self) public { require(self.uintVars[keccak256("decimals")] == 0, "Too many decimals"); //Give this contract 6000 Tellor Tributes so that it can stake the initial 6 miners TellorTransfer.updateBalanceAtNow(self.balances[address(this)], 2**256 - 1 - 6000e18); // //the initial 5 miner addresses are specfied below // //changed payable[5] to 6 address payable[6] memory _initalMiners = [ address(0xE037EC8EC9ec423826750853899394dE7F024fee), address(0xcdd8FA31AF8475574B8909F135d510579a8087d3), address(0xb9dD5AfD86547Df817DA2d0Fb89334A6F8eDd891), address(0x230570cD052f40E14C14a81038c6f3aa685d712B), address(0x3233afA02644CCd048587F8ba6e99b3C00A34DcC), address(0xe010aC6e0248790e08F42d5F697160DEDf97E024) ]; //Stake each of the 5 miners specified above for (uint256 i = 0; i < 6; i++) { //6th miner to allow for dispute //Miner balance is set at 1000e18 at the block that this function is ran TellorTransfer.updateBalanceAtNow(self.balances[_initalMiners[i]], 1000e18); newStake(self, _initalMiners[i]); } //update the total suppply self.uintVars[keccak256("total_supply")] += 6000e18; //6th miner to allow for dispute //set Constants self.uintVars[keccak256("decimals")] = 18; self.uintVars[keccak256("targetMiners")] = 200; self.uintVars[keccak256("stakeAmount")] = 1000e18; self.uintVars[keccak256("disputeFee")] = 970e18; self.uintVars[keccak256("timeTarget")] = 600; self.uintVars[keccak256("timeOfLastNewValue")] = now - (now % self.uintVars[keccak256("timeTarget")]); self.uintVars[keccak256("difficulty")] = 1; } /** * @dev This function allows stakers to request to withdraw their stake (no longer stake) * once they lock for withdraw(stakes.currentStatus = 2) they are locked for 7 days before they * can withdraw the deposit */ function requestStakingWithdraw(TellorStorage.TellorStorageStruct storage self) public { TellorStorage.StakeInfo storage stakes = self.stakerDetails[msg.sender]; //Require that the miner is staked require(stakes.currentStatus == 1, "Miner is not staked"); //Change the miner staked to locked to be withdrawStake stakes.currentStatus = 2; //Change the startDate to now since the lock up period begins now //and the miner can only withdraw 7 days later from now(check the withdraw function) stakes.startDate = now - (now % 86400); //Reduce the staker count self.uintVars[keccak256("stakerCount")] -= 1; //Update the minimum dispute fee that is based on the number of stakers TellorDispute.updateMinDisputeFee(self); emit StakeWithdrawRequested(msg.sender); } /** * @dev This function allows users to withdraw their stake after a 7 day waiting period from request */ function withdrawStake(TellorStorage.TellorStorageStruct storage self) public { TellorStorage.StakeInfo storage stakes = self.stakerDetails[msg.sender]; //Require the staker has locked for withdraw(currentStatus ==2) and that 7 days have //passed by since they locked for withdraw require(now - (now % 86400) - stakes.startDate >= 7 days, "7 days didn't pass"); require(stakes.currentStatus == 2, "Miner was not locked for withdrawal"); stakes.currentStatus = 0; emit StakeWithdrawn(msg.sender); } /** * @dev This function allows miners to deposit their stake. */ function depositStake(TellorStorage.TellorStorageStruct storage self) public { newStake(self, msg.sender); //self adjusting disputeFee TellorDispute.updateMinDisputeFee(self); } /** * @dev This function is used by the init function to succesfully stake the initial 5 miners. * The function updates their status/state and status start date so they are locked it so they can't withdraw * and updates the number of stakers in the system. */ function newStake(TellorStorage.TellorStorageStruct storage self, address staker) internal { require(TellorTransfer.balanceOf(self, staker) >= self.uintVars[keccak256("stakeAmount")], "Balance is lower than stake amount"); //Ensure they can only stake if they are not currrently staked or if their stake time frame has ended //and they are currently locked for witdhraw require(self.stakerDetails[staker].currentStatus == 0 || self.stakerDetails[staker].currentStatus == 2, "Miner is in the wrong state"); self.uintVars[keccak256("stakerCount")] += 1; self.stakerDetails[staker] = TellorStorage.StakeInfo({ currentStatus: 1, //this resets their stake start date to today startDate: now - (now % 86400) }); emit NewStake(staker); } /** * @dev Getter function for the requestId being mined * @return variables for the current minin event: Challenge, 5 RequestId, difficulty and Totaltips */ function getNewCurrentVariables(TellorStorage.TellorStorageStruct storage self) internal view returns(bytes32 _challenge,uint[5] memory _requestIds,uint256 _difficutly, uint256 _tip){ for(uint i=0;i<5;i++){ _requestIds[i] = self.currentMiners[i].value; } return (self.currentChallenge,_requestIds,self.uintVars[keccak256("difficulty")],self.uintVars[keccak256("currentTotalTips")]); } /** * @dev Getter function for next requestId on queue/request with highest payout at time the function is called * @return onDeck/info on top 5 requests(highest payout)-- RequestId, Totaltips */ function getNewVariablesOnDeck(TellorStorage.TellorStorageStruct storage self) internal view returns (uint256[5] memory idsOnDeck, uint256[5] memory tipsOnDeck) { idsOnDeck = getTopRequestIDs(self); for(uint i = 0;i<5;i++){ tipsOnDeck[i] = self.requestDetails[idsOnDeck[i]].apiUintVars[keccak256("totalTip")]; } } /** * @dev Getter function for the top 5 requests with highest payouts. This function is used within the getNewVariablesOnDeck function * @return uint256[5] is an array with the top 5(highest payout) _requestIds at the time the function is called */ function getTopRequestIDs(TellorStorage.TellorStorageStruct storage self) internal view returns (uint256[5] memory _requestIds) { uint256[5] memory _max; uint256[5] memory _index; (_max, _index) = Utilities.getMax5(self.requestQ); for(uint i=0;i<5;i++){ if(_max[i] > 0){ _requestIds[i] = self.requestIdByRequestQIndex[_index[i]]; } else{ _requestIds[i] = self.currentMiners[4-i].value; } } } } //Slightly modified SafeMath library - includes a min and max function, removes useless div function library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function add(int256 a, int256 b) internal pure returns (int256 c) { if (b > 0) { c = a + b; assert(c >= a); } else { c = a + b; assert(c <= a); } } function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } function max(int256 a, int256 b) internal pure returns (uint256) { return a > b ? uint256(a) : uint256(b); } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function sub(int256 a, int256 b) internal pure returns (int256 c) { if (b > 0) { c = a - b; assert(c <= a); } else { c = a - b; assert(c >= a); } } } /** * @title Tellor Oracle Storage Library * @dev Contains all the variables/structs used by Tellor */ library TellorStorage { //Internal struct for use in proof-of-work submission struct Details { uint256 value; address miner; } struct Dispute { bytes32 hash; //unique hash of dispute: keccak256(_miner,_requestId,_timestamp) int256 tally; //current tally of votes for - against measure bool executed; //is the dispute settled bool disputeVotePassed; //did the vote pass? bool isPropFork; //true for fork proposal NEW address reportedMiner; //miner who alledgedly submitted the 'bad value' will get disputeFee if dispute vote fails address reportingParty; //miner reporting the 'bad value'-pay disputeFee will get reportedMiner's stake if dispute vote passes address proposedForkAddress; //new fork address (if fork proposal) mapping(bytes32 => uint256) disputeUintVars; //Each of the variables below is saved in the mapping disputeUintVars for each disputeID //e.g. TellorStorageStruct.DisputeById[disputeID].disputeUintVars[keccak256("requestId")] //These are the variables saved in this mapping: // uint keccak256("requestId");//apiID of disputed value // uint keccak256("timestamp");//timestamp of distputed value // uint keccak256("value"); //the value being disputed // uint keccak256("minExecutionDate");//7 days from when dispute initialized // uint keccak256("numberOfVotes");//the number of parties who have voted on the measure // uint keccak256("blockNumber");// the blocknumber for which votes will be calculated from // uint keccak256("minerSlot"); //index in dispute array // uint keccak256("fee"); //fee paid corresponding to dispute mapping(address => bool) voted; //mapping of address to whether or not they voted } struct StakeInfo { uint256 currentStatus; //0-not Staked, 1=Staked, 2=LockedForWithdraw 3= OnDispute uint256 startDate; //stake start date } //Internal struct to allow balances to be queried by blocknumber for voting purposes struct Checkpoint { uint128 fromBlock; // fromBlock is the block number that the value was generated from uint128 value; // value is the amount of tokens at a specific block number } struct Request { string queryString; //id to string api string dataSymbol; //short name for api request bytes32 queryHash; //hash of api string and granularity e.g. keccak256(abi.encodePacked(_sapi,_granularity)) uint256[] requestTimestamps; //array of all newValueTimestamps requested mapping(bytes32 => uint256) apiUintVars; //Each of the variables below is saved in the mapping apiUintVars for each api request //e.g. requestDetails[_requestId].apiUintVars[keccak256("totalTip")] //These are the variables saved in this mapping: // uint keccak256("granularity"); //multiplier for miners // uint keccak256("requestQPosition"); //index in requestQ // uint keccak256("totalTip");//bonus portion of payout mapping(uint256 => uint256) minedBlockNum; //[apiId][minedTimestamp]=>block.number //This the time series of finalValues stored by the contract where uint UNIX timestamp is mapped to value mapping(uint256 => uint256) finalValues; mapping(uint256 => bool) inDispute; //checks if API id is in dispute or finalized. mapping(uint256 => address[5]) minersByValue; mapping(uint256 => uint256[5]) valuesByTimestamp; } struct TellorStorageStruct { bytes32 currentChallenge; //current challenge to be solved uint256[51] requestQ; //uint50 array of the top50 requests by payment amount uint256[] newValueTimestamps; //array of all timestamps requested Details[5] currentMiners; //This struct is for organizing the five mined values to find the median mapping(bytes32 => address) addressVars; //Address fields in the Tellor contract are saved the addressVars mapping //e.g. addressVars[keccak256("tellorContract")] = address //These are the variables saved in this mapping: // address keccak256("tellorContract");//Tellor address // address keccak256("_owner");//Tellor Owner address // address keccak256("_deity");//Tellor Owner that can do things at will mapping(bytes32 => uint256) uintVars; //uint fields in the Tellor contract are saved the uintVars mapping //e.g. uintVars[keccak256("decimals")] = uint //These are the variables saved in this mapping: // keccak256("decimals"); //18 decimal standard ERC20 // keccak256("disputeFee");//cost to dispute a mined value // keccak256("disputeCount");//totalHistoricalDisputes // keccak256("total_supply"); //total_supply of the token in circulation // keccak256("stakeAmount");//stakeAmount for miners (we can cut gas if we just hardcode it in...or should it be variable?) // keccak256("stakerCount"); //number of parties currently staked // keccak256("timeOfLastNewValue"); // time of last challenge solved // keccak256("difficulty"); // Difficulty of current block // keccak256("currentTotalTips"); //value of highest api/timestamp PayoutPool // keccak256("currentRequestId"); //API being mined--updates with the ApiOnQ Id // keccak256("requestCount"); // total number of requests through the system // keccak256("slotProgress");//Number of miners who have mined this value so far // keccak256("miningReward");//Mining Reward in PoWo tokens given to all miners per value // keccak256("timeTarget"); //The time between blocks (mined Oracle values) //This is a boolean that tells you if a given challenge has been completed by a given miner mapping(bytes32 => mapping(address => bool)) minersByChallenge; mapping(uint256 => uint256) requestIdByTimestamp; //minedTimestamp to apiId mapping(uint256 => uint256) requestIdByRequestQIndex; //link from payoutPoolIndex (position in payout pool array) to apiId mapping(uint256 => Dispute) disputesById; //disputeId=> Dispute details mapping(address => Checkpoint[]) balances; //balances of a party given blocks mapping(address => mapping(address => uint256)) allowed; //allowance for a given party and approver mapping(address => StakeInfo) stakerDetails; //mapping from a persons address to their staking info mapping(uint256 => Request) requestDetails; //mapping of apiID to details mapping(bytes32 => uint256) requestIdByQueryHash; // api bytes32 gets an id = to count of requests array mapping(bytes32 => uint256) disputeIdByDisputeHash; //maps a hash to an ID for each dispute } } //Functions for retrieving min and Max in 51 length array (requestQ) //Taken partly from: https://github.com/modular-network/ethereum-libraries-array-utils/blob/master/contracts/Array256Lib.sol library Utilities { /** * @dev Returns the minimum value in an array. * The zero position here is ignored. It's because * there's no null in solidity and we map each address * to an index in this array. So when we get 51 parties, * and one person is kicked out of the top 50, we * assign them a 0, and when you get mined and pulled * out of the top 50, also a 0. So then lot's of parties * will have zero as the index so we made the array run * from 1-51 with zero as nothing. * @param data is the array to calculate max from * @return max amount and its index within the array */ function getMax(uint256[51] memory data) internal pure returns (uint256 max, uint256 maxIndex) { max = data[1]; maxIndex = 1; for (uint256 i = 1; i < data.length; i++) { if (data[i] > max) { max = data[i]; maxIndex = i; } } } /** * @dev Returns the minimum value in an array. * @param data is the array to calculate min from * @return min amount and its index within the array */ function getMin(uint256[51] memory data) internal pure returns (uint256 min, uint256 minIndex) { minIndex = data.length - 1; min = data[minIndex]; for (uint256 i = data.length - 1; i > 0; i--) { if (data[i] < min) { min = data[i]; minIndex = i; } } } /** * @dev Returns the 5 requestsId's with the top payouts in an array. * @param data is the array to get the top 5 from * @return to 5 max amounts and their respective index within the array */ function getMax5(uint256[51] memory data) internal pure returns (uint256[5] memory max, uint256[5] memory maxIndex) { uint256 min5 = data[1]; uint256 minI = 1; for(uint256 j=0;j<5;j++){ max[j]= data[j+1];//max[0]=data[1] maxIndex[j] = j+1;//maxIndex[0]= 1 if(max[j] < min5){ min5 = max[j]; minI = j; } } for(uint256 i = 5; i < data.length; i++) { if (data[i] > min5) { max[minI] = data[i]; maxIndex[minI] = i; min5 = data[i]; for(uint256 j=0;j<5;j++){ if(max[j] < min5){ min5 = max[j]; minI = j; } } } } } } /** * @title Tellor Getters Library * @dev This is the getter library for all variables in the Tellor Tributes system. TellorGetters references this * libary for the getters logic */ library TellorGettersLibrary { using SafeMath for uint256; event NewTellorAddress(address _newTellor); //emmited when a proposed fork is voted true /*Functions*/ //The next two functions are onlyOwner functions. For Tellor to be truly decentralized, we will need to transfer the Deity to the 0 address. //Only needs to be in library /** * @dev This function allows us to set a new Deity (or remove it) * @param _newDeity address of the new Deity of the tellor system */ function changeDeity(TellorStorage.TellorStorageStruct storage self, address _newDeity) internal { require(self.addressVars[keccak256("_deity")] == msg.sender, "Sender is not deity"); self.addressVars[keccak256("_deity")] = _newDeity; } //Only needs to be in library /** * @dev This function allows the deity to upgrade the Tellor System * @param _tellorContract address of new updated TellorCore contract */ function changeTellorContract(TellorStorage.TellorStorageStruct storage self, address _tellorContract) internal { require(self.addressVars[keccak256("_deity")] == msg.sender, "Sender is not deity"); self.addressVars[keccak256("tellorContract")] = _tellorContract; emit NewTellorAddress(_tellorContract); } /*Tellor Getters*/ /** * @dev This function tells you if a given challenge has been completed by a given miner * @param _challenge the challenge to search for * @param _miner address that you want to know if they solved the challenge * @return true if the _miner address provided solved the */ function didMine(TellorStorage.TellorStorageStruct storage self, bytes32 _challenge, address _miner) public view returns (bool) { return self.minersByChallenge[_challenge][_miner]; } /** * @dev Checks if an address voted in a dispute * @param _disputeId to look up * @param _address of voting party to look up * @return bool of whether or not party voted */ function didVote(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId, address _address) internal view returns (bool) { return self.disputesById[_disputeId].voted[_address]; } /** * @dev allows Tellor to read data from the addressVars mapping * @param _data is the keccak256("variable_name") of the variable that is being accessed. * These are examples of how the variables are saved within other functions: * addressVars[keccak256("_owner")] * addressVars[keccak256("tellorContract")] */ function getAddressVars(TellorStorage.TellorStorageStruct storage self, bytes32 _data) internal view returns (address) { return self.addressVars[_data]; } /** * @dev Gets all dispute variables * @param _disputeId to look up * @return bytes32 hash of dispute * @return bool executed where true if it has been voted on * @return bool disputeVotePassed * @return bool isPropFork true if the dispute is a proposed fork * @return address of reportedMiner * @return address of reportingParty * @return address of proposedForkAddress * @return uint of requestId * @return uint of timestamp * @return uint of value * @return uint of minExecutionDate * @return uint of numberOfVotes * @return uint of blocknumber * @return uint of minerSlot * @return uint of quorum * @return uint of fee * @return int count of the current tally */ function getAllDisputeVars(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId) internal view returns (bytes32, bool, bool, bool, address, address, address, uint256[9] memory, int256) { TellorStorage.Dispute storage disp = self.disputesById[_disputeId]; return ( disp.hash, disp.executed, disp.disputeVotePassed, disp.isPropFork, disp.reportedMiner, disp.reportingParty, disp.proposedForkAddress, [ disp.disputeUintVars[keccak256("requestId")], disp.disputeUintVars[keccak256("timestamp")], disp.disputeUintVars[keccak256("value")], disp.disputeUintVars[keccak256("minExecutionDate")], disp.disputeUintVars[keccak256("numberOfVotes")], disp.disputeUintVars[keccak256("blockNumber")], disp.disputeUintVars[keccak256("minerSlot")], disp.disputeUintVars[keccak256("quorum")], disp.disputeUintVars[keccak256("fee")] ], disp.tally ); } /** * @dev Getter function for variables for the requestId being currently mined(currentRequestId) * @return current challenge, curretnRequestId, level of difficulty, api/query string, and granularity(number of decimals requested), total tip for the request */ function getCurrentVariables(TellorStorage.TellorStorageStruct storage self) internal view returns (bytes32, uint256, uint256, string memory, uint256, uint256) { return ( self.currentChallenge, self.uintVars[keccak256("currentRequestId")], self.uintVars[keccak256("difficulty")], self.requestDetails[self.uintVars[keccak256("currentRequestId")]].queryString, self.requestDetails[self.uintVars[keccak256("currentRequestId")]].apiUintVars[keccak256("granularity")], self.requestDetails[self.uintVars[keccak256("currentRequestId")]].apiUintVars[keccak256("totalTip")] ); } /** * @dev Checks if a given hash of miner,requestId has been disputed * @param _hash is the sha256(abi.encodePacked(_miners[2],_requestId)); * @return uint disputeId */ function getDisputeIdByDisputeHash(TellorStorage.TellorStorageStruct storage self, bytes32 _hash) internal view returns (uint256) { return self.disputeIdByDisputeHash[_hash]; } /** * @dev Checks for uint variables in the disputeUintVars mapping based on the disuputeId * @param _disputeId is the dispute id; * @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is * the variables/strings used to save the data in the mapping. The variables names are * commented out under the disputeUintVars under the Dispute struct * @return uint value for the bytes32 data submitted */ function getDisputeUintVars(TellorStorage.TellorStorageStruct storage self, uint256 _disputeId, bytes32 _data) internal view returns (uint256) { return self.disputesById[_disputeId].disputeUintVars[_data]; } /** * @dev Gets the a value for the latest timestamp available * @return value for timestamp of last proof of work submited * @return true if the is a timestamp for the lastNewValue */ function getLastNewValue(TellorStorage.TellorStorageStruct storage self) internal view returns (uint256, bool) { return ( retrieveData( self, self.requestIdByTimestamp[self.uintVars[keccak256("timeOfLastNewValue")]], self.uintVars[keccak256("timeOfLastNewValue")] ), true ); } /** * @dev Gets the a value for the latest timestamp available * @param _requestId being requested * @return value for timestamp of last proof of work submited and if true if it exist or 0 and false if it doesn't */ function getLastNewValueById(TellorStorage.TellorStorageStruct storage self, uint256 _requestId) internal view returns (uint256, bool) { TellorStorage.Request storage _request = self.requestDetails[_requestId]; if (_request.requestTimestamps.length > 0) { return (retrieveData(self, _requestId, _request.requestTimestamps[_request.requestTimestamps.length - 1]), true); } else { return (0, false); } } /** * @dev Gets blocknumber for mined timestamp * @param _requestId to look up * @param _timestamp is the timestamp to look up blocknumber * @return uint of the blocknumber which the dispute was mined */ function getMinedBlockNum(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _timestamp) internal view returns (uint256) { return self.requestDetails[_requestId].minedBlockNum[_timestamp]; } /** * @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp * @param _requestId to look up * @param _timestamp is the timestamp to look up miners for * @return the 5 miners' addresses */ function getMinersByRequestIdAndTimestamp(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _timestamp) internal view returns (address[5] memory) { return self.requestDetails[_requestId].minersByValue[_timestamp]; } /** * @dev Get the name of the token * @return string of the token name */ /* function getName(TellorStorage.TellorStorageStruct storage self) internal pure returns (string memory) { return "Tellor Tributes"; }*/ /** * @dev Counts the number of values that have been submited for the request * if called for the currentRequest being mined it can tell you how many miners have submitted a value for that * request so far * @param _requestId the requestId to look up * @return uint count of the number of values received for the requestId */ function getNewValueCountbyRequestId(TellorStorage.TellorStorageStruct storage self, uint256 _requestId) internal view returns (uint256) { return self.requestDetails[_requestId].requestTimestamps.length; } /** * @dev Getter function for the specified requestQ index * @param _index to look up in the requestQ array * @return uint of reqeuestId */ function getRequestIdByRequestQIndex(TellorStorage.TellorStorageStruct storage self, uint256 _index) internal view returns (uint256) { require(_index <= 50, "RequestQ index is above 50"); return self.requestIdByRequestQIndex[_index]; } /** * @dev Getter function for requestId based on timestamp * @param _timestamp to check requestId * @return uint of reqeuestId */ function getRequestIdByTimestamp(TellorStorage.TellorStorageStruct storage self, uint256 _timestamp) internal view returns (uint256) { return self.requestIdByTimestamp[_timestamp]; } /** * @dev Getter function for requestId based on the qeuaryHash * @param _queryHash hash(of string api and granularity) to check if a request already exists * @return uint requestId */ function getRequestIdByQueryHash(TellorStorage.TellorStorageStruct storage self, bytes32 _queryHash) internal view returns (uint256) { return self.requestIdByQueryHash[_queryHash]; } /** * @dev Getter function for the requestQ array * @return the requestQ arrray */ function getRequestQ(TellorStorage.TellorStorageStruct storage self) internal view returns (uint256[51] memory) { return self.requestQ; } /** * @dev Allowes access to the uint variables saved in the apiUintVars under the requestDetails struct * for the requestId specified * @param _requestId to look up * @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is * the variables/strings used to save the data in the mapping. The variables names are * commented out under the apiUintVars under the requestDetails struct * @return uint value of the apiUintVars specified in _data for the requestId specified */ function getRequestUintVars(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, bytes32 _data) internal view returns (uint256) { return self.requestDetails[_requestId].apiUintVars[_data]; } /** * @dev Gets the API struct variables that are not mappings * @param _requestId to look up * @return string of api to query * @return string of symbol of api to query * @return bytes32 hash of string * @return bytes32 of the granularity(decimal places) requested * @return uint of index in requestQ array * @return uint of current payout/tip for this requestId */ function getRequestVars(TellorStorage.TellorStorageStruct storage self, uint256 _requestId) internal view returns (string memory, string memory, bytes32, uint256, uint256, uint256) { TellorStorage.Request storage _request = self.requestDetails[_requestId]; return ( _request.queryString, _request.dataSymbol, _request.queryHash, _request.apiUintVars[keccak256("granularity")], _request.apiUintVars[keccak256("requestQPosition")], _request.apiUintVars[keccak256("totalTip")] ); } /** * @dev This function allows users to retireve all information about a staker * @param _staker address of staker inquiring about * @return uint current state of staker * @return uint startDate of staking */ function getStakerInfo(TellorStorage.TellorStorageStruct storage self, address _staker) internal view returns (uint256, uint256) { return (self.stakerDetails[_staker].currentStatus, self.stakerDetails[_staker].startDate); } /** * @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp * @param _requestId to look up * @param _timestamp is the timestampt to look up miners for * @return address[5] array of 5 addresses ofminers that mined the requestId */ function getSubmissionsByTimestamp(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _timestamp) internal view returns (uint256[5] memory) { return self.requestDetails[_requestId].valuesByTimestamp[_timestamp]; } /** * @dev Get the symbol of the token * @return string of the token symbol */ /* function getSymbol(TellorStorage.TellorStorageStruct storage self) internal pure returns (string memory) { return "TT"; }*/ /** * @dev Gets the timestamp for the value based on their index * @param _requestID is the requestId to look up * @param _index is the value index to look up * @return uint timestamp */ function getTimestampbyRequestIDandIndex(TellorStorage.TellorStorageStruct storage self, uint256 _requestID, uint256 _index) internal view returns (uint256) { return self.requestDetails[_requestID].requestTimestamps[_index]; } /** * @dev Getter for the variables saved under the TellorStorageStruct uintVars variable * @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is * the variables/strings used to save the data in the mapping. The variables names are * commented out under the uintVars under the TellorStorageStruct struct * This is an example of how data is saved into the mapping within other functions: * self.uintVars[keccak256("stakerCount")] * @return uint of specified variable */ function getUintVar(TellorStorage.TellorStorageStruct storage self, bytes32 _data) internal view returns (uint256) { return self.uintVars[_data]; } /** * @dev Getter function for next requestId on queue/request with highest payout at time the function is called * @return onDeck/info on request with highest payout-- RequestId, Totaltips, and API query string */ function getVariablesOnDeck(TellorStorage.TellorStorageStruct storage self) internal view returns (uint256, uint256, string memory) { uint256 newRequestId = getTopRequestID(self); return ( newRequestId, self.requestDetails[newRequestId].apiUintVars[keccak256("totalTip")], self.requestDetails[newRequestId].queryString ); } /** * @dev Getter function for the request with highest payout. This function is used within the getVariablesOnDeck function * @return uint _requestId of request with highest payout at the time the function is called */ function getTopRequestID(TellorStorage.TellorStorageStruct storage self) internal view returns (uint256 _requestId) { uint256 _max; uint256 _index; (_max, _index) = Utilities.getMax(self.requestQ); _requestId = self.requestIdByRequestQIndex[_index]; } /** * @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp * @param _requestId to looku p * @param _timestamp is the timestamp to look up miners for * @return bool true if requestId/timestamp is under dispute */ function isInDispute(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _timestamp) internal view returns (bool) { return self.requestDetails[_requestId].inDispute[_timestamp]; } /** * @dev Retreive value from oracle based on requestId/timestamp * @param _requestId being requested * @param _timestamp to retreive data/value from * @return uint value for requestId/timestamp submitted */ function retrieveData(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _timestamp) internal view returns (uint256) { return self.requestDetails[_requestId].finalValues[_timestamp]; } /** * @dev Getter for the total_supply of oracle tokens * @return uint total supply */ function totalSupply(TellorStorage.TellorStorageStruct storage self) internal view returns (uint256) { return self.uintVars[keccak256("total_supply")]; } } /** * @title Tellor Oracle System Library * @dev Contains the functions' logic for the Tellor contract where miners can submit the proof of work * along with the value and smart contracts can requestData and tip miners. */ library TellorLibrary { using SafeMath for uint256; event TipAdded(address indexed _sender, uint256 indexed _requestId, uint256 _tip, uint256 _totalTips); //emits when a new challenge is created (either on mined block or when a new request is pushed forward on waiting system) event NewChallenge( bytes32 indexed _currentChallenge, uint256[5] _currentRequestId, uint256 _difficulty, uint256 _totalTips ); //Emits upon a successful Mine, indicates the blocktime at point of the mine and the value mined event NewValue(uint256[5] _requestId, uint256 _time, uint256[5] _value, uint256 _totalTips, bytes32 indexed _currentChallenge); //Emits upon each mine (5 total) and shows the miner, nonce, and value submitted event NonceSubmitted(address indexed _miner, string _nonce, uint256[5] _requestId, uint256[5] _value, bytes32 indexed _currentChallenge); event OwnershipTransferred(address indexed _previousOwner, address indexed _newOwner); event OwnershipProposed(address indexed _previousOwner, address indexed _newOwner); /*Functions*/ /** * @dev Add tip to Request value from oracle * @param _requestId being requested to be mined * @param _tip amount the requester is willing to pay to be get on queue. Miners * mine the onDeckQueryHash, or the api with the highest payout pool */ function addTip(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _tip) public { require(_requestId > 0, "RequestId is 0"); require(_tip > 0, "Tip should be greater than 0"); require(_requestId <= self.uintVars[keccak256("requestCount")]+1, "RequestId is not less than count"); if(_requestId > self.uintVars[keccak256("requestCount")]){ self.uintVars[keccak256("requestCount")]++; } TellorTransfer.doTransfer(self, msg.sender, address(this), _tip); //Update the information for the request that should be mined next based on the tip submitted updateOnDeck(self, _requestId, _tip); emit TipAdded(msg.sender, _requestId, _tip, self.requestDetails[_requestId].apiUintVars[keccak256("totalTip")]); } /** * @dev This fucntion is called by submitMiningSolution and adjusts the difficulty, sorts and stores the first * 5 values received, pays the miners, the dev share and assigns a new challenge * @param _nonce or solution for the PoW for the requestId * @param _requestId for the current request being mined */ function newBlock(TellorStorage.TellorStorageStruct storage self, string memory _nonce, uint256[5] memory _requestId) public { TellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[keccak256("_tblock")]]; // If the difference between the timeTarget and how long it takes to solve the challenge this updates the challenge //difficulty up or donw by the difference between the target time and how long it took to solve the prevous challenge //otherwise it sets it to 1 int256 _change = int256(SafeMath.min(1200, (now - self.uintVars[keccak256("timeOfLastValue")]))); _change = (int256(self.uintVars[keccak256("difficulty")]) * (int256(self.uintVars[keccak256("timeTarget")]) - _change)) / 4000; if (_change < 2 && _change > -2) { if (_change >= 0) { _change = 1; } else { _change = -1; } } if ((int256(self.uintVars[keccak256("difficulty")]) + _change) <= 0) { self.uintVars[keccak256("difficulty")] = 1; } else { self.uintVars[keccak256("difficulty")] = uint256(int256(self.uintVars[keccak256("difficulty")]) + _change); } //Sets time of value submission rounded to 1 minute uint256 _timeOfLastNewValue = now - (now % 1 minutes); self.uintVars[keccak256("timeOfLastNewValue")] = _timeOfLastNewValue; uint[5] memory a; for (uint k = 0; k < 5; k++) { a = _tblock.valuesByTimestamp[k]; address[5] memory b = _tblock.minersByValue[1]; for (uint i = 1; i < 5; i++) { uint256 temp = a[i]; address temp2 = b[i]; uint256 j = i; while (j > 0 && temp < a[j - 1]) { a[j] = a[j - 1]; b[j] = b[j - 1]; j--; } if (j < i) { a[j] = temp; b[j] = temp2; } } TellorStorage.Request storage _request = self.requestDetails[_requestId[k]]; //Save the official(finalValue), timestamp of it, 5 miners and their submitted values for it, and its block number _request.finalValues[_timeOfLastNewValue] = a[2]; _request.requestTimestamps.push(_timeOfLastNewValue); //these are miners by timestamp _request.minersByValue[_timeOfLastNewValue] = [b[0], b[1], b[2], b[3], b[4]]; _request.valuesByTimestamp[_timeOfLastNewValue] = [a[0],a[1],a[2],a[3],a[4]]; _request.minedBlockNum[_timeOfLastNewValue] = block.number; _request.apiUintVars[keccak256("totalTip")] = 0; } emit NewValue( _requestId, _timeOfLastNewValue, a, self.uintVars[keccak256("runningTips")],//what should this be? self.currentChallenge ); //map the timeOfLastValue to the requestId that was just mined self.requestIdByTimestamp[_timeOfLastNewValue] = _requestId[0]; ///don't know what to do with this... if (self.uintVars[keccak256("currentReward")] > 1e18) { self.uintVars[keccak256("currentReward")] = self.uintVars[keccak256("currentReward")] - self.uintVars[keccak256("currentReward")] * 30612633181126/1e18; self.uintVars[keccak256("devShare")] = self.uintVars[keccak256("currentReward")] * 50/100; } else { self.uintVars[keccak256("currentReward")] = 1e18; } //update the total supply self.uintVars[keccak256("total_supply")] += self.uintVars[keccak256("devShare")] + self.uintVars[keccak256("currentReward")]*5 - (self.uintVars[keccak256("currentTotalTips")]); //transfer to zero address ( do not need, just leave it in addressThis) //TellorTransfer.doTransfer(self, address(this), address(0x0), self.uintVars[keccak256("currentTotalTips")]); //pay the dev-share TellorTransfer.doTransfer(self, address(this), self.addressVars[keccak256("_owner")], self.uintVars[keccak256("devShare")]); //The ten there is the devshare //add timeOfLastValue to the newValueTimestamps array self.newValueTimestamps.push(_timeOfLastNewValue); self.uintVars[keccak256("_tblock")] ++; uint256[5] memory _topId = TellorStake.getTopRequestIDs(self); for(uint i = 0; i< 5;i++){ self.currentMiners[i].value = _topId[i]; self.requestQ[self.requestDetails[_topId[i]].apiUintVars[keccak256("requestQPosition")]] = 0; self.uintVars[keccak256("currentTotalTips")] += self.requestDetails[_topId[i]].apiUintVars[keccak256("totalTip")]; } //Issue the the next challenge self.currentChallenge = keccak256(abi.encodePacked(_nonce, self.currentChallenge, blockhash(block.number - 1))); // Save hash for next proof emit NewChallenge( self.currentChallenge, _topId, self.uintVars[keccak256("difficulty")], self.uintVars[keccak256("currentTotalTips")] ); } /** * @dev This fucntion is called by submitMiningSolution and adjusts the difficulty, sorts and stores the first * 5 values received, pays the miners, the dev share and assigns a new challenge * @param _nonce or solution for the PoW for the requestId * @param _requestId for the current request being mined ** OLD BUT HAS SWITCH!!!!!!!! */ function newBlock(TellorStorage.TellorStorageStruct storage self, string memory _nonce, uint256 _requestId) public { TellorStorage.Request storage _request = self.requestDetails[_requestId]; // If the difference between the timeTarget and how long it takes to solve the challenge this updates the challenge //difficulty up or donw by the difference between the target time and how long it took to solve the prevous challenge //otherwise it sets it to 1 int256 _change = int256(SafeMath.min(1200, (now - self.uintVars[keccak256("timeOfLastNewValue")]))); _change = (int256(self.uintVars[keccak256("difficulty")]) * (int256(self.uintVars[keccak256("timeTarget")]) - _change)) / 4000; if (_change < 2 && _change > -2) { if (_change >= 0) { _change = 1; } else { _change = -1; } } if ((int256(self.uintVars[keccak256("difficulty")]) + _change) <= 0) { self.uintVars[keccak256("difficulty")] = 1; } else { self.uintVars[keccak256("difficulty")] = uint256(int256(self.uintVars[keccak256("difficulty")]) + _change); } //Sets time of value submission rounded to 1 minute uint256 _timeOfLastNewValue = now - (now % 1 minutes); self.uintVars[keccak256("timeOfLastNewValue")] = _timeOfLastNewValue; //The sorting algorithm that sorts the values of the first five values that come in TellorStorage.Details[5] memory a = self.currentMiners; uint256 i; for (i = 1; i < 5; i++) { uint256 temp = a[i].value; address temp2 = a[i].miner; uint256 j = i; while (j > 0 && temp < a[j - 1].value) { a[j].value = a[j - 1].value; a[j].miner = a[j - 1].miner; j--; } if (j < i) { a[j].value = temp; a[j].miner = temp2; } } //Pay the miners //adjust by payout = payout * ratio 0.000030612633181126/1e18 //uint _currentReward = self.uintVars[keccak256("currentReward")]; if(self.uintVars[keccak256("currentReward")] == 0){ self.uintVars[keccak256("currentReward")] = 5e18; } if (self.uintVars[keccak256("currentReward")] > 1e18) { self.uintVars[keccak256("currentReward")] = self.uintVars[keccak256("currentReward")] - self.uintVars[keccak256("currentReward")] * 30612633181126/1e18; self.uintVars[keccak256("devShare")] = self.uintVars[keccak256("currentReward")] * 50/100; } else { self.uintVars[keccak256("currentReward")] = 1e18; } for (i = 0; i < 5; i++) { TellorTransfer.doTransfer(self, address(this), a[i].miner, self.uintVars[keccak256("currentReward")] + self.uintVars[keccak256("currentTotalTips")] / 5); } //update the total supply self.uintVars[keccak256("total_supply")] += self.uintVars[keccak256("devShare")] + self.uintVars[keccak256("currentReward")]*5 ; //pay the dev-share TellorTransfer.doTransfer(self, address(this), self.addressVars[keccak256("_owner")], self.uintVars[keccak256("devShare")]); //The ten there is the devshare //Save the official(finalValue), timestamp of it, 5 miners and their submitted values for it, and its block number _request.finalValues[_timeOfLastNewValue] = a[2].value; _request.requestTimestamps.push(_timeOfLastNewValue); //these are miners by timestamp _request.minersByValue[_timeOfLastNewValue] = [a[0].miner, a[1].miner, a[2].miner, a[3].miner, a[4].miner]; _request.valuesByTimestamp[_timeOfLastNewValue] = [a[0].value, a[1].value, a[2].value, a[3].value, a[4].value]; _request.minedBlockNum[_timeOfLastNewValue] = block.number; //map the timeOfLastValue to the requestId that was just mined self.requestIdByTimestamp[_timeOfLastNewValue] = _requestId; //add timeOfLastValue to the newValueTimestamps array self.newValueTimestamps.push(_timeOfLastNewValue); //re-start the count for the slot progress to zero before the new request mining starts self.uintVars[keccak256("slotProgress")] = 0; // THIS IS THE NEW PART if(self.uintVars[keccak256("timeTarget")] == 600){ self.uintVars[keccak256("timeTarget")] = 300; self.uintVars[keccak256("currentReward")] = self.uintVars[keccak256("currentReward")]/2; self.uintVars[keccak256("_tblock")] = 1e18; self.uintVars[keccak256("difficulty")] = SafeMath.max(1,self.uintVars[keccak256("difficulty")]/3); } for(i = 0; i< 5;i++){ self.currentMiners[i].value = i+1; self.requestQ[self.requestDetails[i+1].apiUintVars[keccak256("requestQPosition")]] = 0; self.uintVars[keccak256("currentTotalTips")] += self.requestDetails[i+1].apiUintVars[keccak256("totalTip")]; } self.currentChallenge = keccak256(abi.encodePacked(_nonce, self.currentChallenge, blockhash(block.number - 1))); // Save hash for next proof emit NewChallenge( self.currentChallenge, [uint256(1),uint256(2),uint256(3),uint256(4),uint256(5)], self.uintVars[keccak256("difficulty")], self.uintVars[keccak256("currentTotalTips")] ); } /** * @dev Proof of work is called by the miner when they submit the solution (proof of work and value) * @param _nonce uint submitted by miner * @param _requestId the apiId being mined * @param _value of api query ** OLD!!!!!!!! */ function submitMiningSolution(TellorStorage.TellorStorageStruct storage self, string memory _nonce, uint256 _requestId, uint256 _value) public { require (self.uintVars[keccak256("timeTarget")] == 600, "Contract has upgraded, call new function"); //require miner is staked require(self.stakerDetails[msg.sender].currentStatus == 1, "Miner status is not staker"); //Check the miner is submitting the pow for the current request Id require(_requestId == self.uintVars[keccak256("currentRequestId")], "RequestId is wrong"); //Saving the challenge information as unique by using the msg.sender require( uint256( sha256(abi.encodePacked(ripemd160(abi.encodePacked(keccak256(abi.encodePacked(self.currentChallenge, msg.sender, _nonce)))))) ) % self.uintVars[keccak256("difficulty")] == 0, "Incorrect nonce for current challenge" ); //Make sure the miner does not submit a value more than once require(self.minersByChallenge[self.currentChallenge][msg.sender] == false, "Miner already submitted the value"); //Save the miner and value received self.currentMiners[self.uintVars[keccak256("slotProgress")]].value = _value; self.currentMiners[self.uintVars[keccak256("slotProgress")]].miner = msg.sender; //Add to the count how many values have been submitted, since only 5 are taken per request self.uintVars[keccak256("slotProgress")]++; //Update the miner status to true once they submit a value so they don't submit more than once self.minersByChallenge[self.currentChallenge][msg.sender] = true; //If 5 values have been received, adjust the difficulty otherwise sort the values until 5 are received if (self.uintVars[keccak256("slotProgress")] == 5) { newBlock(self, _nonce, _requestId); } } /** * @dev Proof of work is called by the miner when they submit the solution (proof of work and value) * @param _nonce uint submitted by miner * @param _requestId is the array of the 5 PSR's being mined * @param _value is an array of 5 values */ function submitMiningSolution(TellorStorage.TellorStorageStruct storage self, string memory _nonce,uint256[5] memory _requestId, uint256[5] memory _value) public { require(self.stakerDetails[msg.sender].currentStatus == 1, "Miner status is not staker"); //has to be a better way to do this... for(uint i=0;i<5;i++){ require(_requestId[i] == self.currentMiners[i].value,"Request ID is wrong"); } TellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[keccak256("_tblock")]]; //Saving the challenge information as unique by using the msg.sender require(uint256( sha256(abi.encodePacked(ripemd160(abi.encodePacked(keccak256(abi.encodePacked(self.currentChallenge, msg.sender, _nonce)))))) ) % self.uintVars[keccak256("difficulty")] == 0 || (now - (now % 1 minutes)) - self.uintVars[keccak256("timeOfLastNewValue")] >= 15 minutes, "Incorrect nonce for current challenge" ); require(now - self.uintVars[keccak256(abi.encodePacked(msg.sender))] > 1 hours); //Make sure the miner does not submit a value more than once require(self.minersByChallenge[self.currentChallenge][msg.sender] == false, "Miner already submitted the value"); //require the miner did not receive awards in the last hour // self.uintVars[keccak256(abi.encodePacked(msg.sender))] = now; if(self.uintVars[keccak256("slotProgress")] == 0){ self.uintVars[keccak256("runningTips")] = self.uintVars[keccak256("currentTotalTips")]; } uint _extraTip = (self.uintVars[keccak256("currentTotalTips")]-self.uintVars[keccak256("runningTips")])/(5-self.uintVars[keccak256("slotProgress")]); TellorTransfer.doTransfer(self, address(this), msg.sender, self.uintVars[keccak256("currentReward")] + self.uintVars[keccak256("runningTips")] / 2 / 5 + _extraTip); self.uintVars[keccak256("currentTotalTips")] -= _extraTip; //Save the miner and value received _tblock.minersByValue[1][self.uintVars[keccak256("slotProgress")]]= msg.sender; //this will fill the currentMiners array for (uint j = 0; j < 5; j++) { _tblock.valuesByTimestamp[j][self.uintVars[keccak256("slotProgress")]] = _value[j]; } self.uintVars[keccak256("slotProgress")]++; //Update the miner status to true once they submit a value so they don't submit more than once self.minersByChallenge[self.currentChallenge][msg.sender] = true; emit NonceSubmitted(msg.sender, _nonce, _requestId, _value, self.currentChallenge); //If 5 values have been received, adjust the difficulty otherwise sort the values until 5 are received if (self.uintVars[keccak256("slotProgress")] == 5) { newBlock(self, _nonce, _requestId); self.uintVars[keccak256("slotProgress")] = 0; } } /** * @dev Allows the current owner to propose transfer control of the contract to a * newOwner and the ownership is pending until the new owner calls the claimOwnership * function * @param _pendingOwner The address to transfer ownership to. */ function proposeOwnership(TellorStorage.TellorStorageStruct storage self, address payable _pendingOwner) public { require(msg.sender == self.addressVars[keccak256("_owner")], "Sender is not owner"); emit OwnershipProposed(self.addressVars[keccak256("_owner")], _pendingOwner); self.addressVars[keccak256("pending_owner")] = _pendingOwner; } /** * @dev Allows the new owner to claim control of the contract */ function claimOwnership(TellorStorage.TellorStorageStruct storage self) public { require(msg.sender == self.addressVars[keccak256("pending_owner")], "Sender is not pending owner"); emit OwnershipTransferred(self.addressVars[keccak256("_owner")], self.addressVars[keccak256("pending_owner")]); self.addressVars[keccak256("_owner")] = self.addressVars[keccak256("pending_owner")]; } /** * @dev This function updates APIonQ and the requestQ when requestData or addTip are ran * @param _requestId being requested * @param _tip is the tip to add */ function updateOnDeck(TellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _tip) public { TellorStorage.Request storage _request = self.requestDetails[_requestId]; _request.apiUintVars[keccak256("totalTip")] = _request.apiUintVars[keccak256("totalTip")].add(_tip); //maybe use a request uintVar to keep track if its being mined? if(self.currentMiners[0].value == _requestId || self.currentMiners[1].value== _requestId ||self.currentMiners[2].value == _requestId||self.currentMiners[3].value== _requestId || self.currentMiners[4].value== _requestId ){ self.uintVars[keccak256("currentTotalTips")] += _tip; } else { //if the request is not part of the requestQ[51] array //then add to the requestQ[51] only if the _payout/tip is greater than the minimum(tip) in the requestQ[51] array if (_request.apiUintVars[keccak256("requestQPosition")] == 0) { uint256 _min; uint256 _index; (_min, _index) = Utilities.getMin(self.requestQ); //we have to zero out the oldOne //if the _payout is greater than the current minimum payout in the requestQ[51] or if the minimum is zero //then add it to the requestQ array aand map its index information to the requestId and the apiUintvars if (_request.apiUintVars[keccak256("totalTip")] > _min || _min == 0) { self.requestQ[_index] = _request.apiUintVars[keccak256("totalTip")]; self.requestDetails[self.requestIdByRequestQIndex[_index]].apiUintVars[keccak256("requestQPosition")] = 0; self.requestIdByRequestQIndex[_index] = _requestId; _request.apiUintVars[keccak256("requestQPosition")] = _index; } // else if the requestid is part of the requestQ[51] then update the tip for it } else{ self.requestQ[_request.apiUintVars[keccak256("requestQPosition")]] += _tip; } } } /**********************CHEAT Functions for Testing******************************/ /**********************CHEAT Functions for Testing******************************/ /**********************CHEAT Functions for Testing--No Nonce******************************/ // /*This is a cheat for demo purposes, will delete upon actual launch*/ // function theLazyCoon(TellorStorage.TellorStorageStruct storage self,address _address, uint _amount) public { // self.uintVars[keccak256("total_supply")] += _amount; // TellorTransfer.updateBalanceAtNow(self.balances[_address],_amount); // } // /** // * @dev Proof of work is called by the miner when they submit the solution (proof of work and value) // * @param _nonce uint submitted by miner // * @param _requestId the apiId being mined // * @param _value of api query // ** OLD!!!!!!!! // */ // function testSubmitMiningSolution(TellorStorage.TellorStorageStruct storage self, string memory _nonce, uint256 _requestId, uint256 _value) // public // { // require (self.uintVars[keccak256("timeTarget")] == 600, "Contract has upgraded, call new function"); // //require miner is staked // require(self.stakerDetails[msg.sender].currentStatus == 1, "Miner status is not staker"); // //Check the miner is submitting the pow for the current request Id // require(_requestId == self.uintVars[keccak256("currentRequestId")], "RequestId is wrong"); // //Saving the challenge information as unique by using the msg.sender // // require( // // uint256( // // sha256(abi.encodePacked(ripemd160(abi.encodePacked(keccak256(abi.encodePacked(self.currentChallenge, msg.sender, _nonce)))))) // // ) % // // self.uintVars[keccak256("difficulty")] == // // 0, // // "Incorrect nonce for current challenge" // // ); // //Make sure the miner does not submit a value more than once // require(self.minersByChallenge[self.currentChallenge][msg.sender] == false, "Miner already submitted the value"); // //Save the miner and value received // self.currentMiners[self.uintVars[keccak256("slotProgress")]].value = _value; // self.currentMiners[self.uintVars[keccak256("slotProgress")]].miner = msg.sender; // //Add to the count how many values have been submitted, since only 5 are taken per request // self.uintVars[keccak256("slotProgress")]++; // //Update the miner status to true once they submit a value so they don't submit more than once // self.minersByChallenge[self.currentChallenge][msg.sender] = true; // //If 5 values have been received, adjust the difficulty otherwise sort the values until 5 are received // if (self.uintVars[keccak256("slotProgress")] == 5) { // newBlock(self, _nonce, _requestId); // } // } // /** // * @dev Proof of work is called by the miner when they submit the solution (proof of work and value) // * @param _nonce uint submitted by miner // * @param _requestId is the array of the 5 PSR's being mined // * @param _value is an array of 5 values // */ // function testSubmitMiningSolution(TellorStorage.TellorStorageStruct storage self, string memory _nonce,uint256[5] memory _requestId, uint256[5] memory _value) // public // { // require(self.stakerDetails[msg.sender].currentStatus == 1, "Miner status is not staker"); // //has to be a better way to do this... // for(uint i=0;i<5;i++){ // require(_requestId[i] == self.currentMiners[i].value,"Request ID is wrong"); // } // TellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[keccak256("_tblock")]]; // //Saving the challenge information as unique by using the msg.sender // // require(uint256( // // sha256(abi.encodePacked(ripemd160(abi.encodePacked(keccak256(abi.encodePacked(self.currentChallenge, msg.sender, _nonce)))))) // // ) % // // self.uintVars[keccak256("difficulty")] == 0 // // || (now - (now % 1 minutes)) - self.uintVars[keccak256("timeOfLastNewValue")] >= 15 minutes, // // "Incorrect nonce for current challenge" // // ); // // require(now - self.uintVars[keccak256(abi.encodePacked(msg.sender))] > 1 hours); // //Make sure the miner does not submit a value more than once // require(self.minersByChallenge[self.currentChallenge][msg.sender] == false, "Miner already submitted the value"); // //require the miner did not receive awards in the last hour // // // self.uintVars[keccak256(abi.encodePacked(msg.sender))] = now; // if(self.uintVars[keccak256("slotProgress")] == 0){ // self.uintVars[keccak256("runningTips")] = self.uintVars[keccak256("currentTotalTips")]; // } // uint _extraTip = (self.uintVars[keccak256("currentTotalTips")]-self.uintVars[keccak256("runningTips")])/(5-self.uintVars[keccak256("slotProgress")]); // TellorTransfer.doTransfer(self, address(this), msg.sender, self.uintVars[keccak256("currentReward")] + self.uintVars[keccak256("runningTips")] / 2 / 5 + _extraTip); // self.uintVars[keccak256("currentTotalTips")] -= _extraTip; // //Save the miner and value received // _tblock.minersByValue[1][self.uintVars[keccak256("slotProgress")]]= msg.sender; // //this will fill the currentMiners array // for (uint j = 0; j < 5; j++) { // _tblock.valuesByTimestamp[j][self.uintVars[keccak256("slotProgress")]] = _value[j]; // } // self.uintVars[keccak256("slotProgress")]++; // //Update the miner status to true once they submit a value so they don't submit more than once // self.minersByChallenge[self.currentChallenge][msg.sender] = true; // emit NonceSubmitted(msg.sender, _nonce, _requestId, _value, self.currentChallenge); // //If 5 values have been received, adjust the difficulty otherwise sort the values until 5 are received // if (self.uintVars[keccak256("slotProgress")] == 5) { // newBlock(self, _nonce, _requestId); // self.uintVars[keccak256("slotProgress")] = 0; // } // } } /** * @title Tellor Oracle System * @dev Oracle contract where miners can submit the proof of work along with the value. * The logic for this contract is in TellorLibrary.sol, TellorDispute.sol, TellorStake.sol, * and TellorTransfer.sol */ contract Tellor { using SafeMath for uint256; using TellorDispute for TellorStorage.TellorStorageStruct; using TellorLibrary for TellorStorage.TellorStorageStruct; using TellorStake for TellorStorage.TellorStorageStruct; using TellorTransfer for TellorStorage.TellorStorageStruct; TellorStorage.TellorStorageStruct tellor; /*Functions*/ /** * @dev Helps initialize a dispute by assigning it a disputeId * when a miner returns a false on the validate array(in Tellor.ProofOfWork) it sends the * invalidated value information to POS voting * @param _requestId being disputed * @param _timestamp being disputed * @param _minerIndex the index of the miner that submitted the value being disputed. Since each official value * requires 5 miners to submit a value. */ function beginDispute(uint256 _requestId, uint256 _timestamp, uint256 _minerIndex) external { tellor.beginDispute(_requestId, _timestamp, _minerIndex); } /** * @dev Allows token holders to vote * @param _disputeId is the dispute id * @param _supportsDispute is the vote (true=the dispute has basis false = vote against dispute) */ function vote(uint256 _disputeId, bool _supportsDispute) external { tellor.vote(_disputeId, _supportsDispute); } /** * @dev tallies the votes. * @param _disputeId is the dispute id */ function tallyVotes(uint256 _disputeId) external { tellor.tallyVotes(_disputeId); } /** * @dev Allows for a fork to be proposed * @param _propNewTellorAddress address for new proposed Tellor */ function proposeFork(address _propNewTellorAddress) external { tellor.proposeFork(_propNewTellorAddress); } /** * @dev Add tip to Request value from oracle * @param _requestId being requested to be mined * @param _tip amount the requester is willing to pay to be get on queue. Miners * mine the onDeckQueryHash, or the api with the highest payout pool */ function addTip(uint256 _requestId, uint256 _tip) external { tellor.addTip(_requestId, _tip); } /** * @dev This is called by the miner when they submit the PoW solution (proof of work and value) * @param _nonce uint submitted by miner * @param _requestId the apiId being mined * @param _value of api query * OLD!!!!!!!!!!! */ function submitMiningSolution(string calldata _nonce, uint256 _requestId, uint256 _value) external { tellor.submitMiningSolution(_nonce, _requestId, _value); } /** * @dev This is called by the miner when they submit the PoW solution (proof of work and value) * @param _nonce uint submitted by miner * @param _requestId is the array of the 5 PSR's being mined * @param _value is an array of 5 values */ function submitMiningSolution(string calldata _nonce,uint256[5] calldata _requestId, uint256[5] calldata _value) external { tellor.submitMiningSolution(_nonce,_requestId, _value); } /** * @dev Allows the current owner to propose transfer control of the contract to a * newOwner and the ownership is pending until the new owner calls the claimOwnership * function * @param _pendingOwner The address to transfer ownership to. */ function proposeOwnership(address payable _pendingOwner) external { tellor.proposeOwnership(_pendingOwner); } /** * @dev Allows the new owner to claim control of the contract */ function claimOwnership() external { tellor.claimOwnership(); } /** * @dev This function allows miners to deposit their stake. */ function depositStake() external { tellor.depositStake(); } /** * @dev This function allows stakers to request to withdraw their stake (no longer stake) * once they lock for withdraw(stakes.currentStatus = 2) they are locked for 7 days before they * can withdraw the stake */ function requestStakingWithdraw() external { tellor.requestStakingWithdraw(); } /** * @dev This function allows users to withdraw their stake after a 7 day waiting period from request */ function withdrawStake() external { tellor.withdrawStake(); } /** * @dev This function approves a _spender an _amount of tokens to use * @param _spender address * @param _amount amount the spender is being approved for * @return true if spender appproved successfully */ function approve(address _spender, uint256 _amount) external returns (bool) { return tellor.approve(_spender, _amount); } /** * @dev Allows for a transfer of tokens to _to * @param _to The address to send tokens to * @param _amount The amount of tokens to send * @return true if transfer is successful */ function transfer(address _to, uint256 _amount) external returns (bool) { return tellor.transfer(_to, _amount); } /** * @dev Sends _amount tokens to _to from _from on the condition it * is approved by _from * @param _from The address holding the tokens being transferred * @param _to The address of the recipient * @param _amount The amount of tokens to be transferred * @return True if the transfer was successful */ function transferFrom(address _from, address _to, uint256 _amount) external returns (bool) { return tellor.transferFrom(_from, _to, _amount); } /** * @dev Allows users to access the token's name */ function name() external pure returns (string memory) { return "Tellor Tributes"; } /** * @dev Allows users to access the token's symbol */ function symbol() external pure returns (string memory) { return "TRB"; } /** * @dev Allows users to access the number of decimals */ function decimals() external pure returns (uint8) { return 18; } /** * @dev Getter for the current variables that include the 5 requests Id's * @return the challenge, 5 requestsId, difficulty and tip */ function getNewCurrentVariables() external view returns(bytes32 _challenge,uint[5] memory _requestIds,uint256 _difficutly, uint256 _tip){ return tellor.getNewCurrentVariables(); } /** * @dev Getter for the top tipped 5 requests Id's * @return the 5 requestsId */ function getTopRequestIDs() external view returns(uint256[5] memory _requestIds){ return tellor.getTopRequestIDs(); } /** * @dev Getter for the 5 requests Id's next in line to get mined * @return the 5 requestsId */ function getNewVariablesOnDeck() external view returns (uint256[5] memory idsOnDeck, uint256[5] memory tipsOnDeck) { return tellor.getNewVariablesOnDeck(); } /** * @dev Updates the Tellor address after a proposed fork has * passed the vote and day has gone by without a dispute * @param _disputeId the disputeId for the proposed fork */ function updateTellor(uint _disputeId) external{ return tellor.updateTellor(_disputeId); } /** * @dev Allows disputer to unlock the dispute fee * @param _disputeId to unlock fee from */ function unlockDisputeFee (uint _disputeId) external{ return tellor.unlockDisputeFee(_disputeId); } /*******************TEST Functions NOT INCLUDED ON PRODUCTION/MAINNET/RINKEBY******/ /*This is a cheat for demo purposes, will delete upon actual launch*/ // function theLazyCoon(address _address, uint _amount) external { // tellor.theLazyCoon(_address,_amount); // } // function testSubmitMiningSolution(string calldata _nonce, uint256 _requestId, uint256 _value) external { // tellor.testSubmitMiningSolution(_nonce, _requestId, _value); // } // function testSubmitMiningSolution(string calldata _nonce,uint256[5] calldata _requestId, uint256[5] calldata _value) external { // tellor.testSubmitMiningSolution(_nonce,_requestId, _value); // } /***************END TEST Functions NOT INCLUDED ON PRODUCTION/MAINNET/RINKEBY******/ }
[{"constant":false,"inputs":[{"internalType":"uint256","name":"_requestId","type":"uint256"},{"internalType":"uint256","name":"_tip","type":"uint256"}],"name":"addTip","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_requestId","type":"uint256"},{"internalType":"uint256","name":"_timestamp","type":"uint256"},{"internalType":"uint256","name":"_minerIndex","type":"uint256"}],"name":"beginDispute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"claimOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[],"name":"depositStake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getNewCurrentVariables","outputs":[{"internalType":"bytes32","name":"_challenge","type":"bytes32"},{"internalType":"uint256[5]","name":"_requestIds","type":"uint256[5]"},{"internalType":"uint256","name":"_difficutly","type":"uint256"},{"internalType":"uint256","name":"_tip","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getNewVariablesOnDeck","outputs":[{"internalType":"uint256[5]","name":"idsOnDeck","type":"uint256[5]"},{"internalType":"uint256[5]","name":"tipsOnDeck","type":"uint256[5]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getTopRequestIDs","outputs":[{"internalType":"uint256[5]","name":"_requestIds","type":"uint256[5]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_propNewTellorAddress","type":"address"}],"name":"proposeFork","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"_pendingOwner","type":"address"}],"name":"proposeOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"requestStakingWithdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_nonce","type":"string"},{"internalType":"uint256[5]","name":"_requestId","type":"uint256[5]"},{"internalType":"uint256[5]","name":"_value","type":"uint256[5]"}],"name":"submitMiningSolution","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_nonce","type":"string"},{"internalType":"uint256","name":"_requestId","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"submitMiningSolution","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_disputeId","type":"uint256"}],"name":"tallyVotes","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_disputeId","type":"uint256"}],"name":"unlockDisputeFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_disputeId","type":"uint256"}],"name":"updateTellor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_disputeId","type":"uint256"},{"internalType":"bool","name":"_supportsDispute","type":"bool"}],"name":"vote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"withdrawStake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506117b0806100206000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806368c180d5116100c35780639a7077ab1161007c5780639a7077ab1461065a578063a9059cbb146106cf578063bed9d86114610735578063c9d27afe1461073f578063f458ab9814610779578063fe1cd15d146107a75761014d565b806368c180d51461045e578063710bf322146104eb578063752d49a11461052f5780638581af191461056757806395d89b41146105a95780639a01ca131461062c5761014d565b806328449c3a1161011557806328449c3a1461030f578063313ce567146103195780634049f1981461033d5780634350283e146103985780634d318b0e146104265780634e71e0c8146104545761014d565b806306fdde0314610152578063095ea7b3146101d55780630d2d76a21461023b57806323b872dd1461024557806326b7d9f6146102cb575b600080fd5b61015a6107ed565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561019a57808201518184015260208101905061017f565b50505050905090810190601f1680156101c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610221600480360360408110156101eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082a565b604051808215151515815260200191505060405180910390f35b6102436108fc565b005b6102b16004803603606081101561025b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610968565b604051808215151515815260200191505060405180910390f35b61030d600480360360208110156102e157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a6f565b005b610317610b10565b005b610321610b7c565b604051808260ff1660ff16815260200191505060405180910390f35b610345610b85565b6040518085815260200184600560200280838360005b8381101561037657808201518184015260208101905061035b565b5050505090500183815260200182815260200194505050505060405180910390f35b61042460048036036101608110156103af57600080fd5b81019080803590602001906401000000008111156103cc57600080fd5b8201836020820111156103de57600080fd5b8035906020019184600183028401116401000000008311171561040057600080fd5b90919293919293908060a0019091929192908060a001909192919290505050610baa565b005b6104526004803603602081101561043c57600080fd5b8101908080359060200190929190505050610c94565b005b61045c610d09565b005b6104e96004803603606081101561047457600080fd5b810190808035906020019064010000000081111561049157600080fd5b8201836020820111156104a357600080fd5b803590602001918460018302840111640100000000831117156104c557600080fd5b90919293919293908035906020019092919080359060200190929190505050610d75565b005b61052d6004803603602081101561050157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e29565b005b6105656004803603604081101561054557600080fd5b810190808035906020019092919080359060200190929190505050610eca565b005b6105a76004803603606081101561057d57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610f48565b005b6105b1610fcf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105f15780820151818401526020810190506105d6565b50505050905090810190601f16801561061e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106586004803603602081101561064257600080fd5b810190808035906020019092919050505061100c565b005b610662611081565b6040518083600560200280838360005b8381101561068d578082015181840152602081019050610672565b5050505090500182600560200280838360005b838110156106bb5780820151818401526020810190506106a0565b505050509050019250505060405180910390f35b61071b600480360360408110156106e557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110a3565b604051808215151515815260200191505060405180910390f35b61073d611175565b005b6107776004803603604081101561075557600080fd5b81019080803590602001909291908035151590602001909291905050506111e1565b005b6107a56004803603602081101561078f57600080fd5b8101908080359060200190929190505050611263565b005b6107af6112d8565b6040518082600560200280838360005b838110156107da5780820151818401526020810190506107bf565b5050505090500191505060405180910390f35b60606040518060400160405280600f81526020017f54656c6c6f722054726962757465730000000000000000000000000000000000815250905090565b6000807382b8d6b5dc1a6955aefc86d470fc76021ef89d9c63850dcc32909185856040518463ffffffff1660e01b8152600401808481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060206040518083038186803b1580156108b957600080fd5b505af41580156108cd573d6000803e3d6000fd5b505050506040513d60208110156108e357600080fd5b8101908080519060200190929190505050905092915050565b6000732115bee35c7519ff353141258e62ee534c3d090f63820a2d6690916040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561094e57600080fd5b505af4158015610962573d6000803e3d6000fd5b50505050565b6000807382b8d6b5dc1a6955aefc86d470fc76021ef89d9c63ca50189990918686866040518563ffffffff1660e01b8152600401808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060206040518083038186803b158015610a2b57600080fd5b505af4158015610a3f573d6000803e3d6000fd5b505050506040513d6020811015610a5557600080fd5b810190808051906020019092919050505090509392505050565b600073b8d292c3c553f0e4f99ba73c84565e51b65b4d0f63694bf49f9091836040518363ffffffff1660e01b8152600401808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060006040518083038186803b158015610af557600080fd5b505af4158015610b09573d6000803e3d6000fd5b5050505050565b6000732115bee35c7519ff353141258e62ee534c3d090f63c9cf5e4c90916040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b158015610b6257600080fd5b505af4158015610b76573d6000803e3d6000fd5b50505050565b60006012905090565b6000610b8f611759565b600080610b9c60006112ef565b935093509350935090919293565b6000733b3552cd4477f9b5494c67cdc093350c072315b263a4bc40679091868686866040518663ffffffff1660e01b8152600401808681526020018060200184600560200280828437600081840152601f19601f82011690508083019250505083600560200280828437600081840152601f19601f8201169050808301925050508281038252868682818152602001925080828437600081840152601f19601f820116905080830192505050965050505050505060006040518083038186803b158015610c7657600080fd5b505af4158015610c8a573d6000803e3d6000fd5b5050505050505050565b600073b8d292c3c553f0e4f99ba73c84565e51b65b4d0f63def6fac79091836040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b158015610cee57600080fd5b505af4158015610d02573d6000803e3d6000fd5b5050505050565b6000733b3552cd4477f9b5494c67cdc093350c072315b263314691ff90916040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b158015610d5b57600080fd5b505af4158015610d6f573d6000803e3d6000fd5b50505050565b6000733b3552cd4477f9b5494c67cdc093350c072315b263a098b5b49091868686866040518663ffffffff1660e01b815260040180868152602001806020018481526020018381526020018281038252868682818152602001925080828437600081840152601f19601f820116905080830192505050965050505050505060006040518083038186803b158015610e0b57600080fd5b505af4158015610e1f573d6000803e3d6000fd5b5050505050505050565b6000733b3552cd4477f9b5494c67cdc093350c072315b263291f8b739091836040518363ffffffff1660e01b8152600401808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060006040518083038186803b158015610eaf57600080fd5b505af4158015610ec3573d6000803e3d6000fd5b5050505050565b6000733b3552cd4477f9b5494c67cdc093350c072315b26302e8f21b909184846040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060006040518083038186803b158015610f2c57600080fd5b505af4158015610f40573d6000803e3d6000fd5b505050505050565b600073b8d292c3c553f0e4f99ba73c84565e51b65b4d0f63ca9a4ea590918585856040518563ffffffff1660e01b81526004018085815260200184815260200183815260200182815260200194505050505060006040518083038186803b158015610fb257600080fd5b505af4158015610fc6573d6000803e3d6000fd5b50505050505050565b60606040518060400160405280600381526020017f5452420000000000000000000000000000000000000000000000000000000000815250905090565b600073b8d292c3c553f0e4f99ba73c84565e51b65b4d0f6397f5f9729091836040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561106657600080fd5b505af415801561107a573d6000803e3d6000fd5b5050505050565b611089611759565b611091611759565b61109b60006113f0565b915091509091565b6000807382b8d6b5dc1a6955aefc86d470fc76021ef89d9c63c84b96f5909185856040518463ffffffff1660e01b8152600401808481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060206040518083038186803b15801561113257600080fd5b505af4158015611146573d6000803e3d6000fd5b505050506040513d602081101561115c57600080fd5b8101908080519060200190929190505050905092915050565b6000732115bee35c7519ff353141258e62ee534c3d090f6344bacc4b90916040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b1580156111c757600080fd5b505af41580156111db573d6000803e3d6000fd5b50505050565b600073b8d292c3c553f0e4f99ba73c84565e51b65b4d0f632da0706e909184846040518463ffffffff1660e01b81526004018084815260200183815260200182151515158152602001935050505060006040518083038186803b15801561124757600080fd5b505af415801561125b573d6000803e3d6000fd5b505050505050565b600073b8d292c3c553f0e4f99ba73c84565e51b65b4d0f6322048ecf9091836040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b1580156112bd57600080fd5b505af41580156112d1573d6000803e3d6000fd5b5050505050565b6112e0611759565b6112ea60006114b1565b905090565b60006112f9611759565b60008060008090505b60058110156113445785603501816005811061131a57fe5b600202016000015484826005811061132e57fe5b6020020181815250508080600101915050611302565b5084600001548386604001600060405180807f646966666963756c747900000000000000000000000000000000000000000000815250600a019050604051809103902081526020019081526020016000205487604001600060405180807f63757272656e74546f74616c54697073000000000000000000000000000000008152506010019050604051809103902081526020019081526020016000205493509350935093509193509193565b6113f8611759565b611400611759565b611409836114b1565b915060008090505b60058110156114ab5783604801600084836005811061142c57fe5b60200201518152602001908152602001600020600401600060405180807f746f74616c5469700000000000000000000000000000000000000000000000008152506008019050604051809103902081526020019081526020016000205482826005811061149557fe5b6020020181815250508080600101915050611411565b50915091565b6114b9611759565b6114c1611759565b6114c9611759565b61151184600101603380602002604051908101604052809291908260338015611507576020028201915b8154815260200190600101908083116114f3575b50505050506115c6565b809250819350505060008090505b60058110156115be57600083826005811061153657fe5b602002015111156115815784604301600083836005811061155357fe5b602002015181526020019081526020016000205484826005811061157357fe5b6020020181815250506115b1565b84603501816004036005811061159357fe5b60020201600001548482600581106115a757fe5b6020020181815250505b808060010191505061151f565b505050919050565b6115ce611759565b6115d6611759565b6000836001603381106115e557fe5b6020020151905060006001905060008090505b600581101561167f5785600182016033811061161057fe5b602002015185826005811061162157fe5b6020020181815250506001810184826005811061163a57fe5b6020020181815250508285826005811061165057fe5b602002015110156116725784816005811061166757fe5b602002015192508091505b80806001019150506115f8565b506000600590505b6033811015611751578286826033811061169d57fe5b60200201511115611744578581603381106116b457fe5b60200201518583600581106116c557fe5b602002018181525050808483600581106116db57fe5b6020020181815250508581603381106116f057fe5b6020020151925060008090505b6005811015611742578386826005811061171357fe5b602002015110156117355785816005811061172a57fe5b602002015193508092505b80806001019150506116fd565b505b8080600101915050611687565b505050915091565b6040518060a0016040528060059060208202803883398082019150509050509056fea265627a7a723158204e40307cae9c4be0201d18965c51e37151094012c2cef32c9885237e051d17dd64736f6c63430005100032
Libraries Used
TellorTransfer : 0x82b8d6b5dc1a6955aefc86d470fc76021ef89d9cUnverifiedTellorDispute : 0xb8d292c3c553f0e4f99ba73c84565e51b65b4d0fUnverifiedTellorStake : 0x2115bee35c7519ff353141258e62ee534c3d090fUnverifiedTellorLibrary : 0x3b3552cd4477f9b5494c67cdc093350c072315b2Unverified
Deployed ByteCode Sourcemap
92705:8422:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;92705:8422:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;98435:97;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;98435:97:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;97366:135;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;97366:135:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;96499:73;;;:::i;:::-;;98201:157;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;98201:157:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;94396:121;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;94396:121:0;;;;;;;;;;;;;;;;;;;:::i;:::-;;96821:93;;;:::i;:::-;;98781:78;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;99025:193;;;:::i;:::-;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;99025:193:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;95639:195;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;95639:195:0;;;;;;;;;;21:11:-1;8;5:28;2:2;;;46:1;43;36:12;2:2;95639:195:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;95639:195:0;;;;;;100:9:-1;95:1;81:12;77:20;67:8;63:35;60:50;39:11;25:12;22:29;11:107;8:2;;;131:1;128;121:12;8:2;95639:195:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;94161:97;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;94161:97:0;;;;;;;;;;;;;;;;;:::i;:::-;;96333:77;;;:::i;:::-;;95186:173;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;95186:173:0;;;;;;;;;;21:11:-1;8;5:28;2:2;;;46:1;43;36:12;2:2;95186:173:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;95186:173:0;;;;;;100:9:-1;95:1;81:12;77:20;67:8;63:35;60:50;39:11;25:12;22:29;11:107;8:2;;;131:1;128;121:12;8:2;95186:173:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;96119:123;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;96119:123:0;;;;;;;;;;;;;;;;;;;:::i;:::-;;94802:109;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;94802:109:0;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;93559:167;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;93559:167:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;98611:87;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;98611:87:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;100199:113;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;100199:113:0;;;;;;;;;;;;;;;;;:::i;:::-;;99586:171;;;:::i;:::-;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;99586:171:0;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;99586:171:0;;;;;;;;;;;;;;;;;97722:127;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;97722:127:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;97044:75;;;:::i;:::-;;93936:126;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;93936:126:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;99971:104;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;99971:104:0;;;;;;;;;;;;;;;;;:::i;:::-;;99329:131;;;:::i;:::-;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;99329:131:0;;;;;;;;;;;;;;;;98435:97;98474:13;98500:24;;;;;;;;;;;;;;;;;;;98435:97;:::o;97366:135::-;97436:4;97460:6;:14;;;;97475:8;97485:7;97460:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;97460:33:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;97460:33:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;97460:33:0;;;;;;;;;;;;;;;;97453:40;;97366:135;;;;:::o;96499:73::-;96543:6;:19;;;;:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;96543:21:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;96543:21:0;;;;96499:73::o;98201:157::-;98286:4;98310:6;:19;;;;98330:5;98337:3;98342:7;98310:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;98310:40:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;98310:40:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;98310:40:0;;;;;;;;;;;;;;;;98303:47;;98201:157;;;;;:::o;94396:121::-;94468:6;:18;;;;94487:21;94468:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;94468:41:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;94468:41:0;;;;94396:121;:::o;96821:93::-;96875:6;:29;;;;:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;96875:31:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;96875:31:0;;;;96821:93::o;98781:78::-;98824:5;98849:2;98842:9;;98781:78;:::o;99025:193::-;99081:18;99100:26;;:::i;:::-;99127:19;99148:12;99179:31;:6;:29;:31::i;:::-;99172:38;;;;;;;;99025:193;;;;:::o;95639:195::-;95772:6;:27;;;;95800:6;;95807:10;95819:6;95772:54;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;95772:54:0;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;95772:54:0;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;95772:54:0;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;95772:54:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;95772:54:0;;;;95639:195;;;;:::o;94161:97::-;94221:6;:17;;;;94239:10;94221:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;94221:29:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;94221:29:0;;;;94161:97;:::o;96333:77::-;96379:6;:21;;;;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;96379:23:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;96379:23:0;;;;96333:77::o;95186:173::-;95296:6;:27;;;;95324:6;;95332:10;95344:6;95296:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;95296:55:0;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;95296:55:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;95296:55:0;;;;95186:173;;;;:::o;96119:123::-;96196:6;:23;;;;96220:13;96196:38;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;96196:38:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;96196:38:0;;;;96119:123;:::o;94802:109::-;94872:6;:13;;;;94886:10;94898:4;94872:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;94872:31:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;94872:31:0;;;;94802:109;;:::o;93559:167::-;93662:6;:19;;;;93682:10;93694;93706:11;93662:56;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;93662:56:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;93662:56:0;;;;93559:167;;;:::o;98611:87::-;98652:13;98678:12;;;;;;;;;;;;;;;;;;;98611:87;:::o;100199:113::-;100269:6;:23;;;;100293:10;100269:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;100269:35:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;100269:35:0;;;;100199:113;:::o;99586:171::-;99642:27;;:::i;:::-;99671:28;;:::i;:::-;99719:30;:6;:28;:30::i;:::-;99712:37;;;;99586:171;;:::o;97722:127::-;97788:4;97812:6;:15;;;;97828:3;97833:7;97812:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;97812:29:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;97812:29:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;97812:29:0;;;;;;;;;;;;;;;;97805:36;;97722:127;;;;:::o;97044:75::-;97089:6;:20;;;;:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;97089:22:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;97089:22:0;;;;97044:75::o;93936:126::-;94013:6;:11;;;;94025:10;94037:16;94013:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;94013:41:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;94013:41:0;;;;93936:126;;:::o;99971:104::-;100036:6;:19;;;;100056:10;100036:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;100036:31:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;100036:31:0;;;;99971:104;:::o;99329:131::-;99379:29;;:::i;:::-;99427:25;:6;:23;:25::i;:::-;99420:32;;99329:131;:::o;30987:430::-;31089:18;31108:26;;:::i;:::-;31135:19;31156:12;31184:6;31191:1;31184:8;;31180:93;31195:1;31193;:3;31180:93;;;31234:4;:18;;31253:1;31234:21;;;;;;;;;;:27;;;31216:11;31228:1;31216:14;;;;;;;;;;:45;;;;;31197:3;;;;;;;31180:93;;;;31291:4;:21;;;31313:11;31325:4;:13;;:38;31339:23;;;;;;;;;;;;;;;;;;;31325:38;;;;;;;;;;;;31364:4;:13;;:44;31378:29;;;;;;;;;;;;;;;;;;;31364:44;;;;;;;;;;;;31283:126;;;;;;;;30987:430;;;;;:::o;31641:358::-;31743:27;;:::i;:::-;31772:28;;:::i;:::-;31825:22;31842:4;31825:16;:22::i;:::-;31813:34;;31862:6;31871:1;31862:10;;31858:134;31875:1;31873;:3;31858:134;;;31912:4;:19;;:33;31932:9;31942:1;31932:12;;;;;;;;;;;31912:33;;;;;;;;;;;:45;;:68;31958:21;;;;;;;;;;;;;;;;;;;31912:68;;;;;;;;;;;;31896:10;31907:1;31896:13;;;;;;;;;;:84;;;;;31877:3;;;;;;;31858:134;;;;31641:358;;;:::o;32277:527::-;32374:29;;:::i;:::-;32416:22;;:::i;:::-;32449:24;;:::i;:::-;32501:32;32519:4;:13;;32501:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:17;:32::i;:::-;32484:49;;;;;;;;32548:6;32555:1;32548:8;;32544:253;32559:1;32557;:3;32544:253;;;32593:1;32583:4;32588:1;32583:7;;;;;;;;;;;:11;32580:206;;;32631:4;:29;;:40;32661:6;32668:1;32661:9;;;;;;;;;;;32631:40;;;;;;;;;;;;32614:11;32626:1;32614:14;;;;;;;;;;:57;;;;;32580:206;;;32741:4;:18;;32762:1;32760;:3;32741:23;;;;;;;;;;:29;;;32724:11;32736:1;32724:14;;;;;;;;;;:46;;;;;32580:206;32561:3;;;;;;;32544:253;;;;32277:527;;;;;:::o;43263:853::-;43328:21;;:::i;:::-;43351:26;;:::i;:::-;43390:12;43405:4;43410:1;43405:7;;;;;;;;;;;43390:22;;43423:12;43438:1;43423:16;;43454:9;43464:1;43454:11;;43450:238;43468:1;43466;:3;43450:238;;;43497:4;43504:1;43502;:3;43497:9;;;;;;;;;;;43489:3;43493:1;43489:6;;;;;;;;;;:17;;;;;43553:1;43551;:3;43537:8;43546:1;43537:11;;;;;;;;;;:17;;;;;43597:4;43588:3;43592:1;43588:6;;;;;;;;;;;:13;43585:92;;;43628:3;43632:1;43628:6;;;;;;;;;;;43621:13;;43660:1;43653:8;;43585:92;43470:3;;;;;;;43450:238;;;;43702:9;43714:1;43702:13;;43698:411;43721:11;43717:1;:15;43698:411;;;43768:4;43758;43763:1;43758:7;;;;;;;;;;;:14;43754:344;;;43805:4;43810:1;43805:7;;;;;;;;;;;43793:3;43797:4;43793:9;;;;;;;;;;:19;;;;;43848:1;43831:8;43840:4;43831:14;;;;;;;;;;:18;;;;;43875:4;43880:1;43875:7;;;;;;;;;;;43868:14;;43905:9;43915:1;43905:11;;43901:182;43919:1;43917;:3;43901:182;;;43960:4;43951:3;43955:1;43951:6;;;;;;;;;;;:13;43948:116;;;43999:3;44003:1;43999:6;;;;;;;;;;;43992:13;;44039:1;44032:8;;43948:116;43921:3;;;;;;;43901:182;;;;43754:344;43734:3;;;;;;;43698:411;;;;43263:853;;;;;:::o;92705:8422::-;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;92705:8422:0;;;;:::o
Swarm Source
bzzr://4e40307cae9c4be0201d18965c51e37151094012c2cef32c9885237e051d17dd
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.