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 |
|---|---|---|---|---|
57 | // attempt to add borrower to the market | Error err = addToMarketInternal(CToken(msg.sender), borrower);
if (err != Error.NO_ERROR) {
return uint(err);
}
| Error err = addToMarketInternal(CToken(msg.sender), borrower);
if (err != Error.NO_ERROR) {
return uint(err);
}
| 3,912 |
37 | // Makes a swap request. contractAddress1 The contract address of the first token. contractAddress2 The contract address of the second token. token1 The token Id of the token whose owner is making the request. token2 The token Id of the token being requested for the swap. / | function makeSwapRequest(
address contractAddress1,
address contractAddress2,
uint256 token1,
uint256 token2
)
public
onlyOwnerOfToken(contractAddress1, token1)
nonReentrant
whenNotPaused
| function makeSwapRequest(
address contractAddress1,
address contractAddress2,
uint256 token1,
uint256 token2
)
public
onlyOwnerOfToken(contractAddress1, token1)
nonReentrant
whenNotPaused
| 23,776 |
3 | // be specified by overriding the virtual {_implementation} function.Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to adifferent contract through the {_delegate} function./ Delegates the current call to `implementation`. This function does not return to its internall call site, it will return directly to the external caller. / | function _delegate(address implementation) internal virtual {
| function _delegate(address implementation) internal virtual {
| 16,608 |
2 | // get user's vote power staking balance at given blockNumber user The address of specific user blockNumber The blockNumber as index. / ------------------------------------------------------------------------ Note: if the blockNumber is less than the current block number, function will return current vote power. ------------------------------------------------------------------------ | function getVotePower(address user, uint blockNumber) public view returns (uint) {}
| function getVotePower(address user, uint blockNumber) public view returns (uint) {}
| 51,628 |
269 | // Monday, December 20, 2021 12:00:00 AM, 1639958400 | uint256 public SALE_START;
uint256 public PRESALE;
| uint256 public SALE_START;
uint256 public PRESALE;
| 43,506 |
167 | // ZEUSToken with Governance. | contract ZEUSToken is ERC20("ZEUSToken", "ZEUS"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "ZEUS::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "ZEUS::delegateBySig: invalid nonce");
require(now <= expiry, "ZEUS::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, "ZEUS::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 ZEUSs (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, "ZEUS::_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 ZEUSToken is ERC20("ZEUSToken", "ZEUS"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "ZEUS::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "ZEUS::delegateBySig: invalid nonce");
require(now <= expiry, "ZEUS::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, "ZEUS::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 ZEUSs (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, "ZEUS::_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;
}
}
| 30,053 |
23 | // dataset | if (ids.hasDataset) // only check if dataset is enabled
{
ids.datasetHash = _datasetorder.hash();
ids.datasetOwner = Dataset(_datasetorder.dataset).m_owner();
require(m_presigned[ids.datasetHash] || verifySignature(ids.datasetOwner, ids.datasetHash, _datasetorder.sign));
}
| if (ids.hasDataset) // only check if dataset is enabled
{
ids.datasetHash = _datasetorder.hash();
ids.datasetOwner = Dataset(_datasetorder.dataset).m_owner();
require(m_presigned[ids.datasetHash] || verifySignature(ids.datasetOwner, ids.datasetHash, _datasetorder.sign));
}
| 32,542 |
1 | // How much WETH tokens to keep? | uint256 public keepWETH = 2000;
uint256 public constant keepWETHMax = 10000;
constructor(
address _governance,
address _strategist,
address _controller,
address _timelock
)
public
| uint256 public keepWETH = 2000;
uint256 public constant keepWETHMax = 10000;
constructor(
address _governance,
address _strategist,
address _controller,
address _timelock
)
public
| 42,378 |
47 | // Mapping from token ID to index of the owner tokens list | mapping(uint256 => uint256) private _ownedTokensIndex;
| mapping(uint256 => uint256) private _ownedTokensIndex;
| 8,019 |
2 | // Sets the config / | function setConfig(bytes32 poolId, bytes calldata config) external;
| function setConfig(bytes32 poolId, bytes calldata config) external;
| 29,164 |
30 | // Returns the backing amount history of a user/ | // function getAmount() public constant returns (uint[]) {
// return votes[msg.sender].amount;
// }
| // function getAmount() public constant returns (uint[]) {
// return votes[msg.sender].amount;
// }
| 18,506 |
26 | // Allow fund transfers to DAO contract. | receive() external payable {
// do nothing
}
| receive() external payable {
// do nothing
}
| 13,208 |
44 | // get affiliate ID from aff Code | _affID = pIDxAddr_[_affCode];
| _affID = pIDxAddr_[_affCode];
| 44,816 |
15 | // Ensure that only the creator can call this function | require(msg.sender == creator, "Only the creator can retrieve assets");
IERC20 asset = IERC20(assetAddress);
uint256 balance = asset.balanceOf(address(this));
| require(msg.sender == creator, "Only the creator can retrieve assets");
IERC20 asset = IERC20(assetAddress);
uint256 balance = asset.balanceOf(address(this));
| 5,014 |
396 | // 9 total active currencies possible (2 bytes each) | bytes18 activeCurrencies;
| bytes18 activeCurrencies;
| 10,908 |
1 | // Returns amount of CELO that can be claimed for savingsAmount SavingsCELO tokens./savingsAmount amount of sCELO tokens./ return amount of CELO tokens. | function savingsToCELO(uint256 savingsAmount) external view returns (uint256);
| function savingsToCELO(uint256 savingsAmount) external view returns (uint256);
| 27,475 |
246 | // This invariant is used only to compute the final balance when calculating the protocol fees. These are rounded down, so we round the invariant up. | _updateLastInvariant(StableMath._calculateInvariant(currentAmp, balances, true), currentAmp);
| _updateLastInvariant(StableMath._calculateInvariant(currentAmp, balances, true), currentAmp);
| 44,451 |
203 | // Listing must be in apply stage or already on the whitelist | require(appWasMade(_listingHash) || listing.whitelisted);
| require(appWasMade(_listingHash) || listing.whitelisted);
| 5,318 |
119 | // View function to see pending ERC20s for a user. | function pending(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accERC20PerShare = pool.accERC20PerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 lastBlock = block.number;
uint256 nrOfBlocks = lastBlock.sub(pool.lastRewardBlock);
uint256 erc20Reward = rewardsToDistribute.mul(pool.allocPoint).div(totalAllocPoint);
accERC20PerShare = accERC20PerShare.add(erc20Reward.mul(1e36).div(lpSupply));
}
return user.amount.mul(accERC20PerShare).div(1e36).sub(user.rewardDebt);
}
| function pending(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accERC20PerShare = pool.accERC20PerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 lastBlock = block.number;
uint256 nrOfBlocks = lastBlock.sub(pool.lastRewardBlock);
uint256 erc20Reward = rewardsToDistribute.mul(pool.allocPoint).div(totalAllocPoint);
accERC20PerShare = accERC20PerShare.add(erc20Reward.mul(1e36).div(lpSupply));
}
return user.amount.mul(accERC20PerShare).div(1e36).sub(user.rewardDebt);
}
| 7,687 |
68 | // update the total quantity of tickets that have been entered for this raffle item | raffleItem.totalEntered = totalEntered + ticketItem.ticketQuantity;
| raffleItem.totalEntered = totalEntered + ticketItem.ticketQuantity;
| 13,422 |
101 | // Constructor. beneficiary The beneficiary of the deposits. / | constructor (address payable beneficiary) public {
require(beneficiary != address(0));
_beneficiary = beneficiary;
_state = State.Active;
}
| constructor (address payable beneficiary) public {
require(beneficiary != address(0));
_beneficiary = beneficiary;
_state = State.Active;
}
| 33,401 |
6 | // Background N°7 => Artistic | function item_7() public pure returns (string memory) {
return
base(
string(
abi.encodePacked(
'<g id="Artistic"><radialGradient id="radial-gradient" cx="210" cy="-1171.6" r="210" gradientTransform="matrix(1, 0, 0, -1, 0, -961.6)" gradientUnits="userSpaceOnUse"> <stop offset="0.5" stop-color="#fff9ab"/> <stop offset="1" stop-color="#16c7b5"/> </radialGradient>',
background("ff9fd7"),
"</g>"
)
)
);
}
| function item_7() public pure returns (string memory) {
return
base(
string(
abi.encodePacked(
'<g id="Artistic"><radialGradient id="radial-gradient" cx="210" cy="-1171.6" r="210" gradientTransform="matrix(1, 0, 0, -1, 0, -961.6)" gradientUnits="userSpaceOnUse"> <stop offset="0.5" stop-color="#fff9ab"/> <stop offset="1" stop-color="#16c7b5"/> </radialGradient>',
background("ff9fd7"),
"</g>"
)
)
);
}
| 13,431 |
13 | // Removes a verified recipient./Can only be called by contract owner./_address The address of the verified recipient that is to be removed. | function removeVerifiedRecipient(address _address)
public
onlyOwner
| function removeVerifiedRecipient(address _address)
public
onlyOwner
| 50,269 |
67 | // nix/store/jhkj8my1hkpiklhhkl8xyzpxwpzix5fj-geb-uniswap-median/dapp/geb-uniswap-median/src/univ3/libraries/FullMath.sol SPDX-License-Identifier: MIT/ pragma solidity >=0.4.0; //Contains 512-bit math functions/Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision/Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits | library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = -denominator & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < (0 - uint256(1)));
result++;
}
}
}
| library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = -denominator & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < (0 - uint256(1)));
result++;
}
}
}
| 72,874 |
231 | // if we don't set reserve here withdrawer will be sent our full balance | return (_amountNeeded,0);
| return (_amountNeeded,0);
| 61,491 |
6 | // Send buyer newly minted tokens | token.mint(msg.sender, _amount);
| token.mint(msg.sender, _amount);
| 27,291 |
49 | // Check if the guard value has its original value | require(_guardValue == 0, "REENTRANCY");
| require(_guardValue == 0, "REENTRANCY");
| 32,080 |
3 | // read function to see the list of candidates | function getCandidates() external view returns(candidateDetails[] memory) {
return candidates;
}
| function getCandidates() external view returns(candidateDetails[] memory) {
return candidates;
}
| 24,797 |
25 | // Refunds the creation of the wallet when provided with a valid signature from the wallet owner. _wallet The wallet created _owner The owner address _refundAmount The amount to refund _refundToken The token to use for the refund _ownerSignature A signature from the wallet owner approving the refund amount and token./ | function validateAndRefund(
address _wallet,
address _owner,
uint256 _refundAmount,
address _refundToken,
bytes memory _ownerSignature
)
internal
| function validateAndRefund(
address _wallet,
address _owner,
uint256 _refundAmount,
address _refundToken,
bytes memory _ownerSignature
)
internal
| 21,279 |
25 | // The percentage fee charged for operations. | uint256 public operationFee = 2;
uint256 private _previousOperationFee = operationFee;
| uint256 public operationFee = 2;
uint256 private _previousOperationFee = operationFee;
| 31,482 |
20 | // Constructor _guardian The guardian address / | constructor(address _guardian) {
require(
_guardian != address(0),
| constructor(address _guardian) {
require(
_guardian != address(0),
| 5,114 |
153 | // Check after the hook | require(_amount > 0 && _amount <= balances[msg.sender] && originalAmount <= balances[msg.sender], "E3");
totalSupply -= originalAmount * supplyScalingFactor;
balances[msg.sender] -= originalAmount;
stakingToken.safeTransfer(msg.sender, _amount);
emit Withdrawn(msg.sender, _amount);
| require(_amount > 0 && _amount <= balances[msg.sender] && originalAmount <= balances[msg.sender], "E3");
totalSupply -= originalAmount * supplyScalingFactor;
balances[msg.sender] -= originalAmount;
stakingToken.safeTransfer(msg.sender, _amount);
emit Withdrawn(msg.sender, _amount);
| 24,733 |
38 | // Handle dapp relations for the bridges | function setDappRelation(address _dapp, address _customInterface) public onlyOwner {
dappRelations[_dapp] = _customInterface;
}
| function setDappRelation(address _dapp, address _customInterface) public onlyOwner {
dappRelations[_dapp] = _customInterface;
}
| 51,659 |
20 | // Token MetadatatokenURIs[tokenId] = Strings.strConcat(baseTokenURI(), "QmdDW36bvr2W6ua4FxnT8bKysXhYEUo7QbLTbkGW4Foxr8"); | tokenURIs[tokenId] = Strings.strConcat(baseTokenURI(), ipfsHash);
emit Transfer(address(0), msg.sender, tokenId);
| tokenURIs[tokenId] = Strings.strConcat(baseTokenURI(), ipfsHash);
emit Transfer(address(0), msg.sender, tokenId);
| 17,648 |
28 | // ICAP registry contract. | RegistryICAPInterface public registryICAP;
| RegistryICAPInterface public registryICAP;
| 28,999 |
6 | // Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.- E.g. User deposits 100 USDC and gets in return 100 aUSDC asset The address of the underlying asset to deposit amount The amount to be deposited onBehalfOf The address that will receive the aTokens, same as msg.sender if the userwants to receive them on his own wallet, or a different address if the beneficiary of aTokensis a different wallet referralCode Code used to register the integrator originating the operation, for potential rewards.0 if the action is executed directly by the user, without any middle-man / | ) external override whenNotPaused {
DataTypes.ReserveData storage reserve = _reserves[asset];
ValidationLogic.validateDeposit(reserve, amount);
address aToken = reserve.aTokenAddress;
reserve.updateState();
reserve.updateInterestRates(asset, aToken, amount, 0);
IERC20(asset).safeTransferFrom(msg.sender, aToken, amount);
bool isFirstDeposit = IAToken(aToken).mint(onBehalfOf, amount, reserve.liquidityIndex);
if (isFirstDeposit) {
_usersConfig[onBehalfOf].setUsingAsCollateral(reserve.id, true);
emit ReserveUsedAsCollateralEnabled(asset, onBehalfOf);
}
emit Deposit(asset, msg.sender, onBehalfOf, amount, referralCode);
}
| ) external override whenNotPaused {
DataTypes.ReserveData storage reserve = _reserves[asset];
ValidationLogic.validateDeposit(reserve, amount);
address aToken = reserve.aTokenAddress;
reserve.updateState();
reserve.updateInterestRates(asset, aToken, amount, 0);
IERC20(asset).safeTransferFrom(msg.sender, aToken, amount);
bool isFirstDeposit = IAToken(aToken).mint(onBehalfOf, amount, reserve.liquidityIndex);
if (isFirstDeposit) {
_usersConfig[onBehalfOf].setUsingAsCollateral(reserve.id, true);
emit ReserveUsedAsCollateralEnabled(asset, onBehalfOf);
}
emit Deposit(asset, msg.sender, onBehalfOf, amount, referralCode);
}
| 21,085 |
38 | // Liquidity mining participants or Stater NFT holders will be able to get some discount requester The address of the requester / | function calculateDiscount(address requester) public view returns(uint256){
for (uint i = 0; i < staterNftTokenIdArray.length; ++i)
if ( IERC1155(nftAddress).balanceOf(requester,staterNftTokenIdArray[i]) > 0 )
return uint256(100).div(discountNft);
for (uint256 i = 0; i < geyserAddressArray.length; ++i)
if ( Geyser(geyserAddressArray[i]).totalStakedFor(requester) > 0 )
return uint256(100).div(discountGeyser);
return 1;
}
| function calculateDiscount(address requester) public view returns(uint256){
for (uint i = 0; i < staterNftTokenIdArray.length; ++i)
if ( IERC1155(nftAddress).balanceOf(requester,staterNftTokenIdArray[i]) > 0 )
return uint256(100).div(discountNft);
for (uint256 i = 0; i < geyserAddressArray.length; ++i)
if ( Geyser(geyserAddressArray[i]).totalStakedFor(requester) > 0 )
return uint256(100).div(discountGeyser);
return 1;
}
| 60,870 |
13 | // Only the administrator (OpenSea) can set feeBps. | if (msg.sender != administrator) {
| if (msg.sender != administrator) {
| 11,857 |
284 | // No need to verify amount > 0, a deposit with amount = 0 can be used to undo cancellation. |
require(vaultId <= MAX_VAULT_ID, "OUT_OF_RANGE_VAULT_ID");
|
require(vaultId <= MAX_VAULT_ID, "OUT_OF_RANGE_VAULT_ID");
| 2,390 |
144 | // get current chainid | function getChainID() internal view returns (uint256) {
uint256 id;
assembly {
id := chainid()
}
return id;
}
| function getChainID() internal view returns (uint256) {
uint256 id;
assembly {
id := chainid()
}
return id;
}
| 32,527 |
24 | // Reserve a room if available. Fail if the given day to book is "maxDays"after the current day._roomId Room ID _slotIdxSlot _time Day to reserve in unix epoch format. Can be any second of the day. / | function reserve(uint64 _roomId, uint64 _slotIdx, uint64 _time) public noEmptyRoom(_roomId) {
uint64 reservationDay = getDay(_time);
reserveInternal(_roomId, _slotIdx, reservationDay);
mintGasToken(reservationDay, _slotIdx, _roomId);
}
| function reserve(uint64 _roomId, uint64 _slotIdx, uint64 _time) public noEmptyRoom(_roomId) {
uint64 reservationDay = getDay(_time);
reserveInternal(_roomId, _slotIdx, reservationDay);
mintGasToken(reservationDay, _slotIdx, _roomId);
}
| 35,513 |
124 | // Gets hash of an order for `eth_sign` | function hashOrder(
uint8 _order, address _token, uint _nonce, uint _price, uint _amount,
uint _expire
| function hashOrder(
uint8 _order, address _token, uint _nonce, uint _price, uint _amount,
uint _expire
| 41,749 |
495 | // Minimal allowed Hf after increasing borrow amount | uint256 public override minHealthFactor;
| uint256 public override minHealthFactor;
| 28,813 |
8 | // The address that receives all primary sales value. | address primarySaleRecipient;
| address primarySaleRecipient;
| 14,337 |
181 | // The block number when AKITA mining starts. | uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
AkitaToken _akita,
address _devaddr,
address _opFundAddr,
| uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
AkitaToken _akita,
address _devaddr,
address _opFundAddr,
| 18,282 |
77 | // adds a list of beneficiaries | function addBeneficiaries(address[] memory _beneficiaries, VestingPeriod[] memory _vestingPeriods)
external
onlyAdmin
setupOnly
| function addBeneficiaries(address[] memory _beneficiaries, VestingPeriod[] memory _vestingPeriods)
external
onlyAdmin
setupOnly
| 34,315 |
21 | // Block Limit Passed : block.number >= AnswerBlockNumber + BLOCK_LIMIT 3 | if (currBlockStatus == BlockStatus.BlockLimitPassed) {
| if (currBlockStatus == BlockStatus.BlockLimitPassed) {
| 11,253 |
62 | // Since the proof has already verified, that both blocks have been issued by the same validator, it doesn't matter which one is used here to recover the address. | address validator =
EquivocationInspector.getSignerAddress(
_rlpUnsignedHeaderOne,
_signatureOne
);
depositContract.slash(validator);
| address validator =
EquivocationInspector.getSignerAddress(
_rlpUnsignedHeaderOne,
_signatureOne
);
depositContract.slash(validator);
| 30,927 |
43 | // Is a given id retired? / | function retired(uint256 id) public view virtual returns (bool) {
return _supplyInfo[id].retired;
}
| function retired(uint256 id) public view virtual returns (bool) {
return _supplyInfo[id].retired;
}
| 83,187 |
31 | // constructor / | constructor(address addressDev, address addressAd) {
require(addressDev != address(0), "constructor: dev address error");
require(addressAd != address(0), "constructor: airdrop address error");
require(
addressDev != addressAd,
"constructor: dev and airdrop not same"
);
_totalSupply = 100_000_000 * 10**decimals();
_totalBurn = 0;
_burnStop = 2_100_000 * 10**decimals();
// owner
_addressExists[_msgSender()] = true;
_addresses[_addressCount++] = _msgSender();
// dev
if (!_addressExists[addressDev]) {
_addressExists[addressDev] = true;
_addresses[_addressCount++] = addressDev;
}
_addressDev = addressDev;
// airdrop
if (!_addressExists[addressAd]) {
_addressExists[addressAd] = true;
_addresses[_addressCount++] = addressAd;
}
_addressAd = addressAd;
_admins[_msgSender()] = true;
}
| constructor(address addressDev, address addressAd) {
require(addressDev != address(0), "constructor: dev address error");
require(addressAd != address(0), "constructor: airdrop address error");
require(
addressDev != addressAd,
"constructor: dev and airdrop not same"
);
_totalSupply = 100_000_000 * 10**decimals();
_totalBurn = 0;
_burnStop = 2_100_000 * 10**decimals();
// owner
_addressExists[_msgSender()] = true;
_addresses[_addressCount++] = _msgSender();
// dev
if (!_addressExists[addressDev]) {
_addressExists[addressDev] = true;
_addresses[_addressCount++] = addressDev;
}
_addressDev = addressDev;
// airdrop
if (!_addressExists[addressAd]) {
_addressExists[addressAd] = true;
_addresses[_addressCount++] = addressAd;
}
_addressAd = addressAd;
_admins[_msgSender()] = true;
}
| 67,082 |
217 | // return Returns index and isIn for the first occurrence starting from/ end | function indexOfFromEnd(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = length; i > 0; i--) {
if (A[i - 1] == a) {
return (i, true);
}
}
return (0, false);
}
| function indexOfFromEnd(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = length; i > 0; i--) {
if (A[i - 1] == a) {
return (i, true);
}
}
return (0, false);
}
| 7,121 |
6 | // Returns bank node lending pool token upBeacon contract/ return upBeaconBankNodeLendingPoolToken bank node lending pool token upBeacon contract | function upBeaconBankNodeLendingPoolToken() external view returns (UpgradeableBeacon);
| function upBeaconBankNodeLendingPoolToken() external view returns (UpgradeableBeacon);
| 9,236 |
0 | // Whitelist for presale changes. | function addToWhitelist(address[] calldata entries) external onlyOwner {
for(uint256 i = 0; i < entries.length; i++) {
address entry = entries[i];
require(entry != address(0), "NULL_ADDRESS");
require(!_whitelist[entry], "DUPLICATE_ENTRY");
_whitelist[entry] = true;
}
| function addToWhitelist(address[] calldata entries) external onlyOwner {
for(uint256 i = 0; i < entries.length; i++) {
address entry = entries[i];
require(entry != address(0), "NULL_ADDRESS");
require(!_whitelist[entry], "DUPLICATE_ENTRY");
_whitelist[entry] = true;
}
| 20,449 |
1 | // Constants / | uint public constant MONTH = 30 * 1 days;
| uint public constant MONTH = 30 * 1 days;
| 3,403 |
139 | // RunnerToken with Governance. | contract RunnerToken is BEP20('Runner Token', 'Runner') {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @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)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "Runner::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "Runner::delegateBySig: invalid nonce");
require(now <= expiry, "Runner::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, "Runner::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 Runners (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, "Runner::_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 RunnerToken is BEP20('Runner Token', 'Runner') {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @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)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "Runner::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "Runner::delegateBySig: invalid nonce");
require(now <= expiry, "Runner::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, "Runner::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 Runners (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, "Runner::_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;
}
}
| 21,656 |
16 | // MARK: ERC721 Enumerable | function totalSupply() public view returns (uint256) {
uint256 _total = 0;
for (uint256 i = 0; i < _tokenId; i++) {
if (_owners[i] != address(0)) {
_total++;
}
}
return _total;
}
| function totalSupply() public view returns (uint256) {
uint256 _total = 0;
for (uint256 i = 0; i < _tokenId; i++) {
if (_owners[i] != address(0)) {
_total++;
}
}
return _total;
}
| 48,194 |
97 | // unpack the packed bet to get to know its amount, options chosen and whether it should play for Jackpot | (GameOption gameOptions, uint amount, bool isJackpot) = packedBet.unpack();
| (GameOption gameOptions, uint amount, bool isJackpot) = packedBet.unpack();
| 37,531 |
14 | // https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.mddecimals function decimals() constant returns (uint8 decimals) | uint8 public decimals = 0;
| uint8 public decimals = 0;
| 49,007 |
18 | // Events // Initial / | uint _estimatesActualBefore) ROSBridge(msg.sender) {
homebaseLatitude = _homebaseLatitude;
homebaseLongitude = _homebaseLongitude;
estimatesActualBefore = _estimatesActualBefore * 1 minutes;
}
| uint _estimatesActualBefore) ROSBridge(msg.sender) {
homebaseLatitude = _homebaseLatitude;
homebaseLongitude = _homebaseLongitude;
estimatesActualBefore = _estimatesActualBefore * 1 minutes;
}
| 21,742 |
260 | // Number of nTokens held by the account | uint80 nTokenBalance;
| uint80 nTokenBalance;
| 15,897 |
91 | // By this mechanism, any occurrence of the `\{id\}` substring in either theURI or any of the amounts in the JSON file at said URI will be replaced byclients with the token type ID. interpreted by clients asfor token type ID 0x4cce0. See {uri}. Because these URIs cannot be meaningfully represented by the {URI} event,this function emits no events. / | function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
| function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
| 8,315 |
11 | // Returns the stake that a user has. | function stakes(address user) external returns (uint128, uint64);
| function stakes(address user) external returns (uint128, uint64);
| 38,586 |
4 | // Useful enum, for initial field filling. / | enum Direction {// x, y
UP, // [ 0, 1 ]
RIGHT, // [ 1, 0 ]
DOWN, // [ 0, -1 ]
LEFT // [-1, 0 ]
}
| enum Direction {// x, y
UP, // [ 0, 1 ]
RIGHT, // [ 1, 0 ]
DOWN, // [ 0, -1 ]
LEFT // [-1, 0 ]
}
| 25,439 |
32 | // solium-disable-next-line security/no-block-members | block.timestamp < crowdsales[_token].closingTime,
"Failed to buy token due to crowdsale is closed."
);
deposits[msg.sender][_token] = (
deposits[msg.sender][_token].add(msg.value)
);
crowdsales[_token].raised = crowdsales[_token].raised.add(msg.value);
emit TokenBought(msg.sender, _token, msg.value);
| block.timestamp < crowdsales[_token].closingTime,
"Failed to buy token due to crowdsale is closed."
);
deposits[msg.sender][_token] = (
deposits[msg.sender][_token].add(msg.value)
);
crowdsales[_token].raised = crowdsales[_token].raised.add(msg.value);
emit TokenBought(msg.sender, _token, msg.value);
| 31,467 |
24 | // Gets the number of emergency pause has been toggled. | function getEmergencyPausedLength() public view returns(uint len) {
len = emergencyPaused.length;
}
| function getEmergencyPausedLength() public view returns(uint len) {
len = emergencyPaused.length;
}
| 36,604 |
77 | // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. | if (transferDelayEnabled) {
if (
to != owner() &&
to != address(uniswapV2Router) &&
to != address(uniswapV2Pair)
) {
require(
_holderLastTransferTimestamp[tx.origin] <
block.number,
"_transfer:: Transfer Delay enabled. Only one purchase per block allowed."
| if (transferDelayEnabled) {
if (
to != owner() &&
to != address(uniswapV2Router) &&
to != address(uniswapV2Pair)
) {
require(
_holderLastTransferTimestamp[tx.origin] <
block.number,
"_transfer:: Transfer Delay enabled. Only one purchase per block allowed."
| 25,782 |
57 | // manually set rates for each pool / | function setRates(
uint256 _enclaveRate,
uint256 _summitRate,
uint256 _anoRate
) external onlyOwner {
_poolConfig[0].rate = _enclaveRate;
_poolConfig[1].rate = _summitRate;
_poolConfig[2].rate = _anoRate;
}
| function setRates(
uint256 _enclaveRate,
uint256 _summitRate,
uint256 _anoRate
) external onlyOwner {
_poolConfig[0].rate = _enclaveRate;
_poolConfig[1].rate = _summitRate;
_poolConfig[2].rate = _anoRate;
}
| 33,776 |
37 | // Transfer tokens to the DAO | lockTokens(msg.sender, votes);
uint256 votesAccepted;
if (!votings[proposalId].voted[msg.sender]) {
| lockTokens(msg.sender, votes);
uint256 votesAccepted;
if (!votings[proposalId].voted[msg.sender]) {
| 4,184 |
21 | // The start collateral ratio to enter recap mode, multiplied by 1e18. | uint64 recapRatio;
| uint64 recapRatio;
| 28,338 |
15 | // building the jackpot (they will increase the value for the person seeing the crash coming) | if (profitFromCrash < 1000 * 10**18) {
profitFromCrash += amount * 5/100;
}
| if (profitFromCrash < 1000 * 10**18) {
profitFromCrash += amount * 5/100;
}
| 9,926 |
59 | // Remove his state to empty member | address2Member[targetMember] = Member(
{
memberAddress: address(0),
memberSince: block.timestamp,
votingPower: 0,
name: "0x0"
}
| address2Member[targetMember] = Member(
{
memberAddress: address(0),
memberSince: block.timestamp,
votingPower: 0,
name: "0x0"
}
| 15,389 |
221 | // NFT Info | string public baseURI;
uint256 public mintPrice = 79000000000000000;
uint256 public maxSupply;
uint256 public whitelistMintLimit;
uint256 public totalMinted;
| string public baseURI;
uint256 public mintPrice = 79000000000000000;
uint256 public maxSupply;
uint256 public whitelistMintLimit;
uint256 public totalMinted;
| 50,184 |
259 | // internal helper to execute a single transaction of a proposal/special execution is done if target is a method in the DAO controller | function _executeTransaction(
address target,
uint256 value,
string memory signature,
bytes memory data
| function _executeTransaction(
address target,
uint256 value,
string memory signature,
bytes memory data
| 65,504 |
21 | // Get Uint value from InstaMemory Contract./ | function getUint(uint getId, uint val) internal returns (uint returnVal) {
returnVal = getId == 0 ? val : MemoryInterface(getMemoryAddr()).getUint(getId);
}
| function getUint(uint getId, uint val) internal returns (uint returnVal) {
returnVal = getId == 0 ? val : MemoryInterface(getMemoryAddr()).getUint(getId);
}
| 28,918 |
46 | // event for token purchase logging purchaser who paid for the tokens beneficiary who got the tokens value weis paid for purchase bonusPercent free tokens percantage for the phase amount amount of tokens purchased / | event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 bonusPercent, uint256 amount);
| event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 bonusPercent, uint256 amount);
| 36,228 |
328 | // We solve the 0^0 indetermination by making it equal one. | return uint256(ONE_18);
| return uint256(ONE_18);
| 1,680 |
1 | // To be raised when a ruling is given. _arbitrator The arbitrator giving the ruling. _disputeID ID of the dispute in the Arbitrator contract. _ruling The ruling which was given. / |
event Ruling(IArbitrator indexed _arbitrator, uint256 indexed _disputeID, uint256 _ruling);
|
event Ruling(IArbitrator indexed _arbitrator, uint256 indexed _disputeID, uint256 _ruling);
| 1,670 |
104 | // IERC1363Receiver Interface Interface for any contract that wants to support transferAndCall or transferFromAndCall from ERC1363 token contracts as defined in / | interface IERC1363Receiver {
/**
* @notice Handle the receipt of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the
* transfer. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param operator address The address which called `transferAndCall` or `transferFromAndCall` function
* @param sender address The address which are token transferred from
* @param amount uint256 The amount of tokens transferred
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` unless throwing
*/
function onTransferReceived(
address operator,
address sender,
uint256 amount,
bytes calldata data
) external returns (bytes4);
}
| interface IERC1363Receiver {
/**
* @notice Handle the receipt of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the
* transfer. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param operator address The address which called `transferAndCall` or `transferFromAndCall` function
* @param sender address The address which are token transferred from
* @param amount uint256 The amount of tokens transferred
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` unless throwing
*/
function onTransferReceived(
address operator,
address sender,
uint256 amount,
bytes calldata data
) external returns (bytes4);
}
| 5,096 |
160 | // Trigger countdown if new reserve price is greater than any current bids | if (reserveAuction.bid >= _reservePrice) {
reserveAuction.biddingEnd = uint128(block.timestamp) + reserveAuctionLengthOnceReserveMet;
}
| if (reserveAuction.bid >= _reservePrice) {
reserveAuction.biddingEnd = uint128(block.timestamp) + reserveAuctionLengthOnceReserveMet;
}
| 18,106 |
219 | // Check that mom and dad are both owned by caller, or that the dad has given breeding permission to caller (i.e. mom's owner). Will fail for _dadId = 0 | require(_isBreedingPermitted(_dadId, _momId));
| require(_isBreedingPermitted(_dadId, _momId));
| 64,462 |
2 | // holds some useful pieces of information related to an item which can be reviewed by registered reviewers present in dApp ecosystem | struct Thing {
bytes32 id;
string name;
string description;
uint8 rate;
uint256 rateCount;
mapping(address => uint8) rates;
uint256 reviewCount;
mapping(address => string) reviews;
}
| struct Thing {
bytes32 id;
string name;
string description;
uint8 rate;
uint256 rateCount;
mapping(address => uint8) rates;
uint256 reviewCount;
mapping(address => string) reviews;
}
| 19,367 |
2 | // Configurable permissionless curve lp token wrapper. | address curveTokenWrapper;
| address curveTokenWrapper;
| 82,078 |
4 | // current implementation cannot be initialized more than once: | require(_state().base != base(), "WitnetRequestBoardTrustableBase: already initialized");
| require(_state().base != base(), "WitnetRequestBoardTrustableBase: already initialized");
| 13,761 |
292 | // Update withdraw batch | if (pendingSharesToWithdraw > 0) {
batch.withdrawnReceived = processInfo.totalWithdrawReceived;
batch.withdrawnShares = pendingSharesToWithdraw;
strategyTotalShares -= pendingSharesToWithdraw;
| if (pendingSharesToWithdraw > 0) {
batch.withdrawnReceived = processInfo.totalWithdrawReceived;
batch.withdrawnShares = pendingSharesToWithdraw;
strategyTotalShares -= pendingSharesToWithdraw;
| 21,648 |
22 | // Take a fee rate and calculate the potentially discounted rate for this trader based onHOT token ownership.trader The address of the trader who made the order. rate The raw rate which we will discount if needed. isParticipantRelayer Whether this relayer is participating in hot discount.return The final potentially discounted rate. / | function getFinalFeeRate(
Store.State storage state,
address trader,
uint256 rate,
bool isParticipantRelayer
)
private
view
returns(uint256)
| function getFinalFeeRate(
Store.State storage state,
address trader,
uint256 rate,
bool isParticipantRelayer
)
private
view
returns(uint256)
| 5,690 |
13 | // Auction state. The price goes down 10% every `CEO_auction_blocks` blocks | CEO_price = _calcDiscount();
| CEO_price = _calcDiscount();
| 48,557 |
25 | // Utilization rate is 0 when there are no borrows | if (borrows == 0) {
return 0;
}
| if (borrows == 0) {
return 0;
}
| 10,705 |
0 | // Converts `n` to a string using LibUintToString and /measures the gas cost./n The integer to convert./ return str `n` as a decimal string./ return gasCost The gas cost of the conversion. | function testToString(uint256 n)
public
view
returns (string memory str, uint256 gasCost)
| function testToString(uint256 n)
public
view
returns (string memory str, uint256 gasCost)
| 35,205 |
39 | // Execute a multi-signature transaction from this wallet using 2 signers: one from msg.sender and the other from ecrecover.Sequence IDs are numbers starting from 1. They are used to prevent replay attacks and may not be repeated.toAddress the destination address to send an outgoing transaction value the amount in Wei to be sent data the data to send to the toAddress when invoking the transaction expireTime the number of seconds since 1970 for which this transaction is valid sequenceId the unique sequence id obtainable from getNextSequenceId signature see Data Formats / | function sendMultiSig(
address toAddress,
uint256 value,
bytes calldata data,
uint256 expireTime,
uint256 sequenceId,
bytes calldata signature
| function sendMultiSig(
address toAddress,
uint256 value,
bytes calldata data,
uint256 expireTime,
uint256 sequenceId,
bytes calldata signature
| 35,397 |
174 | // Function for designer group update _address Address of designer to be updated _uri ipfs uri for designer to be updated _tokenIds Array of token ids to be updated / | function updateDesignerGroup(address _address, string calldata _uri, uint256[] calldata _tokenIds) external {
require(accessControls.hasAdminRole(_msgSender()), "DigitalaxIndex.updateDesignerGroup: Sender must be admin");
designerGroupSet[_address] = DesignerGroup(_uri, TokenIdSet(_tokenIds));
emit DesignerGroupUpdated(_address, _uri, _tokenIds);
}
| function updateDesignerGroup(address _address, string calldata _uri, uint256[] calldata _tokenIds) external {
require(accessControls.hasAdminRole(_msgSender()), "DigitalaxIndex.updateDesignerGroup: Sender must be admin");
designerGroupSet[_address] = DesignerGroup(_uri, TokenIdSet(_tokenIds));
emit DesignerGroupUpdated(_address, _uri, _tokenIds);
}
| 13,180 |
243 | // Deposit pubdata | struct Deposit {
uint32 accountId;
uint16 tokenId;
uint128 amount;
address owner;
}
| struct Deposit {
uint32 accountId;
uint16 tokenId;
uint128 amount;
address owner;
}
| 29,807 |
16 | // Calculate token fee based off total token deposit | uint tokenFee = MathUpgradeable.mulDiv(
totalDeposited,
percentLockPrice,
10000
);
| uint tokenFee = MathUpgradeable.mulDiv(
totalDeposited,
percentLockPrice,
10000
);
| 13,422 |
177 | // check if the scheme is registered | if (_isSchemeRegistered(_scheme) == false) {
return false;
}
| if (_isSchemeRegistered(_scheme) == false) {
return false;
}
| 27,265 |
8 | // / | struct ProposalData {
uint256 index;
string title;
string content;
string[] options;
address[] voters;
uint256[] weights;
bool opened;
uint256[] result;
}
| struct ProposalData {
uint256 index;
string title;
string content;
string[] options;
address[] voters;
uint256[] weights;
bool opened;
uint256[] result;
}
| 14,998 |
176 | // Allows strategist to utilize Aave V2 flashloans while rebalancing the cellar. / | function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
| function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
| 3,910 |
68 | // contract responsible for funds accounting | LightFundsRegistry public m_funds;
| LightFundsRegistry public m_funds;
| 42,888 |
38 | // Upgrade the backing implementation of the proxy and call a functionon the new implementation.This is useful to initialize the proxied contract. newImplementation Address of the new implementation. data Data to send as msg.data in the low level call.It should include the signature and the parameters of the function to be called, as described in / | function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin {
_upgradeTo(newImplementation);
(bool success,) = newImplementation.delegatecall(data);
require(success);
}
| function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin {
_upgradeTo(newImplementation);
(bool success,) = newImplementation.delegatecall(data);
require(success);
}
| 6,442 |
2 | // Max supply of 5555 tokens | uint256 public constant MAX_SUPPLY = 5555;
| uint256 public constant MAX_SUPPLY = 5555;
| 2,508 |
93 | // Disable solium check because of https:github.com/duaraghav8/Solium/issues/175 solium-disable-next-line operator-whitespace | return (
spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender)
);
| return (
spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender)
);
| 39,602 |
26 | // Setup the owner role | _setupRole(DEFAULT_ADMIN_ROLE, _initialOwner);
| _setupRole(DEFAULT_ADMIN_ROLE, _initialOwner);
| 26,553 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.