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
26
// Ensure that the pledge is not already at max pledge depth and the project has not been canceled
require(_getPledgeLevel(p) < MAX_INTERPROJECT_LEVEL); require(!isProjectCanceled(idReceiver)); uint64 oldPledge = _findOrCreatePledge( p.owner, p.delegationChain, 0, 0, p.oldPledge, p.token,
require(_getPledgeLevel(p) < MAX_INTERPROJECT_LEVEL); require(!isProjectCanceled(idReceiver)); uint64 oldPledge = _findOrCreatePledge( p.owner, p.delegationChain, 0, 0, p.oldPledge, p.token,
4,067
309
// Internal mint function /
function _coreMint(uint256 amount) internal { uint256 tokenId; for(uint256 i = 0; i < amount; i++) { // Generate new tokenId _tokenIdCounter.increment(); tokenId = _tokenIdCounter.current(); // mint the tokenId for caller _safeMint(msg.sender, tokenId); } }
function _coreMint(uint256 amount) internal { uint256 tokenId; for(uint256 i = 0; i < amount; i++) { // Generate new tokenId _tokenIdCounter.increment(); tokenId = _tokenIdCounter.current(); // mint the tokenId for caller _safeMint(msg.sender, tokenId); } }
76,600
11
// Returns the quorum for a block number, in terms of number of votes: `supplynumerator / denominator`. /
function quorum(uint256 blockNumber) public view virtual override returns (uint256) { return (token.getPastTotalSupply(blockNumber) * quorumNumerator(blockNumber)) / quorumDenominator(); }
function quorum(uint256 blockNumber) public view virtual override returns (uint256) { return (token.getPastTotalSupply(blockNumber) * quorumNumerator(blockNumber)) / quorumDenominator(); }
22,141
29
// get affiliate ID from aff Code
_affID = pIDxAddr_[_affCode];
_affID = pIDxAddr_[_affCode];
20,805
69
// ERC20 compliant approve function _spender party that msg.sender approves for transferring funds _amount amount of token to approve for sendingreturn true for successful/
function approve(TokenStorage storage self, address _spender, uint _amount) public returns (bool) { self.allowed[msg.sender][_spender] = _amount; emit Approval(msg.sender, _spender, _amount); return true; }
function approve(TokenStorage storage self, address _spender, uint _amount) public returns (bool) { self.allowed[msg.sender][_spender] = _amount; emit Approval(msg.sender, _spender, _amount); return true; }
72,644
11
// Swap the token-to-unbind with the last token, then delete the last token
uint256 index = record.index; uint256 last = dynasetTokens.length - 1;
uint256 index = record.index; uint256 last = dynasetTokens.length - 1;
19,395
183
// Transfer want tokens strategy -> autoFarm
function withdraw(address _userAddress, uint256 _wantAmt) external returns (uint256); function inCaseTokensGetStuck( address _token, uint256 _amount, address _to ) external;
function withdraw(address _userAddress, uint256 _wantAmt) external returns (uint256); function inCaseTokensGetStuck( address _token, uint256 _amount, address _to ) external;
106
13
// claim rewards till now
uint256 claimableReward = stakes[account].multiplyDecimalPrecise(globalIntegral.sub(integrals[account])); claimableRewards[account] = claimableRewards[account].add(claimableReward);
uint256 claimableReward = stakes[account].multiplyDecimalPrecise(globalIntegral.sub(integrals[account])); claimableRewards[account] = claimableRewards[account].add(claimableReward);
42,208
25
// pop the samurai headoff the leve chain
pop(levelChain[samuraiHead.level]); if(samuraiHead.autoLevelUp) { levelUp(samuraiHeadId); } else {
pop(levelChain[samuraiHead.level]); if(samuraiHead.autoLevelUp) { levelUp(samuraiHeadId); } else {
26,068
52
// Storage of set values
bytes32[] _values;
bytes32[] _values;
1,378
523
// Reduce the unclaimed amount by the amount already claimed.
uint256 unclaimedAmount = claimAmount.sub(claim.amountClaimed); return unclaimedAmount;
uint256 unclaimedAmount = claimAmount.sub(claim.amountClaimed); return unclaimedAmount;
41,484
82
// PUBLIC FACING: External helper for the current day number since launch timereturn Current day number (zero-based) /
function currentDay() external view returns (uint256)
function currentDay() external view returns (uint256)
17,506
19
// Before Metropolis update require will not refund gas, but for some reason require statement around msg.value always throws
assert(msg.value > 0 finney);
assert(msg.value > 0 finney);
40,633
97
// ============================================================================= //=============================MultiSig Wallet================================= //============================================================================= //Multisignature wallet - Allows multiple parties to agree on transactions before execution./Stefan George - <stefan.george@consensys.net>
contract MultiSigWallet { //Load Gifto and IAMICOIN Contracts to this contract. //ERC20 private Gifto = ERC20(0x92e87a5622cf9955d1062822454701198a028a72); //ERC20 private IAMIToken = ERC20(0xee10a06b2a0cf7e04115edfbee46242136eb6ae1); uint constant public MAX_OWNER_COUNT = 50; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); event CoinCreation(address coin); mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; bool flag = true; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { if (msg.sender != address(this)) revert(); _; } modifier ownerDoesNotExist(address owner) { if (isOwner[owner]) revert(); _; } modifier ownerExists(address owner) { if (!isOwner[owner]) revert(); _; } modifier transactionExists(uint transactionId) { if (transactions[transactionId].destination == 0) revert(); _; } modifier confirmed(uint transactionId, address owner) { if (!confirmations[transactionId][owner]) revert(); _; } modifier notConfirmed(uint transactionId, address owner) { if (confirmations[transactionId][owner]) revert(); _; } modifier notExecuted(uint transactionId) { if (transactions[transactionId].executed) revert(); _; } modifier notNull(address _address) { if (_address == 0) revert(); _; } modifier validRequirement(uint ownerCount, uint _required) { if ( ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0) revert(); _; } /// @dev Fallback function allows to deposit ether. function() payable { if (msg.value > 0) Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. function MultiSigWallet(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { if (isOwner[_owners[i]] || _owners[i] == 0) revert(); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param owner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; OwnerRemoval(owner); OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction tx = transactions[transactionId]; tx.executed = true; if (tx.destination.call.value(tx.value)(tx.data)) Execution(transactionId); else { ExecutionFailure(transactionId); tx.executed = false; } } } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } // Transfer GTO to an outside account /*function _withdrawGTO(address _to, uint256 _balance) onlyOwner internal { require(Gifto.balanceOf(address(this)) >= _balance); Gifto.transfer(_to, _balance); } // Transfer IAMI to an outside account function _withdrawIAMI(address _to, uint256 _balance) onlyOwner internal { require(IAMIToken.balanceOf(address(this)) >= _balance); IAMIToken.transfer(_to, _balance); } // Change Gifto contract's address or another type of token, like Ether. function setIAMITokenAddress(address newAddress) public onlyOwner { IAMIToken = ERC20(newAddress); } function setGiftoAddress(address newAddress) public onlyOwner { Gifto = ERC20(newAddress); }*/ modifier onlyOwner() { require(isOwner[msg.sender] == true); _; } /// @dev Create new forever rose. function createForeverRose() external onlyWallet { require(flag == true); CoinCreation(new DivisibleForeverRose()); flag = false; } }
contract MultiSigWallet { //Load Gifto and IAMICOIN Contracts to this contract. //ERC20 private Gifto = ERC20(0x92e87a5622cf9955d1062822454701198a028a72); //ERC20 private IAMIToken = ERC20(0xee10a06b2a0cf7e04115edfbee46242136eb6ae1); uint constant public MAX_OWNER_COUNT = 50; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); event CoinCreation(address coin); mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; bool flag = true; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { if (msg.sender != address(this)) revert(); _; } modifier ownerDoesNotExist(address owner) { if (isOwner[owner]) revert(); _; } modifier ownerExists(address owner) { if (!isOwner[owner]) revert(); _; } modifier transactionExists(uint transactionId) { if (transactions[transactionId].destination == 0) revert(); _; } modifier confirmed(uint transactionId, address owner) { if (!confirmations[transactionId][owner]) revert(); _; } modifier notConfirmed(uint transactionId, address owner) { if (confirmations[transactionId][owner]) revert(); _; } modifier notExecuted(uint transactionId) { if (transactions[transactionId].executed) revert(); _; } modifier notNull(address _address) { if (_address == 0) revert(); _; } modifier validRequirement(uint ownerCount, uint _required) { if ( ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0) revert(); _; } /// @dev Fallback function allows to deposit ether. function() payable { if (msg.value > 0) Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. function MultiSigWallet(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { if (isOwner[_owners[i]] || _owners[i] == 0) revert(); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param owner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; OwnerRemoval(owner); OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction tx = transactions[transactionId]; tx.executed = true; if (tx.destination.call.value(tx.value)(tx.data)) Execution(transactionId); else { ExecutionFailure(transactionId); tx.executed = false; } } } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } // Transfer GTO to an outside account /*function _withdrawGTO(address _to, uint256 _balance) onlyOwner internal { require(Gifto.balanceOf(address(this)) >= _balance); Gifto.transfer(_to, _balance); } // Transfer IAMI to an outside account function _withdrawIAMI(address _to, uint256 _balance) onlyOwner internal { require(IAMIToken.balanceOf(address(this)) >= _balance); IAMIToken.transfer(_to, _balance); } // Change Gifto contract's address or another type of token, like Ether. function setIAMITokenAddress(address newAddress) public onlyOwner { IAMIToken = ERC20(newAddress); } function setGiftoAddress(address newAddress) public onlyOwner { Gifto = ERC20(newAddress); }*/ modifier onlyOwner() { require(isOwner[msg.sender] == true); _; } /// @dev Create new forever rose. function createForeverRose() external onlyWallet { require(flag == true); CoinCreation(new DivisibleForeverRose()); flag = false; } }
16,137
8
// Base Token for ERC20 compatibilityERC20 interface/
contract ERC20 { //function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint); function allowance(address owner, address spender) public view returns (uint); function transfer(address to, uint value) public returns (bool ok); function transferFrom(address from, address to, uint value) public returns (bool); function approve(address spender, uint value) public returns (bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); }
contract ERC20 { //function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint); function allowance(address owner, address spender) public view returns (uint); function transfer(address to, uint value) public returns (bool ok); function transferFrom(address from, address to, uint value) public returns (bool); function approve(address spender, uint value) public returns (bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); }
30,923
83
// reduce bidRate
uint256 _price = user[_user][_index].price;
uint256 _price = user[_user][_index].price;
35,047
20
// div 10000^6
expo = expo / (10**24); if (expo > SAT) return 0; return (SAT - expo).mul(_tAmount);
expo = expo / (10**24); if (expo > SAT) return 0; return (SAT - expo).mul(_tAmount);
65,136
125
// Update lockedTokens amount before using it in computations after.updateAccounting();
unlockTokens(); uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(_initialSharesPerToken); UnlockSchedule memory schedule; schedule.initialLockedShares = mintedLockedShares; schedule.lastUnlockTimestampSec = now;
unlockTokens(); uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(_initialSharesPerToken); UnlockSchedule memory schedule; schedule.initialLockedShares = mintedLockedShares; schedule.lastUnlockTimestampSec = now;
48,174
38
// Reverts if the actual amount passed does not match the expected amount expected amount that should match the actual amount data bytes /
modifier isActualAmount(uint256 expected, bytes calldata data) { // decode register function arguments to get actual amount (, , , , , , , , , uint96 amount, ) = abi.decode( data[4:], (string, bytes, address, uint32, address, uint8, bytes, bytes, bytes, uint96, address) ); if (expected != amount) { revert AmountMismatch(); } _; }
modifier isActualAmount(uint256 expected, bytes calldata data) { // decode register function arguments to get actual amount (, , , , , , , , , uint96 amount, ) = abi.decode( data[4:], (string, bytes, address, uint32, address, uint8, bytes, bytes, bytes, uint96, address) ); if (expected != amount) { revert AmountMismatch(); } _; }
18,971
1
// Multiplies two unsigned integers, reverts on overflow. /
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
9,623
29
// Sets the contract level metadata URI hash. contractURIHash The hash to the initial contract level metadata. /
function setContractURIHash(string memory contractURIHash) external override onlyAdmin
function setContractURIHash(string memory contractURIHash) external override onlyAdmin
9,369
92
// Creates `amount` tokens and assigns them to `msg.sender`, increasingthe total supply. Requirements - `msg.sender` must be the token owner /
function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; }
function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; }
2,394
12
// accumulate the ticks derived from the current pool into the running synthetic ticks, ensuring that intermediate tokens "cancel out"
bool add = (i == 0) || (previousTokenIn < tokenIn ? tokenIn < tokenOut : tokenOut < tokenIn); if (add) { syntheticAverageTick += averageTick; syntheticCurrentTick += currentTick; } else {
bool add = (i == 0) || (previousTokenIn < tokenIn ? tokenIn < tokenOut : tokenOut < tokenIn); if (add) { syntheticAverageTick += averageTick; syntheticCurrentTick += currentTick; } else {
24,793
125
// Minimum number of payTokens to open a position
uint128 public minPay;
uint128 public minPay;
10,835
15
// Internal function to generate a random registration ID for a member
function _generateRandomId() private view returns (string memory) { uint256 randomNumber = uint256(keccak256(abi.encodePacked(block.timestamp, block.basefee, msg.sender))) % 10000; string memory registrationId = string(abi.encodePacked(toString(randomNumber), "JAM")); return registrationId; }
function _generateRandomId() private view returns (string memory) { uint256 randomNumber = uint256(keccak256(abi.encodePacked(block.timestamp, block.basefee, msg.sender))) % 10000; string memory registrationId = string(abi.encodePacked(toString(randomNumber), "JAM")); return registrationId; }
28,790
14
// Set a new URI for the items metadata_baseuri token URI in string format/
function setBaseURI(string memory _baseuri) external onlyOwner { baseURI = _baseuri; }
function setBaseURI(string memory _baseuri) external onlyOwner { baseURI = _baseuri; }
18,390
43
// Pending request completed
delete currentRequestId[packId][receiver];
delete currentRequestId[packId][receiver];
37,260
37
// Splits the slice, setting `self` to everything after the first occurrence of `needle`, and returning everything before it. If `needle` does not occur in `self`, `self` is set to the empty slice, and the entirety of `self` is returned. self The slice to split. needle The text to search for in `self`.return The part of `self` up to the first occurrence of `delim`. /
function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { split(self, needle, token); }
function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { split(self, needle, token); }
10,114
600
// Make sure received eth is enough
require(msg.value >= amountETH, 'Not enough ETH');
require(msg.value >= amountETH, 'Not enough ETH');
45,010
6
// not found
return;
return;
23,799
47
// ============ Init Functions ============
constructor( address _token, uint256 _startReleaseTime, uint256 _releaseDuration, uint256 _cliffRate
constructor( address _token, uint256 _startReleaseTime, uint256 _releaseDuration, uint256 _cliffRate
683
11
// Process disbursements.
for (uint256 i = 0; i < _numDisbursements; i++) { uint256 _amount = _disbursements[i].amount; address _addr = _disbursements[i].addr;
for (uint256 i = 0; i < _numDisbursements; i++) { uint256 _amount = _disbursements[i].amount; address _addr = _disbursements[i].addr;
14,350
187
// On monthly pools lender interest maybe be repayed in advance, therefore we should pay no interest
currentTs = block.timestamp; if (!isBulletLoan && accrualTs > currentTs) { currentTs = accrualTs; }
currentTs = block.timestamp; if (!isBulletLoan && accrualTs > currentTs) { currentTs = accrualTs; }
20,376
2
// Blocks data, in the form: blockHeaderHash => BlockHeader
mapping (uint => StoredBlockHeader) public blocks;
mapping (uint => StoredBlockHeader) public blocks;
31,489
69
// Discount (compared to the system coin's current redemption price) at which collateral is being sold
uint256 public discount = 0.95E18; // 5% discount // [wad]
uint256 public discount = 0.95E18; // 5% discount // [wad]
31,369
89
// Update the rewards and time
_updateStoredRewardsAndTime();
_updateStoredRewardsAndTime();
3,719
952
// 478
entry "head-first" : ENG_ADVERB
entry "head-first" : ENG_ADVERB
21,314
37
// Bonus levels per each round
mapping (uint256 => uint256) public bonusLevels;
mapping (uint256 => uint256) public bonusLevels;
64,639
186
// Returns the normalized variable debt per unit of asset asset The address of the underlying asset of the reservereturn The reserve normalized variable debt /
function getReserveNormalizedVariableDebt(address asset) external view returns (uint256);
function getReserveNormalizedVariableDebt(address asset) external view returns (uint256);
1,082
5
// Terminate flag
bool public terminated;
bool public terminated;
54,485
5
// Base client to interact with the registry.
contract ERC1820Client { ERC1820Registry constant ERC1820REGISTRY = ERC1820Registry( 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24 ); function setInterfaceImplementation( string memory _interfaceLabel, address _implementation ) internal { bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel)); ERC1820REGISTRY.setInterfaceImplementer( address(this), interfaceHash, _implementation ); } function interfaceAddr(address addr, string memory _interfaceLabel) internal view returns (address) { bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel)); return ERC1820REGISTRY.getInterfaceImplementer(addr, interfaceHash); } function delegateManagement(address _newManager) internal { ERC1820REGISTRY.setManager(address(this), _newManager); } }
contract ERC1820Client { ERC1820Registry constant ERC1820REGISTRY = ERC1820Registry( 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24 ); function setInterfaceImplementation( string memory _interfaceLabel, address _implementation ) internal { bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel)); ERC1820REGISTRY.setInterfaceImplementer( address(this), interfaceHash, _implementation ); } function interfaceAddr(address addr, string memory _interfaceLabel) internal view returns (address) { bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel)); return ERC1820REGISTRY.getInterfaceImplementer(addr, interfaceHash); } function delegateManagement(address _newManager) internal { ERC1820REGISTRY.setManager(address(this), _newManager); } }
12,625
20
// mapping(string => uint) storage tmp;
uint _patientId = patientId; string memory city = find_city(patientId); // we need to write a function to query the city if(isCityPresent[city] == 0){
uint _patientId = patientId; string memory city = find_city(patientId); // we need to write a function to query the city if(isCityPresent[city] == 0){
36,975
16
// Return bool indicating if this address is an active validator
return validators[_validatorAddress][currentValsetVersion];
return validators[_validatorAddress][currentValsetVersion];
34,755
50
// require(!_isBlackListedBot[recipient], "You have no power here!");require(!_isBlackListedBot[tx.origin], "You have no power here!");
_transfer(_msgSender(), recipient, amount); return true;
_transfer(_msgSender(), recipient, amount); return true;
23,026
29
// May be called from frontend to check if a refresh is required/advised Compare with characters.getNftVar(NFTVAR_POWER_DATA)
Characters characters = Characters(links[LINK_CHARACTERS]);
Characters characters = Characters(links[LINK_CHARACTERS]);
30,669
52
// Forward the fund to fund collection wallet.
wallet.transfer(msg.value);
wallet.transfer(msg.value);
24,094
2,504
// 1254
entry "stepmeal" : ENG_ADVERB
entry "stepmeal" : ENG_ADVERB
22,090
58
// unstaking possible after 72 hours
uint public constant cliffTime = 72 hours; uint public totalClaimedRewards = 0; EnumerableSet.AddressSet private holders;
uint public constant cliffTime = 72 hours; uint public totalClaimedRewards = 0; EnumerableSet.AddressSet private holders;
10,183
56
// add earned from the convex reward pool for the given token
d_reward = d_reward.add(IRewardStaking(reward.reward_pool).earned(address(this)));
d_reward = d_reward.add(IRewardStaking(reward.reward_pool).earned(address(this)));
30,368
772
// a raw call is required so we can return false if the call reverts, rather than reverting
bytes memory checkCalldata = abi.encodeWithSelector(sig, _who, _where, _what, _how); uint256 oracleCheckGas = ORACLE_CHECK_GAS; bool ok; assembly { ok := staticcall(oracleCheckGas, _oracleAddr, add(checkCalldata, 0x20), mload(checkCalldata), 0, 0) }
bytes memory checkCalldata = abi.encodeWithSelector(sig, _who, _where, _what, _how); uint256 oracleCheckGas = ORACLE_CHECK_GAS; bool ok; assembly { ok := staticcall(oracleCheckGas, _oracleAddr, add(checkCalldata, 0x20), mload(checkCalldata), 0, 0) }
14,473
73
// Updates external position unit for given borrow asset on SetToken /
function _updateBorrowPosition(ISetToken _setToken, IERC20 _underlyingAsset, int256 _newPositionUnit) internal { _setToken.editExternalPosition(address(_underlyingAsset), address(this), _newPositionUnit, ""); }
function _updateBorrowPosition(ISetToken _setToken, IERC20 _underlyingAsset, int256 _newPositionUnit) internal { _setToken.editExternalPosition(address(_underlyingAsset), address(this), _newPositionUnit, ""); }
14,131
3
// Prevents a contract from calling itself, directly or indirectly.Calling a `nonReentrant` function from another `nonReentrant`function is not supported. It is possible to prevent this from happeningby making the `nonReentrant` function external, and make it call a`private` function that does the actual work. /
modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); }
modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); }
1,448
87
// IStarNFT Galaxy Protocol Interface for operating with StarNFTs. /
interface IStarNFT is IERC1155 { /* ============ Events =============== */ // event PowahUpdated(uint256 indexed id, uint256 indexed oldPoints, uint256 indexed newPoints); /* ============ Functions ============ */ function isOwnerOf(address, uint256) external view returns (bool); // function starInfo(uint256) external view returns (uint128 powah, uint128 mintBlock, address originator); // function quasarInfo(uint256) external view returns (uint128 mintBlock, IERC20 stakeToken, uint256 amount, uint256 campaignID); // function superInfo(uint256) external view returns (uint128 mintBlock, IERC20[] memory stakeToken, uint256[] memory amount, uint256 campaignID); // mint function mint(address account, uint256 powah) external returns (uint256); function mintBatch(address account, uint256 amount, uint256[] calldata powahArr) external returns (uint256[] memory); function burn(address account, uint256 id) external; function burnBatch(address account, uint256[] calldata ids) external; // asset-backing mint // function mintQuasar(address account, uint256 powah, uint256 cid, IERC20 stakeToken, uint256 amount) external returns (uint256); // function burnQuasar(address account, uint256 id) external; // asset-backing forge // function mintSuper(address account, uint256 powah, uint256 campaignID, IERC20[] calldata stakeTokens, uint256[] calldata amounts) external returns (uint256); // function burnSuper(address account, uint256 id) external; // update // function updatePowah(address owner, uint256 id, uint256 powah) external; }
interface IStarNFT is IERC1155 { /* ============ Events =============== */ // event PowahUpdated(uint256 indexed id, uint256 indexed oldPoints, uint256 indexed newPoints); /* ============ Functions ============ */ function isOwnerOf(address, uint256) external view returns (bool); // function starInfo(uint256) external view returns (uint128 powah, uint128 mintBlock, address originator); // function quasarInfo(uint256) external view returns (uint128 mintBlock, IERC20 stakeToken, uint256 amount, uint256 campaignID); // function superInfo(uint256) external view returns (uint128 mintBlock, IERC20[] memory stakeToken, uint256[] memory amount, uint256 campaignID); // mint function mint(address account, uint256 powah) external returns (uint256); function mintBatch(address account, uint256 amount, uint256[] calldata powahArr) external returns (uint256[] memory); function burn(address account, uint256 id) external; function burnBatch(address account, uint256[] calldata ids) external; // asset-backing mint // function mintQuasar(address account, uint256 powah, uint256 cid, IERC20 stakeToken, uint256 amount) external returns (uint256); // function burnQuasar(address account, uint256 id) external; // asset-backing forge // function mintSuper(address account, uint256 powah, uint256 campaignID, IERC20[] calldata stakeTokens, uint256[] calldata amounts) external returns (uint256); // function burnSuper(address account, uint256 id) external; // update // function updatePowah(address owner, uint256 id, uint256 powah) external; }
5,979
167
// Deposits `amount` of `token` with `tokenId` from `from` into the `vault`/Virtual method to be implement in token specific UserAction contracts
function enterVault( address vault, address token, uint256 tokenId, address from, uint256 amount ) public virtual;
function enterVault( address vault, address token, uint256 tokenId, address from, uint256 amount ) public virtual;
71,976
155
// lib/dss-interfaces/src/dss/PotAbstract.sol/ pragma solidity >=0.5.12; / https:github.com/makerdao/dss/blob/master/src/pot.sol
interface PotAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function pie(address) external view returns (uint256); function Pie() external view returns (uint256); function dsr() external view returns (uint256); function chi() external view returns (uint256); function vat() external view returns (address); function vow() external view returns (address); function rho() external view returns (uint256); function live() external view returns (uint256); function file(bytes32, uint256) external; function file(bytes32, address) external; function cage() external; function drip() external returns (uint256); function join(uint256) external; function exit(uint256) external; }
interface PotAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function pie(address) external view returns (uint256); function Pie() external view returns (uint256); function dsr() external view returns (uint256); function chi() external view returns (uint256); function vat() external view returns (address); function vow() external view returns (address); function rho() external view returns (uint256); function live() external view returns (uint256); function file(bytes32, uint256) external; function file(bytes32, address) external; function cage() external; function drip() external returns (uint256); function join(uint256) external; function exit(uint256) external; }
10,218
27
// Allow a Lock manager to change the transfer fee. Throws if called by other than a Lock manager _transferFeeBasisPoints The new transfer fee in basis-points(bps).Ex: 200 bps = 2% /
function updateTransferFee(
function updateTransferFee(
30,067
121
// exit pool1. Transfer pool tokens from sender2. Burn pool tokens3. Transfer value of pool tokens in TUSD to sender /
function exit(uint256 amount) external;
function exit(uint256 amount) external;
26,640
15
// Transfer tokens Send `_value` tokens to `_to` from your account_to The address of the recipient _value the amount to send /
function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }
function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }
879
102
// ERC20 interface that includes burn and mint methods. /
abstract contract ExpandedIERC20 is IERC20 { /** * @notice Burns a specific amount of the caller's tokens. * @dev Only burns the caller's tokens, so it is safe to leave this method permissionless. */ function burn(uint256 value) external virtual; /** * @notice Mints tokens and adds them to the balance of the `to` address. * @dev This method should be permissioned to only allow designated parties to mint tokens. */ function mint(address to, uint256 value) external virtual returns (bool); }
abstract contract ExpandedIERC20 is IERC20 { /** * @notice Burns a specific amount of the caller's tokens. * @dev Only burns the caller's tokens, so it is safe to leave this method permissionless. */ function burn(uint256 value) external virtual; /** * @notice Mints tokens and adds them to the balance of the `to` address. * @dev This method should be permissioned to only allow designated parties to mint tokens. */ function mint(address to, uint256 value) external virtual returns (bool); }
1,059
25
// Royalty out of 10000
uint256 public royaltyBp; mapping(uint256 => uint256) public tokenToEdition; uint256 public nextEditionId;
uint256 public royaltyBp; mapping(uint256 => uint256) public tokenToEdition; uint256 public nextEditionId;
30,656
16
// require that they havent voted
require(!voted[msg.sender]);
require(!voted[msg.sender]);
4,459
20
// 0.881870060450728%
bonusToken = _balance.div(100000000000000000).mul(881870060450728);
bonusToken = _balance.div(100000000000000000).mul(881870060450728);
6,118
24
// Accept application to allow them to take the task./_taskId Id of the task./_applicationIds Indexes of the applications to accept.
function acceptApplications( uint256 _taskId, uint16[] calldata _applicationIds ) external;
function acceptApplications( uint256 _taskId, uint16[] calldata _applicationIds ) external;
22,826
170
// Owner is supposed to be a Governance Contract
function disburseRewardTokens() public onlyOwner { require(now.sub(lastBurnOrTokenDistributeTime) > burnOrDisburseTokensPeriod, "Recently executed, Please wait!"); // force reserves to match balances uniswapV2Pair.sync(); uint maxSwappableAmount = getMaxSwappableAmount(); uint _tokensToBeDisbursed = tokensToBeDisbursedOrBurnt; uint _tokensToBeBurnt; if (maxSwappableAmount < _tokensToBeDisbursed) { _tokensToBeBurnt = _tokensToBeDisbursed.sub(maxSwappableAmount); _tokensToBeDisbursed = maxSwappableAmount; } distributeDivs(_tokensToBeDisbursed); if (_tokensToBeBurnt > 0) { IERC20(trustedRewardTokenAddress).safeTransfer(BURN_ADDRESS, _tokensToBeBurnt); } tokensToBeDisbursedOrBurnt = 0; lastBurnOrTokenDistributeTime = now; }
function disburseRewardTokens() public onlyOwner { require(now.sub(lastBurnOrTokenDistributeTime) > burnOrDisburseTokensPeriod, "Recently executed, Please wait!"); // force reserves to match balances uniswapV2Pair.sync(); uint maxSwappableAmount = getMaxSwappableAmount(); uint _tokensToBeDisbursed = tokensToBeDisbursedOrBurnt; uint _tokensToBeBurnt; if (maxSwappableAmount < _tokensToBeDisbursed) { _tokensToBeBurnt = _tokensToBeDisbursed.sub(maxSwappableAmount); _tokensToBeDisbursed = maxSwappableAmount; } distributeDivs(_tokensToBeDisbursed); if (_tokensToBeBurnt > 0) { IERC20(trustedRewardTokenAddress).safeTransfer(BURN_ADDRESS, _tokensToBeBurnt); } tokensToBeDisbursedOrBurnt = 0; lastBurnOrTokenDistributeTime = now; }
9,463
12
// unlock the old fee token
depositLockOrUnlock( _traderBalanceVault, _order.feeToken, _order.protocolFee, _params.payFeeFromWallet, false ); _order.feeToken = feeToken;
depositLockOrUnlock( _traderBalanceVault, _order.feeToken, _order.protocolFee, _params.payFeeFromWallet, false ); _order.feeToken = feeToken;
16,476
140
// Performs a multiplication between two scaled numbers /
function scaledMul(uint256 a, uint256 b) internal pure returns (uint256) { return (a * b) / DECIMAL_SCALE; }
function scaledMul(uint256 a, uint256 b) internal pure returns (uint256) { return (a * b) / DECIMAL_SCALE; }
80,169
17
// Returns number of possible ruling options. Valid rulings are [0, count]. return count The number of ruling options. /
function numberOfRulingOptions(uint256) external pure override returns (uint256 count) { return NUMBER_OF_RULING_OPTIONS; }
function numberOfRulingOptions(uint256) external pure override returns (uint256 count) { return NUMBER_OF_RULING_OPTIONS; }
56,952
19
// The (percentage) fee rate applied to any gage-reward computations not using ETRNL (x 105)
bytes32 public immutable feeRate;
bytes32 public immutable feeRate;
32,021
118
// Starts earning and deposits all current balance into strategy.Anyone can call this function to start earning. /
function earn() public { if (strategy != address(0x0)) { uint256 _bal = token.balanceOf(address(this)); token.safeTransfer(strategy, _bal); IStrategy(strategy).deposit(); } }
function earn() public { if (strategy != address(0x0)) { uint256 _bal = token.balanceOf(address(this)); token.safeTransfer(strategy, _bal); IStrategy(strategy).deposit(); } }
4,328
74
// Query if a contract implements an interface, also checks support of ERC165 account The address of the contract to query for support of an interface interfaceId The interface identifier, as specified in ERC-165return true if the contract at account indicates support of the interface withidentifier interfaceId, false otherwise Interface identification is specified in ERC-165. /
function _supportsInterface(address account, bytes4 interfaceId) internal view returns (bool)
function _supportsInterface(address account, bytes4 interfaceId) internal view returns (bool)
30,084
0
// Fixed gas limit to ensure pairing precompile doesn't use entire gas limit upon reversion
uint256 public constant pairingGasLimit = 500e3;
uint256 public constant pairingGasLimit = 500e3;
38,717
5
// Emitted when liquidation incentive is changed by admin
event NewLiquidationIncentive(uint oldLiquidationIncentiveMantissa, uint newLiquidationIncentiveMantissa);
event NewLiquidationIncentive(uint oldLiquidationIncentiveMantissa, uint newLiquidationIncentiveMantissa);
18,860
73
// Transfers the ownership of a given token ID to another address.
* Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * Requires the msg.sender to be the owner, approved, or operator. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transferFrom(from, to, tokenId); }
* Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * Requires the msg.sender to be the owner, approved, or operator. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transferFrom(from, to, tokenId); }
237
3
// Calculated using invariant onchain properties. Note we DONT use safemath here
function _getTotalDepositsBob(address assetId) internal view returns (uint256)
function _getTotalDepositsBob(address assetId) internal view returns (uint256)
41,590
100
// make sure name fees paid
require (msg.value >= registrationFee_, "umm..... you have to pay the name fee");
require (msg.value >= registrationFee_, "umm..... you have to pay the name fee");
2,741
65
// Emitted when Kine changed
event NewKine(address oldKine, address newKine);
event NewKine(address oldKine, address newKine);
34,064
10
// A record of each account's voting power historical dataPrimarily data structure to store voting power for each account. Voting power sums up from the account's token balance and delegated balances.Stores current value and entire history of its changes. The changes are stored as an array of checkpoints (key-value pairs). Checkpoint is an auxiliary data structure containing voting power (number of votes) and block number when the checkpoint is savedMaps voting delegate => voting power record /
mapping(address => KV[]) public votingPowerHistory;
mapping(address => KV[]) public votingPowerHistory;
49,961
20
// Allow lending pool convert DAI deposited on this contract to aDAI on lending pool
uint MAX_ALLOWANCE = 2**256 - 1; address core = lendingPoolAddressProvider.getLendingPoolCore(); daiToken.approve(core, MAX_ALLOWANCE);
uint MAX_ALLOWANCE = 2**256 - 1; address core = lendingPoolAddressProvider.getLendingPoolCore(); daiToken.approve(core, MAX_ALLOWANCE);
3,795
8
// Called by a crowdsale contract upon creation./self Stored crowdsale from crowdsale contract/_owner Address of crowdsale owner/_saleData Array of 3 item sets such that, in each 3 element/ set, 1 is timestamp, 2 is price in tokens/ETH at that time,/ 3 is address purchase cap at that time, 0 if no address cap/_endTime Timestamp of sale end time/_percentBurn Percentage of extra tokens to burn/_staticCap Whether or not the address cap is going to be static/_token Token being sold
function init(EvenDistroCrowdsaleStorage storage self, address _owner, uint256[] _saleData, uint256 _endTime, uint8 _percentBurn, uint256 _initialAddressTokenCap, bool _staticCap, CrowdsaleToken _token) public
function init(EvenDistroCrowdsaleStorage storage self, address _owner, uint256[] _saleData, uint256 _endTime, uint8 _percentBurn, uint256 _initialAddressTokenCap, bool _staticCap, CrowdsaleToken _token) public
30,017
235
// See {ERC20-_beforeTokenTransfer}./
function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal virtual { }
function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal virtual { }
15,239
11
// Verify link signature is valid and unused V _currentAddress Address signing intention to link _addressToAdd Address being linked _nonce Unique nonce for this request _linkSignature Signature of address a /
function validateLinkSignature( address _currentAddress, address _addressToAdd, bytes32 _nonce, bytes memory _linkSignature
function validateLinkSignature( address _currentAddress, address _addressToAdd, bytes32 _nonce, bytes memory _linkSignature
33,981
344
// Constraint expression for pedersen/hash0/ec_subset_sum/add_points/x: column3_row0column3_row0 - pedersen__hash0__ec_subset_sum__bit_0(column1_row0 + pedersen__points__x + column1_row1).
let val := addmod( mulmod(/*column3_row0*/ mload(0x1920), /*column3_row0*/ mload(0x1920), PRIME), sub( PRIME, mulmod(
let val := addmod( mulmod(/*column3_row0*/ mload(0x1920), /*column3_row0*/ mload(0x1920), PRIME), sub( PRIME, mulmod(
33,851
35
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0)); require(balances[address(this)] >= tokens, "Insufficient tokens in contract"); balances[address(this)] = balances[address(this)].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(address(this),to,tokens); return true;
require(address(to) != address(0)); require(balances[address(this)] >= tokens, "Insufficient tokens in contract"); balances[address(this)] = balances[address(this)].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(address(this),to,tokens); return true;
16,950
17
// Also emitted when {transferDepositFrom} is called.
event Approval( address indexed owner, address indexed spender, uint256 amount );
event Approval( address indexed owner, address indexed spender, uint256 amount );
1,834
25
// set community sale merkleroot /
function setCommunitySaleMerkleRoot(bytes32 _merkleRoot) external onlyOwner { communitySaleMerkleRoot = _merkleRoot; }
function setCommunitySaleMerkleRoot(bytes32 _merkleRoot) external onlyOwner { communitySaleMerkleRoot = _merkleRoot; }
49,177
372
// add new element into array representing the value for current block
history.push(VotingPowerRecord(uint64(block.number), uint192(_toVal)));
history.push(VotingPowerRecord(uint64(block.number), uint192(_toVal)));
49,938
10
// Borrows tokens on the given position.
function borrow( address _owner, uint _pid, uint _amount ) external;
function borrow( address _owner, uint _pid, uint _amount ) external;
73,922
121
// only locker can add investor lock /
function addInvestorLock( address account, uint256 startsAt, uint256 period, uint256 count
function addInvestorLock( address account, uint256 startsAt, uint256 period, uint256 count
16,987
20
// Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a static call. _Available since v3.3._/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract");
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract");
32,214
71
// event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity );
event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity );
55,300
19
// Check and update the pending executionResult record. _tnBytes The packedExecutionResult transition bytes. _blockId Commit block Id. /
function checkPendingExecutionResult(bytes memory _tnBytes, uint256 _blockId) external onlyController { dt.ExecutionResultTransition memory er = tn.decodePackedExecutionResultTransition(_tnBytes); EventQueuePointer memory queuePointer = execResultQueuePointers[er.strategyId]; uint64 aggregateId = queuePointer.commitHead; require(aggregateId < queuePointer.tail, ErrMsg.REQ_BAD_EXECRES_TN); bytes32 ehash = keccak256( abi.encodePacked(er.strategyId, er.aggregateId, er.success, er.sharesFromBuy, er.amountFromSell) ); require(pendingExecResults[er.strategyId][aggregateId].ehash == ehash, ErrMsg.REQ_BAD_HASH); pendingExecResults[er.strategyId][aggregateId].status = PendingEventStatus.Done; pendingExecResults[er.strategyId][aggregateId].blockId = uint64(_blockId); // "done": block holding the transition queuePointer.commitHead++; execResultQueuePointers[er.strategyId] = queuePointer; }
function checkPendingExecutionResult(bytes memory _tnBytes, uint256 _blockId) external onlyController { dt.ExecutionResultTransition memory er = tn.decodePackedExecutionResultTransition(_tnBytes); EventQueuePointer memory queuePointer = execResultQueuePointers[er.strategyId]; uint64 aggregateId = queuePointer.commitHead; require(aggregateId < queuePointer.tail, ErrMsg.REQ_BAD_EXECRES_TN); bytes32 ehash = keccak256( abi.encodePacked(er.strategyId, er.aggregateId, er.success, er.sharesFromBuy, er.amountFromSell) ); require(pendingExecResults[er.strategyId][aggregateId].ehash == ehash, ErrMsg.REQ_BAD_HASH); pendingExecResults[er.strategyId][aggregateId].status = PendingEventStatus.Done; pendingExecResults[er.strategyId][aggregateId].blockId = uint64(_blockId); // "done": block holding the transition queuePointer.commitHead++; execResultQueuePointers[er.strategyId] = queuePointer; }
21,529
29
// calculate some stuff
users[_user].hardworker.time = now; users[_user].hardworker.seq++; if (users[_user].hardworker.seq % 7 == 0 && users[_user].hardworker.seq > 0 && users[_user].hardworker.seq < 42) { users[_user].info.score += 100; users[_user].alltime.score += 100; AllScore += 100; emit ScoreEarned(_user); emit HardworkerSeq(_user, users[_user].hardworker.seq, users[_user].hardworker.title); return;
users[_user].hardworker.time = now; users[_user].hardworker.seq++; if (users[_user].hardworker.seq % 7 == 0 && users[_user].hardworker.seq > 0 && users[_user].hardworker.seq < 42) { users[_user].info.score += 100; users[_user].alltime.score += 100; AllScore += 100; emit ScoreEarned(_user); emit HardworkerSeq(_user, users[_user].hardworker.seq, users[_user].hardworker.title); return;
38,156
17
// This is called during the initialization of a new pool. It registers thepool for this pair and type in storage for later access. Note that thecaller still needs to actually construct the curve, collect the requiredcollateral, etc. All this does is storage the pool specs. base The base-side token (or 0x0 for native Eth) defining the pair. quote The quote-side token defining the pair. poolIdx The pool type index for the newly created pool. The pool specs will be created from the current template for this index. (If notemplate exists, this call will revert the transaction.) return pool The pool
returns (PoolSpecs.PoolCursor memory, uint128) { assertPoolFresh(base, quote, poolIdx); PoolSpecs.Pool memory template = queryTemplate(poolIdx); template.protocolTake_ = protocolTakeRate_; PoolSpecs.writePool(pools_, base, quote, poolIdx, template); return (queryPool(base, quote, poolIdx), newPoolLiq_); }
returns (PoolSpecs.PoolCursor memory, uint128) { assertPoolFresh(base, quote, poolIdx); PoolSpecs.Pool memory template = queryTemplate(poolIdx); template.protocolTake_ = protocolTakeRate_; PoolSpecs.writePool(pools_, base, quote, poolIdx, template); return (queryPool(base, quote, poolIdx), newPoolLiq_); }
13,159
539
// revokes pcvController role from address/pcvController ex pcvController
function revokePCVController(address pcvController) external override onlyGovernor { revokeRole(PCV_CONTROLLER_ROLE, pcvController); }
function revokePCVController(address pcvController) external override onlyGovernor { revokeRole(PCV_CONTROLLER_ROLE, pcvController); }
9,246
8
// Throws if the msg.sender is not admin or owner.
modifier onlyAdmin() { require(msg.sender == admin || msg.sender == owner); _; }
modifier onlyAdmin() { require(msg.sender == admin || msg.sender == owner); _; }
16,688
37
// funds successfully unstaked - emit new event
emit StakeWithdrawn(_msgSender(), tokenAddress, amount);
emit StakeWithdrawn(_msgSender(), tokenAddress, amount);
33,225
61
// Require that the signature is not expired
require( deadline == 0 || block.timestamp <= deadline, "ERC20: permit-expired" );
require( deadline == 0 || block.timestamp <= deadline, "ERC20: permit-expired" );
3,880
37
// set a new fee for an specific contract type restricted to master
function updateFee(uint256 _masterFee) public onlyMaster { // set master parameters masterFee = _masterFee; }
function updateFee(uint256 _masterFee) public onlyMaster { // set master parameters masterFee = _masterFee; }
6,430
53
// If there is no existing outflow, then create new flow to equal inflow
(newCtx, ) = _host.callAgreementWithContext( _cfa, abi.encodeWithSelector( _cfa.createFlow.selector, backerToken, customer, backerFlowRate, new bytes(0) // placeholder ), "0x",
(newCtx, ) = _host.callAgreementWithContext( _cfa, abi.encodeWithSelector( _cfa.createFlow.selector, backerToken, customer, backerFlowRate, new bytes(0) // placeholder ), "0x",
22,509
19
// Winning outcome should be set
require(eventContract.isOutcomeSet()); market.close(); market.withdrawFees(); eventContract.redeemWinnings(); finalBalance = eventContract.collateralToken().balanceOf(address(this)); stage = Stages.MarketClosed; emit MarketClosing();
require(eventContract.isOutcomeSet()); market.close(); market.withdrawFees(); eventContract.redeemWinnings(); finalBalance = eventContract.collateralToken().balanceOf(address(this)); stage = Stages.MarketClosed; emit MarketClosing();
23,902