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 |
|---|---|---|---|---|
243 | // Retrieves a Digital Media object. / | function getDigitalMedia(uint256 _id)
external
view
| function getDigitalMedia(uint256 _id)
external
view
| 36,889 |
92 | // Exit fee recipient for the index pools | address public defaultExitFeeRecipient;
| address public defaultExitFeeRecipient;
| 59,972 |
323 | // Internal function that stores the eventAddress in the NFT metadataStorage of the eventAddress is immutable / | function _markEventAddress(uint256 nftIndex, address _eventAddress) internal {
require(_exists(nftIndex), "GET TX FAILED Func: _markEventAddress : Nonexistent nftIndex");
_eventAddresses[nftIndex] = _eventAddress;
}
| function _markEventAddress(uint256 nftIndex, address _eventAddress) internal {
require(_exists(nftIndex), "GET TX FAILED Func: _markEventAddress : Nonexistent nftIndex");
_eventAddresses[nftIndex] = _eventAddress;
}
| 20,836 |
29 | // Returns the underlying contents of a wrapped NFT. | function getWrappedContents(uint256 _tokenId) external view returns (Token[] memory contents) {
uint256 total = getTokenCountOfBundle(_tokenId);
contents = new Token[](total);
for (uint256 i = 0; i < total; i += 1) {
contents[i] = getTokenOfBundle(_tokenId, i);
}
}
| function getWrappedContents(uint256 _tokenId) external view returns (Token[] memory contents) {
uint256 total = getTokenCountOfBundle(_tokenId);
contents = new Token[](total);
for (uint256 i = 0; i < total; i += 1) {
contents[i] = getTokenOfBundle(_tokenId, i);
}
}
| 8,601 |
0 | // Lib_PredeployAddresses / | library Lib_PredeployAddresses {
address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
address payable internal constant OVM_GCD = payable(0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000);
address internal constant L2_CROSS_DOMAIN_MESSENGER =
0x4200000000000000000000000000000000000007;
address internal constant LIB_ADDRESS_MANAGER = 0x4200000000000000000000000000000000000008;
address internal constant PROXY_EOA = 0x4200000000000000000000000000000000000009;
address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;
address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;
address internal constant L2_STANDARD_TOKEN_FACTORY =
0x4200000000000000000000000000000000000012;
address internal constant L1_BLOCK_NUMBER = 0x4200000000000000000000000000000000000013;
}
| library Lib_PredeployAddresses {
address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
address payable internal constant OVM_GCD = payable(0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000);
address internal constant L2_CROSS_DOMAIN_MESSENGER =
0x4200000000000000000000000000000000000007;
address internal constant LIB_ADDRESS_MANAGER = 0x4200000000000000000000000000000000000008;
address internal constant PROXY_EOA = 0x4200000000000000000000000000000000000009;
address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;
address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;
address internal constant L2_STANDARD_TOKEN_FACTORY =
0x4200000000000000000000000000000000000012;
address internal constant L1_BLOCK_NUMBER = 0x4200000000000000000000000000000000000013;
}
| 29,261 |
24 | // require(cue.balanceOf(msg.sender) >= amount,"balance is low"); | cue.transferFrom(msg.sender, address(this), amount);
emit Deposit(msg.sender, amount, game_id);
| cue.transferFrom(msg.sender, address(this), amount);
emit Deposit(msg.sender, amount, game_id);
| 4,904 |
33 | // Getters / | function getPresaleRate() internal pure returns (uint256) {
return _presaleRate;
}
| function getPresaleRate() internal pure returns (uint256) {
return _presaleRate;
}
| 51,105 |
11 | // internal function for generating the proof-set | function _escrow(
string seed,
address caller,
address receiver,
address tokenAddress,
Algorithm algorithm
| function _escrow(
string seed,
address caller,
address receiver,
address tokenAddress,
Algorithm algorithm
| 24,392 |
7 | // Reports the Witnet-provided result to a previously posted request./Fails if:/- called from unauthorized address;/- the `_queryId` is not in 'Posted' status./- provided `_drTxHash` is zero;/- length of provided `_result` is zero./_queryId The unique query identifier/_timestamp The timestamp of the solving tally transaction in Witnet./_drTxHash The hash of the solving tally transaction in Witnet./_result The result itself as bytes. | function reportResult(uint256 _queryId, uint256 _timestamp, bytes32 _drTxHash, bytes calldata _result) external;
| function reportResult(uint256 _queryId, uint256 _timestamp, bytes32 _drTxHash, bytes calldata _result) external;
| 38,011 |
59 | // CDS | function defund(
address _cds,
address _to,
uint256 _amount
| function defund(
address _cds,
address _to,
uint256 _amount
| 38,433 |
2 | // Recover signer address from a personal signed message by using his signature hash bytes32 message, the hash is the signed message. What is recovered is the signer address. sig bytes signature, the signature is generated using web3.personal.sign() / | function personalRecover(bytes32 hash, bytes sig) internal pure returns (address) {
return recover(toEthSignedMessageHash(hash), sig);
}
| function personalRecover(bytes32 hash, bytes sig) internal pure returns (address) {
return recover(toEthSignedMessageHash(hash), sig);
}
| 21,148 |
58 | // logged events: Funds has arrived into the wallet (record how much). | event Deposit(address _from, uint value);
| event Deposit(address _from, uint value);
| 87,247 |
40 | // This is check claimable for cliff vesting./_poolId : Pool Id from which pool user want to check./_user : User address for which user want to check claimables./ return returning the claimable amount of the user from cliff vesting. | function cliffClaimable(uint256 _poolId, address _user)
public
view
returns (uint256)
| function cliffClaimable(uint256 _poolId, address _user)
public
view
returns (uint256)
| 3,660 |
53 | // 14 first epochs with 6% expansion | _sendToAcropolis(basedSupply.mul(bootstrapSupplyExpansionPercent).div(10000));
| _sendToAcropolis(basedSupply.mul(bootstrapSupplyExpansionPercent).div(10000));
| 29,054 |
8 | // Current game number. | uint public game;
| uint public game;
| 32,354 |
39 | // withdraw + claim reward / | function exit() external override {
withdraw(store.balanceOf(_msgSender()));
claimReward();
}
| function exit() external override {
withdraw(store.balanceOf(_msgSender()));
claimReward();
}
| 19,317 |
50 | // The OctToken contract | IERC20 private immutable _token;
| IERC20 private immutable _token;
| 3,538 |
99 | // Mint new tokens. _to Address to send the newly minted tokens _amount Amount of tokens to mint / | function mint(address _to, uint256 _amount) external onlyMinter {
_mint(_to, _amount);
}
| function mint(address _to, uint256 _amount) external onlyMinter {
_mint(_to, _amount);
}
| 620 |
12 | // causality params are wrong based on the block number | if (block.number <= voyageConfig.boughtAt + voyageConfig.noOfBlockJumps) revert WrongState(4);
lockedVoyage.lockedBlock = block.number;
lockedVoyage.lockedTimestamp = block.timestamp;
lockedVoyage.claimedTime = 0;
lockedVoyage.navigation = 0;
lockedVoyage.luck = 0;
lockedVoyage.strength = 0;
lockedVoyage.sequence = voyageConfig.sequence;
lockedVoyage.totalSupportShips = uint8(totalSupportShips);
| if (block.number <= voyageConfig.boughtAt + voyageConfig.noOfBlockJumps) revert WrongState(4);
lockedVoyage.lockedBlock = block.number;
lockedVoyage.lockedTimestamp = block.timestamp;
lockedVoyage.claimedTime = 0;
lockedVoyage.navigation = 0;
lockedVoyage.luck = 0;
lockedVoyage.strength = 0;
lockedVoyage.sequence = voyageConfig.sequence;
lockedVoyage.totalSupportShips = uint8(totalSupportShips);
| 22,452 |
19 | // SPDX-License-Identifier: MIT/ Wrappers over Solidity's arithmetic operations with added overflowchecks. Arithmetic operations in Solidity wrap on overflow. This can easily resultin bugs, because programmers usually assume that an overflow raises anerror, which is the standard behavior in high level programming languages.`SafeMath` restores this intuition by reverting the transaction when anoperation overflows. Using this library instead of the unchecked operations eliminates an entireclass of bugs, so it's recommended to use it always. / | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a <= b ? a : b;
}
function abs(uint256 a, uint256 b) internal pure returns (uint256) {
if (a < b) {
return b - a;
}
return a - b;
}
}
| library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a <= b ? a : b;
}
function abs(uint256 a, uint256 b) internal pure returns (uint256) {
if (a < b) {
return b - a;
}
return a - b;
}
}
| 13,446 |
73 | // return delay time (UNIX time). / | function delay() public view returns (uint256) {
return _delay;
}
| function delay() public view returns (uint256) {
return _delay;
}
| 19,698 |
336 | // if creation is locked or not | bool internal _locked;
| bool internal _locked;
| 44,384 |
83 | // 2 days | changeConfiguration(_proposeTimelock_, 60 * 60 * 24 * 2);
changeConfiguration(_spanLo_, 24 * 60 * 60 * 3);
| changeConfiguration(_proposeTimelock_, 60 * 60 * 24 * 2);
changeConfiguration(_spanLo_, 24 * 60 * 60 * 3);
| 77,109 |
157 | // Note that we extract the block from the sharedCash field, which is the one that is updated by swaps. Both token A and token B use the same block | return toBalance(_decodeBalanceA(sharedCash), _decodeBalanceA(sharedManaged), lastChangeBlock(sharedCash));
| return toBalance(_decodeBalanceA(sharedCash), _decodeBalanceA(sharedManaged), lastChangeBlock(sharedCash));
| 85,450 |
14 | // decode | (
uint8 decimals_,
uint256 cap_,
uint256 initialSupply_,
bool canMint_,
bool canBurn_,
uint8 tax_,
address sale_,
uint256 saleSupply_,
address vesting_,
| (
uint8 decimals_,
uint256 cap_,
uint256 initialSupply_,
bool canMint_,
bool canBurn_,
uint8 tax_,
address sale_,
uint256 saleSupply_,
address vesting_,
| 13,680 |
69 | // Sets the minimum nonce for a valid off-chain approval message from thesenders account. This can be used to invalidate a previously signed message. / | function invalidateOffchainApproval(
| function invalidateOffchainApproval(
| 49,478 |
44 | // marketId => Market | mapping(uint256 => Market) markets;
| mapping(uint256 => Market) markets;
| 448 |
0 | // but ends before the requested range | storageForceMajeure[i].endDate >= _startDate &&
storageForceMajeure[i].endDate <= _endDate //In this case the maintenance ends after the start frequested time
| storageForceMajeure[i].endDate >= _startDate &&
storageForceMajeure[i].endDate <= _endDate //In this case the maintenance ends after the start frequested time
| 22,852 |
123 | // This means the controller will deposit tokens to keep the price. They will be minted and given PCTokens | deltaWeight = BalancerSafeMath.bsub(newWeight, currentWeight);
require(BalancerSafeMath.badd(totalWeight, deltaWeight) <= BalancerConstants.MAX_TOTAL_WEIGHT,
"ERR_MAX_TOTAL_WEIGHT");
| deltaWeight = BalancerSafeMath.bsub(newWeight, currentWeight);
require(BalancerSafeMath.badd(totalWeight, deltaWeight) <= BalancerConstants.MAX_TOTAL_WEIGHT,
"ERR_MAX_TOTAL_WEIGHT");
| 11,601 |
181 | // Update the miner status to true once they submit a value so they don't submit more than once | self.minersByChallenge[self.currentChallenge][msg.sender] = true;
if (self.uintVars[slotProgress] == 5) {
newBlock(self, _nonce, _requestId);
}
| self.minersByChallenge[self.currentChallenge][msg.sender] = true;
if (self.uintVars[slotProgress] == 5) {
newBlock(self, _nonce, _requestId);
}
| 41,769 |
37 | // checks if an address is authorized to govern | function isAuthorizedToGovern(address _toCheck) public view returns(bool) {
IMaster ms = IMaster(masterAddress);
return (ms.getLatestAddress("GV") == _toCheck);
}
| function isAuthorizedToGovern(address _toCheck) public view returns(bool) {
IMaster ms = IMaster(masterAddress);
return (ms.getLatestAddress("GV") == _toCheck);
}
| 45,827 |
5 | // HiddenCalldataProxy reads the version that identifies the implementation contract from 4 bytes at the end of the calldata | contract HiddenCalldataProxy {
mapping (uint32 => address) public implementationForVersion;
constructor() {
// set up a couple of dummy test target contracts that have a function that acts slightly differently
// depending on its constructor param
implementationForVersion[1] = address(new TestTarget(1));
implementationForVersion[2] = address(new TestTarget(2));
}
// Testing: send 0xaeae3802[version] to call 'emitNumber()'. Eg. 0xaeae380200000002
fallback (bytes calldata _calldata) external payable returns (bytes memory) {
// Using as little assembly as possible for clarity, can be optimized with more assembly
uint32 version;
assembly {
// last 4 bytes (uint32) of calldata are assigned to version
version := shr(224, calldataload(sub(calldatasize(), 4)))
}
address implementation = implementationForVersion[version];
require(implementation != address(0), "unset version");
(bool ok, bytes memory returndata) = implementation.delegatecall(_calldata);
require(ok, "delegatecall failed");
return returndata;
}
}
| contract HiddenCalldataProxy {
mapping (uint32 => address) public implementationForVersion;
constructor() {
// set up a couple of dummy test target contracts that have a function that acts slightly differently
// depending on its constructor param
implementationForVersion[1] = address(new TestTarget(1));
implementationForVersion[2] = address(new TestTarget(2));
}
// Testing: send 0xaeae3802[version] to call 'emitNumber()'. Eg. 0xaeae380200000002
fallback (bytes calldata _calldata) external payable returns (bytes memory) {
// Using as little assembly as possible for clarity, can be optimized with more assembly
uint32 version;
assembly {
// last 4 bytes (uint32) of calldata are assigned to version
version := shr(224, calldataload(sub(calldatasize(), 4)))
}
address implementation = implementationForVersion[version];
require(implementation != address(0), "unset version");
(bool ok, bytes memory returndata) = implementation.delegatecall(_calldata);
require(ok, "delegatecall failed");
return returndata;
}
}
| 20,470 |
242 | // Split into two functions to avoid error 'call stack too deep'. | function _forcedTradeRequestPremiumCostTrue(
uint256[12] calldata args,
bytes calldata signature
)
private
| function _forcedTradeRequestPremiumCostTrue(
uint256[12] calldata args,
bytes calldata signature
)
private
| 4,672 |
32 | // Mints Single+ | ISinglePlus(_singles[i]).mint(_lpAmounts[i]);
_amounts[i] = IERC20Upgradeable(_singles[i]).balanceOf(address(this));
| ISinglePlus(_singles[i]).mint(_lpAmounts[i]);
_amounts[i] = IERC20Upgradeable(_singles[i]).balanceOf(address(this));
| 53,966 |
69 | // We write the previously calculated values into storage // We emit a RepayBorrow event // We call the defense hook / unused function comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex); |
return (uint256(Error.NO_ERROR), vars.actualRepayAmount);
|
return (uint256(Error.NO_ERROR), vars.actualRepayAmount);
| 19,270 |
12 | // setStart | function setStart() public onlyOwner {
started = true;
}
| function setStart() public onlyOwner {
started = true;
}
| 85,041 |
10 | // Calculate the current price for buy in amount. / | function calculateTokenAmount(uint weiAmount) public constant returns (uint tokenAmount) {
uint bonusRate = 0;
if (weiAmount >= minimumWeiAmount) {
bonusRate = rate0;
}
if (weiAmount >= threshold1) {
bonusRate = rate1;
}
if (weiAmount >= threshold2) {
bonusRate = rate2;
}
return weiAmount.mul(bonusRate);
}
| function calculateTokenAmount(uint weiAmount) public constant returns (uint tokenAmount) {
uint bonusRate = 0;
if (weiAmount >= minimumWeiAmount) {
bonusRate = rate0;
}
if (weiAmount >= threshold1) {
bonusRate = rate1;
}
if (weiAmount >= threshold2) {
bonusRate = rate2;
}
return weiAmount.mul(bonusRate);
}
| 4,574 |
187 | // Ethereum average block time interval, 14 seconds | uint constant ETHEREUM_BLOCK_TIMESPAN = 14;
| uint constant ETHEREUM_BLOCK_TIMESPAN = 14;
| 30,486 |
66 | // always round down when calculating tokens | fixedSlotEquityTokenInt = discountedAmount / calculatePriceFraction(wlTicket.fullTokenPriceFrac);
| fixedSlotEquityTokenInt = discountedAmount / calculatePriceFraction(wlTicket.fullTokenPriceFrac);
| 38,394 |
158 | // Update the merkle root. | _allowListMerkleRoots[msg.sender] = allowListData.merkleRoot;
| _allowListMerkleRoots[msg.sender] = allowListData.merkleRoot;
| 38,021 |
16 | // It is important to set this to zero because the recipient can call this function again as part of the receiving call before `send` returns. |
totalReturns -= amount;
pendingReturns[msg.sender] -= amount;
msg.sender.transfer(amount);
|
totalReturns -= amount;
pendingReturns[msg.sender] -= amount;
msg.sender.transfer(amount);
| 60,355 |
1 | // 80% of index | uint256 internal constant LOWER_MARK_RATIO = 8e17;
| uint256 internal constant LOWER_MARK_RATIO = 8e17;
| 42,270 |
11 | // Moves all tokens to a new reserve contract | function migrateReserves(
address newReserve,
address[] memory tokens
)
public
onlyGov
| function migrateReserves(
address newReserve,
address[] memory tokens
)
public
onlyGov
| 30,089 |
123 | // original position was longsubReserve(addressValues[0], addressValues[1], uintValues[7], safeMul(uintValues[0], safeSub(retrievePosition(positionHash)[1], futuresContracts[futuresContract].floorPrice)));pam[1] = safeMul(uintValues[0], safeSub(retrievePosition(positionHash)[1], futuresContracts[futuresContract].floorPrice)) / futuresContracts[futuresContract].floorPrice; | pam[1] = calculateCollateral(futuresContracts[futuresContract].floorPrice, retrievePosition(positionHash)[1], uintValues[0], true, futuresContract);
| pam[1] = calculateCollateral(futuresContracts[futuresContract].floorPrice, retrievePosition(positionHash)[1], uintValues[0], true, futuresContract);
| 1,201 |
412 | // do nothing | } else if (action == Action.REENTER) {
| } else if (action == Action.REENTER) {
| 30,085 |
63 | // Calculate tax that owner will have to cover for upgrading or deprecating. _tokens Tokens that were received from deprecating the old subgraph _owner Subgraph owner _curationTaxPercentage Tax percentage on curation deposits from Curation contractreturn Total tokens that will be sent to curation, _tokens + ownerTax / | function _chargeOwnerTax(
uint256 _tokens,
address _owner,
uint32 _curationTaxPercentage
| function _chargeOwnerTax(
uint256 _tokens,
address _owner,
uint32 _curationTaxPercentage
| 22,395 |
171 | // Emit the `Transfer` event. | log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
from, // `from`.
toMasked, // `to`.
tokenId // `tokenId`.
)
| log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
from, // `from`.
toMasked, // `to`.
tokenId // `tokenId`.
)
| 5,073 |
66 | // Hash (keccak256) of the payload used by deposit _contractAddress the target ERC20 address _amount the original minter / | function entranceHash(bytes32 txnHash, address _contractAddress, uint256 _amount) public view returns (bytes32) {
// "0x8177cf3c": entranceHash(bytes32, address,uint256)
return keccak256(abi.encode( bytes4(0x8177cf3c), msg.sender, txnHash, _contractAddress, _amount));
}
| function entranceHash(bytes32 txnHash, address _contractAddress, uint256 _amount) public view returns (bytes32) {
// "0x8177cf3c": entranceHash(bytes32, address,uint256)
return keccak256(abi.encode( bytes4(0x8177cf3c), msg.sender, txnHash, _contractAddress, _amount));
}
| 24,550 |
2,142 | // 1073 | entry "geekishly" : ENG_ADVERB
| entry "geekishly" : ENG_ADVERB
| 21,909 |
8 | // Verifiy that pERC20 is official token | require(IContractRegistry(contractRegistry).checkERC20(erc20Addr)==true, "pERC20 not official");
require(checkAttributeMatching(erc20Addr)==true, "The token sent is not accepted");
| require(IContractRegistry(contractRegistry).checkERC20(erc20Addr)==true, "pERC20 not official");
require(checkAttributeMatching(erc20Addr)==true, "The token sent is not accepted");
| 55,032 |
12 | // if no rewards claimed so far, then he gets rewards from when the rewards started. | epochsToReward = (block.timestamp - STARTING_POINT) / EPOCH_LENGTH;
| epochsToReward = (block.timestamp - STARTING_POINT) / EPOCH_LENGTH;
| 37,342 |
19 | // ------------------------------------------------------------------------ Get the token balance for account `tokenOwner` ------------------------------------------------------------------------ | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| 4,147 |
25 | // The lastChangeBlock field is left uninitialized |
uint256 amountIn;
uint256 amountOut;
(previousAmountCalculated, amountIn, amountOut) = _swapWithPool(poolRequest);
previousTokenCalculated = _tokenCalculated(kind, tokenIn, tokenOut);
|
uint256 amountIn;
uint256 amountOut;
(previousAmountCalculated, amountIn, amountOut) = _swapWithPool(poolRequest);
previousTokenCalculated = _tokenCalculated(kind, tokenIn, tokenOut);
| 12,044 |
69 | // Modify from ERC721Enumerable | function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256[] storage tokens = _ownedTokens[to];
uint256 length = tokens.length;
tokens.push(tokenId);
_ownedTokensIndex[tokenId] = length;
}
| function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256[] storage tokens = _ownedTokens[to];
uint256 length = tokens.length;
tokens.push(tokenId);
_ownedTokensIndex[tokenId] = length;
}
| 22,584 |
1 | // Person array stores the persons. The Person array index is the ID | Person[] people;
| Person[] people;
| 16,064 |
36 | // clerk as ward | AuthLike_2(seniorTranche).rely(clerk);
AuthLike_2(reserve).rely(clerk);
AuthLike_2(assessor).rely(clerk);
| AuthLike_2(seniorTranche).rely(clerk);
AuthLike_2(reserve).rely(clerk);
AuthLike_2(assessor).rely(clerk);
| 19,103 |
64 | // Tax and charity fees will start at 0 so we don't have a big impact when deploying to Uniswap Charity wallet address is null but the method to set the address is exposed | uint256 private _taxFee = 3; // 3% reflection fee for every holder
uint256 private _charityFee = 3; // 3% charity
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousCharityFee = _charityFee;
address payable public _charityWalletAddress = payable(0x52eEA4149a25F2e88efae0a673Eca374F7E1a75a);
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
| uint256 private _taxFee = 3; // 3% reflection fee for every holder
uint256 private _charityFee = 3; // 3% charity
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousCharityFee = _charityFee;
address payable public _charityWalletAddress = payable(0x52eEA4149a25F2e88efae0a673Eca374F7E1a75a);
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
| 33,388 |
1 | // method that is simulated by the keepers to see if any work actuallyneeds to be performed. This method does does not actually need to beexecutable, and since it is only ever simulated it can consume lots of gas. To ensure that it is never called, you may want to add thecannotExecute modifier from KeeperBase to your implementation of thismethod. checkData specified in the upkeep registration so it is always thesame for a registered upkeep. This can easily be broken down into specificarguments using `abi.decode`, so multiple upkeeps can be registered on thesame contract and easily differentiated by the contract.return upkeepNeeded | function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);
| function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);
| 18,269 |
26 | // Signals successful execution of function MakeOffer | WorkbenchBase.ContractUpdated("MakeOffer");
| WorkbenchBase.ContractUpdated("MakeOffer");
| 46,120 |
39 | // No leading underscore per naming convention (non-private) Cannot call totalSupply (name conflict) solhint-disable-next-line private-vars-leading-underscore | uint internal varTotalSupply;
mapping(address => uint) private _balance;
mapping(address => mapping(address => uint)) private _allowance;
string private _symbol;
string private _name;
| uint internal varTotalSupply;
mapping(address => uint) private _balance;
mapping(address => mapping(address => uint)) private _allowance;
string private _symbol;
string private _name;
| 30,662 |
63 | // stopDelegate allows a user to take back the delegated voting power | function stopDelegate() external;
| function stopDelegate() external;
| 11,678 |
79 | // The current phase of this Epoch. | Phase phase;
address deposit_account_v2;
address reward_account_v2;
uint reward_total_v2;
Phase phase_v2;
| Phase phase;
address deposit_account_v2;
address reward_account_v2;
uint reward_total_v2;
Phase phase_v2;
| 20,801 |
136 | // MUST emit when an approval is updated. | event ApprovalForAll(
address indexed _owner,
address indexed _operator,
bool _approved
);
| event ApprovalForAll(
address indexed _owner,
address indexed _operator,
bool _approved
);
| 14,395 |
10 | // Begins iterating over resource records. self The byte string to read from. offset The offset to start reading at.return ret An iterator object. / | function iterateRRs(
bytes memory self,
uint256 offset
| function iterateRRs(
bytes memory self,
uint256 offset
| 7,067 |
27 | // Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth/newSellPrice Price the users can sell to the contract/newBuyPrice Price users can buy from the contract | function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
| function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
| 947 |
227 | // Boardroom | address public boardroom;
| address public boardroom;
| 37,156 |
23 | // multiply by 1e12 to avoid zero rounding | uint256 transfersForMintedWithCurrentMultiplicity = (amount.mul(1e12))
.div(mintingPerThreshold)
.mul(currentMultiplicity)
.div(1e12);
transfersForMintedWithCurrentMultiplicity = transfersForMintedWithCurrentMultiplicity.mod(currentMultiplicity) == 0 ?
transfersForMintedWithCurrentMultiplicity : (
(transfersForMintedWithCurrentMultiplicity.div(currentMultiplicity)).add(1)
).mul(currentMultiplicity);
return transfersForMintedWithCurrentMultiplicity;
| uint256 transfersForMintedWithCurrentMultiplicity = (amount.mul(1e12))
.div(mintingPerThreshold)
.mul(currentMultiplicity)
.div(1e12);
transfersForMintedWithCurrentMultiplicity = transfersForMintedWithCurrentMultiplicity.mod(currentMultiplicity) == 0 ?
transfersForMintedWithCurrentMultiplicity : (
(transfersForMintedWithCurrentMultiplicity.div(currentMultiplicity)).add(1)
).mul(currentMultiplicity);
return transfersForMintedWithCurrentMultiplicity;
| 45,412 |
77 | // Check if the funding goal or cap have been reached TODO check impact on gas cost | checkFundingGoal();
checkFundingCap();
| checkFundingGoal();
checkFundingCap();
| 35,807 |
6 | // Checks if amount is within allowed burn bounds anddestroys `amount` tokens from `account`, reducing thetotal supply. account account to burn tokens for amount amount of tokens to burn | * Emits a {Burn} event
*/
function _burn(address account, uint256 amount) internal virtual override {
require(amount >= burnMin, "BurnableTokenWithBounds: below min burn bound");
require(amount <= burnMax, "BurnableTokenWithBounds: exceeds max burn bound");
super._burn(account, amount);
emit Burn(account, amount);
}
| * Emits a {Burn} event
*/
function _burn(address account, uint256 amount) internal virtual override {
require(amount >= burnMin, "BurnableTokenWithBounds: below min burn bound");
require(amount <= burnMax, "BurnableTokenWithBounds: exceeds max burn bound");
super._burn(account, amount);
emit Burn(account, amount);
}
| 16,008 |
603 | // allows for entry into the Genesis Group via ETH. Only callable during Genesis Period./to address to send FGEN Genesis tokens to/value amount of ETH to deposit | function purchase(address to, uint value) external payable;
| function purchase(address to, uint value) external payable;
| 39,667 |
12 | // Traverses the harvest log backwards _n items, and returns the average APR calculated across all the included log entries. APR is multiplied by PERCENT_DIVISOR to retain precision. / | function averageAPRAcrossLastNHarvests(int256 _n) external view returns (int256) {
require(harvestLog.length >= 2, "need at least 2 log entries");
int256 runningAPRSum;
int256 numLogsProcessed;
for (uint256 i = harvestLog.length - 1; i > 0 && numLogsProcessed < _n; i--) {
runningAPRSum += calculateAPRUsingLogs(i - 1, i);
numLogsProcessed++;
}
return runningAPRSum / numLogsProcessed;
}
| function averageAPRAcrossLastNHarvests(int256 _n) external view returns (int256) {
require(harvestLog.length >= 2, "need at least 2 log entries");
int256 runningAPRSum;
int256 numLogsProcessed;
for (uint256 i = harvestLog.length - 1; i > 0 && numLogsProcessed < _n; i--) {
runningAPRSum += calculateAPRUsingLogs(i - 1, i);
numLogsProcessed++;
}
return runningAPRSum / numLogsProcessed;
}
| 1,665 |
3 | // Grant other privileges to the contract creator | grantPrivileges(msg.sender, PRIV_MANAGE|PRIV_WITHDRAW);
| grantPrivileges(msg.sender, PRIV_MANAGE|PRIV_WITHDRAW);
| 55,409 |
11 | // Get the extra fee for collection in iToken. | function getLoanExtra(uint256 _loanId) external view virtual returns (uint256);
| function getLoanExtra(uint256 _loanId) external view virtual returns (uint256);
| 9,671 |
16 | // Sends synthesize request Token -> sToken on a second chain _stableBridgingFee Bridging fee on another network _token The address of the token that the user wants to synthesize _amount Number of tokens to synthesize _chain2address The address to which the user wants to receive the synth asset on another network _receiveSide Synthesis address on another network _oppositeBridge Bridge address on another network _revertableAddress An address on another network that allows the user to revert a stuck request _chainID Chain id of the network where synthesization will take place / | function synthesize(
uint256 _stableBridgingFee,
address _token,
uint256 _amount,
address _chain2address,
address _receiveSide,
address _oppositeBridge,
address _revertableAddress,
uint256 _chainID,
| function synthesize(
uint256 _stableBridgingFee,
address _token,
uint256 _amount,
address _chain2address,
address _receiveSide,
address _oppositeBridge,
address _revertableAddress,
uint256 _chainID,
| 24,686 |
442 | // If non of the above conditions have been met, the last round is considered ended | return AdjudicationState.Ended;
| return AdjudicationState.Ended;
| 27,809 |
14 | // return CFT balance available for withdrawal / | function CFTBalance() external view returns (uint256);
| function CFTBalance() external view returns (uint256);
| 18,173 |
104 | // allows list of supported tokens to be updated, addition/ | function addWinnableToken (string memory symbol_, address address_) public onlyOwner returns (bool) {
tokens[symbol_] = address_;
return true;
}
| function addWinnableToken (string memory symbol_, address address_) public onlyOwner returns (bool) {
tokens[symbol_] = address_;
return true;
}
| 14,849 |
17 | // https:github.com/ethereum/EIPs/issues/20issuecomment-263524729 | require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
| require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
| 7,053 |
21 | // Set max tokens that can be minted | uint256 public maxMintable;
mapping(address => uint256) private _balanceOf;
mapping(address => mapping (address => uint256)) private _allowed;
string public constant tokenSymbol = "BLVD";
string public constant tokenName = "BULVRD";
uint8 public constant tokenDecimals = 18;
uint256 public _totalSupply = 0;
| uint256 public maxMintable;
mapping(address => uint256) private _balanceOf;
mapping(address => mapping (address => uint256)) private _allowed;
string public constant tokenSymbol = "BLVD";
string public constant tokenName = "BULVRD";
uint8 public constant tokenDecimals = 18;
uint256 public _totalSupply = 0;
| 16,771 |
19 | // Calculates amounts of underlyings in some amount of cluster based on balances of cluster contract./Currently, returns all underlyings with 18 decimals./_clusterAmount Amount of cluster to calculate underlyings from./_clusterAddress Address of cluster token./ return Array, which contains amounts of underlyings. | function getUnderlyingsAmountsFromClusterAmount(uint256 _clusterAmount, address _clusterAddress)
external
view
override
returns (uint256[] memory)
| function getUnderlyingsAmountsFromClusterAmount(uint256 _clusterAmount, address _clusterAddress)
external
view
override
returns (uint256[] memory)
| 34,342 |
86 | // Logic for ether | if (_token == 0) {
escapeHatchDestination.transfer(_amount);
| if (_token == 0) {
escapeHatchDestination.transfer(_amount);
| 46,639 |
26 | // End timestamp of crowdsale, absolute UTC time | uint256 public endTimestamp;
| uint256 public endTimestamp;
| 29,720 |
59 | // Swap tokens for USDC | uint256 amountUsdc = _swapToUSDCOnZeroX(
_earnTermsId,
_tokenAddress,
_amount,
payable(_swapTarget), // address payable swapTarget
_swapCallData // bytes calldata swapCallData
);
earnTerms[_earnTermsId].usdcAccepted =
earnTerms[_earnTermsId].usdcAccepted +
| uint256 amountUsdc = _swapToUSDCOnZeroX(
_earnTermsId,
_tokenAddress,
_amount,
payable(_swapTarget), // address payable swapTarget
_swapCallData // bytes calldata swapCallData
);
earnTerms[_earnTermsId].usdcAccepted =
earnTerms[_earnTermsId].usdcAccepted +
| 14,503 |
37 | // set the sequence number to max uint32 to disable proxy submitted ballots after a voter submits a transaction personally - effectivley disables proxy ballots. You can _always_ submit a new vote _personally_ with this scheme. | if (db.sequenceNumber[msg.sender] != MAX_UINT32) {
| if (db.sequenceNumber[msg.sender] != MAX_UINT32) {
| 38,705 |
0 | // Owner definition. / | function owned() internal {
owner = msg.sender;
}
| function owned() internal {
owner = msg.sender;
}
| 45,825 |
18 | // Operational functions //Used for sending own tokens to other addresses. Keep in mind that you have to take decimals into account. Multiply the value in tokens with 10^tokenDecimals._to address Destination where we want to send the tokens to._value uint256 Amount of tokens we want to sender./ | function transfer(address _to, uint256 _value) unfrozenToken instForbiddenAddress(_to) public returns(bool success){
require(balances[msg.sender] >= _value); // Check if the sender has enough
require(balances[_to] + _value >= balances[_to]) ; // Check for overflows
balances[msg.sender] -= _value; // Subtract from the sender
balances[_to] += _value; // Add the same to the recipient
emit Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
return true;
}
| function transfer(address _to, uint256 _value) unfrozenToken instForbiddenAddress(_to) public returns(bool success){
require(balances[msg.sender] >= _value); // Check if the sender has enough
require(balances[_to] + _value >= balances[_to]) ; // Check for overflows
balances[msg.sender] -= _value; // Subtract from the sender
balances[_to] += _value; // Add the same to the recipient
emit Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
return true;
}
| 3,450 |
19 | // Add optional override | }
| }
| 38 |
68 | // integrate over ask orders, our trade can be a bid or an ask | return integralAsk(q);
| return integralAsk(q);
| 52,629 |
40 | // Checks if account is blacklisted account The address to check / | function isBlacklisted(address account) external view returns (bool) {
return blacklisted[account];
}
| function isBlacklisted(address account) external view returns (bool) {
return blacklisted[account];
}
| 55,611 |
22 | // Padlock v0.1.0 Multisignature Agreement LibraryAuthor: Blox Consulting LLCLast Updated: 07.17.2020 Library to compartmentalize multisignature logic with Padlock's four roles / | library Agreements {
/// EVENTS ///
event ChangeOrderAgreement(address _admin, address _owner, address _gc, address _sc);
event LienReleaseAgreement(address _gc, address _sc);
event AgreementSigned(address _by);
/// MODIFIERS ///
modifier onlySigner(Agreement storage _self) {
require(_self.signer[msg.sender], 'Only predefined signers can participate in this agreement!');
_;
}
modifier uninitialized(Agreement storage _self) {
require(_self.kind == AgreementType.None, 'Cannot operate on initialized Agreement!');
_;
}
/// MUTABLE FUNCTIONS ///
// Agreement Initialization //
/**
* Initialize an agreement as a change order sequence
* @param _admin address the Padlock service contract
* @param _owner address the owner account
* @param _gc address the general contractor account
* @param _sc address the subcontractor account
*/
function initChangeOrder(
Agreement storage _self,
address _admin,
address _owner,
address _gc,
address _sc
) internal {
//Agreement metadata
_self.kind = AgreementType.ChangeOrder;
_self.threshold = 4;
//Agreement Signers
_self.signer[_admin] = true;
_self.signer[_owner] = true;
_self.signer[_gc] = true;
_self.signer[_sc] = true;
//Agreement Roles
_self.admin = _admin;
_self.owner = _owner;
_self.gc = _gc;
_self.sc = _sc;
emit ChangeOrderAgreement(_admin, _owner, _gc, _sc);
}
/**
* Initialize an agreement as a lien release check sequence
* @param _gc address the general contractor account
* @param _sc address the subcontractor account
*/
function initLienRelease(
Agreement storage _self,
address _gc,
address _sc
) internal {
//Agreement metadata
_self.kind = AgreementType.LienRelease;
_self.threshold = 2;
//Agreement Signers
_self.signer[_gc] = true;
_self.signer[_sc] = true;
//Agreement Roles
_self.gc = _gc;
_self.sc = _sc;
emit LienReleaseAgreement(_gc, _sc);
}
// Signature //
/**
* Sign a multisignature agreement
* @param _self the agreement struct being mutated
* @return _nonce uint number of signatures recieved
*/
function sign(Agreement storage _self) internal onlySigner(_self) returns (uint256 _nonce) {
require(!_self.signed[msg.sender], 'Cannot sign an agreement twice!');
_self.signed[msg.sender] = true;
_self.nonce += 1;
emit AgreementSigned(msg.sender);
return _self.nonce;
}
/// VIEWABLE FUNCTIONS ///
/**
* Determine whether a multisignature agreement can be considered resolved
* @param _self Agreement the struct being evaluated
* @return bool true if all signers have approved, and false otherwise
*/
function resolved(Agreement storage _self) internal view returns (bool) {
return (_self.nonce == _self.threshold);
}
/**
* Determine whether or not an Agreement has been signed by a given address
* @param _self Agreement the agreeement struct being mutated
* @param _by address the address being queried for signature submission status
* @return true if _by has signed the agreement, and false otherwise
*/
function hasSigned(Agreement storage _self, address _by) internal view returns (bool) {
return _self.signed[_by];
}
/**
* Determine whether or not an Agreement has a given address as a signer
* @param _self Agreement the agreeement struct being mutated
* @param _by address the address being queried for signature authorization status
* @return true if _by is allowed to sign the agreement, and false otherwise
*/
function isSigner(Agreement storage _self, address _by) internal view returns (bool) {
return _self.signer[_by];
}
}
| library Agreements {
/// EVENTS ///
event ChangeOrderAgreement(address _admin, address _owner, address _gc, address _sc);
event LienReleaseAgreement(address _gc, address _sc);
event AgreementSigned(address _by);
/// MODIFIERS ///
modifier onlySigner(Agreement storage _self) {
require(_self.signer[msg.sender], 'Only predefined signers can participate in this agreement!');
_;
}
modifier uninitialized(Agreement storage _self) {
require(_self.kind == AgreementType.None, 'Cannot operate on initialized Agreement!');
_;
}
/// MUTABLE FUNCTIONS ///
// Agreement Initialization //
/**
* Initialize an agreement as a change order sequence
* @param _admin address the Padlock service contract
* @param _owner address the owner account
* @param _gc address the general contractor account
* @param _sc address the subcontractor account
*/
function initChangeOrder(
Agreement storage _self,
address _admin,
address _owner,
address _gc,
address _sc
) internal {
//Agreement metadata
_self.kind = AgreementType.ChangeOrder;
_self.threshold = 4;
//Agreement Signers
_self.signer[_admin] = true;
_self.signer[_owner] = true;
_self.signer[_gc] = true;
_self.signer[_sc] = true;
//Agreement Roles
_self.admin = _admin;
_self.owner = _owner;
_self.gc = _gc;
_self.sc = _sc;
emit ChangeOrderAgreement(_admin, _owner, _gc, _sc);
}
/**
* Initialize an agreement as a lien release check sequence
* @param _gc address the general contractor account
* @param _sc address the subcontractor account
*/
function initLienRelease(
Agreement storage _self,
address _gc,
address _sc
) internal {
//Agreement metadata
_self.kind = AgreementType.LienRelease;
_self.threshold = 2;
//Agreement Signers
_self.signer[_gc] = true;
_self.signer[_sc] = true;
//Agreement Roles
_self.gc = _gc;
_self.sc = _sc;
emit LienReleaseAgreement(_gc, _sc);
}
// Signature //
/**
* Sign a multisignature agreement
* @param _self the agreement struct being mutated
* @return _nonce uint number of signatures recieved
*/
function sign(Agreement storage _self) internal onlySigner(_self) returns (uint256 _nonce) {
require(!_self.signed[msg.sender], 'Cannot sign an agreement twice!');
_self.signed[msg.sender] = true;
_self.nonce += 1;
emit AgreementSigned(msg.sender);
return _self.nonce;
}
/// VIEWABLE FUNCTIONS ///
/**
* Determine whether a multisignature agreement can be considered resolved
* @param _self Agreement the struct being evaluated
* @return bool true if all signers have approved, and false otherwise
*/
function resolved(Agreement storage _self) internal view returns (bool) {
return (_self.nonce == _self.threshold);
}
/**
* Determine whether or not an Agreement has been signed by a given address
* @param _self Agreement the agreeement struct being mutated
* @param _by address the address being queried for signature submission status
* @return true if _by has signed the agreement, and false otherwise
*/
function hasSigned(Agreement storage _self, address _by) internal view returns (bool) {
return _self.signed[_by];
}
/**
* Determine whether or not an Agreement has a given address as a signer
* @param _self Agreement the agreeement struct being mutated
* @param _by address the address being queried for signature authorization status
* @return true if _by is allowed to sign the agreement, and false otherwise
*/
function isSigner(Agreement storage _self, address _by) internal view returns (bool) {
return _self.signer[_by];
}
}
| 30,709 |
44 | // aka ERC20Detailed | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory name_, string memory symbol_, uint8 decimals_) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
}
function compare( string memory a, string memory b) public pure returns(bool) { return keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b));
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
//logs
console.log("[sc] _transfer(): balanceFrom %s, amount: %s, balanceTo %s", _balances[sender], amount, _balances[recipient]);
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
| contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory name_, string memory symbol_, uint8 decimals_) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
}
function compare( string memory a, string memory b) public pure returns(bool) { return keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b));
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
//logs
console.log("[sc] _transfer(): balanceFrom %s, amount: %s, balanceTo %s", _balances[sender], amount, _balances[recipient]);
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
| 36,836 |
17 | // Dividend-Paying Token Optional Interface/Roger Wu (https:github.com/roger-wu)/OPTIONAL functions for a dividend-paying token contract. | interface DividendPayingTokenOptionalInterface {
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function withdrawableDividendOf(address _owner)
external
view
returns (uint256);
/// @notice View the amount of dividend in wei that an address has withdrawn.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has withdrawn.
function withdrawnDividendOf(address _owner)
external
view
returns (uint256);
/// @notice View the amount of dividend in wei that an address has earned in total.
/// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has earned in total.
function accumulativeDividendOf(address _owner)
external
view
returns (uint256);
}
| interface DividendPayingTokenOptionalInterface {
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function withdrawableDividendOf(address _owner)
external
view
returns (uint256);
/// @notice View the amount of dividend in wei that an address has withdrawn.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has withdrawn.
function withdrawnDividendOf(address _owner)
external
view
returns (uint256);
/// @notice View the amount of dividend in wei that an address has earned in total.
/// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has earned in total.
function accumulativeDividendOf(address _owner)
external
view
returns (uint256);
}
| 18,447 |
182 | // Returns whether the Time Lock app is a forwarder or notIForwarder interface conformance return Always true/ | function isForwarder() external pure returns (bool) {
return true;
}
| function isForwarder() external pure returns (bool) {
return true;
}
| 18,469 |
13 | // Channel accepted, close request and close events | event channelAccepted(uint256 farEndValue, uint256 totalValue);
event closeRequest(address indexed end, bool closeChange);
event channelClosed(address indexed NearEnd, uint256 nearEndFinalValue, address indexed FarEnd,
uint256 farEndFinalValue, uint256 finalId);
bool public closed;
bool public accepted;
mapping(address => bool) public disputed;
| event channelAccepted(uint256 farEndValue, uint256 totalValue);
event closeRequest(address indexed end, bool closeChange);
event channelClosed(address indexed NearEnd, uint256 nearEndFinalValue, address indexed FarEnd,
uint256 farEndFinalValue, uint256 finalId);
bool public closed;
bool public accepted;
mapping(address => bool) public disputed;
| 38,525 |
4 | // register as a user on the portal | function register(address reciever, string memory name) public {
require(reciever != address(0), "not a valid address");
users[msg.sender] = UserProfile(reciever, name, false, 0, true);
}
| function register(address reciever, string memory name) public {
require(reciever != address(0), "not a valid address");
users[msg.sender] = UserProfile(reciever, name, false, 0, true);
}
| 13,216 |
20 | // Length of approval period in seconds. | uint64 public approvalPeriod;
| uint64 public approvalPeriod;
| 36,039 |
147 | // we only read balance again if rewards were claimed | balanceOfWantAfter = balanceOfWant();
| balanceOfWantAfter = balanceOfWant();
| 27,405 |
3 | // Notifies the controller about an approval allowing the/controller to react if desired/_owner The address that calls `approve()`/_spender The spender in the `approve()` call/_amount The amount in the `approve()` call/ return False if the controller does not authorize the approval | function onApprove(address _owner, address _spender, uint _amount) external returns(bool);
| function onApprove(address _owner, address _spender, uint _amount) external returns(bool);
| 26,209 |
4 | // check user's hodl time, and calculate the accured interest | uint depositTime = block.timestamp - depositStart[msg.sender];
uint interestperSecond = 31668017 * (etherBalanceOf[msg.sender] / 1e16);
uint interest = interestperSecond * depositTime;
| uint depositTime = block.timestamp - depositStart[msg.sender];
uint interestperSecond = 31668017 * (etherBalanceOf[msg.sender] / 1e16);
uint interest = interestperSecond * depositTime;
| 47,290 |
1 | // Payment to Fees | uint256 fees;
| uint256 fees;
| 11,229 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.