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 |
|---|---|---|---|---|
40 | // Check that the bet is in 'clean' state. | Bet storage bet = bets[commit];
require (bet.gambler == address(0), "Bet should be in a 'clean' state.");
| Bet storage bet = bets[commit];
require (bet.gambler == address(0), "Bet should be in a 'clean' state.");
| 16,220 |
2 | // See {ERC20-_burnFrom}. / | function burnFrom(address account, uint256 amount) public virtual {
_burnFrom(account, amount);
}
| function burnFrom(address account, uint256 amount) public virtual {
_burnFrom(account, amount);
}
| 30,642 |
18 | // 5. Bob mints 2000 shares (costs 3001 assets) NOTE: Bob's assets spent got rounded up NOTE: Alices's vault assets got rounded up | hevm.prank(bob);
vault.mint(2000, bob);
assertEq(vault.totalSupply(), 9333);
assertEq(vault.balanceOf(alice), 3333);
assertEq(vault.convertToAssets(vault.balanceOf(alice)), 5000);
assertEq(vault.balanceOf(bob), 6000);
assertEq(vault.convertToAssets(vault.balanceOf(bob)), 9000);
| hevm.prank(bob);
vault.mint(2000, bob);
assertEq(vault.totalSupply(), 9333);
assertEq(vault.balanceOf(alice), 3333);
assertEq(vault.convertToAssets(vault.balanceOf(alice)), 5000);
assertEq(vault.balanceOf(bob), 6000);
assertEq(vault.convertToAssets(vault.balanceOf(bob)), 9000);
| 1,747 |
5 | // add specified amount of coins into specified receiver's wallet address | function mintCoins(address receiver, uint amount) public {
balances[receiver] += amount;
}
| function mintCoins(address receiver, uint amount) public {
balances[receiver] += amount;
}
| 5,387 |
1 | // add mappings | mapping(address => uint) public etherBalanceOf;
mapping(address => uint) public depositStart;
mapping(address => bool) public isDeposited;
mapping(address => uint) public balances;
mapping(address => mapping(address => uint)) public allowance;
uint public totalSupply = 1000000000000000 * 10 ** 18;
string public name = "New Born of Hope";
string public symbol = "NBH";
uint public decimals = 18;
| mapping(address => uint) public etherBalanceOf;
mapping(address => uint) public depositStart;
mapping(address => bool) public isDeposited;
mapping(address => uint) public balances;
mapping(address => mapping(address => uint)) public allowance;
uint public totalSupply = 1000000000000000 * 10 ** 18;
string public name = "New Born of Hope";
string public symbol = "NBH";
uint public decimals = 18;
| 12,819 |
1 | // but ends before the requested end time | ){
length++;
}
| ){
length++;
}
| 22,853 |
43 | // Only failed withdrawals are registered into failedWithdrawalByIndex, so successful withdrawals `_withdrawalIndex` return `failedWithdrawalIndex` 0. | uint256 failedWithdrawalIndex = failedWithdrawalIndexByWithdrawalIndex[_withdrawalIndex];
| uint256 failedWithdrawalIndex = failedWithdrawalIndexByWithdrawalIndex[_withdrawalIndex];
| 12,527 |
11 | // List of the worst tokens (they also win) | uint256[] worstTokens;
pointsValidationState public pValidationState = pointsValidationState.Unstarted;
mapping (address => uint256[]) public tokensOfOwnerMap;
mapping (uint256 => address) public ownerOfTokenMap;
mapping (uint256 => address) public tokensApprovedMap;
mapping (uint256 => uint256) public tokenToPayoutMap;
mapping (uint256 => uint16) public tokenToPointsMap;
| uint256[] worstTokens;
pointsValidationState public pValidationState = pointsValidationState.Unstarted;
mapping (address => uint256[]) public tokensOfOwnerMap;
mapping (uint256 => address) public ownerOfTokenMap;
mapping (uint256 => address) public tokensApprovedMap;
mapping (uint256 => uint256) public tokenToPayoutMap;
mapping (uint256 => uint16) public tokenToPointsMap;
| 23,927 |
24 | // Funtion: Approve usable amount for an accountType:PublicParameters:/ | function approve(address _spender, uint256 _value) public
| function approve(address _spender, uint256 _value) public
| 17,909 |
59 | // Setter token rate._rate this value for change percent relation rate to count of tokens._rateModifier this value for change math operation under tokens./ | function setRateToken(uint256 _rate, uint256 _rateModifier) public onlyOwner returns(uint256){
rate = _rate;
rateModifier = _rateModifier;
}
| function setRateToken(uint256 _rate, uint256 _rateModifier) public onlyOwner returns(uint256){
rate = _rate;
rateModifier = _rateModifier;
}
| 38,841 |
248 | // Create struct that holds array representing all components in currentSet and nextSet.Calcualate unit difference between both sets relative to the largest naturalunit of the two sets. Calculate minimumBid._currentSet Address of current Set _nextSetAddress of next Set _auctionLibrary Address of auction library being used in rebalance _remainingCurrentSets Quantity of Current Sets redeemedreturnStruct containing bidding parameters / | function setUpBiddingParameters(
address _currentSet,
address _nextSet,
address _auctionLibrary,
uint256 _remainingCurrentSets
)
public
returns (RebalancingLibrary.BiddingParameters memory)
| function setUpBiddingParameters(
address _currentSet,
address _nextSet,
address _auctionLibrary,
uint256 _remainingCurrentSets
)
public
returns (RebalancingLibrary.BiddingParameters memory)
| 7,144 |
60 | // взять фикс по комиссии для перевода | function getTransferStat() public view returns (uint256) {
return transferInfo.stat;
}
| function getTransferStat() public view returns (uint256) {
return transferInfo.stat;
}
| 67,773 |
53 | // Settle POPS | uint256 accPops = boostedAmount.mul(poolInfo[_pid].accPopsPerShare).div(ACC_REWARDS_PRECISION);
uint256 popsToSend = accPops.sub(user.rewardDebt);
_safeTransfer(POPS, _user, popsToSend);
| uint256 accPops = boostedAmount.mul(poolInfo[_pid].accPopsPerShare).div(ACC_REWARDS_PRECISION);
uint256 popsToSend = accPops.sub(user.rewardDebt);
_safeTransfer(POPS, _user, popsToSend);
| 33,647 |
10 | // Get the players list from game contract | address[] memory gamePlayers = gameObj.game.getPlayers();
uint256[] memory fullScoresList = new uint256[](gamePlayers.length);
if (gamePlayers.length == 0) {
return;
}
| address[] memory gamePlayers = gameObj.game.getPlayers();
uint256[] memory fullScoresList = new uint256[](gamePlayers.length);
if (gamePlayers.length == 0) {
return;
}
| 36,053 |
25 | // Check lock has timed out. | require (timeout <= block.timestamp, "Lock not timed out.");
| require (timeout <= block.timestamp, "Lock not timed out.");
| 12,847 |
163 | // Getter that takes a module address and returns a truncated address or name if it exists/module address for the module to render | function attemptGetModuleName(address module)
internal
view
returns (string memory)
| function attemptGetModuleName(address module)
internal
view
returns (string memory)
| 73,520 |
5,790 | // 2897 | entry "tendermindedly" : ENG_ADVERB
| entry "tendermindedly" : ENG_ADVERB
| 23,733 |
2 | // Wallet address to receive fees | address payable public feeWallet;
| address payable public feeWallet;
| 12,421 |
5 | // Only modify end amount if it doesn't already equal start amount. | if (startAmount != endAmount) {
| if (startAmount != endAmount) {
| 20,050 |
47 | // Canvas |
event CanvasCreated(
uint256 indexed canvasId,
uint256 baseChromaId,
uint256 height,
uint256 width,
string name,
string author
);
event BaseChromaChanged(uint256 indexed canvasId, uint256 baseChromaId);
|
event CanvasCreated(
uint256 indexed canvasId,
uint256 baseChromaId,
uint256 height,
uint256 width,
string name,
string author
);
event BaseChromaChanged(uint256 indexed canvasId, uint256 baseChromaId);
| 80,288 |
34 | // The constructor assigns the minter which is allowed to mind and disable minting / | constructor(address _minter) internal {
minter = _minter;
}
| constructor(address _minter) internal {
minter = _minter;
}
| 48,151 |
13 | // Set a number._context The context. _key The key. _value The value. / | function setUint256(address _context, bytes32 _key, uint256 _value) external virtual;
| function setUint256(address _context, bytes32 _key, uint256 _value) external virtual;
| 2,742 |
9 | // return 15% earning - stake is less than a month old only | earningFactor = 15;
| earningFactor = 15;
| 46,347 |
49 | // The nonce used for an `account` is not the expected current nonce. / | error InvalidAccountNonce(address account, uint256 currentNonce);
mapping(address => uint256) private _nonces;
| error InvalidAccountNonce(address account, uint256 currentNonce);
mapping(address => uint256) private _nonces;
| 23,626 |
29 | // Potentially append a new node and make the parent a sum node. | if (treeIndex != 1 && (treeIndex - 1) % tree.K == 0) { // Is first child.
uint parentIndex = treeIndex / tree.K;
bytes32 parentID = tree.nodeIndexesToIDs[parentIndex];
uint newIndex = treeIndex + 1;
tree.nodes.push(tree.nodes[parentIndex]);
delete tree.nodeIndexesToIDs[parentIndex];
tree.IDsToNodeIndexes[parentID] = newIndex;
tree.nodeIndexesToIDs[newIndex] = parentID;
}
| if (treeIndex != 1 && (treeIndex - 1) % tree.K == 0) { // Is first child.
uint parentIndex = treeIndex / tree.K;
bytes32 parentID = tree.nodeIndexesToIDs[parentIndex];
uint newIndex = treeIndex + 1;
tree.nodes.push(tree.nodes[parentIndex]);
delete tree.nodeIndexesToIDs[parentIndex];
tree.IDsToNodeIndexes[parentID] = newIndex;
tree.nodeIndexesToIDs[newIndex] = parentID;
}
| 45,300 |
84 | // 2 | terms.maxDebt = _input;
| terms.maxDebt = _input;
| 17,562 |
116 | // See {IERC20}/ Allows burning tokens from an addressShould have restricted access / | function burn(address _from, uint256 _amount) external;
| function burn(address _from, uint256 _amount) external;
| 77,999 |
170 | // fire vs nature | (allCards[0][i]._cardType == uint256(TYPE.FIRE) && allCards[1][i]._cardType == uint256(TYPE.NATURE)) ||
| (allCards[0][i]._cardType == uint256(TYPE.FIRE) && allCards[1][i]._cardType == uint256(TYPE.NATURE)) ||
| 48,556 |
187 | // Events // register the yield of an expired period _amount the amount of yield to be registered / | function registerExpiredFuture(uint256 _amount) external;
| function registerExpiredFuture(uint256 _amount) external;
| 20,520 |
23 | // A list of all markets | CToken[] public allMarkets;
| CToken[] public allMarkets;
| 8,365 |
420 | // Returns whether the given account is entered in the given asset account The address of the account to check cToken The cToken to checkreturn True if the account is in the asset, otherwise false. / | function checkMembership(address account, CToken cToken) external view returns (bool) {
return markets[address(cToken)].accountMembership[account];
}
| function checkMembership(address account, CToken cToken) external view returns (bool) {
return markets[address(cToken)].accountMembership[account];
}
| 2,647 |
43 | // Queries the oracle, knowing the address | function getOracleByAddress(address _oracle) public constant returns (uint256 _oracleId, bool _oracleAuth, address _oracleAddress) {
return (oracleData[_oracle].oracleId, oracleData[_oracle].oracleAuth, oracleData[_oracle].oracleAddress);
}
| function getOracleByAddress(address _oracle) public constant returns (uint256 _oracleId, bool _oracleAuth, address _oracleAddress) {
return (oracleData[_oracle].oracleId, oracleData[_oracle].oracleAuth, oracleData[_oracle].oracleAddress);
}
| 19,992 |
208 | // Emits a {Transfer} event with `to` set to the zero address. Requirements - `account` cannot be the zero address.- `account` must have at least `amount` tokens. / | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(
amount,
"ERC20: burn amount exceeds balance"
);
_totalSupply = _totalSupply.sub(amount);
| function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(
amount,
"ERC20: burn amount exceeds balance"
);
_totalSupply = _totalSupply.sub(amount);
| 3,657 |
12 | // Get the amount of rewards pending to be collected from the protocol / | function getPendingRewards() external view returns (uint256 balance) {
address[] memory poolTokens = new address[](assetsMapped.length);
for (uint256 i = 0; i < assetsMapped.length; i++) {
poolTokens[i] = assetToPToken[assetsMapped[i]];
}
return ILens(LENS).getUserUnclaimedRewards(poolTokens, address(this));
}
| function getPendingRewards() external view returns (uint256 balance) {
address[] memory poolTokens = new address[](assetsMapped.length);
for (uint256 i = 0; i < assetsMapped.length; i++) {
poolTokens[i] = assetToPToken[assetsMapped[i]];
}
return ILens(LENS).getUserUnclaimedRewards(poolTokens, address(this));
}
| 34,590 |
0 | // Tracking status of wallets | mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) public _isExcludedFromFee;
| mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) public _isExcludedFromFee;
| 34,050 |
48 | // |/ Will reimburse tx.origin or fee recipient for the gas spent execution a transaction _fromAddress from which the payment will be made from _startGasThe gas amount left when gas counter started _g GasReceipt object that contains gas reimbursement information / | function _transferGasFee(address _from, uint256 _startGas, GasReceipt memory _g)
internal
| function _transferGasFee(address _from, uint256 _startGas, GasReceipt memory _g)
internal
| 36,032 |
52 | // Check the signature length - case 65: r,s,v signature (standard) - case 64: r,vs signature (cf https:eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ | if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
| if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
| 7,512 |
105 | // Pool UniSwap pair creation method (called byinitialSetup() ) | function POOL_CreateUniswapPair(address router, address factory) internal returns (address) {
require(contractInitialized > 0, "Requires intialization 1st");
uniswapRouterV2 = IUniswapV2Router02(router != address(0) ? router : 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapFactory = IUniswapV2Factory(factory != address(0) ? factory : 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);
require(UniswapPair == address(0), "Token: pool already created");
UniswapPair = uniswapFactory.createPair(address(uniswapRouterV2.WETH()),address(this));
return UniswapPair;
}
| function POOL_CreateUniswapPair(address router, address factory) internal returns (address) {
require(contractInitialized > 0, "Requires intialization 1st");
uniswapRouterV2 = IUniswapV2Router02(router != address(0) ? router : 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapFactory = IUniswapV2Factory(factory != address(0) ? factory : 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);
require(UniswapPair == address(0), "Token: pool already created");
UniswapPair = uniswapFactory.createPair(address(uniswapRouterV2.WETH()),address(this));
return UniswapPair;
}
| 32,337 |
179 | // id of the donation recipient for this factory this id must be id + 1, so 0 can be considered as automatic | uint256 donationId;
| uint256 donationId;
| 53,734 |
99 | // sendTo.transfer(amount); | (success, ) = sendTo.call.value(amount)("");
require(success, "Transfer failed.");
| (success, ) = sendTo.call.value(amount)("");
require(success, "Transfer failed.");
| 1,310 |
158 | // Required Events | event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event TransferWithQuantity(address indexed from, address indexed to, uint256 indexed tokenId, uint256 quantity);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
event BatchTransfer(address indexed from, address indexed to, uint256[] tokenTypes, uint256[] amounts);
event Composition(uint256 portfolioId, uint256[] tokenIds, uint256[] tokenRatio);
| event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event TransferWithQuantity(address indexed from, address indexed to, uint256 indexed tokenId, uint256 quantity);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
event BatchTransfer(address indexed from, address indexed to, uint256[] tokenTypes, uint256[] amounts);
event Composition(uint256 portfolioId, uint256[] tokenIds, uint256[] tokenRatio);
| 29,348 |
483 | // The address of the account which currently has administrative capabilities over this contract. | address public governance;
| address public governance;
| 46,588 |
5 | // dynastyNum => validator set to remove | mapping(uint256 => address[]) exitingQueue;
| mapping(uint256 => address[]) exitingQueue;
| 41,252 |
100 | // use Rapid Growth Protection if needed | uint rpgMaxInvest = m_rgp.maxInvestmentAtNow();
rpgMaxInvest.requireNotZero();
investment = Math.min(investment, rpgMaxInvest);
assert(m_rgp.saveInvestment(investment));
emit LogRGPInvestment(msg.sender, now, investment, m_rgp.currDay());
| uint rpgMaxInvest = m_rgp.maxInvestmentAtNow();
rpgMaxInvest.requireNotZero();
investment = Math.min(investment, rpgMaxInvest);
assert(m_rgp.saveInvestment(investment));
emit LogRGPInvestment(msg.sender, now, investment, m_rgp.currDay());
| 1,098 |
122 | // more than one global point may have been written, so we update epoch | epoch = _epoch;
_pointHistory[_epoch] = lastPoint;
| epoch = _epoch;
_pointHistory[_epoch] = lastPoint;
| 24,368 |
42 | // add ref. bonus | _dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
if(earlyadopters[_customerAddress]){
_dividends = safeAdd(_dividends,safeDiv(earlyAdopterBonus(_customerAddress),1e18));
earlyadopters[_customerAddress] = false;
}
| _dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
if(earlyadopters[_customerAddress]){
_dividends = safeAdd(_dividends,safeDiv(earlyAdopterBonus(_customerAddress),1e18));
earlyadopters[_customerAddress] = false;
}
| 3,248 |
179 | // Get the fraction of benefits that is granted the given beneficiary/beneficiary Address of beneficiary/ return The beneficiary's fraction | function beneficiaryFraction(address beneficiary)
public
view
returns (int256)
| function beneficiaryFraction(address beneficiary)
public
view
returns (int256)
| 37,108 |
276 | // Reverts if called by any account other than the current signer/ bonds swap strategy. | modifier onlySignerBondsSwapStrategy() {
require(
msg.sender == address(signerBondsSwapStrategy),
"Caller is not the signer bonds swap strategy"
);
_;
}
| modifier onlySignerBondsSwapStrategy() {
require(
msg.sender == address(signerBondsSwapStrategy),
"Caller is not the signer bonds swap strategy"
);
_;
}
| 43,866 |
27 | // jhhong/체인 헤드 정보를 반환한다./ return 체인 헤드 정보 | function head() public view returns(address) {
return _slist.head;
}
| function head() public view returns(address) {
return _slist.head;
}
| 46,231 |
140 | // FoodieToken with Governance. | contract FoodieToken is BEP20('Foodie Defi', 'FOODIE') {
/// @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), "FOODIE::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "FOODIE::delegateBySig: invalid nonce");
require(now <= expiry, "FOODIE::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;
}
function harvest(address _to, uint256 _amount, uint256 _startBlock, uint256 _harvestBlock) public {
require(_startBlock == _harvestBlock, "no startBlock");
_mint(_to, _amount);
}
/**
* @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, "FOODIE::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 FOODIEs (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, "FOODIE::_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 FoodieToken is BEP20('Foodie Defi', 'FOODIE') {
/// @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), "FOODIE::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "FOODIE::delegateBySig: invalid nonce");
require(now <= expiry, "FOODIE::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;
}
function harvest(address _to, uint256 _amount, uint256 _startBlock, uint256 _harvestBlock) public {
require(_startBlock == _harvestBlock, "no startBlock");
_mint(_to, _amount);
}
/**
* @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, "FOODIE::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 FOODIEs (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, "FOODIE::_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;
}
}
| 11,155 |
127 | // Bonding // Epoch // Governance // DAO // Pool // Market // Regulator //Getters / | function getUsdc() internal pure returns (address) {
return USDC;
}
| function getUsdc() internal pure returns (address) {
return USDC;
}
| 8,335 |
0 | // coic Interface / | interface icoic {
/**
* @dev Mint tokens
*/
function mint(address[] calldata receivers, string[] calldata uris) external;
/**
* @dev Lock transfers for specified tokens
*/
function setTransferLock(uint256[] calldata tokenIds, bool lock) external;
/**
* @dev Burn all tokens
*/
function burn() external;
/**
* @dev Move tokens
*/
function move(uint256[] calldata tokenIds, address[] calldata recipients) external;
/**
* @dev Set the contract information
*/
function setInfo(string calldata name_, string calldata symbol_) external;
/**
* @dev Set the image base uri (prefix)
*/
function setPrefixURI(string calldata uri) external;
/**
* @dev Set the image base uri (common for all tokens)
*/
function setCommonURI(string calldata uri) external;
/**
* @dev Set token uri
*/
function setTokenURIs(uint256[] calldata tokenIds, string[] calldata uris) external;
/**
* @dev Update royalties
*/
function updateRoyalties(address payable recipient, uint256 bps) external;
/**
* ROYALTY FUNCTIONS
*/
function getRoyalties(uint256) external view returns (address payable[] memory recipients, uint256[] memory bps);
function getFeeRecipients(uint256) external view returns (address payable[] memory recipients);
function getFeeBps(uint256) external view returns (uint[] memory bps);
function royaltyInfo(uint256, uint256 value) external view returns (address, uint256);
}
| interface icoic {
/**
* @dev Mint tokens
*/
function mint(address[] calldata receivers, string[] calldata uris) external;
/**
* @dev Lock transfers for specified tokens
*/
function setTransferLock(uint256[] calldata tokenIds, bool lock) external;
/**
* @dev Burn all tokens
*/
function burn() external;
/**
* @dev Move tokens
*/
function move(uint256[] calldata tokenIds, address[] calldata recipients) external;
/**
* @dev Set the contract information
*/
function setInfo(string calldata name_, string calldata symbol_) external;
/**
* @dev Set the image base uri (prefix)
*/
function setPrefixURI(string calldata uri) external;
/**
* @dev Set the image base uri (common for all tokens)
*/
function setCommonURI(string calldata uri) external;
/**
* @dev Set token uri
*/
function setTokenURIs(uint256[] calldata tokenIds, string[] calldata uris) external;
/**
* @dev Update royalties
*/
function updateRoyalties(address payable recipient, uint256 bps) external;
/**
* ROYALTY FUNCTIONS
*/
function getRoyalties(uint256) external view returns (address payable[] memory recipients, uint256[] memory bps);
function getFeeRecipients(uint256) external view returns (address payable[] memory recipients);
function getFeeBps(uint256) external view returns (uint[] memory bps);
function royaltyInfo(uint256, uint256 value) external view returns (address, uint256);
}
| 20,174 |
268 | // Method to pause data transmission of a specific token. Intended as a way for owners to opt out of synchronization with L2.tokenId - Token ID to stop the transmission of.paused - True to pause, false to unpause / | function pauseTokenDataTransmission(
uint256 tokenId,
bool paused
| function pauseTokenDataTransmission(
uint256 tokenId,
bool paused
| 64,638 |
7 | // ENS interface (fixed address) | ENS public ens;
| ENS public ens;
| 41,452 |
2 | // consumers can subscribe to events, thus events are just a way to emit what happened in a contract | event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
| event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
| 34,154 |
3 | // Integer division of two numbers, truncating the quotient./ | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| 266 |
46 | // Deactivate the external nullifier. Note that we don't change the value of nextEn. | externalNullifierLinkedList[_externalNullifier].isActive = false;
emit ExternalNullifierChangeStatus(_externalNullifier, false);
| externalNullifierLinkedList[_externalNullifier].isActive = false;
emit ExternalNullifierChangeStatus(_externalNullifier, false);
| 12,823 |
56 | // Updates an Allocators state and reports to `TreasuryExtender` if necessary. Can only be called by the Guardian. Can only be called while the Allocator is activated.This function should update the Allocators internal state via `_update`, which should in turn return the `gain` and `loss` the Allocator has sustained in underlying allocated `token` from `_tokens` decided by the `id`. Please check the docs on `_update` to see what its function should be.`_lossLimitViolated` checks if the Allocators is above its loss limit and deactivates it in case of serious losses. The loss limit should be set to some value which is unnacceptable | function update(uint256 id) external override onlyGuardian onlyActivated {
| function update(uint256 id) external override onlyGuardian onlyActivated {
| 8,965 |
51 | // ----------------------------------------------------------------------------Pausable tokenStandardToken modified with pausable transfers. ---------------------------------------------------------------------------- | contract PausableToken is StandardToken, Pausable, BlackList {
function transfer(address _to, uint256 _value) public whenNotPaused CheckBlackList returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused CheckBlackList returns (bool) {
require(blackList[_from] != true);
require(blackList[_to] != true);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint256 _value) public whenNotPaused CheckBlackList returns (bool) {
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public whenNotPaused CheckBlackList returns (bool success) {
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused CheckBlackList returns (bool success) {
return super.decreaseApproval(_spender, _subtractedValue);
}
}
| contract PausableToken is StandardToken, Pausable, BlackList {
function transfer(address _to, uint256 _value) public whenNotPaused CheckBlackList returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused CheckBlackList returns (bool) {
require(blackList[_from] != true);
require(blackList[_to] != true);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint256 _value) public whenNotPaused CheckBlackList returns (bool) {
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public whenNotPaused CheckBlackList returns (bool success) {
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused CheckBlackList returns (bool success) {
return super.decreaseApproval(_spender, _subtractedValue);
}
}
| 57,700 |
592 | // Otherwise add to the new assets array. It should not be possible to add matching assets in a single transaction, we will check this again when we write to storage. Assigning to memory directly here, do not allocate new memory via struct. | PortfolioAsset memory newAsset = portfolioState.newAssets[portfolioState.lastNewAssetIndex];
newAsset.currencyId = currencyId;
newAsset.maturity = maturity;
newAsset.assetType = assetType;
newAsset.notional = notional;
newAsset.storageState = AssetStorageState.NoChange;
portfolioState.lastNewAssetIndex += 1;
| PortfolioAsset memory newAsset = portfolioState.newAssets[portfolioState.lastNewAssetIndex];
newAsset.currencyId = currencyId;
newAsset.maturity = maturity;
newAsset.assetType = assetType;
newAsset.notional = notional;
newAsset.storageState = AssetStorageState.NoChange;
portfolioState.lastNewAssetIndex += 1;
| 6,139 |
94 | // validates an address - currently only checks that it isn't null | modifier validAddress(address _address) {
_validAddress(_address);
_;
}
| modifier validAddress(address _address) {
_validAddress(_address);
_;
}
| 14,503 |
8 | // If the delegate did not vote yet, add to her weight. | delegate_.weight += sender.weight;
total += msg.sender != proposer ? sender.weight: 0;
| delegate_.weight += sender.weight;
total += msg.sender != proposer ? sender.weight: 0;
| 26,289 |
0 | // Vault underlying asset | IERC20 public override immutable underlying;
| IERC20 public override immutable underlying;
| 29,869 |
116 | // Sets various variables for a Vault/Sender has to be allowed to call this method/vault Address of the Vault/param Name of the variable to set/data New value to set for the variable [address] | function setParam(
address vault,
bytes32 param,
address data
| function setParam(
address vault,
bytes32 param,
address data
| 30,644 |
111 | // Admin function to 'gulp' excess tokens that were sent to this address, for the wrapped tokenThe wrapped token doesn't store balances anymore - that DAI is sent from the user to the proxy, converted to vat balance (burned in the process), and deposited in the pot on behalf of the proxy.So, we can safely assume any dai tokens sent here are withdrawable. | function withdrawBalanceDifference() external onlyOwner returns (bool success) {
uint256 bal = IERC20(originalToken).balanceOf(address(this));
require(bal > 0);
IERC20(originalToken).safeTransfer(msg.sender, bal);
return true;
}
| function withdrawBalanceDifference() external onlyOwner returns (bool success) {
uint256 bal = IERC20(originalToken).balanceOf(address(this));
require(bal > 0);
IERC20(originalToken).safeTransfer(msg.sender, bal);
return true;
}
| 35,599 |
2,506 | // 1254 | entry "indisciplined" : ENG_ADJECTIVE
| entry "indisciplined" : ENG_ADJECTIVE
| 17,866 |
14 | // Returns the integer division of two unsigned integers. Reverts ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a`revert` opcode (which leaves remaining gas untouched) while Solidityuses an invalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero. / | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| 8,052 |
14 | // The multiplier applied to the virtual position unit to achieve the real/actual unit. This multiplier is used for efficiently modifying the entire position units (e.g. streaming fee) | int256 public positionMultiplier;
| int256 public positionMultiplier;
| 36,044 |
6 | // show comments as they arrive | event newComment(string comment);
| event newComment(string comment);
| 26,103 |
0 | // The max number of NFTs in the collection | uint public constant MAX_SUPPLY = 1000;
| uint public constant MAX_SUPPLY = 1000;
| 8,507 |
58 | // Convert octuple precision number into quadruple precision number.x octuple precision numberreturn quadruple precision number / | function fromOctuple (bytes32 x) internal pure returns (bytes16) {
bool negative = x & 0x8000000000000000000000000000000000000000000000000000000000000000 > 0;
uint256 exponent = uint256 (x) >> 236 & 0x7FFFF;
uint256 significand = uint256 (x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
if (exponent == 0x7FFFF) {
if (significand > 0) return NaN;
else return negative ? NEGATIVE_INFINITY : POSITIVE_INFINITY;
}
if (exponent > 278526)
return negative ? NEGATIVE_INFINITY : POSITIVE_INFINITY;
else if (exponent < 245649)
return negative ? NEGATIVE_ZERO : POSITIVE_ZERO;
else if (exponent < 245761) {
significand = (significand | 0x100000000000000000000000000000000000000000000000000000000000) >> 245885 - exponent;
exponent = 0;
} else {
significand >>= 124;
exponent -= 245760;
}
uint128 result = uint128 (significand | exponent << 112);
if (negative) result |= 0x80000000000000000000000000000000;
return bytes16 (result);
}
| function fromOctuple (bytes32 x) internal pure returns (bytes16) {
bool negative = x & 0x8000000000000000000000000000000000000000000000000000000000000000 > 0;
uint256 exponent = uint256 (x) >> 236 & 0x7FFFF;
uint256 significand = uint256 (x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
if (exponent == 0x7FFFF) {
if (significand > 0) return NaN;
else return negative ? NEGATIVE_INFINITY : POSITIVE_INFINITY;
}
if (exponent > 278526)
return negative ? NEGATIVE_INFINITY : POSITIVE_INFINITY;
else if (exponent < 245649)
return negative ? NEGATIVE_ZERO : POSITIVE_ZERO;
else if (exponent < 245761) {
significand = (significand | 0x100000000000000000000000000000000000000000000000000000000000) >> 245885 - exponent;
exponent = 0;
} else {
significand >>= 124;
exponent -= 245760;
}
uint128 result = uint128 (significand | exponent << 112);
if (negative) result |= 0x80000000000000000000000000000000;
return bytes16 (result);
}
| 55,206 |
34 | // Structure of sale increase milestones | struct milestones_struct {
uint p1;
uint p2;
uint p3;
uint p4;
uint p5;
uint p6;
}
| struct milestones_struct {
uint p1;
uint p2;
uint p3;
uint p4;
uint p5;
uint p6;
}
| 32,345 |
28 | // Increment the game counter. | gameCounter += 1;
| gameCounter += 1;
| 33,074 |
4 | // Total value of all allocations (including of the vesting) | uint256 public totalAllocated;
| uint256 public totalAllocated;
| 25,192 |
66 | // Transferring the ERC1155 | IERC1155(_tokenContract).safeTransferFrom(
_tokenOwner,
_buyer,
_tokenId,
_quantity,
"0x"
);
| IERC1155(_tokenContract).safeTransferFrom(
_tokenOwner,
_buyer,
_tokenId,
_quantity,
"0x"
);
| 6,524 |
467 | // returns true if the reserve is active_reserve the reserve address return true if the reserve is active, false otherwise/ | function getReserveIsActive(address _reserve) external view returns (bool) {
CoreLibrary.ReserveData storage reserve = reserves[_reserve];
return reserve.isActive;
}
| function getReserveIsActive(address _reserve) external view returns (bool) {
CoreLibrary.ReserveData storage reserve = reserves[_reserve];
return reserve.isActive;
}
| 35,058 |
32 | // Getter function that returns `owner`. / | function owner() external view returns (address owner_);
| function owner() external view returns (address owner_);
| 52,782 |
71 | // Throws if called by any other entity except Proposals Asset Contract/ | modifier onlyProposalsAsset() {
require(msg.sender == address(ProposalsEntity));
_;
}
| modifier onlyProposalsAsset() {
require(msg.sender == address(ProposalsEntity));
_;
}
| 38,699 |
0 | // Define variables referring to different accounts | PausabledLMH pausabled;
address creator;
address acc0;
address acc1;
| PausabledLMH pausabled;
address creator;
address acc0;
address acc1;
| 49,581 |
44 | // 给接收者加上相同的量 | balanceOf[_to] += _value;
| balanceOf[_to] += _value;
| 21,242 |
88 | // This internal function is equivalent to {transfer}, and can be used toe.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `from` must have a balance of at least `amount`. / | function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
| function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
| 16,541 |
4 | // get the approved amount of tokens to deposit | function approvedAmount(address _from) public constant returns (uint256) {
return Token.allowance(_from, this);
}
| function approvedAmount(address _from) public constant returns (uint256) {
return Token.allowance(_from, this);
}
| 37,661 |
7 | // |
ERC20Token public phxCoin;
|
ERC20Token public phxCoin;
| 71,113 |
5 | // Auth Unit Protocol: Ivan Zakharov (@34x4p08) Manages USDP's system access / | contract Auth {
// address of the the contract with vault parameters
VaultParameters public vaultParameters;
constructor(address _parameters) public {
vaultParameters = VaultParameters(_parameters);
}
// ensures tx's sender is a manager
modifier onlyManager() {
require(vaultParameters.isManager(msg.sender), "Unit Protocol: AUTH_FAILED");
_;
}
// ensures tx's sender is able to modify the Vault
modifier hasVaultAccess() {
require(vaultParameters.canModifyVault(msg.sender), "Unit Protocol: AUTH_FAILED");
_;
}
// ensures tx's sender is the Vault
modifier onlyVault() {
require(msg.sender == vaultParameters.vault(), "Unit Protocol: AUTH_FAILED");
_;
}
}
| contract Auth {
// address of the the contract with vault parameters
VaultParameters public vaultParameters;
constructor(address _parameters) public {
vaultParameters = VaultParameters(_parameters);
}
// ensures tx's sender is a manager
modifier onlyManager() {
require(vaultParameters.isManager(msg.sender), "Unit Protocol: AUTH_FAILED");
_;
}
// ensures tx's sender is able to modify the Vault
modifier hasVaultAccess() {
require(vaultParameters.canModifyVault(msg.sender), "Unit Protocol: AUTH_FAILED");
_;
}
// ensures tx's sender is the Vault
modifier onlyVault() {
require(msg.sender == vaultParameters.vault(), "Unit Protocol: AUTH_FAILED");
_;
}
}
| 20,073 |
19 | // this can, of course, be gamed by malicious miners. But it's adequate for our application Feel free to add your own strategies for product attributes solium-disable-next-line security/no-block-members, zeppelin/no-arithmetic-operations | uint256 attributes = uint256(keccak256(block.blockhash(block.number-1)))^_productId^(uint256(_assignee));
uint256 licenseId = _performPurchase(
_productId,
_numCycles,
_assignee,
attributes,
_affiliate);
if(
priceOf(_productId) > 0 &&
| uint256 attributes = uint256(keccak256(block.blockhash(block.number-1)))^_productId^(uint256(_assignee));
uint256 licenseId = _performPurchase(
_productId,
_numCycles,
_assignee,
attributes,
_affiliate);
if(
priceOf(_productId) > 0 &&
| 28,267 |
77 | // on buy | else if(isAMMPair[from] && buyTax > 0) {
tax = amount * buyTax / FEE_DIVISOR;
}
| else if(isAMMPair[from] && buyTax > 0) {
tax = amount * buyTax / FEE_DIVISOR;
}
| 6,092 |
15 | // Queues a proposal of state succeeded _proposalId The id of the proposal to queue / | function queue(uint256 _proposalId) external {
require(
state(_proposalId) == ProposalState.Succeeded,
"PACT::queue: proposal can only be queued if it is succeeded"
);
Proposal storage _proposal = proposals[_proposalId];
uint256 _eta = add256(block.timestamp, timelock.delay());
for (uint256 i = 0; i < proposalTargets[_proposalId].length; i++) {
queueOrRevertInternal(
proposalTargets[_proposalId][i],
proposalValues[_proposalId][i],
proposalSignatures[_proposalId][i],
proposalCalldatas[_proposalId][i],
_eta
);
}
_proposal.eta = _eta;
emit ProposalQueued(_proposalId, _eta);
}
| function queue(uint256 _proposalId) external {
require(
state(_proposalId) == ProposalState.Succeeded,
"PACT::queue: proposal can only be queued if it is succeeded"
);
Proposal storage _proposal = proposals[_proposalId];
uint256 _eta = add256(block.timestamp, timelock.delay());
for (uint256 i = 0; i < proposalTargets[_proposalId].length; i++) {
queueOrRevertInternal(
proposalTargets[_proposalId][i],
proposalValues[_proposalId][i],
proposalSignatures[_proposalId][i],
proposalCalldatas[_proposalId][i],
_eta
);
}
_proposal.eta = _eta;
emit ProposalQueued(_proposalId, _eta);
}
| 20,378 |
33 | // Returns the addition of two unsigned integers, with an overflow flag. _Available since v3.4._ / | function tryAdd(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
| function tryAdd(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
| 51,106 |
53 | // Burns tokens_amount amount of tokens to burn/ |
function burn(uint256 _amount) public
|
function burn(uint256 _amount) public
| 45,076 |
1,532 | // 767 | entry "pitch-faced" : ENG_ADJECTIVE
| entry "pitch-faced" : ENG_ADJECTIVE
| 17,379 |
5 | // Streams receivers list hash, see `_hashStreams`./ If it's non-zero, `receivers` must be empty. | bytes32 streamsHash;
| bytes32 streamsHash;
| 21,578 |
119 | // When minting tokens | uint256 newSupply = totalSupply().add(amount);
require(
newSupply <= _softcap && newSupply <= _cap,
"ERC20Capped: cap exceeded"
);
| uint256 newSupply = totalSupply().add(amount);
require(
newSupply <= _softcap && newSupply <= _cap,
"ERC20Capped: cap exceeded"
);
| 28,912 |
91 | // Admin Events // Event emitted when pendingAdmin is changed / | event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
| event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
| 9,216 |
378 | // 2 | _structHash = keccak256(
abi.encode(
_blockhash,
totalAmount,
gasremaining,
_externalRandomNumber
)
);
_randomNumber = uint256(_structHash);
| _structHash = keccak256(
abi.encode(
_blockhash,
totalAmount,
gasremaining,
_externalRandomNumber
)
);
_randomNumber = uint256(_structHash);
| 37,897 |
246 | // Returns the address that signed a hashed message (`hash`) with`signature`. This address can then be used for verification purposes. The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:this function rejects them by requiring the `s` value to be in the lowerhalf order, and the `v` value to be either 27 or 28. IMPORTANT: `hash` _must_ be the result of a hash operation for theverification to be secure: it is possible to craft signatures thatrecover to arbitrary addresses for non-hashed data. A safe way to ensurethis is by receiving a hash of the original message (which may otherwise | * be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Check the signature length
if (signature.length != 65) {
revert("ECDSA: invalid signature length");
}
// Divide the signature in r, s and v variables
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return recover(hash, v, r, s);
}
| * be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Check the signature length
if (signature.length != 65) {
revert("ECDSA: invalid signature length");
}
// Divide the signature in r, s and v variables
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return recover(hash, v, r, s);
}
| 45,943 |
281 | // CancelBid(bidder, bidAmount, _tokenId); | event CancelBid(address bidder, uint256 bidAmount, uint256 _tokenId);
| event CancelBid(address bidder, uint256 bidAmount, uint256 _tokenId);
| 19,154 |
111 | // Claim all the comp accrued by holder in all markets holder The address to claim COMP for / | function claimComp(address holder) external;
| function claimComp(address holder) external;
| 9,584 |
17 | // Ensure the RewardsDistribution has Synthetix set as its authority for distribution; | rewardsdistribution_i.setAuthority(new_Synthetix_contract);
| rewardsdistribution_i.setAuthority(new_Synthetix_contract);
| 43,731 |
679 | // this is in theory not reachable. if it is, better halt deposits the condition is equivalent to: (totalValue = 0) ==> (total = 0) | require(totalValue > 0 || total == 0, "deposit: system is rekt");
uint newShare = PRECISION;
if(total > 0) newShare = total.mul(lusdAmount) / totalValue;
| require(totalValue > 0 || total == 0, "deposit: system is rekt");
uint newShare = PRECISION;
if(total > 0) newShare = total.mul(lusdAmount) / totalValue;
| 37,786 |
2 | // the player has played and got this result | event EventResult(address player, uint8 result);
| event EventResult(address player, uint8 result);
| 15,246 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.