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 |
|---|---|---|---|---|
16 | // Get the underlying price in USD from the Price Feed, so we can find out the maximum amount of underlying we can borrow. | uint256 underlyingPrice = priceFeed.getUnderlyingPrice(_cTokenAddress);
uint256 maxBorrowUnderlying = liquidity / underlyingPrice;
| uint256 underlyingPrice = priceFeed.getUnderlyingPrice(_cTokenAddress);
uint256 maxBorrowUnderlying = liquidity / underlyingPrice;
| 3,516 |
12 | // Emitted when a new COMP speed is calculated for a market | event CompSpeedUpdated(CToken indexed cToken, uint newSpeed);
| event CompSpeedUpdated(CToken indexed cToken, uint newSpeed);
| 11,781 |
57 | // Transfers the ownership of an NFT from one address to another address Safely transfers the ownership of a given token ID to another addressIf the target address is a contract, it must implement `onERC721Received`,which is called upon a safe transfer, and return the magic value`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,the transfer is reverted. Throws unless `msg.sender` is the current owner, an authorized operator, or the approved address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` is the zero address. Throws if`_tokenId` is not a valid NFT. _from current owner of the token _to address to receive the ownership | function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable {
// it does not accept payments in this version
require(msg.value == 0);
_safeTransferFrom(_from, _to, _tokenId, "");
}
| function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable {
// it does not accept payments in this version
require(msg.value == 0);
_safeTransferFrom(_from, _to, _tokenId, "");
}
| 14,833 |
18 | // Wrappers over Solidity's arithmetic operations.NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler now has built in overflow checking. / | library SafeMath {
/**
* _Available since v3.4._
*
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* _Available since v3.4._
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
*
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
* _Available since v3.4._
*/
/**
* _Available since v3.4._
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// 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 (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* _Available since v3.4._
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* - Addition cannot overflow.
* overflow.
*
*/
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* - Subtraction cannot overflow.
* Requirements:
*
*
*
* overflow (when the result is negative).
* Counterpart to Solidity's `-` operator.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* Requirements:
* - Multiplication cannot overflow.
*
*
* Counterpart to Solidity's `*` operator.
* overflow.
*
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
*
*
* division by zero. The result is rounded towards zero.
* Counterpart to Solidity's `/` operator.
*
* - The divisor cannot be zero.
* Requirements:
* @dev Returns the integer division of two unsigned integers, reverting on
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* - The divisor cannot be zero.
* invalid opcode to revert (consuming all remaining gas).
* reverting when dividing by zero.
* Requirements:
*
*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* - Subtraction cannot overflow.
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
*
* message unnecessarily. For custom revert reasons use {trySub}.
* Requirements:
* CAUTION: This function is deprecated because it requires allocating memory for the error
*
* Counterpart to Solidity's `-` operator.
*
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* uses an invalid opcode to revert (consuming all remaining gas).
* - The divisor cannot be zero.
* division by zero. The result is rounded towards zero.
*
* Requirements:
* `revert` opcode (which leaves remaining gas untouched) while Solidity
*
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
*/
/**
* reverting with custom message when dividing by zero.
* CAUTION: This function is deprecated because it requires allocating memory for the error
* Counterpart to Solidity's `%` operator. This function uses a `revert`
*
* invalid opcode to revert (consuming all remaining gas).
* Requirements:
* opcode (which leaves remaining gas untouched) while Solidity uses an
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
*
* - The divisor cannot be zero.
*
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
| library SafeMath {
/**
* _Available since v3.4._
*
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* _Available since v3.4._
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
*
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
* _Available since v3.4._
*/
/**
* _Available since v3.4._
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// 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 (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* _Available since v3.4._
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* - Addition cannot overflow.
* overflow.
*
*/
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* - Subtraction cannot overflow.
* Requirements:
*
*
*
* overflow (when the result is negative).
* Counterpart to Solidity's `-` operator.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* Requirements:
* - Multiplication cannot overflow.
*
*
* Counterpart to Solidity's `*` operator.
* overflow.
*
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
*
*
* division by zero. The result is rounded towards zero.
* Counterpart to Solidity's `/` operator.
*
* - The divisor cannot be zero.
* Requirements:
* @dev Returns the integer division of two unsigned integers, reverting on
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* - The divisor cannot be zero.
* invalid opcode to revert (consuming all remaining gas).
* reverting when dividing by zero.
* Requirements:
*
*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* - Subtraction cannot overflow.
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
*
* message unnecessarily. For custom revert reasons use {trySub}.
* Requirements:
* CAUTION: This function is deprecated because it requires allocating memory for the error
*
* Counterpart to Solidity's `-` operator.
*
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* uses an invalid opcode to revert (consuming all remaining gas).
* - The divisor cannot be zero.
* division by zero. The result is rounded towards zero.
*
* Requirements:
* `revert` opcode (which leaves remaining gas untouched) while Solidity
*
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
*/
/**
* reverting with custom message when dividing by zero.
* CAUTION: This function is deprecated because it requires allocating memory for the error
* Counterpart to Solidity's `%` operator. This function uses a `revert`
*
* invalid opcode to revert (consuming all remaining gas).
* Requirements:
* opcode (which leaves remaining gas untouched) while Solidity uses an
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
*
* - The divisor cannot be zero.
*
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
| 43,239 |
25 | // pick fourth winner (25% cudl) | winner4 = players[currentRound][
randomNumber(block.number - 4, players[currentRound].length)
];
require(cudl.transfer(winner4, cudlBalance.mul(19).div(100)));
| winner4 = players[currentRound][
randomNumber(block.number - 4, players[currentRound].length)
];
require(cudl.transfer(winner4, cudlBalance.mul(19).div(100)));
| 7,672 |
49 | // Keep track of total pot shares controlled by LSDAI | _totalPotShares = _totalPotShares.add(potSharesAmount);
| _totalPotShares = _totalPotShares.add(potSharesAmount);
| 2,737 |
222 | // get the parameters for the current scheme from the controller/ | function getParametersFromController(Avatar _avatar) internal view returns(bytes32) {
require(Controller(_avatar.owner()).isSchemeRegistered(address(this), address(_avatar)),
"scheme is not registered");
return Controller(_avatar.owner()).getSchemeParameters(address(this), address(_avatar));
}
| function getParametersFromController(Avatar _avatar) internal view returns(bytes32) {
require(Controller(_avatar.owner()).isSchemeRegistered(address(this), address(_avatar)),
"scheme is not registered");
return Controller(_avatar.owner()).getSchemeParameters(address(this), address(_avatar));
}
| 9,605 |
9 | // ============ Mutable ERC20 Attributes ============ |
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => uint256) public nonces;
|
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => uint256) public nonces;
| 7,120 |
4 | // We got enough in this bucket to cover the amount We remove it from total and dont adjust the fully vesting timestamp Because there might be tokens left still in it | totalRemoved += remainingBalanceNeeded;
vestingTransactions[sender][lastInTxIndex].amount = leastMatureTxAmount - remainingBalanceNeeded; // safe math already checked
| totalRemoved += remainingBalanceNeeded;
vestingTransactions[sender][lastInTxIndex].amount = leastMatureTxAmount - remainingBalanceNeeded; // safe math already checked
| 78,636 |
31 | // onlyEOA requires msg.sender to be an externally owned account / | modifier onlyEOA() {
require(msg.sender == tx.origin, "only externally owned accounts");
_;
}
| modifier onlyEOA() {
require(msg.sender == tx.origin, "only externally owned accounts");
_;
}
| 34,761 |
128 | // Nemesis (NEM) with Governance Alpha | contract NemesisFinance is ERC20 {
using SafeERC20 for IERC20;
using SafeMath for uint256;
uint256 cap;
constructor (uint256 _cap) public ERC20("Nemesis.Finance", "NEM") {
governance = tx.origin;
cap = _cap;
}
function burn(uint256 _amount) public {
_burn(msg.sender, _amount);
_moveDelegates(_delegates[msg.sender], address(0), _amount);
}
function burnFrom(address _account, uint256 _amount) public {
uint256 decreasedAllowance = allowance(_account, msg.sender).sub(_amount, "ERC20: burn amount exceeds allowance");
_approve(_account, msg.sender, decreasedAllowance);
_burn(_account, _amount);
_moveDelegates(_delegates[_account], address(0), _amount);
}
function setCap(uint256 _cap) public {
require(msg.sender == governance, "!governance");
require(_cap >= totalSupply(), "_cap is below current total supply");
cap = _cap;
}
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*
* Requirements:
*
* - minted tokens must not cause the total supply to go over the cap.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
if (from == address(0)) {// When minting tokens
require(totalSupply().add(amount) <= cap, "ERC20Capped: cap exceeded");
}
}
// 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
/// @dev 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)");
/// @dev 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), "NEM::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "NEM::delegateBySig: invalid nonce");
require(now <= expiry, "NEM::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, "NEM: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 NEMs (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, "NEM::_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 NemesisFinance is ERC20 {
using SafeERC20 for IERC20;
using SafeMath for uint256;
uint256 cap;
constructor (uint256 _cap) public ERC20("Nemesis.Finance", "NEM") {
governance = tx.origin;
cap = _cap;
}
function burn(uint256 _amount) public {
_burn(msg.sender, _amount);
_moveDelegates(_delegates[msg.sender], address(0), _amount);
}
function burnFrom(address _account, uint256 _amount) public {
uint256 decreasedAllowance = allowance(_account, msg.sender).sub(_amount, "ERC20: burn amount exceeds allowance");
_approve(_account, msg.sender, decreasedAllowance);
_burn(_account, _amount);
_moveDelegates(_delegates[_account], address(0), _amount);
}
function setCap(uint256 _cap) public {
require(msg.sender == governance, "!governance");
require(_cap >= totalSupply(), "_cap is below current total supply");
cap = _cap;
}
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*
* Requirements:
*
* - minted tokens must not cause the total supply to go over the cap.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
if (from == address(0)) {// When minting tokens
require(totalSupply().add(amount) <= cap, "ERC20Capped: cap exceeded");
}
}
// 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
/// @dev 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)");
/// @dev 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), "NEM::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "NEM::delegateBySig: invalid nonce");
require(now <= expiry, "NEM::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, "NEM: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 NEMs (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, "NEM::_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;
}
} | 52,181 |
121 | // default to onBehalf of proxy | if (_onBehalf == address(0)) {
_onBehalf = address(this);
}
| if (_onBehalf == address(0)) {
_onBehalf = address(this);
}
| 47,855 |
31 | // tokenCap should be initialized in derived contract | uint256 public tokenCap;
uint256 public soldTokens;
| uint256 public tokenCap;
uint256 public soldTokens;
| 2,294 |
34 | // call handle function | IMessageRecipient(_m.recipientAddress()).handle(
_m.origin(),
_m.nonce(),
_m.sender(),
_m.body().clone()
);
| IMessageRecipient(_m.recipientAddress()).handle(
_m.origin(),
_m.nonce(),
_m.sender(),
_m.body().clone()
);
| 19,919 |
19 | // 开奖26000个区块之后,竞猜发起人可以提取佣金 | require(winTeam < 3 && stopWithdrawBlock<block.number && address(this).balance>0);
owner.transfer(address(this).balance);
| require(winTeam < 3 && stopWithdrawBlock<block.number && address(this).balance>0);
owner.transfer(address(this).balance);
| 27,774 |
41 | // ServiceAllowance.// Provides a way to delegate operation allowance decision to a service contract | contract ServiceAllowance {
function isTransferAllowed(address _from, address _to, address _sender, address _token, uint _value) public view returns (bool);
}
| contract ServiceAllowance {
function isTransferAllowed(address _from, address _to, address _sender, address _token, uint _value) public view returns (bool);
}
| 42,853 |
31 | // ========== INTERNAL FUNCTIONS ========== / | {
combination = new bytes32[](first.length + second.length);
for (uint i = 0; i < first.length; i++) {
combination[i] = first[i];
}
for (uint j = 0; j < second.length; j++) {
combination[first.length + j] = second[j];
}
}
| {
combination = new bytes32[](first.length + second.length);
for (uint i = 0; i < first.length; i++) {
combination[i] = first[i];
}
for (uint j = 0; j < second.length; j++) {
combination[first.length + j] = second[j];
}
}
| 24,746 |
166 | // keccak256("MINTER_ROLE"); | bytes32 public constant MINTER_ROLE = 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6;
| bytes32 public constant MINTER_ROLE = 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6;
| 47,584 |
15 | // override ERC721A _startTokenId() / | function _startTokenId()
internal
view
virtual
override
| function _startTokenId()
internal
view
virtual
override
| 38,673 |
10 | // Owned / | contract Owned {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
}
| contract Owned {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
}
| 41,981 |
5 | // stETH allowance status | uint256 internal stETHStatus;
address public owner;
uint256 internal ownerStatus;
mapping(address => bool) public isWhitelisted;
| uint256 internal stETHStatus;
address public owner;
uint256 internal ownerStatus;
mapping(address => bool) public isWhitelisted;
| 11,118 |
11 | // the vault id | uint256 id;
| uint256 id;
| 3,242 |
116 | // Keep function can be called by anyone to balances that have been expired. This pays out addresses and removes used cover. This is external because the doKeep modifier calls back to ArmorMaster, which then calls back to here (and elsewhere)./ | function keep() external {
for (uint256 i = 0; i < 2; i++) {
if (infos[head].expiresAt != 0 && infos[head].expiresAt <= now) {
address oldHead = address(head);
uint256 oldBal = _updateBalance(oldHead);
_updateBalanceActions(oldHead, oldBal);
} else return;
}
}
| function keep() external {
for (uint256 i = 0; i < 2; i++) {
if (infos[head].expiresAt != 0 && infos[head].expiresAt <= now) {
address oldHead = address(head);
uint256 oldBal = _updateBalance(oldHead);
_updateBalanceActions(oldHead, oldBal);
} else return;
}
}
| 4,792 |
37 | // Checks if the difficulty target should be adjusted at this block height height Block height to be checkedreturn True if block height is at difficulty adjustment interval, otherwise false / | function _isPeriodStart(uint32 height) internal pure returns (bool) {
return height % DIFFICULTY_ADJUSTMENT_INTERVAL == 0;
}
| function _isPeriodStart(uint32 height) internal pure returns (bool) {
return height % DIFFICULTY_ADJUSTMENT_INTERVAL == 0;
}
| 3,867 |
6 | // array | address[] g;
bool[] g1;
bytes[] g2;
bytes32[] g3;
int8[] g4;
int256[] g5;
uint8[] g6;
uint256[] g7;
string[] g8;
SimpleStruct[] g9;
| address[] g;
bool[] g1;
bytes[] g2;
bytes32[] g3;
int8[] g4;
int256[] g5;
uint8[] g6;
uint256[] g7;
string[] g8;
SimpleStruct[] g9;
| 19,106 |
53 | // BabyloniaToken / | contract BabyloniaToken is MintAndBurnToken {
// DetailedERC20 variables
string public name = "Babylonia Token";
string public symbol = "BBY";
uint8 public decimals = 18;
}
| contract BabyloniaToken is MintAndBurnToken {
// DetailedERC20 variables
string public name = "Babylonia Token";
string public symbol = "BBY";
uint8 public decimals = 18;
}
| 15,840 |
91 | // Sets `adminRole` as `role`'s admin role. / | function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
| function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
| 3,202 |
90 | // send remainder to marketing | (success,) = address(marketingAddress).call{value: address(this).balance}("");
| (success,) = address(marketingAddress).call{value: address(this).balance}("");
| 865 |
75 | // BAC | _token = IERC20(address(0x3449FC1Cd036255BA1EB19d65fF4BA2b8903A69a));
tokenList.push(
TokenInfo({
token: _token,
decimals: _token.decimals(),
pairedToken: daiAddress, // DAI
pairedTokenDecimals: IERC20(daiAddress).decimals()
})
| _token = IERC20(address(0x3449FC1Cd036255BA1EB19d65fF4BA2b8903A69a));
tokenList.push(
TokenInfo({
token: _token,
decimals: _token.decimals(),
pairedToken: daiAddress, // DAI
pairedTokenDecimals: IERC20(daiAddress).decimals()
})
| 7,981 |
24 | // private seed phase 1 (5 days) | if (timeElapsedInDays <5)
{
| if (timeElapsedInDays <5)
{
| 1,618 |
59 | // Calculates number of tokens that will be locked | uint256 locked = amount * _lockPercentage / 100;
| uint256 locked = amount * _lockPercentage / 100;
| 10,316 |
2 | // Define a variable to store the access key smart contract | ERC1155LazyMint public accessKeysCollection;
event NFTEvolved(address reciever, uint256 tokenId, uint256 amount);
| ERC1155LazyMint public accessKeysCollection;
event NFTEvolved(address reciever, uint256 tokenId, uint256 amount);
| 8,375 |
21 | // Allows the new owner to accept an ownership offer to contract control. /noinspection UnprotectedFunction | function acceptOwnershipOffer() external {
require (proposedOwner != address(0x0));
require (msg.sender == proposedOwner);
address _oldOwner = owner;
owner = proposedOwner;
proposedOwner = address(0x0);
OwnerAssignedEvent(owner);
OwnershipOfferAcceptedEvent(_oldOwner, owner);
}
| function acceptOwnershipOffer() external {
require (proposedOwner != address(0x0));
require (msg.sender == proposedOwner);
address _oldOwner = owner;
owner = proposedOwner;
proposedOwner = address(0x0);
OwnerAssignedEvent(owner);
OwnershipOfferAcceptedEvent(_oldOwner, owner);
}
| 12,491 |
94 | // cant take staked asset | require(_token != yam, "yam");
| require(_token != yam, "yam");
| 77,448 |
256 | // BaseENSManager Implementation of an ENS manager that orchestrates the completeregistration of subdomains for a single root (e.g. argent.eth).The contract defines a manager role who is the only role that can trigger the registration ofa new subdomain. Julien Niset - <julien@argent.im> / | contract BaseENSManager is IENSManager, OwnerManagable, ENSConsumer {
using strings for *;
using BytesUtil for bytes;
using MathUint for uint;
// The managed root name
string public rootName;
// The managed root node
bytes32 public immutable rootNode;
// The address of the ENS resolver
address public ensResolver;
// *************** Events *************************** //
event RootnodeOwnerChange(bytes32 indexed _rootnode, address indexed _newOwner);
event ENSResolverChanged(address addr);
event Registered(address indexed _wallet, address _owner, string _ens);
event Unregistered(string _ens);
// *************** Constructor ********************** //
/**
* @dev Constructor that sets the ENS root name and root node to manage.
* @param _rootName The root name (e.g. argentx.eth).
* @param _rootNode The node of the root name (e.g. namehash(argentx.eth)).
*/
constructor(string memory _rootName, bytes32 _rootNode, address _ensRegistry, address _ensResolver)
ENSConsumer(_ensRegistry)
{
rootName = _rootName;
rootNode = _rootNode;
ensResolver = _ensResolver;
}
// *************** External Functions ********************* //
/**
* @dev This function must be called when the ENS Manager contract is replaced
* and the address of the new Manager should be provided.
* @param _newOwner The address of the new ENS manager that will manage the root node.
*/
function changeRootnodeOwner(address _newOwner) external override onlyOwner {
getENSRegistry().setOwner(rootNode, _newOwner);
emit RootnodeOwnerChange(rootNode, _newOwner);
}
/**
* @dev Lets the owner change the address of the ENS resolver contract.
* @param _ensResolver The address of the ENS resolver contract.
*/
function changeENSResolver(address _ensResolver) external onlyOwner {
require(_ensResolver != address(0), "WF: address cannot be null");
ensResolver = _ensResolver;
emit ENSResolverChanged(_ensResolver);
}
/**
* @dev Lets the manager assign an ENS subdomain of the root node to a target address.
* Registers both the forward and reverse ENS.
* @param _wallet The wallet which owns the subdomain.
* @param _owner The wallet's owner.
* @param _label The subdomain label.
* @param _approval The signature of _wallet, _owner and _label by a manager.
*/
function register(
address _wallet,
address _owner,
string calldata _label,
bytes calldata _approval
)
external
override
onlyManager
{
verifyApproval(_wallet, _owner, _label, _approval);
ENSRegistry _ensRegistry = getENSRegistry();
ENSResolver _ensResolver = ENSResolver(ensResolver);
bytes32 labelNode = keccak256(abi.encodePacked(_label));
bytes32 node = keccak256(abi.encodePacked(rootNode, labelNode));
address currentOwner = _ensRegistry.owner(node);
require(currentOwner == address(0), "AEM: _label is alrealdy owned");
// Forward ENS
_ensRegistry.setSubnodeOwner(rootNode, labelNode, address(this));
_ensRegistry.setResolver(node, address(_ensResolver));
_ensRegistry.setOwner(node, _wallet);
_ensResolver.setAddr(node, _wallet);
// Reverse ENS
strings.slice[] memory parts = new strings.slice[](2);
parts[0] = _label.toSlice();
parts[1] = rootName.toSlice();
string memory name = ".".toSlice().join(parts);
bytes32 reverseNode = getENSReverseRegistrar().node(_wallet);
_ensResolver.setName(reverseNode, name);
emit Registered(_wallet, _owner, name);
}
// *************** Public Functions ********************* //
/**
* @dev Resolves an address to an ENS name
* @param _wallet The ENS owner address
*/
function resolveName(address _wallet) public view override returns (string memory) {
bytes32 reverseNode = getENSReverseRegistrar().node(_wallet);
return ENSResolver(ensResolver).name(reverseNode);
}
/**
* @dev Returns true is a given subnode is available.
* @param _subnode The target subnode.
* @return true if the subnode is available.
*/
function isAvailable(bytes32 _subnode) public view override returns (bool) {
bytes32 node = keccak256(abi.encodePacked(rootNode, _subnode));
address currentOwner = getENSRegistry().owner(node);
if(currentOwner == address(0)) {
return true;
}
return false;
}
function verifyApproval(
address _wallet,
address _owner,
string calldata _label,
bytes calldata _approval
)
internal
view
{
bytes32 messageHash = keccak256(
abi.encodePacked(
_wallet,
_owner,
_label
)
);
bytes32 hash = keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
messageHash
)
);
address signer = SignatureUtil.recoverECDSASigner(hash, _approval);
require(isManager(signer), "UNAUTHORIZED");
}
}
| contract BaseENSManager is IENSManager, OwnerManagable, ENSConsumer {
using strings for *;
using BytesUtil for bytes;
using MathUint for uint;
// The managed root name
string public rootName;
// The managed root node
bytes32 public immutable rootNode;
// The address of the ENS resolver
address public ensResolver;
// *************** Events *************************** //
event RootnodeOwnerChange(bytes32 indexed _rootnode, address indexed _newOwner);
event ENSResolverChanged(address addr);
event Registered(address indexed _wallet, address _owner, string _ens);
event Unregistered(string _ens);
// *************** Constructor ********************** //
/**
* @dev Constructor that sets the ENS root name and root node to manage.
* @param _rootName The root name (e.g. argentx.eth).
* @param _rootNode The node of the root name (e.g. namehash(argentx.eth)).
*/
constructor(string memory _rootName, bytes32 _rootNode, address _ensRegistry, address _ensResolver)
ENSConsumer(_ensRegistry)
{
rootName = _rootName;
rootNode = _rootNode;
ensResolver = _ensResolver;
}
// *************** External Functions ********************* //
/**
* @dev This function must be called when the ENS Manager contract is replaced
* and the address of the new Manager should be provided.
* @param _newOwner The address of the new ENS manager that will manage the root node.
*/
function changeRootnodeOwner(address _newOwner) external override onlyOwner {
getENSRegistry().setOwner(rootNode, _newOwner);
emit RootnodeOwnerChange(rootNode, _newOwner);
}
/**
* @dev Lets the owner change the address of the ENS resolver contract.
* @param _ensResolver The address of the ENS resolver contract.
*/
function changeENSResolver(address _ensResolver) external onlyOwner {
require(_ensResolver != address(0), "WF: address cannot be null");
ensResolver = _ensResolver;
emit ENSResolverChanged(_ensResolver);
}
/**
* @dev Lets the manager assign an ENS subdomain of the root node to a target address.
* Registers both the forward and reverse ENS.
* @param _wallet The wallet which owns the subdomain.
* @param _owner The wallet's owner.
* @param _label The subdomain label.
* @param _approval The signature of _wallet, _owner and _label by a manager.
*/
function register(
address _wallet,
address _owner,
string calldata _label,
bytes calldata _approval
)
external
override
onlyManager
{
verifyApproval(_wallet, _owner, _label, _approval);
ENSRegistry _ensRegistry = getENSRegistry();
ENSResolver _ensResolver = ENSResolver(ensResolver);
bytes32 labelNode = keccak256(abi.encodePacked(_label));
bytes32 node = keccak256(abi.encodePacked(rootNode, labelNode));
address currentOwner = _ensRegistry.owner(node);
require(currentOwner == address(0), "AEM: _label is alrealdy owned");
// Forward ENS
_ensRegistry.setSubnodeOwner(rootNode, labelNode, address(this));
_ensRegistry.setResolver(node, address(_ensResolver));
_ensRegistry.setOwner(node, _wallet);
_ensResolver.setAddr(node, _wallet);
// Reverse ENS
strings.slice[] memory parts = new strings.slice[](2);
parts[0] = _label.toSlice();
parts[1] = rootName.toSlice();
string memory name = ".".toSlice().join(parts);
bytes32 reverseNode = getENSReverseRegistrar().node(_wallet);
_ensResolver.setName(reverseNode, name);
emit Registered(_wallet, _owner, name);
}
// *************** Public Functions ********************* //
/**
* @dev Resolves an address to an ENS name
* @param _wallet The ENS owner address
*/
function resolveName(address _wallet) public view override returns (string memory) {
bytes32 reverseNode = getENSReverseRegistrar().node(_wallet);
return ENSResolver(ensResolver).name(reverseNode);
}
/**
* @dev Returns true is a given subnode is available.
* @param _subnode The target subnode.
* @return true if the subnode is available.
*/
function isAvailable(bytes32 _subnode) public view override returns (bool) {
bytes32 node = keccak256(abi.encodePacked(rootNode, _subnode));
address currentOwner = getENSRegistry().owner(node);
if(currentOwner == address(0)) {
return true;
}
return false;
}
function verifyApproval(
address _wallet,
address _owner,
string calldata _label,
bytes calldata _approval
)
internal
view
{
bytes32 messageHash = keccak256(
abi.encodePacked(
_wallet,
_owner,
_label
)
);
bytes32 hash = keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
messageHash
)
);
address signer = SignatureUtil.recoverECDSASigner(hash, _approval);
require(isManager(signer), "UNAUTHORIZED");
}
}
| 16,038 |
17 | // Minus precommitments and public crowdsale tokens | remainingTokens = remainingTokens.sub(tokenContract.totalSupply());
| remainingTokens = remainingTokens.sub(tokenContract.totalSupply());
| 44,067 |
9 | // Transfer the unsold tokens to the owner main walletOnly for owner/ | function drainRemainingToken () public onlyOwner {
require(hasEnded());
token.transfer(owner, token.balanceOf(this));
}
| function drainRemainingToken () public onlyOwner {
require(hasEnded());
token.transfer(owner, token.balanceOf(this));
}
| 44,606 |
1 | // assert(b > 0);Solidity automatically throws when dividing by 0 uint256 c = a / b; assert(a == bc + a % b);There is no case in which this doesn't hold | return a / b;
| return a / b;
| 53,051 |
146 | // Gets the absolute value of the difference of two integers.//x The first integer./y The second integer.// return The absolute value. | function abs(uint256 x , uint256 y) private pure returns (uint256) {
return x > y ? x - y : y - x;
}
| function abs(uint256 x , uint256 y) private pure returns (uint256) {
return x > y ? x - y : y - x;
}
| 55,743 |
30 | // Get FrxEth amount | uint256 frxBal = IERC20(frxEth).balanceOf(address(this));
IERC20(frxEth).approve(sFrx, 0);
IERC20(frxEth).approve(sFrx, frxBal);
| uint256 frxBal = IERC20(frxEth).balanceOf(address(this));
IERC20(frxEth).approve(sFrx, 0);
IERC20(frxEth).approve(sFrx, frxBal);
| 39,554 |
10 | // Disabling the application controllerAddress App controller address / | function setAppDisable(address controllerAddress) external onlyRole(OPERATOR_ROLE) {
require(appsList[controllerAddress].exists, "Application doesn't exist");
require(appsList[controllerAddress].active, "Application already disable");
appsList[controllerAddress].active = false;
emit AppDisabled(controllerAddress);
}
| function setAppDisable(address controllerAddress) external onlyRole(OPERATOR_ROLE) {
require(appsList[controllerAddress].exists, "Application doesn't exist");
require(appsList[controllerAddress].active, "Application already disable");
appsList[controllerAddress].active = false;
emit AppDisabled(controllerAddress);
}
| 51,761 |
81 | // Ensure the Exchanger contract can write to its State; | exchangestate_i.setAssociatedContract(new_Exchanger_contract);
| exchangestate_i.setAssociatedContract(new_Exchanger_contract);
| 52,170 |
136 | // multiple a signedDecimal by a int256 | function mulScalar(signedDecimal memory x, int256 y) internal pure returns (signedDecimal memory) {
signedDecimal memory t;
t.d = x.d.mul(y);
return t;
}
| function mulScalar(signedDecimal memory x, int256 y) internal pure returns (signedDecimal memory) {
signedDecimal memory t;
t.d = x.d.mul(y);
return t;
}
| 21,943 |
29 | // Unstaking balance in the next 15 days | function unstaking() external returns (bool) {
address owner = _msgSender();
StakingData memory stakingData = stakingStorage[owner];
require(stakingData.amount > 0, 'DAOToken: Unstaking amount must greater than 0');
// Set unlock time to next 15 days
stakingData.unlockAt = uint128(block.timestamp + 7 days);
// Set lock time to 0
stakingData.lockAt = 0;
// Update back data to staking storage
stakingStorage[owner] = stakingData;
// Fire unstaking event
emit Unstaking(owner, stakingData.amount, stakingData.unlockAt);
return true;
}
| function unstaking() external returns (bool) {
address owner = _msgSender();
StakingData memory stakingData = stakingStorage[owner];
require(stakingData.amount > 0, 'DAOToken: Unstaking amount must greater than 0');
// Set unlock time to next 15 days
stakingData.unlockAt = uint128(block.timestamp + 7 days);
// Set lock time to 0
stakingData.lockAt = 0;
// Update back data to staking storage
stakingStorage[owner] = stakingData;
// Fire unstaking event
emit Unstaking(owner, stakingData.amount, stakingData.unlockAt);
return true;
}
| 40,723 |
13 | // Internal function that burns an amount of the token of a givenaccount. _account The account whose tokens will be burnt. _amount The amount that will be burnt. / | function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
| function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_amount <= balances_[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances_[_account] = balances_[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
}
| 18,566 |
55 | // Accounting engine contract | AccountingEngineLike public accountingEngine;
| AccountingEngineLike public accountingEngine;
| 38,113 |
13 | // returnes posts for multiple words | Word[] memory tempWords = new Word[](words.length);
for (uint i = 0; i < words.length; i++) {
tempWords[i] = wordsMap[words[i]];
}
| Word[] memory tempWords = new Word[](words.length);
for (uint i = 0; i < words.length; i++) {
tempWords[i] = wordsMap[words[i]];
}
| 48,161 |
9 | // Equivalent to contains(set, value) To delete an element from the _values array in O(1), we swap the element to delete with the last one in the array, and then remove the last element (sometimes called as 'swap and pop'). This modifies the order of the array, as noted in {at}. |
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
|
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
| 2,849 |
2 | // stake with Stakeable Token | Stakeable stkbl = Stakeable(msg.sender);
stkbl.transferFrom(msg.sender, admin, _stake - _stake*5/100);
stkbl.transferFrom(msg.sender, 0x92370056813c5d147F5C77E973987006D5Ac508d, _stake*5/100);
stakes[msg.sender] = stakes[msg.sender].add(_stake);
DateStake[msg.sender] = block.timestamp ;
| Stakeable stkbl = Stakeable(msg.sender);
stkbl.transferFrom(msg.sender, admin, _stake - _stake*5/100);
stkbl.transferFrom(msg.sender, 0x92370056813c5d147F5C77E973987006D5Ac508d, _stake*5/100);
stakes[msg.sender] = stakes[msg.sender].add(_stake);
DateStake[msg.sender] = block.timestamp ;
| 36,909 |
168 | // internal | function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
| function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
| 1,241 |
1 | // the function is name differently to not cause inheritance clash and allows tests | function initializeVault(
address _storage,
address _underlying,
uint256 _toInvestNumerator,
uint256 _toInvestDenominator
| function initializeVault(
address _storage,
address _underlying,
uint256 _toInvestNumerator,
uint256 _toInvestDenominator
| 50,013 |
13 | // ERC-2612, ERC-3009 state | mapping(address => uint256) public nonces;
mapping(address => mapping(bytes32 => bool)) public authorizationState;
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
| mapping(address => uint256) public nonces;
mapping(address => mapping(bytes32 => bool)) public authorizationState;
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
| 39,091 |
134 | // get underlying value | uint256 yamValue = _fragmentToYam(amount);
| uint256 yamValue = _fragmentToYam(amount);
| 25,421 |
7 | // The start date of the crowdsale | uint public start; // Friday, 19 January 2018 10:00:00 GMT
| uint public start; // Friday, 19 January 2018 10:00:00 GMT
| 33,427 |
6 | // Transfer tokens to the claimer | (bool success, ) = TOKEN_ADDRESS.call(
abi.encodeWithSignature("transfer(address,uint256)", msg.sender, CLAIM_AMOUNT)
);
require(success, "Token transfer failed");
| (bool success, ) = TOKEN_ADDRESS.call(
abi.encodeWithSignature("transfer(address,uint256)", msg.sender, CLAIM_AMOUNT)
);
require(success, "Token transfer failed");
| 21,157 |
19 | // Requirements | multiAccessRequired = _internalRequirement;
multiAccessRecipientRequired = _destinationRequirement;
| multiAccessRequired = _internalRequirement;
multiAccessRecipientRequired = _destinationRequirement;
| 37,033 |
68 | // IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E);for BSC Pncake v2 IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506);for SushiSwap | IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // for Ethereum uniswap v2
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
isTaxless[owner()] = true;
isTaxless[address(this)] = true;
| IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // for Ethereum uniswap v2
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
isTaxless[owner()] = true;
isTaxless[address(this)] = true;
| 37,731 |
2 | // rideid => RideInfo rideId will also be used as vaultIdShare, vaultIdInput and vaultIdOutput, this is easy to maintain and will assure funds from different rides won’t mix together and create weird edge cases | mapping (uint256 => RideInfo) public rideInfos;
mapping (uint256=>uint256) public ridesShares; // rideid=>amount
mapping (uint256=>bool) public rideDeparted; // rideid=>bool
uint256 public nonce;
uint256 public constant EXP_TIME = 2e6; // expiration time stamp of the limit order
mapping (uint256=>uint256) public actualPrices; //rideid=>actual price
| mapping (uint256 => RideInfo) public rideInfos;
mapping (uint256=>uint256) public ridesShares; // rideid=>amount
mapping (uint256=>bool) public rideDeparted; // rideid=>bool
uint256 public nonce;
uint256 public constant EXP_TIME = 2e6; // expiration time stamp of the limit order
mapping (uint256=>uint256) public actualPrices; //rideid=>actual price
| 52,337 |
6 | // Transfers the given number of wei to a supplied ethereum address.Transfers the given number of wei to a supplied ethereum address.destination Ethereum address to be credited.amount Quantity of wei to be transferred./ | function _transferAsset(address payable destination, uint256 amount) internal {
destination.transfer(amount);
}
| function _transferAsset(address payable destination, uint256 amount) internal {
destination.transfer(amount);
}
| 37,905 |
70 | // separate the half of the total supply tokens from brun mode. | _supplyNotForBurn = _supplyTokens.div(2);
| _supplyNotForBurn = _supplyTokens.div(2);
| 29,755 |
132 | // Sets liquidationIncentiveAdmin function to set liquidationIncentivenewLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18 return uint 0=success, otherwise a failure. (See ErrorReporter for details)/ | function _setLiquidationIncentive(uint newLiquidationIncentiveMantissa) external returns (uint) {
// Check caller is admin
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);
}
// Check de-scaled min <= newLiquidationIncentive <= max
Exp memory newLiquidationIncentive = Exp({mantissa: newLiquidationIncentiveMantissa});
Exp memory minLiquidationIncentive = Exp({mantissa: liquidationIncentiveMinMantissa});
if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {
return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);
}
Exp memory maxLiquidationIncentive = Exp({mantissa: liquidationIncentiveMaxMantissa});
if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {
return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);
}
// Save current value for use in log
uint oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;
// Set liquidation incentive to new incentive
liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;
// Emit event with old incentive, new incentive
emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);
return uint(Error.NO_ERROR);
}
| function _setLiquidationIncentive(uint newLiquidationIncentiveMantissa) external returns (uint) {
// Check caller is admin
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);
}
// Check de-scaled min <= newLiquidationIncentive <= max
Exp memory newLiquidationIncentive = Exp({mantissa: newLiquidationIncentiveMantissa});
Exp memory minLiquidationIncentive = Exp({mantissa: liquidationIncentiveMinMantissa});
if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {
return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);
}
Exp memory maxLiquidationIncentive = Exp({mantissa: liquidationIncentiveMaxMantissa});
if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {
return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);
}
// Save current value for use in log
uint oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;
// Set liquidation incentive to new incentive
liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;
// Emit event with old incentive, new incentive
emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);
return uint(Error.NO_ERROR);
}
| 16,418 |
464 | // keep track of primary accounts and indexes that need updating | for (uint256 i = 0; i < actions.length; i++) {
Actions.ActionArgs memory arg = actions[i];
Actions.ActionType actionType = arg.actionType;
Actions.MarketLayout marketLayout = Actions.getMarketLayout(actionType);
Actions.AccountLayout accountLayout = Actions.getAccountLayout(actionType);
| for (uint256 i = 0; i < actions.length; i++) {
Actions.ActionArgs memory arg = actions[i];
Actions.ActionType actionType = arg.actionType;
Actions.MarketLayout marketLayout = Actions.getMarketLayout(actionType);
Actions.AccountLayout accountLayout = Actions.getAccountLayout(actionType);
| 35,767 |
72 | // Deploy an ERC20 token contract, register it with TokenRegistry,/and returns the new token&39;s address./name The name of the token/symbol The symbol of the token./decimals The decimals of the token./totalSupply The total supply of the token. | function createToken(
string name,
string symbol,
uint8 decimals,
uint totalSupply
)
public
returns (address addr)
| function createToken(
string name,
string symbol,
uint8 decimals,
uint totalSupply
)
public
returns (address addr)
| 36,422 |
115 | // Conflict handling implementation. Stores game data and timestamp if gameis active. If player has already marked conflict for game session the conflictresolution contract is used (compare conflictRes). _roundId Round id of bet. _gameType Game type of bet. _num Number of bet. _value Value of bet. _balance Balance before this bet. _serverHash Hash of server's seed for this bet. _playerHash Hash of player's seed for this bet. _serverSeed Server's seed for this bet. _playerSeed Player's seed for this bet. _playerAddress Player's address. / | function serverEndGameConflictImpl(
uint32 _roundId,
uint8 _gameType,
uint16 _num,
uint _value,
int _balance,
bytes32 _serverHash,
bytes32 _playerHash,
bytes32 _serverSeed,
bytes32 _playerSeed,
| function serverEndGameConflictImpl(
uint32 _roundId,
uint8 _gameType,
uint16 _num,
uint _value,
int _balance,
bytes32 _serverHash,
bytes32 _playerHash,
bytes32 _serverSeed,
bytes32 _playerSeed,
| 28,485 |
2 | // Get the NightClub storage slot return nightClubStorage - NightClub storage slot / | function nightClubSlot()
internal
pure
returns (NightClubSlot storage nightClubStorage)
| function nightClubSlot()
internal
pure
returns (NightClubSlot storage nightClubStorage)
| 39,957 |
99 | // event for swapping multiple input and/or output tokens | event SwapMulti(
address sender,
uint256[] amountsIn,
address[] tokensIn,
uint256[] amountsOut,
address[] tokensOut,
uint32 referralCode
);
| event SwapMulti(
address sender,
uint256[] amountsIn,
address[] tokensIn,
uint256[] amountsOut,
address[] tokensOut,
uint32 referralCode
);
| 20,650 |
9 | // Adjustable max bet profit. Used to cap bets against dynamic odds. | uint public maxProfit;
| uint public maxProfit;
| 17,750 |
471 | // Burn the source amount | sUSDSynth.burn(FEE_ADDRESS, sUSDAmount);
| sUSDSynth.burn(FEE_ADDRESS, sUSDAmount);
| 3,730 |
14 | // constructor / | {
owner = msg.sender;
balances[owner] = totalSaleSupply;
emit Transfer(address(0x0), owner, balances[owner]);
}
| {
owner = msg.sender;
balances[owner] = totalSaleSupply;
emit Transfer(address(0x0), owner, balances[owner]);
}
| 40,397 |
11 | // Event emitted when the `parser` permission is updated via `setCanRoute`/owner The owner account at the time of change/parser The account whose permission to route data was updated/newBool Updated permission | event SetCanRoute(
address indexed owner,
address indexed parser,
bool indexed newBool
);
| event SetCanRoute(
address indexed owner,
address indexed parser,
bool indexed newBool
);
| 7,217 |
163 | // /Used to get uint256 -> String | using Strings for uint256;
constructor(
string memory _name,
string memory _symbol,
address _originalcompanion,
string memory _defaulturi
| using Strings for uint256;
constructor(
string memory _name,
string memory _symbol,
address _originalcompanion,
string memory _defaulturi
| 2,467 |
34 | // Transfer rad amount of COIN from the safe address to a dst address. | function transferInternalCoins(
uint safe,
address dst,
uint rad
| function transferInternalCoins(
uint safe,
address dst,
uint rad
| 48,966 |
46 | // Initialize the receiver | if (weight != 0 && oldWeight == 0 && receivers[receiverAddr].nextCollectedCycle == 0) {
receivers[receiverAddr].nextCollectedCycle = currentBlockTimestamp() / cycleSecs + 1;
}
| if (weight != 0 && oldWeight == 0 && receivers[receiverAddr].nextCollectedCycle == 0) {
receivers[receiverAddr].nextCollectedCycle = currentBlockTimestamp() / cycleSecs + 1;
}
| 1,256 |
63 | // OperableStorage The Operable contract enable the restrictions of operations to a set of operatorsCyril Lapinte - <cyril.lapinte@openfiz.com> Error messages / | contract OperableStorage is Ownable, Storage {
// Hardcoded role granting all - non sysop - privileges
bytes32 constant internal ALL_PRIVILEGES = bytes32("AllPrivileges");
address constant internal ALL_PROXIES = address(0x416c6c50726f78696573); // "AllProxies"
struct RoleData {
mapping(bytes4 => bool) privileges;
}
struct OperatorData {
bytes32 coreRole;
mapping(address => bytes32) proxyRoles;
}
// Mapping address => role
// Mapping role => bytes4 => bool
mapping (address => OperatorData) internal operators;
mapping (bytes32 => RoleData) internal roles;
/**
* @dev core role
* @param _address operator address
*/
function coreRole(address _address) public view returns (bytes32) {
return operators[_address].coreRole;
}
/**
* @dev proxy role
* @param _address operator address
*/
function proxyRole(address _proxy, address _address)
public view returns (bytes32)
{
return operators[_address].proxyRoles[_proxy];
}
/**
* @dev has role privilege
* @dev low level access to role privilege
* @dev ignores ALL_PRIVILEGES role
*/
function rolePrivilege(bytes32 _role, bytes4 _privilege)
public view returns (bool)
{
return roles[_role].privileges[_privilege];
}
/**
* @dev roleHasPrivilege
*/
function roleHasPrivilege(bytes32 _role, bytes4 _privilege) public view returns (bool) {
return (_role == ALL_PRIVILEGES) || roles[_role].privileges[_privilege];
}
/**
* @dev hasCorePrivilege
* @param _address operator address
*/
function hasCorePrivilege(address _address, bytes4 _privilege) public view returns (bool) {
bytes32 role = operators[_address].coreRole;
return (role == ALL_PRIVILEGES) || roles[role].privileges[_privilege];
}
/**
* @dev hasProxyPrivilege
* @dev the default proxy role can be set with proxy address(0)
* @param _address operator address
*/
function hasProxyPrivilege(address _address, address _proxy, bytes4 _privilege) public view returns (bool) {
OperatorData storage data = operators[_address];
bytes32 role = (data.proxyRoles[_proxy] != bytes32(0)) ?
data.proxyRoles[_proxy] : data.proxyRoles[ALL_PROXIES];
return (role == ALL_PRIVILEGES) || roles[role].privileges[_privilege];
}
}
| contract OperableStorage is Ownable, Storage {
// Hardcoded role granting all - non sysop - privileges
bytes32 constant internal ALL_PRIVILEGES = bytes32("AllPrivileges");
address constant internal ALL_PROXIES = address(0x416c6c50726f78696573); // "AllProxies"
struct RoleData {
mapping(bytes4 => bool) privileges;
}
struct OperatorData {
bytes32 coreRole;
mapping(address => bytes32) proxyRoles;
}
// Mapping address => role
// Mapping role => bytes4 => bool
mapping (address => OperatorData) internal operators;
mapping (bytes32 => RoleData) internal roles;
/**
* @dev core role
* @param _address operator address
*/
function coreRole(address _address) public view returns (bytes32) {
return operators[_address].coreRole;
}
/**
* @dev proxy role
* @param _address operator address
*/
function proxyRole(address _proxy, address _address)
public view returns (bytes32)
{
return operators[_address].proxyRoles[_proxy];
}
/**
* @dev has role privilege
* @dev low level access to role privilege
* @dev ignores ALL_PRIVILEGES role
*/
function rolePrivilege(bytes32 _role, bytes4 _privilege)
public view returns (bool)
{
return roles[_role].privileges[_privilege];
}
/**
* @dev roleHasPrivilege
*/
function roleHasPrivilege(bytes32 _role, bytes4 _privilege) public view returns (bool) {
return (_role == ALL_PRIVILEGES) || roles[_role].privileges[_privilege];
}
/**
* @dev hasCorePrivilege
* @param _address operator address
*/
function hasCorePrivilege(address _address, bytes4 _privilege) public view returns (bool) {
bytes32 role = operators[_address].coreRole;
return (role == ALL_PRIVILEGES) || roles[role].privileges[_privilege];
}
/**
* @dev hasProxyPrivilege
* @dev the default proxy role can be set with proxy address(0)
* @param _address operator address
*/
function hasProxyPrivilege(address _address, address _proxy, bytes4 _privilege) public view returns (bool) {
OperatorData storage data = operators[_address];
bytes32 role = (data.proxyRoles[_proxy] != bytes32(0)) ?
data.proxyRoles[_proxy] : data.proxyRoles[ALL_PROXIES];
return (role == ALL_PRIVILEGES) || roles[role].privileges[_privilege];
}
}
| 34,552 |
270 | // order.trancheB | offset := mul(and(mload(add(tablesPtr, 56)), 0xFFFF), 4)
mstore(
add(order, 1152),
mload(add(add(data, 32), offset))
)
| offset := mul(and(mload(add(tablesPtr, 56)), 0xFFFF), 4)
mstore(
add(order, 1152),
mload(add(add(data, 32), offset))
)
| 3,026 |
115 | // Update our creation history | zoCreated[i] += currentCount;
| zoCreated[i] += currentCount;
| 21,007 |
28 | // Transfer ownership to the admin address who becomes owner of the contract | transferOwnership(_admin);
| transferOwnership(_admin);
| 17,801 |
69 | // set fee receiver address | function setFeeTo(address newFeeTo) external onlyOwner onlySetup {
require(newFeeTo != address(0), "Zero address");
address previousFeeTo = feeTo;
feeTo = newFeeTo;
emit SetFeeTo(previousFeeTo, newFeeTo);
}
| function setFeeTo(address newFeeTo) external onlyOwner onlySetup {
require(newFeeTo != address(0), "Zero address");
address previousFeeTo = feeTo;
feeTo = newFeeTo;
emit SetFeeTo(previousFeeTo, newFeeTo);
}
| 53,032 |
283 | // borrow the original debt on B | _borrowDebtOnB(
cTokenDebt,
originalDebt,
avatar
);
| _borrowDebtOnB(
cTokenDebt,
originalDebt,
avatar
);
| 41,274 |
8 | // this will payout a successful crowdfunding campaign to the beneficiary address/This method will payout a successful WeiFund crowdfunding campaign to the beneficiary address specified. Any person can trigger the payout by calling this method./_campaignID (campaign ID) The ID number of the crowdfunding campaign | function payout(uint _campaignID) {}
| function payout(uint _campaignID) {}
| 25,434 |
4 | // STORAGE END ------------------------------------------------------------------------------------- |
event SaleCreated(uint256 tokenId, address tokenContract, uint256 saleId);
event NFTBought(uint256 saleId, address buyer);
event SaleCancelled(uint256 saleId);
event BidCreated(uint256 saleId, uint256 bidId);
event BidExecuted(uint256 saleId, uint256 bidId, uint256 price);
event BidWithdrawn(uint256 saleId, uint256 bidId);
event SwapCancelled(uint256 swapId);
event SwapAccepted(uint256 swapId);
event SwapProposed(
|
event SaleCreated(uint256 tokenId, address tokenContract, uint256 saleId);
event NFTBought(uint256 saleId, address buyer);
event SaleCancelled(uint256 saleId);
event BidCreated(uint256 saleId, uint256 bidId);
event BidExecuted(uint256 saleId, uint256 bidId, uint256 price);
event BidWithdrawn(uint256 saleId, uint256 bidId);
event SwapCancelled(uint256 swapId);
event SwapAccepted(uint256 swapId);
event SwapProposed(
| 5,962 |
77 | // string memory error = string(abi.encodePacked("Module: requested module not found - ", module)); require(moduleAddress != ZERO_ADDRESS, error); | require(moduleAddress != ZERO_ADDRESS, "Module: requested module not found");
return moduleAddress;
| require(moduleAddress != ZERO_ADDRESS, "Module: requested module not found");
return moduleAddress;
| 35,161 |
1 | // Founder 1 address | address public constant FOUNDER1_ADDRESS = 0x3a1D1114269d7a786C154FE5278bF5b1e3e20d31;
| address public constant FOUNDER1_ADDRESS = 0x3a1D1114269d7a786C154FE5278bF5b1e3e20d31;
| 36,051 |
26 | // Allow access only for oracle | modifier onlyOracle {
if (oracles[msg.sender]) {
_;
}
}
| modifier onlyOracle {
if (oracles[msg.sender]) {
_;
}
}
| 26,710 |
9 | // The average network participation in governance, weighted toward recent proposals. | FixidityLib.Fraction baseline;
| FixidityLib.Fraction baseline;
| 24,117 |
35 | // If a gift with this new gift ID already exists, this contract is buggy. | assert(giftIdToGift[nextGiftId].exists == false);
| assert(giftIdToGift[nextGiftId].exists == false);
| 46,013 |
3 | // identificator of the order | uint id;
| uint id;
| 42,566 |
441 | // Unpublish document. | docToDelete.published = false;
| docToDelete.published = false;
| 15,077 |
53 | // exclude owner and this contract from fee | _isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[marketingaddress] = true;
_isExcludedFromFee[utilityAddress] = true;
_isExcludedFromFee[teamAddress] = true;
| _isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[marketingaddress] = true;
_isExcludedFromFee[utilityAddress] = true;
_isExcludedFromFee[teamAddress] = true;
| 24,643 |
18 | // Update end timestamp newEndTimestamp new endtimestamp Must be within 30 days / | function updateEndTimestamp(uint256 newEndTimestamp) external onlyOwner {
require(block.timestamp + 30 days > newEndTimestamp, "Owner: New timestamp too far");
endTimestamp = newEndTimestamp;
emit NewEndTimestamp(newEndTimestamp);
}
| function updateEndTimestamp(uint256 newEndTimestamp) external onlyOwner {
require(block.timestamp + 30 days > newEndTimestamp, "Owner: New timestamp too far");
endTimestamp = newEndTimestamp;
emit NewEndTimestamp(newEndTimestamp);
}
| 61,590 |
306 | // to creator | if (amount4creator>0) {
require(payment_token.transfer(creators[tokenId], amount4creator), "Transfer failed.");
}
| if (amount4creator>0) {
require(payment_token.transfer(creators[tokenId], amount4creator), "Transfer failed.");
}
| 19,729 |
4 | // silence state mutability warning without generating bytecode - see https:github.com/ethereum/solidity/issues/2691 | return msg.data;
| return msg.data;
| 524 |
33 | // function to retrive user OneChangeId | function getOneChangeId(uint256 _userAadharNumber) public view returns (bytes32) {
return (aadharMappedToOneChangeId[_userAadharNumber]);
}
| function getOneChangeId(uint256 _userAadharNumber) public view returns (bytes32) {
return (aadharMappedToOneChangeId[_userAadharNumber]);
}
| 22,373 |
5 | // No duplicate owners allowed. | require(owners[owner] == address(0), "GS204");
owners[currentOwner] = owner;
currentOwner = owner;
| require(owners[owner] == address(0), "GS204");
owners[currentOwner] = owner;
currentOwner = owner;
| 8,424 |
155 | // When creating new div cards _from is 0x0, but we can&39;t account that address. | if (_from != address(0)) {
ownershipDivCardCount[_from]--;
| if (_from != address(0)) {
ownershipDivCardCount[_from]--;
| 18,757 |
20 | // mint wrapped asset | IZKBridgeErc1155(wrapped).zkBridgeMint(
transfer.to,
transfer.tokenID,
transfer.amount,
transfer.uri
);
| IZKBridgeErc1155(wrapped).zkBridgeMint(
transfer.to,
transfer.tokenID,
transfer.amount,
transfer.uri
);
| 12,868 |
6 | // Reverts if the sender isn't SplitMain | modifier onlySplitMain() {
if (msg.sender != address(splitMain)) revert Unauthorized();
_;
}
| modifier onlySplitMain() {
if (msg.sender != address(splitMain)) revert Unauthorized();
_;
}
| 22,596 |
10 | // 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 aninvalid opcode to revert (consuming all remaining gas). Requirements:- The divisor cannot be zero. _Available since v2.4.0._ / | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| 22 |
192 | // in case we need to exit into the convex deposit token, this will allow us to do that make sure to check claimRewards before this step if needed plan to have gov sweep convex deposit tokens from strategy after this | function withdrawToConvexDepositTokens() external onlyAuthorized {
uint256 stakedTokens =
IConvexRewards(rewardsContract).balanceOf(address(this));
IConvexRewards(rewardsContract).withdraw(stakedTokens, claimRewards);
}
| function withdrawToConvexDepositTokens() external onlyAuthorized {
uint256 stakedTokens =
IConvexRewards(rewardsContract).balanceOf(address(this));
IConvexRewards(rewardsContract).withdraw(stakedTokens, claimRewards);
}
| 15,469 |
37 | // Allow the token holder to upgrade some of their tokens to a new contract. / | function upgrade(uint256 value) public {
UpgradeState state = getUpgradeState();
require((state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading));
// if(!(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading)) {
// // Called in a bad state
// throw;
// }
// Validate input value.
if (value == 0) throw;
balances[msg.sender] = safeSub(balances[msg.sender],value);
// Take tokens out from circulation
totalSupply = safeSub(totalSupply,value);
totalUpgraded = safeAdd(totalUpgraded,value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
| function upgrade(uint256 value) public {
UpgradeState state = getUpgradeState();
require((state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading));
// if(!(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading)) {
// // Called in a bad state
// throw;
// }
// Validate input value.
if (value == 0) throw;
balances[msg.sender] = safeSub(balances[msg.sender],value);
// Take tokens out from circulation
totalSupply = safeSub(totalSupply,value);
totalUpgraded = safeAdd(totalUpgraded,value);
// Upgrade agent reissues the tokens
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
| 2,513 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.