Unnamed: 0 int64 0 7.36k | comments stringlengths 3 35.2k | code_string stringlengths 1 527k | code stringlengths 1 527k | __index_level_0__ int64 0 88.6k |
|---|---|---|---|---|
33 | // 将`HT数量`的`HT`token发送到`pair合约`地址 | assert(IWHT(WHT).transfer(pair, amountHT));
| assert(IWHT(WHT).transfer(pair, amountHT));
| 15,646 |
271 | // Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. / | function revokeRole(bytes32 role, address account) external;
| function revokeRole(bytes32 role, address account) external;
| 5,198 |
284 | // Increase the boost total proportionately. | totalFeiBoosted += feiAmount;
| totalFeiBoosted += feiAmount;
| 11,048 |
90 | // Anyone: query value associated with address.returns zero if absent. | function get(address a) external view override returns (uint256) {
return theList.contains(a) ? theList.get(a) : 0;
}
| function get(address a) external view override returns (uint256) {
return theList.contains(a) ? theList.get(a) : 0;
}
| 23,388 |
60 | // missing alright | _finalizeSlashing(schainId, toNodeIndex);
return;
| _finalizeSlashing(schainId, toNodeIndex);
return;
| 26,947 |
6 | // Add to token to cToken mapping. Add to token to cToken mapping. _cTokens list of cToken addresses to be added to the mapping. / | function addTokenToCToken(address[] memory _cTokens) public {
for (uint256 i = 0; i < _cTokens.length; i++) {
(bool isMarket_, , ) = troller.markets(_cTokens[i]);
require(isMarket_, "unvalid-ctoken");
address token_ = CTokenInterface(_cTokens[i]).underlying();
require(tokenToCToken[token_] == address((0)), "already-added");
tokenToCToken[token_] = _cTokens[i];
IERC20(token_).safeApprove(_cTokens[i], type(uint256).max);
}
}
| function addTokenToCToken(address[] memory _cTokens) public {
for (uint256 i = 0; i < _cTokens.length; i++) {
(bool isMarket_, , ) = troller.markets(_cTokens[i]);
require(isMarket_, "unvalid-ctoken");
address token_ = CTokenInterface(_cTokens[i]).underlying();
require(tokenToCToken[token_] == address((0)), "already-added");
tokenToCToken[token_] = _cTokens[i];
IERC20(token_).safeApprove(_cTokens[i], type(uint256).max);
}
}
| 19,585 |
91 | // returns the allowance for a spender | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return allowances[owner][spender];
}
| function allowance(address owner, address spender) public view virtual override returns (uint256) {
return allowances[owner][spender];
}
| 11,398 |
138 | // Tellor Getters LibraryThis 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")]
* @return address requested
*/
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 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 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")];
}
}
| 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")]
* @return address requested
*/
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 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 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")];
}
}
| 26,048 |
141 | // S1 + S2 + SL1 + SL2 == TAD | assert(total_available_deposit == (
participant1_amount +
participant2_amount +
participant1_locked_amount +
participant2_locked_amount
));
return (
participant1_amount,
participant2_amount,
| assert(total_available_deposit == (
participant1_amount +
participant2_amount +
participant1_locked_amount +
participant2_locked_amount
));
return (
participant1_amount,
participant2_amount,
| 16,952 |
7 | // delegateTransferBatch is a part of off-chain operations like withdrawing assets. / | function delegateTransferBatch(
address[] calldata from,
address[] calldata to,
uint256[] calldata tokens,
uint256[] calldata expireAt,
bytes[] calldata sig
| function delegateTransferBatch(
address[] calldata from,
address[] calldata to,
uint256[] calldata tokens,
uint256[] calldata expireAt,
bytes[] calldata sig
| 26,191 |
118 | // this portion of earned rewards go to referrer | uint public REFERRAL_FEE_RATE_X_100 = 500;
| uint public REFERRAL_FEE_RATE_X_100 = 500;
| 25,222 |
9 | // Set one or more DNS records.Records are supplied in wire-format.Records with the same node/name/resource must be supplied one after theother to ensure the data is updated correctly. For example, if the datawas supplied:a.example.com IN A 1.2.3.4a.example.com IN A 5.6.7.8www.example.com IN CNAME a.example.com.then this would store the two A records for a.example.com correctly as asingle RRSET, however if the data was supplied:a.example.com IN A 1.2.3.4www.example.com IN CNAME a.example.com.a.example.com IN A 5.6.7.8then this would store the first A record, the CNAME, then the second Arecord which would overwrite the first.node the namehash of the node for which to set the records data | function setDNSRecords(bytes32 node, bytes calldata data) external authorised(node) {
uint16 resource = 0;
uint256 offset = 0;
bytes memory name;
bytes memory value;
bytes32 nameHash;
// Iterate over the data to add the resource records
for (RRUtils.RRIterator memory iter = data.iterateRRs(0); !iter.done(); iter.next()) {
if (resource == 0) {
resource = iter.dnstype;
name = iter.name();
nameHash = keccak256(abi.encodePacked(name));
value = bytes(iter.rdata());
} else {
bytes memory newName = iter.name();
if (resource != iter.dnstype || !name.equals(newName)) {
setDNSRRSet(node, name, resource, data, offset, iter.offset - offset, value.length == 0);
resource = iter.dnstype;
offset = iter.offset;
name = newName;
nameHash = keccak256(name);
value = bytes(iter.rdata());
}
}
}
if (name.length > 0) {
setDNSRRSet(node, name, resource, data, offset, data.length - offset, value.length == 0);
}
}
| function setDNSRecords(bytes32 node, bytes calldata data) external authorised(node) {
uint16 resource = 0;
uint256 offset = 0;
bytes memory name;
bytes memory value;
bytes32 nameHash;
// Iterate over the data to add the resource records
for (RRUtils.RRIterator memory iter = data.iterateRRs(0); !iter.done(); iter.next()) {
if (resource == 0) {
resource = iter.dnstype;
name = iter.name();
nameHash = keccak256(abi.encodePacked(name));
value = bytes(iter.rdata());
} else {
bytes memory newName = iter.name();
if (resource != iter.dnstype || !name.equals(newName)) {
setDNSRRSet(node, name, resource, data, offset, iter.offset - offset, value.length == 0);
resource = iter.dnstype;
offset = iter.offset;
name = newName;
nameHash = keccak256(name);
value = bytes(iter.rdata());
}
}
}
if (name.length > 0) {
setDNSRRSet(node, name, resource, data, offset, data.length - offset, value.length == 0);
}
}
| 29,605 |
21 | // Changes canvas.bookFor variable. Only for the owner of the contract./ | function bookCanvasFor(uint32 _canvasId, address _bookFor) external onlyOwner {
Canvas storage _canvas = _getCanvas(_canvasId);
_canvas.bookedFor = _bookFor;
}
| function bookCanvasFor(uint32 _canvasId, address _bookFor) external onlyOwner {
Canvas storage _canvas = _getCanvas(_canvasId);
_canvas.bookedFor = _bookFor;
}
| 19,738 |
269 | // UserManager Interface Manages the Union members credit lines, and their vouchees and borrowers info. / | interface IUserManager {
/**
* @dev Check if the account is a valid member
* @param account Member address
* @return Address whether is member
*/
function checkIsMember(address account) external view returns (bool);
/**
* @dev Get member borrowerAddresses
* @param account Member address
* @return Address array
*/
function getBorrowerAddresses(address account) external view returns (address[] memory);
/**
* @dev Get member stakerAddresses
* @param account Member address
* @return Address array
*/
function getStakerAddresses(address account) external view returns (address[] memory);
/**
* @dev Get member backer asset
* @param account Member address
* @param borrower Borrower address
* @return Trust amount, vouch amount, and locked stake amount
*/
function getBorrowerAsset(address account, address borrower)
external
view
returns (
uint256,
uint256,
uint256
);
/**
* @dev Get member stakers asset
* @param account Member address
* @param staker Staker address
* @return Vouch amount and lockedStake
*/
function getStakerAsset(address account, address staker)
external
view
returns (
uint256,
uint256,
uint256
);
/**
* @dev Get the member's available credit line
* @param account Member address
* @return Limit
*/
function getCreditLimit(address account) external view returns (int256);
function totalStaked() external view returns (uint256);
function totalFrozen() external view returns (uint256);
function getFrozenCoinAge(address staker, uint256 pastBlocks) external view returns (uint256);
/**
* @dev Add a new member
* Accept claims only from the admin
* @param account Member address
*/
function addMember(address account) external;
/**
* @dev Update the trust amount for exisitng members.
* @param borrower Borrower address
* @param trustAmount Trust amount
*/
function updateTrust(address borrower, uint256 trustAmount) external;
/**
* @dev Apply for membership, and burn UnionToken as application fees
* @param newMember New member address
*/
function registerMember(address newMember) external;
/**
* @dev Stop vouch for other member.
* @param staker Staker address
* @param account Account address
*/
function cancelVouch(address staker, address account) external;
/**
* @dev Change the credit limit model
* Accept claims only from the admin
* @param newCreditLimitModel New credit limit model address
*/
function setCreditLimitModel(address newCreditLimitModel) external;
/**
* @dev Get the user's locked stake from all his backed loans
* @param staker Staker address
* @return LockedStake
*/
function getTotalLockedStake(address staker) external view returns (uint256);
/**
* @dev Get staker's defaulted / frozen staked token amount
* @param staker Staker address
* @return Frozen token amount
*/
function getTotalFrozenAmount(address staker) external view returns (uint256);
/**
* @dev Update userManager locked info
* @param borrower Borrower address
* @param amount Borrow or repay amount(Including previously accrued interest)
* @param isBorrow True is borrow, false is repay
*/
function updateLockedData(
address borrower,
uint256 amount,
bool isBorrow
) external;
/**
* @dev Get the user's deposited stake amount
* @param account Member address
* @return Deposited stake amount
*/
function getStakerBalance(address account) external view returns (uint256);
/**
* @dev Stake
* @param amount Amount
*/
function stake(uint256 amount) external;
/**
* @dev Unstake
* @param amount Amount
*/
function unstake(uint256 amount) external;
/**
* @dev Update total frozen
* @param account borrower address
* @param isOverdue account is overdue
*/
function updateTotalFrozen(address account, bool isOverdue) external;
function batchUpdateTotalFrozen(address[] calldata account, bool[] calldata isOverdue) external;
/**
* @dev Repay user's loan overdue, called only from the lending market
* @param account User address
* @param lastRepay Last repay block number
*/
function repayLoanOverdue(
address account,
address token,
uint256 lastRepay
) external;
}
| interface IUserManager {
/**
* @dev Check if the account is a valid member
* @param account Member address
* @return Address whether is member
*/
function checkIsMember(address account) external view returns (bool);
/**
* @dev Get member borrowerAddresses
* @param account Member address
* @return Address array
*/
function getBorrowerAddresses(address account) external view returns (address[] memory);
/**
* @dev Get member stakerAddresses
* @param account Member address
* @return Address array
*/
function getStakerAddresses(address account) external view returns (address[] memory);
/**
* @dev Get member backer asset
* @param account Member address
* @param borrower Borrower address
* @return Trust amount, vouch amount, and locked stake amount
*/
function getBorrowerAsset(address account, address borrower)
external
view
returns (
uint256,
uint256,
uint256
);
/**
* @dev Get member stakers asset
* @param account Member address
* @param staker Staker address
* @return Vouch amount and lockedStake
*/
function getStakerAsset(address account, address staker)
external
view
returns (
uint256,
uint256,
uint256
);
/**
* @dev Get the member's available credit line
* @param account Member address
* @return Limit
*/
function getCreditLimit(address account) external view returns (int256);
function totalStaked() external view returns (uint256);
function totalFrozen() external view returns (uint256);
function getFrozenCoinAge(address staker, uint256 pastBlocks) external view returns (uint256);
/**
* @dev Add a new member
* Accept claims only from the admin
* @param account Member address
*/
function addMember(address account) external;
/**
* @dev Update the trust amount for exisitng members.
* @param borrower Borrower address
* @param trustAmount Trust amount
*/
function updateTrust(address borrower, uint256 trustAmount) external;
/**
* @dev Apply for membership, and burn UnionToken as application fees
* @param newMember New member address
*/
function registerMember(address newMember) external;
/**
* @dev Stop vouch for other member.
* @param staker Staker address
* @param account Account address
*/
function cancelVouch(address staker, address account) external;
/**
* @dev Change the credit limit model
* Accept claims only from the admin
* @param newCreditLimitModel New credit limit model address
*/
function setCreditLimitModel(address newCreditLimitModel) external;
/**
* @dev Get the user's locked stake from all his backed loans
* @param staker Staker address
* @return LockedStake
*/
function getTotalLockedStake(address staker) external view returns (uint256);
/**
* @dev Get staker's defaulted / frozen staked token amount
* @param staker Staker address
* @return Frozen token amount
*/
function getTotalFrozenAmount(address staker) external view returns (uint256);
/**
* @dev Update userManager locked info
* @param borrower Borrower address
* @param amount Borrow or repay amount(Including previously accrued interest)
* @param isBorrow True is borrow, false is repay
*/
function updateLockedData(
address borrower,
uint256 amount,
bool isBorrow
) external;
/**
* @dev Get the user's deposited stake amount
* @param account Member address
* @return Deposited stake amount
*/
function getStakerBalance(address account) external view returns (uint256);
/**
* @dev Stake
* @param amount Amount
*/
function stake(uint256 amount) external;
/**
* @dev Unstake
* @param amount Amount
*/
function unstake(uint256 amount) external;
/**
* @dev Update total frozen
* @param account borrower address
* @param isOverdue account is overdue
*/
function updateTotalFrozen(address account, bool isOverdue) external;
function batchUpdateTotalFrozen(address[] calldata account, bool[] calldata isOverdue) external;
/**
* @dev Repay user's loan overdue, called only from the lending market
* @param account User address
* @param lastRepay Last repay block number
*/
function repayLoanOverdue(
address account,
address token,
uint256 lastRepay
) external;
}
| 70,480 |
164 | // Deposit assets into the Sett, and return corresponding shares to the user/Only callable by EOA accounts that pass the _defend() check | function deposit(uint256 _amount) public whenNotPaused {
_defend();
_blockLocked();
_lockForBlock(msg.sender);
_depositWithAuthorization(_amount, new bytes32[](0));
}
| function deposit(uint256 _amount) public whenNotPaused {
_defend();
_blockLocked();
_lockForBlock(msg.sender);
_depositWithAuthorization(_amount, new bytes32[](0));
}
| 28,102 |
222 | // Update cumulative fee factor with new fees The cumulativeFeeFactor is used to calculate fees for all delegators including the transcoder (self-delegated) Note that delegatorsFees includes transcoderRewardStakeFees, but no delegator will claim that amount using the earnings claiming algorithm and instead that amount is accounted for in the transcoder's cumulativeFees field | earningsPool.updateCumulativeFeeFactor(prevEarningsPool, delegatorsFees);
t.lastFeeRound = currentRound;
| earningsPool.updateCumulativeFeeFactor(prevEarningsPool, delegatorsFees);
t.lastFeeRound = currentRound;
| 35,238 |
36 | // This contract : The address for the database contract used by this platform | constructor(address _database, address _events, address _kyber)
| constructor(address _database, address _events, address _kyber)
| 11,586 |
29 | // Transfer tokens from msg.sender to this contract on this blockchain,and request tokens on the remote blockchain be given to the requestedaccount on the destination blockchain. NOTE: msg.sender must have called approve() on the token contract._srcTokenContract Address of ERC 20 contract on this blockchain. _recipientAddress of account to transfer tokens to on the destination blockchain. _tokenIdId of token transferred. / | function transferToOtherBlockchain(
uint256 _destBcId,
address _srcTokenContract,
address _recipient,
uint256 _tokenId
| function transferToOtherBlockchain(
uint256 _destBcId,
address _srcTokenContract,
address _recipient,
uint256 _tokenId
| 7,893 |
53 | // Bird's BErc20 Interface/ | contract BErc20Interface is BErc20Storage {
/*** User Interface ***/
function mint(uint mintAmount) external returns (uint);
function redeem(uint redeemTokens) external returns (uint);
function redeemUnderlying(uint redeemAmount) external returns (uint);
function borrow(uint borrowAmount) external returns (uint);
function repayBorrow(uint repayAmount) external returns (uint);
function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);
function liquidateBorrow(address borrower, uint repayAmount, BTokenInterface bTokenCollateral) external returns (uint);
/*** Admin Functions ***/
function _addReserves(uint addAmount) external returns (uint);
}
| contract BErc20Interface is BErc20Storage {
/*** User Interface ***/
function mint(uint mintAmount) external returns (uint);
function redeem(uint redeemTokens) external returns (uint);
function redeemUnderlying(uint redeemAmount) external returns (uint);
function borrow(uint borrowAmount) external returns (uint);
function repayBorrow(uint repayAmount) external returns (uint);
function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);
function liquidateBorrow(address borrower, uint repayAmount, BTokenInterface bTokenCollateral) external returns (uint);
/*** Admin Functions ***/
function _addReserves(uint addAmount) external returns (uint);
}
| 20,148 |
224 | // If the user specifies -1 amount to repay (“max”), repayAmount => the lesser of the senders ERC-20 balance and borrowCurrent | if (amount == uint(-1)) {
localResults.repayAmount = min(getBalanceOf(asset, msg.sender), localResults.userBorrowCurrent);
} else {
| if (amount == uint(-1)) {
localResults.repayAmount = min(getBalanceOf(asset, msg.sender), localResults.userBorrowCurrent);
} else {
| 3,657 |
5 | // if status == open, then no whitelist [no mapping needed]. But then we need a removeListing function for contracts we subsequently/ return open | bool public open;
| bool public open;
| 19,137 |
178 | // KO commission on every sale | uint256 public platformPrimarySaleCommission = 15_00000; // 15.00000%
constructor(IKOAccessControlsLookup _accessControls, IKODAV3 _koda, address _platformAccount)
| uint256 public platformPrimarySaleCommission = 15_00000; // 15.00000%
constructor(IKOAccessControlsLookup _accessControls, IKODAV3 _koda, address _platformAccount)
| 23,967 |
25 | // Allows to add a new _owner. Transaction has to be sent by wallet./_owner Address of new owner./_ownerName Name of new owner. | function addOwner(address payable _owner, bytes32 _ownerName)
public
onlyWallet
ownerDoesNotExist(_owner)
notNull(_owner)
validRequirement(owners.length + 1, required)
| function addOwner(address payable _owner, bytes32 _ownerName)
public
onlyWallet
ownerDoesNotExist(_owner)
notNull(_owner)
validRequirement(owners.length + 1, required)
| 40,995 |
3 | // if owner is not contract, return | if (!owner.isContract()) {
return owner;
}
| if (!owner.isContract()) {
return owner;
}
| 437 |
39 | // get the reserve-configuration of the converter | for (uint i = 0; i < reserveTokenCount; i++) {
IERC20Token reserveToken = _converter.connectorTokens(i);
reserveTokens[i] = reserveToken;
reserveRatios[i] = getReserveRatio(_converter, reserveToken);
}
| for (uint i = 0; i < reserveTokenCount; i++) {
IERC20Token reserveToken = _converter.connectorTokens(i);
reserveTokens[i] = reserveToken;
reserveRatios[i] = getReserveRatio(_converter, reserveToken);
}
| 2,203 |
10 | // Send funds to the addresses provided needsFunding the list of addresses to fund (addresses must be pre-approved) / | function topUpExact(address[] memory needsFunding) internal whenNotPaused {
uint256 minWaitPeriodSeconds = MinWaitPeriodSeconds;
Target memory target;
for (uint256 idx = 0; idx < needsFunding.length; idx++) {
target = recipientConfigs[needsFunding[idx]];
uint256 delta = target.topUpToAmountWei - needsFunding[idx].balance;
if (
target.isActive &&
target.lastTopUpTimestamp + minWaitPeriodSeconds <= block.timestamp // Not too fast
// skip we have bags check as it will revert anyway + should never happen is not a security issue
) {
bool success = payable(needsFunding[idx]).send(delta);
if (needsFunding[idx].balance > target.topUpToAmountWei) {// We're not overfunding
revert BalanceTooHigh(needsFunding[idx], needsFunding[idx].balance);
}
if (success) {
recipientConfigs[needsFunding[idx]].lastTopUpTimestamp = uint56(block.timestamp);
emit TopUpSucceeded(needsFunding[idx]);
} else {
emit TopUpFailed(needsFunding[idx], delta);
}
}
if (gasleft() < MIN_GAS_FOR_TRANSFER) {
emit TopUpFailed(needsFunding[idx], delta);
return;
}
}
}
| function topUpExact(address[] memory needsFunding) internal whenNotPaused {
uint256 minWaitPeriodSeconds = MinWaitPeriodSeconds;
Target memory target;
for (uint256 idx = 0; idx < needsFunding.length; idx++) {
target = recipientConfigs[needsFunding[idx]];
uint256 delta = target.topUpToAmountWei - needsFunding[idx].balance;
if (
target.isActive &&
target.lastTopUpTimestamp + minWaitPeriodSeconds <= block.timestamp // Not too fast
// skip we have bags check as it will revert anyway + should never happen is not a security issue
) {
bool success = payable(needsFunding[idx]).send(delta);
if (needsFunding[idx].balance > target.topUpToAmountWei) {// We're not overfunding
revert BalanceTooHigh(needsFunding[idx], needsFunding[idx].balance);
}
if (success) {
recipientConfigs[needsFunding[idx]].lastTopUpTimestamp = uint56(block.timestamp);
emit TopUpSucceeded(needsFunding[idx]);
} else {
emit TopUpFailed(needsFunding[idx], delta);
}
}
if (gasleft() < MIN_GAS_FOR_TRANSFER) {
emit TopUpFailed(needsFunding[idx], delta);
return;
}
}
}
| 13,326 |
11 | // Stores a new address in the EIP1967 admin slot. / | function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), 'ERC1967: new admin is the zero address');
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
| function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), 'ERC1967: new admin is the zero address');
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
| 30,022 |
142 | // requirement below is satisfied by statements aboverequire(!_isPricedLtOrEq(id, prev_id)); | _rank[prev_id].next = id;
_rank[id].prev = prev_id;
| _rank[prev_id].next = id;
_rank[id].prev = prev_id;
| 39,566 |
4 | // ECN to 1 wei ratio. | uint256 public constant ECN_PER_WEI = 40000;
| uint256 public constant ECN_PER_WEI = 40000;
| 19,599 |
17 | // untistupids function | function transferAnyTokens(address _erc20, address _receiver, uint _amount) public onlyOwner {
BaseERC20(_erc20).transfer(_receiver, _amount);
}
| function transferAnyTokens(address _erc20, address _receiver, uint _amount) public onlyOwner {
BaseERC20(_erc20).transfer(_receiver, _amount);
}
| 42,476 |
27 | // data layer | BitSTDData private data;
constructor(address dataAddress) {
data = BitSTDData(dataAddress);
owner = msg.sender;
}
| BitSTDData private data;
constructor(address dataAddress) {
data = BitSTDData(dataAddress);
owner = msg.sender;
}
| 18,798 |
241 | // Get the consumer address of an NFT/The zero address indicates that there is no consumer/ Throws if `_tokenId` is not a valid NFT/_tokenId The NFT to get the consumer address for/ return The consumer address for this NFT, or the zero address if there is none | function consumerOf(uint256 _tokenId) external view returns (address);
| function consumerOf(uint256 _tokenId) external view returns (address);
| 69,145 |
14 | // Send any extra back | if (msg.value > domain.price) {
payable(msg.sender).transfer(msg.value - domain.price);
}
| if (msg.value > domain.price) {
payable(msg.sender).transfer(msg.value - domain.price);
}
| 46,596 |
8 | // address that rewardsTax is sent to | address payable public rewardsTaxRecipient;
| address payable public rewardsTaxRecipient;
| 15,042 |
7 | // called by a game controller to end a game/leaderboard - a list of wallets in order of descending score/requires GAME_CONTROLLER role | function endGame(address[] calldata leaderboard) public {
require(hasRole(GAME_CONTROLLER_ROLE, msg.sender), "Only an address with the GAME_CONTROLLER role can do this");
require(gameState == GameState.PLAYING, "Can only start a game from the PLAYING state");
require(leaderboard.length > 0, "Must have some players in the leaderboard");
uint prizePool = 0;
// Figure out the prize pool
for(uint i = 0; i < playersInGame.length; i++) {
prizePool += price;
}
uint paidOut = 0;
for(uint i = 0; i < leaderboard.length; i++) {
if(!playersInGameLookup[leaderboard[i]]) {
continue;
}
uint award = calculateAward(leaderboard.length, i, prizePool, paidOut);
if(award > 0) {
paidOut += award;
playerBalances[leaderboard[i]] += award;
playerBalanceTotal += award;
}
}
clearPlayingPlayers();
gameState = GameState.COMPLETE;
return;
}
| function endGame(address[] calldata leaderboard) public {
require(hasRole(GAME_CONTROLLER_ROLE, msg.sender), "Only an address with the GAME_CONTROLLER role can do this");
require(gameState == GameState.PLAYING, "Can only start a game from the PLAYING state");
require(leaderboard.length > 0, "Must have some players in the leaderboard");
uint prizePool = 0;
// Figure out the prize pool
for(uint i = 0; i < playersInGame.length; i++) {
prizePool += price;
}
uint paidOut = 0;
for(uint i = 0; i < leaderboard.length; i++) {
if(!playersInGameLookup[leaderboard[i]]) {
continue;
}
uint award = calculateAward(leaderboard.length, i, prizePool, paidOut);
if(award > 0) {
paidOut += award;
playerBalances[leaderboard[i]] += award;
playerBalanceTotal += award;
}
}
clearPlayingPlayers();
gameState = GameState.COMPLETE;
return;
}
| 4,881 |
406 | // Emitted when an action is paused on a market | event ActionPaused(CToken cToken, string action, bool pauseState);
| event ActionPaused(CToken cToken, string action, bool pauseState);
| 2,638 |
4 | // Harvest any profits made and transfer them to address(this) or report a loss/balance The amount of tokens that have been invested./ return amountAdded The delta (+profit or -loss) that occured in contrast to `balance`./amountAdded can be left at 0 when reporting profits (gas savings)./ amountAdded should not reflect any rewards or tokens the strategy received./ Calcualte the amount added based on what the current deposit is worth./ (The Base Strategy harvest function accounts for rewards). | function _harvest(uint256 balance) internal virtual returns (int256 amountAdded);
| function _harvest(uint256 balance) internal virtual returns (int256 amountAdded);
| 29,450 |
89 | // Check if there is an upgrade in queue and update the bounty. | _checkForUpgrade(bountyId);
| _checkForUpgrade(bountyId);
| 13,527 |
114 | // Safe fire transfer function, just in case if rounding error causes pool to not have enough FIREs. | function safeFireTransfer(address _to, uint256 _amount) public onlyOwner {
uint256 fireBal = fire.balanceOf(address(this));
if (_amount > fireBal) {
fire.transfer(_to, fireBal);
} else {
fire.transfer(_to, _amount);
}
}
| function safeFireTransfer(address _to, uint256 _amount) public onlyOwner {
uint256 fireBal = fire.balanceOf(address(this));
if (_amount > fireBal) {
fire.transfer(_to, fireBal);
} else {
fire.transfer(_to, _amount);
}
}
| 36,518 |
368 | // Time weighted average of the token weightings | function _calcWeightPoints(
uint256 prevWeight,
uint256 newWeight,
uint256 startCurrentWeek
)
internal
view
returns(uint256)
| function _calcWeightPoints(
uint256 prevWeight,
uint256 newWeight,
uint256 startCurrentWeek
)
internal
view
returns(uint256)
| 25,709 |
187 | // mint network tokens for the caller and lock them | networkToken.issue(address(store), targetAmount);
lockTokens(msg.sender, targetAmount);
return;
| networkToken.issue(address(store), targetAmount);
lockTokens(msg.sender, targetAmount);
return;
| 32,337 |
62 | // StakedBear Struct | struct StakedBear{
address owner;
uint256 lastClaimed;
bool isStaked;
bool isEmergencyOut;
uint256 emergencyOutTime;
}
| struct StakedBear{
address owner;
uint256 lastClaimed;
bool isStaked;
bool isEmergencyOut;
uint256 emergencyOutTime;
}
| 79,668 |
3 | // ensures miners that are under dispute cannot vote | require(self.stakerDetails[msg.sender].currentStatus != 3);
| require(self.stakerDetails[msg.sender].currentStatus != 3);
| 7,645 |
308 | // Called before any type of withdrawal occurs./assetAmount The amount of assets being withdrawn./Using requiresAuth here prevents unauthorized users from withdrawing. | function beforeWithdraw(uint256 assetAmount, uint256) internal override nonReentrant requiresAuth {
// Withdraw the assets from the Turbo Fuse Pool.
require(assetTurboCToken.redeemUnderlying(assetAmount) == 0, "REDEEM_FAILED");
}
| function beforeWithdraw(uint256 assetAmount, uint256) internal override nonReentrant requiresAuth {
// Withdraw the assets from the Turbo Fuse Pool.
require(assetTurboCToken.redeemUnderlying(assetAmount) == 0, "REDEEM_FAILED");
}
| 80,749 |
371 | // Send bond amount to challenger | msg.sender.send(BOND_AMOUNT);
| msg.sender.send(BOND_AMOUNT);
| 49,020 |
190 | // Approve or remove `operator` as an operator for the caller.Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. Requirements: - The `operator` cannot be the caller. Emits an {ApprovalForAll} event. / | function setApprovalForAll(address operator, bool _approved) external;
| function setApprovalForAll(address operator, bool _approved) external;
| 30,484 |
45 | // Returns the current implementation.return Address of the current implementation / | function _implementation() internal view returns (address impl) {
bytes32 slot = IMPLEMENTATION_SLOT;
assembly {
impl := sload(slot)
}
}
| function _implementation() internal view returns (address impl) {
bytes32 slot = IMPLEMENTATION_SLOT;
assembly {
impl := sload(slot)
}
}
| 8,413 |
55 | // create duplicate slices of _result string string memory resultCopy = _result; TODO: delete me if this all works | strings.slice memory resSlice = _result.toSlice();
strings.slice memory resCopySlice = _result.toSlice();
| strings.slice memory resSlice = _result.toSlice();
strings.slice memory resCopySlice = _result.toSlice();
| 38,124 |
16 | // make sure any of the voting date set is in the future | require(_votingDate > now, "voting date must be in the future");
_;
| require(_votingDate > now, "voting date must be in the future");
_;
| 17,476 |
16 | // Last two bits of a token ID represent the token type. We can use this mask to quickly check for specific types. | uint8 constant TOKEN_TYPE_MASK = 3; // 0b11
| uint8 constant TOKEN_TYPE_MASK = 3; // 0b11
| 22,843 |
102 | // PacoToken with Governance. | contract PacoToken is BEP20('Paco token', 'PACO') {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "PACO::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "PACO::delegateBySig: invalid nonce");
require(now <= expiry, "PACO::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "PACO::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying PACOs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "PACO::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | contract PacoToken is BEP20('Paco token', 'PACO') {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "PACO::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "PACO::delegateBySig: invalid nonce");
require(now <= expiry, "PACO::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "PACO::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying PACOs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "PACO::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | 23,438 |
47 | // Require caller to be owner | if (msg.sender != owner) revert NotOwner();
IERC721(nftContract).transferFrom(
| if (msg.sender != owner) revert NotOwner();
IERC721(nftContract).transferFrom(
| 43,975 |
112 | // Reassign ownership, clear pending approvals, emit Transfer event. | ethernautsStorage.transfer(msg.sender, _to, _tokenId);
| ethernautsStorage.transfer(msg.sender, _to, _tokenId);
| 14,630 |
22 | // Sets vesting factory address. High level endpoint. _vestingFactory The address of vesting factory contract.Splitting code on two functions: high level and low levelis a pattern that makes easy to extend functionality in a readable way,without accidentally breaking the actual action being performed.For example, checks should be done on high level endpoint, while corefunctionality should be coded on the low level function./ | function setVestingFactory(address _vestingFactory) public onlyOwner {
_setVestingFactory(_vestingFactory);
}
| function setVestingFactory(address _vestingFactory) public onlyOwner {
_setVestingFactory(_vestingFactory);
}
| 37,824 |
230 | // Returns an array of token IDs owned by `owner`,in the range [`start`, `stop`)(i.e. `start <= tokenId < stop`). This function allows for tokens to be queried if the collectiongrows too big for a single call of {ERC721AQueryable-tokensOfOwner}. Requirements: - `start` < `stop` / | function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
| function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
| 4,508 |
82 | // deploy the contract with the address from which tokens needs to be released | contractOwner = msg.sender;
ercToken = IERC20(tokenAddress);
| contractOwner = msg.sender;
ercToken = IERC20(tokenAddress);
| 36,115 |
148 | // Same as {get}, with a custom error message when `key` is not in the map. / | function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint256(_get(map._inner, bytes32(key), errorMessage)));
}
| function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint256(_get(map._inner, bytes32(key), errorMessage)));
}
| 1,336 |
20 | // hash the parameters, save them if necessary, and return the hash value/ | function setParameters(uint256 _precReq, address _voteOnBehalf) public returns(bytes32) {
require(_precReq <= 100 && _precReq > 0);
bytes32 hashedParameters = getParametersHash(_precReq, _voteOnBehalf);
parameters[hashedParameters] = Parameters({
precReq: _precReq,
voteOnBehalf: _voteOnBehalf
});
return hashedParameters;
}
| function setParameters(uint256 _precReq, address _voteOnBehalf) public returns(bytes32) {
require(_precReq <= 100 && _precReq > 0);
bytes32 hashedParameters = getParametersHash(_precReq, _voteOnBehalf);
parameters[hashedParameters] = Parameters({
precReq: _precReq,
voteOnBehalf: _voteOnBehalf
});
return hashedParameters;
}
| 30,238 |
10 | // -------------------------------------------------------------------------------------------------------constructor and tune ------------------------------------------------------------------------------------------------------- | constructor(address _daiTokenAddr, address _optionContractAddr) public {
daiToken = iERC20(_daiTokenAddr);
optionContract = iOptionContract(_optionContractAddr);
}
| constructor(address _daiTokenAddr, address _optionContractAddr) public {
daiToken = iERC20(_daiTokenAddr);
optionContract = iOptionContract(_optionContractAddr);
}
| 16,175 |
128 | // Helper function to migrate user's Ethers. Should be called in migrateFunds() function./ | function migrateEthers() private {
uint256 etherAmount = balances[ETH][msg.sender];
if (etherAmount > 0) {
balances[ETH][msg.sender] = 0;
IUpgradableExchange(newExchangeAddress).importEthers.value(etherAmount)(msg.sender);
}
}
| function migrateEthers() private {
uint256 etherAmount = balances[ETH][msg.sender];
if (etherAmount > 0) {
balances[ETH][msg.sender] = 0;
IUpgradableExchange(newExchangeAddress).importEthers.value(etherAmount)(msg.sender);
}
}
| 12,661 |
209 | // max per tx | function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
maxMintAmountPerTx = _maxMintAmountPerTx;
}
| function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
maxMintAmountPerTx = _maxMintAmountPerTx;
}
| 1,969 |
50 | // Tokens can be minted only before minting finished. / | modifier canMint() {
require(!_mintingFinished, "BEP20Mintable: minting is finished");
_;
}
| modifier canMint() {
require(!_mintingFinished, "BEP20Mintable: minting is finished");
_;
}
| 2,872 |
52 | // Create an ETH to token order _data - Bytes of an ETH to token order. See `encodeEthOrder` for more info / | function depositEth(
bytes calldata _data
| function depositEth(
bytes calldata _data
| 51,998 |
119 | // Update reward per block Only callable by owner. _rewardPerBlock: the reward per block / | function updateRewardPerBlock(uint256 _rewardPerBlock) external onlyOwner {
require(block.number < startBlock, 'Pool has started');
rewardPerBlock = _rewardPerBlock;
emit NewRewardPerBlock(_rewardPerBlock);
}
| function updateRewardPerBlock(uint256 _rewardPerBlock) external onlyOwner {
require(block.number < startBlock, 'Pool has started');
rewardPerBlock = _rewardPerBlock;
emit NewRewardPerBlock(_rewardPerBlock);
}
| 22,796 |
3 | // this event is emitted when the set of claim topics is changed for a given trusted issuer. the event is emitted by the updateIssuerClaimTopics function `trustedIssuer` is the address of the trusted issuer's ClaimIssuer contract `claimTopics` is the set of claims that the trusted issuer is allowed to emit / | event ClaimTopicsUpdated(IClaimIssuer indexed trustedIssuer, uint256[] claimTopics);
| event ClaimTopicsUpdated(IClaimIssuer indexed trustedIssuer, uint256[] claimTopics);
| 5,592 |
77 | // Converts WETH to Unic | function _toSUSHI(uint256 amountIn) internal {
IUnicSwapV2Pair pair = IUnicSwapV2Pair(factory.getPair(weth, unic));
// Choose WETH as input token
(uint reserve0, uint reserve1,) = pair.getReserves();
address token0 = pair.token0();
(uint reserveIn, uint reserveOut) = token0 == weth ? (reserve0, reserve1) : (reserve1, reserve0);
// Calculate information required to swap
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
uint amountOut = numerator / denominator;
(uint amount0Out, uint amount1Out) = token0 == weth ? (uint(0), amountOut) : (amountOut, uint(0));
// Swap WETH for Unic
pair.swap(amount0Out, amount1Out, bar, new bytes(0));
}
| function _toSUSHI(uint256 amountIn) internal {
IUnicSwapV2Pair pair = IUnicSwapV2Pair(factory.getPair(weth, unic));
// Choose WETH as input token
(uint reserve0, uint reserve1,) = pair.getReserves();
address token0 = pair.token0();
(uint reserveIn, uint reserveOut) = token0 == weth ? (reserve0, reserve1) : (reserve1, reserve0);
// Calculate information required to swap
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
uint amountOut = numerator / denominator;
(uint amount0Out, uint amount1Out) = token0 == weth ? (uint(0), amountOut) : (amountOut, uint(0));
// Swap WETH for Unic
pair.swap(amount0Out, amount1Out, bar, new bytes(0));
}
| 27,847 |
5 | // 提高竞价参数:拍卖id,出价人,新价格 | function biddingforNFT(uint256 _auctionid,uint256 _newprice)public {
Auction memory thisauction=allAuctions[_auctionid];
require(thisauction.MaxPrice<_newprice);
thisauction.MaxPrice=_newprice;
thisauction.MaxBidder=payable(msg.sender);
allAuctions[_auctionid]=thisauction;
attendAuctions[msg.sender].push(_auctionid);
attendNum[msg.sender]++;
return ;
}
| function biddingforNFT(uint256 _auctionid,uint256 _newprice)public {
Auction memory thisauction=allAuctions[_auctionid];
require(thisauction.MaxPrice<_newprice);
thisauction.MaxPrice=_newprice;
thisauction.MaxBidder=payable(msg.sender);
allAuctions[_auctionid]=thisauction;
attendAuctions[msg.sender].push(_auctionid);
attendNum[msg.sender]++;
return ;
}
| 51,077 |
4 | // This is the emitted event, when a sell is removed. | event DeletedSell(
address indexed seller,
uint256 indexed sellId,
uint256 tokenId,
uint256 amountOfToken
);
| event DeletedSell(
address indexed seller,
uint256 indexed sellId,
uint256 tokenId,
uint256 amountOfToken
);
| 4,973 |
164 | // Last timestamp at which the `sanRate` has been updated for SLPs | uint256 lastBlockUpdated;
| uint256 lastBlockUpdated;
| 70,899 |
36 | // Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. beneficiary Address performing the token purchase tokenAmount Number of tokens to be emitted / | function _deliverTokens(
address beneficiary,
uint256 tokenAmount
)
internal
| function _deliverTokens(
address beneficiary,
uint256 tokenAmount
)
internal
| 25,461 |
166 | // Transfer dDai into the trade helper. | require(ERC20Interface(address(_DDAI)).transfer(address(_TRADE_HELPER), dDaiToSupply));
| require(ERC20Interface(address(_DDAI)).transfer(address(_TRADE_HELPER), dDaiToSupply));
| 52,666 |
117 | // update data tracking | setNewData(addTokenDataIndex);
addTokenToken = token;
addTokenMinimalResolution = minimalRecordResolution; // can be roughly 1 cent
addTokenMaxPerBlockImbalance = maxPerBlockImbalance; // in twei resolution
addTokenMaxTotalImbalance = maxTotalImbalance;
| setNewData(addTokenDataIndex);
addTokenToken = token;
addTokenMinimalResolution = minimalRecordResolution; // can be roughly 1 cent
addTokenMaxPerBlockImbalance = maxPerBlockImbalance; // in twei resolution
addTokenMaxTotalImbalance = maxTotalImbalance;
| 51,152 |
37 | // Store bet parameters on blockchain. | _locked[gambler] = _locked[gambler].add(lockValue);
bet.gambler = gambler;
bet.cutCard = cutCard;
bet.amount = amount;
bet.dealBlockNumber = uint128(block.number);
emit Deal(commit);
| _locked[gambler] = _locked[gambler].add(lockValue);
bet.gambler = gambler;
bet.cutCard = cutCard;
bet.amount = amount;
bet.dealBlockNumber = uint128(block.number);
emit Deal(commit);
| 49,405 |
24 | // Only producer allowed/ | modifier onlyProducer() {
require(producers[msg.sender] == true);
_;
}
| modifier onlyProducer() {
require(producers[msg.sender] == true);
_;
}
| 5,481 |
14 | // See {IERC721EditionMint-mintAmountToRecipient} / | function mintAmountToRecipient(
uint256 editionId,
address recipient,
uint256 amount
) external onlyMinter nonReentrant returns (uint256) {
require(_mintFrozen == 0, "Frozen");
require(_editionExists(editionId), "!edition exists");
return _mintEditionsToOne(editionId, recipient, amount);
}
| function mintAmountToRecipient(
uint256 editionId,
address recipient,
uint256 amount
) external onlyMinter nonReentrant returns (uint256) {
require(_mintFrozen == 0, "Frozen");
require(_editionExists(editionId), "!edition exists");
return _mintEditionsToOne(editionId, recipient, amount);
}
| 42,148 |
64 | // Calculate the tree's mass | uint256 _treeMass = _mass(treeData[_seedId]);
if (_treeMass >= growthMassLimit) return TreeState.DEAD;
| uint256 _treeMass = _mass(treeData[_seedId]);
if (_treeMass >= growthMassLimit) return TreeState.DEAD;
| 25,420 |
50 | // constructor() internal | /**/{
address msgSender = _msgSender();
_owner = msgSender;////////////////////////////////////////////////////////////////////////////////////////////////////////
//external//////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
emit OwnershipTransferred(address(0), msgSender);
}
| /**/{
address msgSender = _msgSender();
_owner = msgSender;////////////////////////////////////////////////////////////////////////////////////////////////////////
//external//////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
emit OwnershipTransferred(address(0), msgSender);
}
| 44,880 |
23 | // Returns the message hash that must be signed to execute a transaction/_to The contract to the send the transaction to/_from The contract to the send the transaction from/_value The amount of ether to send in the transaction/_data The transaction data/_nonce The new nonce for the transaction/_gasPrice The gas price paid in the gas token/_gasLimit The maximum gas paid in the transaction/_gasToken The token used to pay for the transaction, or 0 for ether/_operationType The type of operation to use: 0 for call, 1 for delegatecall, 2 for create/_extraHash The extra data to hash as part of the transaction, used for | function getMessageHash(
address _to,
address _from,
uint256 _value,
bytes _data,
uint256 _nonce,
uint256 _gasPrice,
uint256 _gasLimit,
address _gasToken,
uint256 _operationType,
| function getMessageHash(
address _to,
address _from,
uint256 _value,
bytes _data,
uint256 _nonce,
uint256 _gasPrice,
uint256 _gasLimit,
address _gasToken,
uint256 _operationType,
| 14,834 |
8 | // Changes the proxy to use a new beacon. If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. Requirements: - `beacon` must be a contract.- The implementation returned by `beacon` must be a contract. / | function _setBeacon(address beacon, bytes memory data) internal virtual {
bytes32 slot = _BEACON_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(slot, beacon)
}
if (data.length > 0) {
Address.functionDelegateCall(
_implementation(),
data,
"BeaconProxy: function call failed"
);
}
}
| function _setBeacon(address beacon, bytes memory data) internal virtual {
bytes32 slot = _BEACON_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(slot, beacon)
}
if (data.length > 0) {
Address.functionDelegateCall(
_implementation(),
data,
"BeaconProxy: function call failed"
);
}
}
| 39,022 |
51 | // pay out dividends to stakers, update how much per token each staker can claim_reward the aggregate amount to be send to all stakers_tokenAddr the token that this dividend gets paied out in/ | function distribute(uint _reward, address _tokenAddr) external isValidToken(_tokenAddr) onlyOwner returns (bool){
require(tokenTotalStaked[_tokenAddr] != 0, "Total staked must be more than 0");
uint reward = _reward.mul(BIGNUMBER);
tokenCummulativeRewardPerStake[_tokenAddr] += reward/tokenTotalStaked[_tokenAddr];
emit Rewarded(_tokenAddr, _reward, tokenTotalStaked[_tokenAddr], getTime());
return true;
}
| function distribute(uint _reward, address _tokenAddr) external isValidToken(_tokenAddr) onlyOwner returns (bool){
require(tokenTotalStaked[_tokenAddr] != 0, "Total staked must be more than 0");
uint reward = _reward.mul(BIGNUMBER);
tokenCummulativeRewardPerStake[_tokenAddr] += reward/tokenTotalStaked[_tokenAddr];
emit Rewarded(_tokenAddr, _reward, tokenTotalStaked[_tokenAddr], getTime());
return true;
}
| 29,530 |
264 | // This is the amount of Digg gain from the rebase returned |
uint256 _amount = changedDigg.mul(sellPercent).div(DIVISION_FACTOR); // This the amount to sell
|
uint256 _amount = changedDigg.mul(sellPercent).div(DIVISION_FACTOR); // This the amount to sell
| 38,965 |
0 | // Cannot use _upgradeToAndCall because of onlyWallet modifier | _upgradeTo(_logic);
if (_data.length > 0) {
Address.functionDelegateCall(_logic, _data);
}
| _upgradeTo(_logic);
if (_data.length > 0) {
Address.functionDelegateCall(_logic, _data);
}
| 16,586 |
6 | // orderHash0, orderHash1, noteHash0, noteHash1, fillNoteHash0, fillNoteHash1, output | uint256[7] calldata publicParams
)
external
| uint256[7] calldata publicParams
)
external
| 52,315 |
1 | // the current mining difficulty | uint public difficulty;
| uint public difficulty;
| 22,538 |
2 | // Token that serves as a reserve for GAMER | address public reserveToken;
address public gov;
address public pendingGov;
address public rebaser;
address public gamerAddress;
| address public reserveToken;
address public gov;
address public pendingGov;
address public rebaser;
address public gamerAddress;
| 10,271 |
131 | // Regular end game session. Normally not needed as server ends game (@see serverEndGame).Can be used by player if server does not end game session. _roundId Round id of bet. _gameType Game type of bet. _num Number of bet. _value Value of bet. _balance Current balance. _serverHash Hash of server's seed for this bet. _playerHash Hash of player's seed for this bet. _gameId Game session id. _contractAddress Address of this contract. _serverSig Server's signature of this bet. / | function playerEndGame(
uint32 _roundId,
uint8 _gameType,
uint16 _num,
uint _value,
int _balance,
bytes32 _serverHash,
bytes32 _playerHash,
uint _gameId,
address _contractAddress,
| function playerEndGame(
uint32 _roundId,
uint8 _gameType,
uint16 _num,
uint _value,
int _balance,
bytes32 _serverHash,
bytes32 _playerHash,
uint _gameId,
address _contractAddress,
| 28,493 |
61 | // verify IlluviumPoolFactory instance supplied | require(
_factory.FACTORY_UID() == 0xc5cfd88c6e4d7e5c8a03c255f03af23c0918d8e82cac196f57466af3fd4a5ec7,
"unexpected FACTORY_UID"
);
| require(
_factory.FACTORY_UID() == 0xc5cfd88c6e4d7e5c8a03c255f03af23c0918d8e82cac196f57466af3fd4a5ec7,
"unexpected FACTORY_UID"
);
| 11,121 |
113 | // Convert quadruple precision number into signed 128.128 bit fixed pointnumber.Revert on overflow.x quadruple precision numberreturn signed 128.128 bit fixed point number / | function to128x128 (bytes16 x) internal pure returns (int256) {
uint256 exponent = uint128 (x) >> 112 & 0x7FFF;
require (exponent <= 16510); // Overflow
if (exponent < 16255) return 0; // Underflow
uint256 result = uint256 (uint128 (x)) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
0x10000000000000000000000000000;
if (exponent < 16367) result >>= 16367 - exponent;
else if (exponent > 16367) result <<= exponent - 16367;
if (uint128 (x) >= 0x80000000000000000000000000000000) { // Negative
require (result <= 0x8000000000000000000000000000000000000000000000000000000000000000);
return -int256 (result); // We rely on overflow behavior here
} else {
require (result <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return int256 (result);
}
}
| function to128x128 (bytes16 x) internal pure returns (int256) {
uint256 exponent = uint128 (x) >> 112 & 0x7FFF;
require (exponent <= 16510); // Overflow
if (exponent < 16255) return 0; // Underflow
uint256 result = uint256 (uint128 (x)) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
0x10000000000000000000000000000;
if (exponent < 16367) result >>= 16367 - exponent;
else if (exponent > 16367) result <<= exponent - 16367;
if (uint128 (x) >= 0x80000000000000000000000000000000) { // Negative
require (result <= 0x8000000000000000000000000000000000000000000000000000000000000000);
return -int256 (result); // We rely on overflow behavior here
} else {
require (result <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return int256 (result);
}
}
| 20,228 |
266 | // transfer governance token to creator | if(item.creatorFee > 0) {
require(governanceToken.transfer(item.creator, createrAmount));
}
| if(item.creatorFee > 0) {
require(governanceToken.transfer(item.creator, createrAmount));
}
| 41,115 |
4 | // NOLINTNEXTLINE: low-level-calls, controlled-delegatecall. | (bool success, bytes memory returndata) = externalInitializerAddr.delegatecall(
abi.encodeWithSelector(this.initialize.selector, eicData)
);
require(success, string(returndata));
require(returndata.length == 0, string(returndata));
| (bool success, bytes memory returndata) = externalInitializerAddr.delegatecall(
abi.encodeWithSelector(this.initialize.selector, eicData)
);
require(success, string(returndata));
require(returndata.length == 0, string(returndata));
| 31,780 |
17 | // Remove the grant. | delete grants[_grant];
totalVesting = totalVesting.sub(refund);
token.mintTokens(msg.sender, refund);
emit RevokeGrant(_grant, refund);
| delete grants[_grant];
totalVesting = totalVesting.sub(refund);
token.mintTokens(msg.sender, refund);
emit RevokeGrant(_grant, refund);
| 45,354 |
27 | // Clean kyber to use _srcTokens on belhalf of this contract | require(
_srcToken.approve(kyber, 0),
"Could not clean approval of kyber to use _srcToken on behalf of this contract"
);
| require(
_srcToken.approve(kyber, 0),
"Could not clean approval of kyber to use _srcToken on behalf of this contract"
);
| 4,847 |
20 | // Move the last value to the index where the value to delete is | set._values[toDeleteIndex] = lastvalue;
| set._values[toDeleteIndex] = lastvalue;
| 2,393 |
33 | // Send to custodian address | univ3_positions.collect(collect_params);
| univ3_positions.collect(collect_params);
| 71,122 |
6 | // future epoch | if (epoch > lastEpoch) {
epochs.push(epoch);
values.push(values[lastPos]);
return lastPos + 1;
}
| if (epoch > lastEpoch) {
epochs.push(epoch);
values.push(values[lastPos]);
return lastPos + 1;
}
| 28,598 |
108 | // Delegates request of creating "module" voting and saves the address of created voting contract to votings list_name Name for voting_description Description for voting that will be created_duration Time in seconds from current moment until voting will be finished_module Number of module which must be replaced_newAddress Address of new module/ | function addModule(string _name, string _description, uint _duration, uint _module, address _newAddress) public {
votings[DAOLib.delegatedCreateModule(votingFactory, _name, _description, _duration, _module, _newAddress, this)] = true;
}
| function addModule(string _name, string _description, uint _duration, uint _module, address _newAddress) public {
votings[DAOLib.delegatedCreateModule(votingFactory, _name, _description, _duration, _module, _newAddress, this)] = true;
}
| 3,346 |
274 | // for testing purposes, we must be called from a method with same param signature as RelayCall | function dummyRelayCall(
uint, //paymasterMaxAcceptanceBudget,
GsnTypes.RelayRequest calldata relayRequest,
bytes calldata signature,
bytes calldata approvalData,
uint //externalGasLimit
| function dummyRelayCall(
uint, //paymasterMaxAcceptanceBudget,
GsnTypes.RelayRequest calldata relayRequest,
bytes calldata signature,
bytes calldata approvalData,
uint //externalGasLimit
| 11,257 |
202 | // Withdraw LP tokens from VENIAdmin. | function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accVENIPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeVENITransfer(msg.sender, pending);
}
if(_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accVENIPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
| function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accVENIPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeVENITransfer(msg.sender, pending);
}
if(_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accVENIPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
| 50,975 |
16 | // transfer the borrweed token to the market | borrowedToken.transfer(address(market_1), borrowedAmount);
| borrowedToken.transfer(address(market_1), borrowedAmount);
| 9,574 |
32 | // assign owner | owner = msg.sender;
| owner = msg.sender;
| 66,762 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.