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
13
// Function will fail if the proof is not a valid inclusion or exclusion proof.
( bool exists, bytes memory encodedAccount ) = Lib_SecureMerkleTrie.get( abi.encodePacked(_ovmContractAddress), _stateTrieWitness, preStateRoot ); if (exists == true) {
( bool exists, bytes memory encodedAccount ) = Lib_SecureMerkleTrie.get( abi.encodePacked(_ovmContractAddress), _stateTrieWitness, preStateRoot ); if (exists == true) {
15,577
10
// Hook called by CFA contract on flow update/This function triggers the metadata update of both COF and CIF NFTs/superToken the SuperToken contract address/flowSender the flow sender/flowReceiver the flow receiver/ NOTE: We do an existence check in here to determine whether or not to execute the hook
function onUpdate( ISuperfluidToken superToken, address flowSender, address flowReceiver
function onUpdate( ISuperfluidToken superToken, address flowSender, address flowReceiver
6,600
40
// ...and send them to the customer
AssetLike(asset).exit(dealStorage.customer, dealStorage.value); emit Refund(dealStorage.provider, serviceId);
AssetLike(asset).exit(dealStorage.customer, dealStorage.value); emit Refund(dealStorage.provider, serviceId);
12,927
308
// DyDx calls this function after doing flash loan
function callFunction( address sender, Account.Info memory account, bytes memory data
function callFunction( address sender, Account.Info memory account, bytes memory data
9,903
4
// Ir Orc has only a last name
if (bytes(_firstNames[orcId]).length == 0 && bytes(_lastNames[orcId]).length > 0) return _lastNames[orcId]; return string(abi.encodePacked(_firstNames[orcId], " ", _lastNames[orcId]));
if (bytes(_firstNames[orcId]).length == 0 && bytes(_lastNames[orcId]).length > 0) return _lastNames[orcId]; return string(abi.encodePacked(_firstNames[orcId], " ", _lastNames[orcId]));
34,666
31
// send ether to the fund collection wallet override to create custom fund forwarding mechanisms
function forwardFunds() internal { wallet.transfer(msg.value); }
function forwardFunds() internal { wallet.transfer(msg.value); }
12,643
144
// Bond a validator _valAddr the address of the validator /
function _bondValidator(address _valAddr) private { bondedValAddrs.push(_valAddr); _setBondedValidator(_valAddr); }
function _bondValidator(address _valAddr) private { bondedValAddrs.push(_valAddr); _setBondedValidator(_valAddr); }
43,175
11
// Returns pool total assets value/ return poolTotalAssetsValue
function getPoolTotalAssetsValue() external view returns (uint256);
function getPoolTotalAssetsValue() external view returns (uint256);
8,414
67
// Returns the ERC20 token balance of a given account. /
function balanceOf(address account) public view returns (uint) { return tokenState.balanceOf(account); }
function balanceOf(address account) public view returns (uint) { return tokenState.balanceOf(account); }
2,283
127
// ============ State Variables ============ Supported burnable tokens on the local domain local token (address) => maximum burn amounts per message
mapping(address => uint256) public burnLimitsPerMessage;
mapping(address => uint256) public burnLimitsPerMessage;
42,691
9
// send all money to chris
chris.transfer(address(this).balance);
chris.transfer(address(this).balance);
46,298
13
// Extend close time if it's required
uint256 bidTimeOffset = _auction_closeTimestamp[tokenContract][tokenId].sub(block.timestamp); if (bidTimeOffset < _extensionTimePeriod) { _auction_closeTimestamp[tokenContract][tokenId] = _auction_closeTimestamp[tokenContract][tokenId].add( _extensionTimePeriod.sub(bidTimeOffset) ); }
uint256 bidTimeOffset = _auction_closeTimestamp[tokenContract][tokenId].sub(block.timestamp); if (bidTimeOffset < _extensionTimePeriod) { _auction_closeTimestamp[tokenContract][tokenId] = _auction_closeTimestamp[tokenContract][tokenId].add( _extensionTimePeriod.sub(bidTimeOffset) ); }
11,348
127
// MegaMoonToken with Governance.
contract MegaMoonToken is BEP20('MegaMoonToken Token', 'Moon') { /// @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 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), "Moon::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "Moon::delegateBySig: invalid nonce"); require(now <= expiry, "Moon::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "Moon::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 Moons (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, "Moon::_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 MegaMoonToken is BEP20('MegaMoonToken Token', 'Moon') { /// @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 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), "Moon::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "Moon::delegateBySig: invalid nonce"); require(now <= expiry, "Moon::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "Moon::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 Moons (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, "Moon::_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; } }
15,292
22
// Used for calculationg inscription Ids when adding without a sig
uint256 latestInscriptionId;
uint256 latestInscriptionId;
748
20
// Mints MadBytes. This function receives ether in the transaction and/ converts them into MadBytes using a bonding price curve./minMB_ Minimum amount of MadBytes that you wish to mint given an/ amount of ether. If its not possible to mint the desired amount with the/ current price in the bonding curve, the transaction is reverted. If the/ minMB_ is met, the whole amount of ether sent will be converted in MadBytes./ Return The number of MadBytes minted
function mint(uint256 minMB_) public payable returns(uint256 nuMB) { nuMB = _mint(msg.sender, msg.value, minMB_); return nuMB; }
function mint(uint256 minMB_) public payable returns(uint256 nuMB) { nuMB = _mint(msg.sender, msg.value, minMB_); return nuMB; }
824
62
// result is unused for now solhint-disable-next-line no-unused-vars
(bool success, bytes memory result) =
(bool success, bytes memory result) =
68,794
162
// tracks auto generated BNB, useful for ticker etc
uint256 public totalLPBNB;
uint256 public totalLPBNB;
13,603
208
// Get issue data from the registry. _repoId The id of the repo in the projects registry /
function getIssue(bytes32 _repoId, uint256 _issueNumber) external view isInitialized returns(bool hasBounty, uint standardBountyId, bool fulfilled, uint balance, address assignee)
function getIssue(bytes32 _repoId, uint256 _issueNumber) external view isInitialized returns(bool hasBounty, uint standardBountyId, bool fulfilled, uint balance, address assignee)
9,844
18
// this is a uint8 rather than a 256 for storage.
uint8 internal noOfAdmins_;
uint8 internal noOfAdmins_;
12,207
9
// Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_APES; }
if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_APES; }
25,205
196
// Reset protocolTokenToGov mapping
for (uint256 i = 0; i < allAvailableTokens.length; i++) { protocolTokenToGov[allAvailableTokens[i]] = address(0); }
for (uint256 i = 0; i < allAvailableTokens.length; i++) { protocolTokenToGov[allAvailableTokens[i]] = address(0); }
6,334
65
// Token Claim
mapping (address => uint) public ethContributedForTokens; uint256 public TokenPerETHUnit; uint256 public bonusTokens = 50000 * 10**9; address public devAddr; event LiquidityAddition(address indexed dst, uint value); event LPTokenClaimed(address dst, uint value); event TokenClaimed(address dst, uint value);
mapping (address => uint) public ethContributedForTokens; uint256 public TokenPerETHUnit; uint256 public bonusTokens = 50000 * 10**9; address public devAddr; event LiquidityAddition(address indexed dst, uint value); event LPTokenClaimed(address dst, uint value); event TokenClaimed(address dst, uint value);
7,783
55
// Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
* can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
31,713
311
// we do a flash loan to give us a big gap. from here on out it is cheaper to use normal deleverage. Use Aave for extremely large loans
if (DyDxActive) { position = position.sub(flashLoanPlugin.doDyDxFlashLoan(deficit, position)); }
if (DyDxActive) { position = position.sub(flashLoanPlugin.doDyDxFlashLoan(deficit, position)); }
4,649
0
// Token Name: TPC TokenContract Name: Third Payment CirculationAuthor: kolidatgmail.comDeveloped for: TPC LLC.TPC is an ERC20 Token /
contract ERC20 { function totalSupply() public view returns (uint supply); function balanceOf(address who) public view returns (uint value); function allowance(address owner, address spender ) public view returns (uint _allowance); function transfer(address to, uint value) public returns (bool ok); function transferFrom(address from, address to, uint value) public returns (bool ok); function approve(address spender, uint value ) public returns (bool ok); 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 (uint supply); function balanceOf(address who) public view returns (uint value); function allowance(address owner, address spender ) public view returns (uint _allowance); function transfer(address to, uint value) public returns (bool ok); function transferFrom(address from, address to, uint value) public returns (bool ok); function approve(address spender, uint value ) public returns (bool ok); event Transfer( address indexed from, address indexed to, uint value); event Approval( address indexed owner, address indexed spender, uint value); }
1,171
6
// Returns true if `user` has approved `relayer` to act as a relayer for them. /
function hasApprovedRelayer(address user, address relayer) external view returns (bool);
function hasApprovedRelayer(address user, address relayer) external view returns (bool);
22,183
298
// execute the actual withdrawal
_executeWithdrawal(contextId, provider, pool, data, poolTokenAmount, amounts); return amounts.baseTokensToTransferFromMasterVault;
_executeWithdrawal(contextId, provider, pool, data, poolTokenAmount, amounts); return amounts.baseTokensToTransferFromMasterVault;
75,557
19
// ISuppliable ISuppliable interface /
interface ISuppliable { function isSupplier(address _supplier) external view returns (bool); function addSupplier(address _supplier) external; function removeSupplier(address _supplier) external; event SupplierAdded(address indexed supplier); event SupplierRemoved(address indexed supplier); }
interface ISuppliable { function isSupplier(address _supplier) external view returns (bool); function addSupplier(address _supplier) external; function removeSupplier(address _supplier) external; event SupplierAdded(address indexed supplier); event SupplierRemoved(address indexed supplier); }
78,822
65
// ERC721, transfer loan to another address
lendersBalance[msg.sender] -= 1; lendersBalance[to] += 1; Transfer(loan.lender, to, index); return true;
lendersBalance[msg.sender] -= 1; lendersBalance[to] += 1; Transfer(loan.lender, to, index); return true;
2,217
57
// user => token => credit
mapping (address => mapping(address => uint)) public credit;
mapping (address => mapping(address => uint)) public credit;
15,964
36
// Adding 1 due to burning token 0
_maxSupply = maxSupply + 1;
_maxSupply = maxSupply + 1;
15,929
20
// Appends a byte array to the end of the buffer. Resizes if doing sowould exceed the capacity of the buffer._buf The buffer to append to._data The data to append. return _buffer The original buffer./
function append(buffer memory _buf, bytes memory _data) internal pure returns (buffer memory _buffer) { if (_data.length + _buf.buf.length > _buf.capacity) { resize(_buf, max(_buf.capacity, _data.length) * 2); } uint dest; uint src; uint len = _data.length; assembly { let bufptr := mload(_buf) // Memory address of the buffer data let buflen := mload(bufptr) // Length of existing buffer data dest := add(add(bufptr, buflen), 32) // Start address = buffer address + buffer length + sizeof(buffer length) mstore(bufptr, add(buflen, mload(_data))) // Update buffer length src := add(_data, 32) } for(; len >= 32; len -= 32) { // Copy word-length chunks while possible assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint mask = 256 ** (32 - len) - 1; // Copy remaining bytes assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } return _buf; }
function append(buffer memory _buf, bytes memory _data) internal pure returns (buffer memory _buffer) { if (_data.length + _buf.buf.length > _buf.capacity) { resize(_buf, max(_buf.capacity, _data.length) * 2); } uint dest; uint src; uint len = _data.length; assembly { let bufptr := mload(_buf) // Memory address of the buffer data let buflen := mload(bufptr) // Length of existing buffer data dest := add(add(bufptr, buflen), 32) // Start address = buffer address + buffer length + sizeof(buffer length) mstore(bufptr, add(buflen, mload(_data))) // Update buffer length src := add(_data, 32) } for(; len >= 32; len -= 32) { // Copy word-length chunks while possible assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint mask = 256 ** (32 - len) - 1; // Copy remaining bytes assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } return _buf; }
36,189
61
// Emits an {IERC1155-TransferSingle} event. from Address of the current token owner. id Identifier of the token to burn. value Amount of token to burn. /
function burnFrom( address from, uint256 id, uint256 value ) external;
function burnFrom( address from, uint256 id, uint256 value ) external;
10,152
979
// https:etherscan.io/address/0xB34F4d7c207D8979D05EDb0F63f174764Bd67825
MultiCollateralSynth public constant synthsada_i = MultiCollateralSynth(0xB34F4d7c207D8979D05EDb0F63f174764Bd67825);
MultiCollateralSynth public constant synthsada_i = MultiCollateralSynth(0xB34F4d7c207D8979D05EDb0F63f174764Bd67825);
34,457
255
// Transfer reward token to sender
rewardToken.safeTransfer(msg.sender, pendingRewards); emit Harvest(msg.sender, pendingRewards);
rewardToken.safeTransfer(msg.sender, pendingRewards); emit Harvest(msg.sender, pendingRewards);
68,468
77
// Ensure that a non-zero recipient has been supplied.
if (recipient == address(0)) { revert(_revertReason(1)); }
if (recipient == address(0)) { revert(_revertReason(1)); }
16,708
2
// Notifies the controller about a token transfer allowing the/controller to react if desired/_from The origin of the transfer/_to The destination of the transfer/_amount The amount of the transfer/ return False if the controller does not authorize the transfer
function onTransfer(address _from, address _to, uint _amount) returns(bool);
function onTransfer(address _from, address _to, uint _amount) returns(bool);
1,713
186
// Optimism L1 Escrow Address
L1EscrowLike(OPTIMISM_ESCROW).approve(MCD_DAI, address(this), 10 * MILLION * WAD); TokenLike(MCD_DAI).transferFrom(OPTIMISM_ESCROW, LOST_SOME_DAI_WALLET, 10 * MILLION * WAD);
L1EscrowLike(OPTIMISM_ESCROW).approve(MCD_DAI, address(this), 10 * MILLION * WAD); TokenLike(MCD_DAI).transferFrom(OPTIMISM_ESCROW, LOST_SOME_DAI_WALLET, 10 * MILLION * WAD);
2,394
18
// if token is already set, don't allow it to set a different L2 address
require(currL2Addr == _l2Address, "NO_UPDATE_TO_DIFFERENT_ADDR");
require(currL2Addr == _l2Address, "NO_UPDATE_TO_DIFFERENT_ADDR");
22,378
537
// Updates the reserve current stable borrow rate Rf, the current variable borrow rate Rv and the current liquidity rate Rl. Also updates the lastUpdateTimestamp value. Please refer to the whitepaper for further information._reserve the address of the reserve to be updated_liquidityAdded the amount of liquidity added to the protocol (deposit or repay) in the previous action_liquidityTaken the amount of liquidity taken from the protocol (redeem or borrow)/
) internal { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; (uint256 newLiquidityRate, uint256 newStableRate, uint256 newVariableRate) = IReserveInterestRateStrategy( reserve .interestRateStrategyAddress ) .calculateInterestRates( _reserve, getReserveAvailableLiquidity(_reserve).add(_liquidityAdded).sub(_liquidityTaken), reserve.totalBorrowsStable, reserve.totalBorrowsVariable, reserve.currentAverageStableBorrowRate ); reserve.currentLiquidityRate = newLiquidityRate; reserve.currentStableBorrowRate = newStableRate; reserve.currentVariableBorrowRate = newVariableRate; //solium-disable-next-line reserve.lastUpdateTimestamp = uint40(block.timestamp); emit ReserveUpdated( _reserve, newLiquidityRate, newStableRate, newVariableRate, reserve.lastLiquidityCumulativeIndex, reserve.lastVariableBorrowCumulativeIndex ); }
) internal { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; (uint256 newLiquidityRate, uint256 newStableRate, uint256 newVariableRate) = IReserveInterestRateStrategy( reserve .interestRateStrategyAddress ) .calculateInterestRates( _reserve, getReserveAvailableLiquidity(_reserve).add(_liquidityAdded).sub(_liquidityTaken), reserve.totalBorrowsStable, reserve.totalBorrowsVariable, reserve.currentAverageStableBorrowRate ); reserve.currentLiquidityRate = newLiquidityRate; reserve.currentStableBorrowRate = newStableRate; reserve.currentVariableBorrowRate = newVariableRate; //solium-disable-next-line reserve.lastUpdateTimestamp = uint40(block.timestamp); emit ReserveUpdated( _reserve, newLiquidityRate, newStableRate, newVariableRate, reserve.lastLiquidityCumulativeIndex, reserve.lastVariableBorrowCumulativeIndex ); }
18,805
27
// onlyOwner/It allows owner to modify allAvailableTokens array in case of emergencyie if a bug on a interest bearing token is discovered and reset protocolWrappersassociated with those tokens.protocolTokens : array of protocolTokens addresses (eg [cDAI, iDAI, ...]) wrappers : array of wrapper addresses (eg [IdleCompound, IdleFulcrum, ...]) allocations : array of allocations keepAllocations : whether to update lastRebalancerAllocations or not /
function setAllAvailableTokensAndWrappers( address[] calldata protocolTokens, address[] calldata wrappers, uint256[] calldata allocations, bool keepAllocations
function setAllAvailableTokensAndWrappers( address[] calldata protocolTokens, address[] calldata wrappers, uint256[] calldata allocations, bool keepAllocations
22,776
898
// Transfers ERC20 Currency asset from this Pool to another Pool on upgrade. /
function _upgradeCapitalPool( bytes4 _curr, address _newPoolAddress ) internal
function _upgradeCapitalPool( bytes4 _curr, address _newPoolAddress ) internal
29,431
48
// return { "caddr": "the associated user contract address" }
function find(bytes32 username) constant returns (address caddr) {
function find(bytes32 username) constant returns (address caddr) {
23,513
5
// Greeter/Cyrus Adkisson The contract definition. A constructor of the same name will be automatically called on contract creation.
contract Suicide { // At first, an empty "address"-type variable of the name "creator". Will be set in the constructor. address creator; // The constructor. It accepts a string input and saves it to the contract's "greeting" variable. constructor() payable { creator = msg.sender; } /********** Standard kill() function to recover funds **********/ function kill() public payable { if (msg.sender == creator){ selfdestruct( payable(msg.sender)); } } receive() external payable{ } fallback() external payable{ } }
contract Suicide { // At first, an empty "address"-type variable of the name "creator". Will be set in the constructor. address creator; // The constructor. It accepts a string input and saves it to the contract's "greeting" variable. constructor() payable { creator = msg.sender; } /********** Standard kill() function to recover funds **********/ function kill() public payable { if (msg.sender == creator){ selfdestruct( payable(msg.sender)); } } receive() external payable{ } fallback() external payable{ } }
51,565
49
// Returns the balances so that they'll be in the order [underlying, bond]./currentBalances balances sorted low to high of address value.
function _getSortedBalances(uint256[] memory currentBalances) internal view returns (uint256 underlyingBalance, uint256 bondBalance)
function _getSortedBalances(uint256[] memory currentBalances) internal view returns (uint256 underlyingBalance, uint256 bondBalance)
66,562
135
// Actions Opyn Team A library that provides a ActionArgs struct, sub types of Action structs, and functions to parse ActionArgs into specific Actions. /
library Actions { // possible actions that can be performed enum ActionType { OpenVault, MintShortOption, BurnShortOption, DepositLongOption, WithdrawLongOption, DepositCollateral, WithdrawCollateral, SettleVault, Redeem, Call } struct ActionArgs { // type of action that is being performed on the system ActionType actionType; // address of the account owner address owner; // address which we move assets from or to (depending on the action type) address secondAddress; // asset that is to be transfered address asset; // index of the vault that is to be modified (if any) uint256 vaultId; // amount of asset that is to be transfered uint256 amount; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // any other data that needs to be passed in for arbitrary function calls bytes data; } struct MintArgs { // address of the account owner address owner; // index of the vault from which the asset will be minted uint256 vaultId; // address to which we transfer the minted oTokens address to; // oToken that is to be minted address otoken; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // amount of oTokens that is to be minted uint256 amount; } struct BurnArgs { // address of the account owner address owner; // index of the vault from which the oToken will be burned uint256 vaultId; // address from which we transfer the oTokens address from; // oToken that is to be burned address otoken; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // amount of oTokens that is to be burned uint256 amount; } struct OpenVaultArgs { // address of the account owner address owner; // vault id to create uint256 vaultId; } struct DepositArgs { // address of the account owner address owner; // index of the vault to which the asset will be added uint256 vaultId; // address from which we transfer the asset address from; // asset that is to be deposited address asset; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // amount of asset that is to be deposited uint256 amount; } struct RedeemArgs { // address to which we pay out the oToken proceeds address receiver; // oToken that is to be redeemed address otoken; // amount of oTokens that is to be redeemed uint256 amount; } struct WithdrawArgs { // address of the account owner address owner; // index of the vault from which the asset will be withdrawn uint256 vaultId; // address to which we transfer the asset address to; // asset that is to be withdrawn address asset; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // amount of asset that is to be withdrawn uint256 amount; } struct SettleVaultArgs { // address of the account owner address owner; // index of the vault to which is to be settled uint256 vaultId; // address to which we transfer the remaining collateral address to; } struct CallArgs { // address of the callee contract address callee; // data field for external calls bytes data; } /** * @notice parses the passed in action arguments to get the arguments for an open vault action * @param _args general action arguments structure * @return arguments for a open vault action */ function _parseOpenVaultArgs(ActionArgs memory _args) internal pure returns (OpenVaultArgs memory) { require(_args.actionType == ActionType.OpenVault, "Actions: can only parse arguments for open vault actions"); require(_args.owner != address(0), "Actions: cannot open vault for an invalid account"); return OpenVaultArgs({owner: _args.owner, vaultId: _args.vaultId}); } /** * @notice parses the passed in action arguments to get the arguments for a mint action * @param _args general action arguments structure * @return arguments for a mint action */ function _parseMintArgs(ActionArgs memory _args) internal pure returns (MintArgs memory) { require(_args.actionType == ActionType.MintShortOption, "Actions: can only parse arguments for mint actions"); require(_args.owner != address(0), "Actions: cannot mint from an invalid account"); return MintArgs({ owner: _args.owner, vaultId: _args.vaultId, to: _args.secondAddress, otoken: _args.asset, index: _args.index, amount: _args.amount }); } /** * @notice parses the passed in action arguments to get the arguments for a burn action * @param _args general action arguments structure * @return arguments for a burn action */ function _parseBurnArgs(ActionArgs memory _args) internal pure returns (BurnArgs memory) { require(_args.actionType == ActionType.BurnShortOption, "Actions: can only parse arguments for burn actions"); require(_args.owner != address(0), "Actions: cannot burn from an invalid account"); return BurnArgs({ owner: _args.owner, vaultId: _args.vaultId, from: _args.secondAddress, otoken: _args.asset, index: _args.index, amount: _args.amount }); } /** * @notice parses the passed in action arguments to get the arguments for a deposit action * @param _args general action arguments structure * @return arguments for a deposit action */ function _parseDepositArgs(ActionArgs memory _args) internal pure returns (DepositArgs memory) { require( (_args.actionType == ActionType.DepositLongOption) || (_args.actionType == ActionType.DepositCollateral), "Actions: can only parse arguments for deposit actions" ); require(_args.owner != address(0), "Actions: cannot deposit to an invalid account"); return DepositArgs({ owner: _args.owner, vaultId: _args.vaultId, from: _args.secondAddress, asset: _args.asset, index: _args.index, amount: _args.amount }); } /** * @notice parses the passed in action arguments to get the arguments for a withdraw action * @param _args general action arguments structure * @return arguments for a withdraw action */ function _parseWithdrawArgs(ActionArgs memory _args) internal pure returns (WithdrawArgs memory) { require( (_args.actionType == ActionType.WithdrawLongOption) || (_args.actionType == ActionType.WithdrawCollateral), "Actions: can only parse arguments for withdraw actions" ); require(_args.owner != address(0), "Actions: cannot withdraw from an invalid account"); require(_args.secondAddress != address(0), "Actions: cannot withdraw to an invalid account"); return WithdrawArgs({ owner: _args.owner, vaultId: _args.vaultId, to: _args.secondAddress, asset: _args.asset, index: _args.index, amount: _args.amount }); } /** * @notice parses the passed in action arguments to get the arguments for an redeem action * @param _args general action arguments structure * @return arguments for a redeem action */ function _parseRedeemArgs(ActionArgs memory _args) internal pure returns (RedeemArgs memory) { require(_args.actionType == ActionType.Redeem, "Actions: can only parse arguments for redeem actions"); require(_args.secondAddress != address(0), "Actions: cannot redeem to an invalid account"); return RedeemArgs({receiver: _args.secondAddress, otoken: _args.asset, amount: _args.amount}); } /** * @notice parses the passed in action arguments to get the arguments for a settle vault action * @param _args general action arguments structure * @return arguments for a settle vault action */ function _parseSettleVaultArgs(ActionArgs memory _args) internal pure returns (SettleVaultArgs memory) { require( _args.actionType == ActionType.SettleVault, "Actions: can only parse arguments for settle vault actions" ); require(_args.owner != address(0), "Actions: cannot settle vault for an invalid account"); require(_args.secondAddress != address(0), "Actions: cannot withdraw payout to an invalid account"); return SettleVaultArgs({owner: _args.owner, vaultId: _args.vaultId, to: _args.secondAddress}); } /** * @notice parses the passed in action arguments to get the arguments for a call action * @param _args general action arguments structure * @return arguments for a call action */ function _parseCallArgs(ActionArgs memory _args) internal pure returns (CallArgs memory) { require(_args.actionType == ActionType.Call, "Actions: can only parse arguments for call actions"); require(_args.secondAddress != address(0), "Actions: target address cannot be address(0)"); return CallArgs({callee: _args.secondAddress, data: _args.data}); } }
library Actions { // possible actions that can be performed enum ActionType { OpenVault, MintShortOption, BurnShortOption, DepositLongOption, WithdrawLongOption, DepositCollateral, WithdrawCollateral, SettleVault, Redeem, Call } struct ActionArgs { // type of action that is being performed on the system ActionType actionType; // address of the account owner address owner; // address which we move assets from or to (depending on the action type) address secondAddress; // asset that is to be transfered address asset; // index of the vault that is to be modified (if any) uint256 vaultId; // amount of asset that is to be transfered uint256 amount; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // any other data that needs to be passed in for arbitrary function calls bytes data; } struct MintArgs { // address of the account owner address owner; // index of the vault from which the asset will be minted uint256 vaultId; // address to which we transfer the minted oTokens address to; // oToken that is to be minted address otoken; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // amount of oTokens that is to be minted uint256 amount; } struct BurnArgs { // address of the account owner address owner; // index of the vault from which the oToken will be burned uint256 vaultId; // address from which we transfer the oTokens address from; // oToken that is to be burned address otoken; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // amount of oTokens that is to be burned uint256 amount; } struct OpenVaultArgs { // address of the account owner address owner; // vault id to create uint256 vaultId; } struct DepositArgs { // address of the account owner address owner; // index of the vault to which the asset will be added uint256 vaultId; // address from which we transfer the asset address from; // asset that is to be deposited address asset; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // amount of asset that is to be deposited uint256 amount; } struct RedeemArgs { // address to which we pay out the oToken proceeds address receiver; // oToken that is to be redeemed address otoken; // amount of oTokens that is to be redeemed uint256 amount; } struct WithdrawArgs { // address of the account owner address owner; // index of the vault from which the asset will be withdrawn uint256 vaultId; // address to which we transfer the asset address to; // asset that is to be withdrawn address asset; // each vault can hold multiple short / long / collateral assets but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // amount of asset that is to be withdrawn uint256 amount; } struct SettleVaultArgs { // address of the account owner address owner; // index of the vault to which is to be settled uint256 vaultId; // address to which we transfer the remaining collateral address to; } struct CallArgs { // address of the callee contract address callee; // data field for external calls bytes data; } /** * @notice parses the passed in action arguments to get the arguments for an open vault action * @param _args general action arguments structure * @return arguments for a open vault action */ function _parseOpenVaultArgs(ActionArgs memory _args) internal pure returns (OpenVaultArgs memory) { require(_args.actionType == ActionType.OpenVault, "Actions: can only parse arguments for open vault actions"); require(_args.owner != address(0), "Actions: cannot open vault for an invalid account"); return OpenVaultArgs({owner: _args.owner, vaultId: _args.vaultId}); } /** * @notice parses the passed in action arguments to get the arguments for a mint action * @param _args general action arguments structure * @return arguments for a mint action */ function _parseMintArgs(ActionArgs memory _args) internal pure returns (MintArgs memory) { require(_args.actionType == ActionType.MintShortOption, "Actions: can only parse arguments for mint actions"); require(_args.owner != address(0), "Actions: cannot mint from an invalid account"); return MintArgs({ owner: _args.owner, vaultId: _args.vaultId, to: _args.secondAddress, otoken: _args.asset, index: _args.index, amount: _args.amount }); } /** * @notice parses the passed in action arguments to get the arguments for a burn action * @param _args general action arguments structure * @return arguments for a burn action */ function _parseBurnArgs(ActionArgs memory _args) internal pure returns (BurnArgs memory) { require(_args.actionType == ActionType.BurnShortOption, "Actions: can only parse arguments for burn actions"); require(_args.owner != address(0), "Actions: cannot burn from an invalid account"); return BurnArgs({ owner: _args.owner, vaultId: _args.vaultId, from: _args.secondAddress, otoken: _args.asset, index: _args.index, amount: _args.amount }); } /** * @notice parses the passed in action arguments to get the arguments for a deposit action * @param _args general action arguments structure * @return arguments for a deposit action */ function _parseDepositArgs(ActionArgs memory _args) internal pure returns (DepositArgs memory) { require( (_args.actionType == ActionType.DepositLongOption) || (_args.actionType == ActionType.DepositCollateral), "Actions: can only parse arguments for deposit actions" ); require(_args.owner != address(0), "Actions: cannot deposit to an invalid account"); return DepositArgs({ owner: _args.owner, vaultId: _args.vaultId, from: _args.secondAddress, asset: _args.asset, index: _args.index, amount: _args.amount }); } /** * @notice parses the passed in action arguments to get the arguments for a withdraw action * @param _args general action arguments structure * @return arguments for a withdraw action */ function _parseWithdrawArgs(ActionArgs memory _args) internal pure returns (WithdrawArgs memory) { require( (_args.actionType == ActionType.WithdrawLongOption) || (_args.actionType == ActionType.WithdrawCollateral), "Actions: can only parse arguments for withdraw actions" ); require(_args.owner != address(0), "Actions: cannot withdraw from an invalid account"); require(_args.secondAddress != address(0), "Actions: cannot withdraw to an invalid account"); return WithdrawArgs({ owner: _args.owner, vaultId: _args.vaultId, to: _args.secondAddress, asset: _args.asset, index: _args.index, amount: _args.amount }); } /** * @notice parses the passed in action arguments to get the arguments for an redeem action * @param _args general action arguments structure * @return arguments for a redeem action */ function _parseRedeemArgs(ActionArgs memory _args) internal pure returns (RedeemArgs memory) { require(_args.actionType == ActionType.Redeem, "Actions: can only parse arguments for redeem actions"); require(_args.secondAddress != address(0), "Actions: cannot redeem to an invalid account"); return RedeemArgs({receiver: _args.secondAddress, otoken: _args.asset, amount: _args.amount}); } /** * @notice parses the passed in action arguments to get the arguments for a settle vault action * @param _args general action arguments structure * @return arguments for a settle vault action */ function _parseSettleVaultArgs(ActionArgs memory _args) internal pure returns (SettleVaultArgs memory) { require( _args.actionType == ActionType.SettleVault, "Actions: can only parse arguments for settle vault actions" ); require(_args.owner != address(0), "Actions: cannot settle vault for an invalid account"); require(_args.secondAddress != address(0), "Actions: cannot withdraw payout to an invalid account"); return SettleVaultArgs({owner: _args.owner, vaultId: _args.vaultId, to: _args.secondAddress}); } /** * @notice parses the passed in action arguments to get the arguments for a call action * @param _args general action arguments structure * @return arguments for a call action */ function _parseCallArgs(ActionArgs memory _args) internal pure returns (CallArgs memory) { require(_args.actionType == ActionType.Call, "Actions: can only parse arguments for call actions"); require(_args.secondAddress != address(0), "Actions: target address cannot be address(0)"); return CallArgs({callee: _args.secondAddress, data: _args.data}); } }
9,453
4
// A contract with an owner. Contract ownership can be transferred by first nominating the new owner,who must then accept the ownership, which prevents accidental incorrect ownership transfers. /
contract Owned { address public owner; address public nominatedOwner; /** * @dev Owned Constructor */ constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } /** * @notice Nominate a new owner of this contract. * @dev Only the current owner may nominate a new owner. */ function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } /** * @notice Accept the nomination to be owner. */ function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); }
contract Owned { address public owner; address public nominatedOwner; /** * @dev Owned Constructor */ constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } /** * @notice Nominate a new owner of this contract. * @dev Only the current owner may nominate a new owner. */ function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } /** * @notice Accept the nomination to be owner. */ function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); }
31,354
39
// just in case the contract is bust and can't pay should never be needed but who knows
function fuelContract() public onlyOwner payable { }
function fuelContract() public onlyOwner payable { }
79,657
24
// if auction end voucher is already submitted
if(auctionEndVoucherSubmitted[_auctionEndVoucherHash] == true) { emit LogError(version, "AUCTION_END_VOUCHER_ALREADY_SUBMITED"); return; }
if(auctionEndVoucherSubmitted[_auctionEndVoucherHash] == true) { emit LogError(version, "AUCTION_END_VOUCHER_ALREADY_SUBMITED"); return; }
25,920
150
// Sets approved amount of tokens for spender. Returns success/spender Address of allowed account/value Number of approved tokens/ return Was approval successful?
function approve(address spender, uint value) public returns (bool)
function approve(address spender, uint value) public returns (bool)
55,161
24
// Get last chainlink oracle data for a given price identifier priceIdentifier Price feed identifierreturn oracleData Oracle data /
function getOracleLatestData(bytes32 priceIdentifier) external view override onlyPools() returns (OracleData memory oracleData)
function getOracleLatestData(bytes32 priceIdentifier) external view override onlyPools() returns (OracleData memory oracleData)
40,138
79
// takes ethers from zebiwallet to smart contract
function takeEth() external payable { TakeEth(msg.sender,msg.value); }
function takeEth() external payable { TakeEth(msg.sender,msg.value); }
25,544
1
// safeApprove works only if trying to set to 0 or current allowance is 0
token.safeApprove(spender, requiredAmount); return;
token.safeApprove(spender, requiredAmount); return;
6,686
57
// _presaleTaxFee
function setPresaleTaxFee(uint256 feeValue) external onlyOwner() { require(feeValue >0, "feeValue must be greater than 0"); _presaleTaxFee = feeValue; }
function setPresaleTaxFee(uint256 feeValue) external onlyOwner() { require(feeValue >0, "feeValue must be greater than 0"); _presaleTaxFee = feeValue; }
31,586
26
// Updates the cached greeks for an OptionBoardCache.greekCacheGlobals The GreekCacheGlobals. boardCacheId The id of the OptionBoardCache. /
function _updateBoardCachedGreeks(ILyraGlobals.GreekCacheGlobals memory greekCacheGlobals, uint boardCacheId) internal
function _updateBoardCachedGreeks(ILyraGlobals.GreekCacheGlobals memory greekCacheGlobals, uint boardCacheId) internal
16,565
23
// See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is notrequired by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address.- `sender` must have a balance of at least `amount`.- the caller must have allowance for ``sender``'s tokens of at least`amount`. /
function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "EToken: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount);
function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "EToken: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount);
26,538
11
// Maturity Date & Penalty Interest Rate (per Sec)
uint256 public immutable maturityDate; uint256 public immutable penaltyRate;
uint256 public immutable maturityDate; uint256 public immutable penaltyRate;
48,529
33
// Constructor. ownerAddr The address of the owner /
constructor (address ownerAddr) Ownable (ownerAddr) { // solhint-disable-line no-empty-blocks }
constructor (address ownerAddr) Ownable (ownerAddr) { // solhint-disable-line no-empty-blocks }
27,107
98
// Emit when new ticker get registers
event RegisterTicker( address indexed _owner, string _ticker, uint256 indexed _registrationDate, uint256 indexed _expiryDate, bool _fromAdmin, uint256 _registrationFeePoly, uint256 _registrationFeeUsd );
event RegisterTicker( address indexed _owner, string _ticker, uint256 indexed _registrationDate, uint256 indexed _expiryDate, bool _fromAdmin, uint256 _registrationFeePoly, uint256 _registrationFeeUsd );
46,764
2
// Emits when ORGiD delegates are removed /
event OrgIdDelegatesRemoved( bytes32 indexed orgId, string[] delegates );
event OrgIdDelegatesRemoved( bytes32 indexed orgId, string[] delegates );
19,296
66
// File: witnet-ethereum-block-relay/contracts/BlockRelayProxy.sol/ Block Relay Proxy Contract to act as a proxy between the Witnet Bridge Interface and the block relay More information can be found hereDISCLAIMER: this is a work in progress, meaning the contract could be voulnerable to attacks Witnet Foundation /
contract BlockRelayProxy { // Address of the current controller address internal blockRelayAddress; // Current interface to the controller BlockRelayInterface internal blockRelayInstance; struct ControllerInfo { // last epoch seen by a controller uint256 lastEpoch; // address of the controller address blockRelayController; } // array containing the information about controllers ControllerInfo[] internal controllers; modifier notIdentical(address _newAddress) { require(_newAddress != blockRelayAddress, "The provided Block Relay instance address is already in use"); _; } constructor(address _blockRelayAddress) public { // Initialize the first epoch pointing to the first controller controllers.push(ControllerInfo({lastEpoch: 0, blockRelayController: _blockRelayAddress})); blockRelayAddress = _blockRelayAddress; blockRelayInstance = BlockRelayInterface(_blockRelayAddress); } /// @notice Returns the beacon from the last inserted block. /// The last beacon (in bytes) will be used by Witnet Bridge nodes to compute their eligibility. /// @return last beacon in bytes function getLastBeacon() external view returns(bytes memory) { return blockRelayInstance.getLastBeacon(); } /// @notice Returns the last Wtinet epoch known to the block relay instance. /// @return The last epoch is used in the WRB to avoid reusage of PoI in a data request. function getLastEpoch() external view returns(uint256) { return blockRelayInstance.getLastEpoch(); } /// @notice Verifies the validity of a data request PoI against the DR merkle root /// @param _poi the proof of inclusion as [sibling1, sibling2,..] /// @param _blockHash the blockHash /// @param _epoch the epoch of the blockchash /// @param _index the index in the merkle tree of the element to verify /// @param _element the leaf to be verified /// @return true if valid data request PoI function verifyDrPoi( uint256[] calldata _poi, uint256 _blockHash, uint256 _epoch, uint256 _index, uint256 _element) external view returns(bool) { address controller = getController(_epoch); return BlockRelayInterface(controller).verifyDrPoi( _poi, _blockHash, _index, _element); } /// @notice Verifies the validity of a tally PoI against the DR merkle root /// @param _poi the proof of inclusion as [sibling1, sibling2,..] /// @param _blockHash the blockHash /// @param _epoch the epoch of the blockchash /// @param _index the index in the merkle tree of the element to verify /// @param _element the leaf to be verified /// @return true if valid data request PoI function verifyTallyPoi( uint256[] calldata _poi, uint256 _blockHash, uint256 _epoch, uint256 _index, uint256 _element) external view returns(bool) { address controller = getController(_epoch); return BlockRelayInterface(controller).verifyTallyPoi( _poi, _blockHash, _index, _element); } /// @notice Upgrades the block relay if the current one is upgradeable /// @param _newAddress address of the new block relay to upgrade function upgradeBlockRelay(address _newAddress) external notIdentical(_newAddress) { // Check if the controller is upgradeable require(blockRelayInstance.isUpgradable(msg.sender), "The upgrade has been rejected by the current implementation"); // Get last epoch seen by the replaced controller uint256 epoch = blockRelayInstance.getLastEpoch(); // Get the length of last epochs seen by the different controllers uint256 n = controllers.length; // If the the last epoch seen by the replaced controller is lower than the one already anotated e.g. 0 // just update the already anotated epoch with the new address, ignoring the previously inserted controller // Else, anotate the epoch from which the new controller should start receiving blocks if (epoch < controllers[n-1].lastEpoch) { controllers[n-1].blockRelayController = _newAddress; } else { controllers.push(ControllerInfo({lastEpoch: epoch+1, blockRelayController: _newAddress})); } // Update instance blockRelayAddress = _newAddress; blockRelayInstance = BlockRelayInterface(_newAddress); } /// @notice Gets the controller associated with the BR controller corresponding to the epoch provided /// @param _epoch the epoch to work with function getController(uint256 _epoch) public view returns(address _controller) { // Get length of all last epochs seen by controllers uint256 n = controllers.length; // Go backwards until we find the controller having that blockhash for (uint i = n; i > 0; i--) { if (_epoch >= controllers[i-1].lastEpoch) { return (controllers[i-1].blockRelayController); } } } }
contract BlockRelayProxy { // Address of the current controller address internal blockRelayAddress; // Current interface to the controller BlockRelayInterface internal blockRelayInstance; struct ControllerInfo { // last epoch seen by a controller uint256 lastEpoch; // address of the controller address blockRelayController; } // array containing the information about controllers ControllerInfo[] internal controllers; modifier notIdentical(address _newAddress) { require(_newAddress != blockRelayAddress, "The provided Block Relay instance address is already in use"); _; } constructor(address _blockRelayAddress) public { // Initialize the first epoch pointing to the first controller controllers.push(ControllerInfo({lastEpoch: 0, blockRelayController: _blockRelayAddress})); blockRelayAddress = _blockRelayAddress; blockRelayInstance = BlockRelayInterface(_blockRelayAddress); } /// @notice Returns the beacon from the last inserted block. /// The last beacon (in bytes) will be used by Witnet Bridge nodes to compute their eligibility. /// @return last beacon in bytes function getLastBeacon() external view returns(bytes memory) { return blockRelayInstance.getLastBeacon(); } /// @notice Returns the last Wtinet epoch known to the block relay instance. /// @return The last epoch is used in the WRB to avoid reusage of PoI in a data request. function getLastEpoch() external view returns(uint256) { return blockRelayInstance.getLastEpoch(); } /// @notice Verifies the validity of a data request PoI against the DR merkle root /// @param _poi the proof of inclusion as [sibling1, sibling2,..] /// @param _blockHash the blockHash /// @param _epoch the epoch of the blockchash /// @param _index the index in the merkle tree of the element to verify /// @param _element the leaf to be verified /// @return true if valid data request PoI function verifyDrPoi( uint256[] calldata _poi, uint256 _blockHash, uint256 _epoch, uint256 _index, uint256 _element) external view returns(bool) { address controller = getController(_epoch); return BlockRelayInterface(controller).verifyDrPoi( _poi, _blockHash, _index, _element); } /// @notice Verifies the validity of a tally PoI against the DR merkle root /// @param _poi the proof of inclusion as [sibling1, sibling2,..] /// @param _blockHash the blockHash /// @param _epoch the epoch of the blockchash /// @param _index the index in the merkle tree of the element to verify /// @param _element the leaf to be verified /// @return true if valid data request PoI function verifyTallyPoi( uint256[] calldata _poi, uint256 _blockHash, uint256 _epoch, uint256 _index, uint256 _element) external view returns(bool) { address controller = getController(_epoch); return BlockRelayInterface(controller).verifyTallyPoi( _poi, _blockHash, _index, _element); } /// @notice Upgrades the block relay if the current one is upgradeable /// @param _newAddress address of the new block relay to upgrade function upgradeBlockRelay(address _newAddress) external notIdentical(_newAddress) { // Check if the controller is upgradeable require(blockRelayInstance.isUpgradable(msg.sender), "The upgrade has been rejected by the current implementation"); // Get last epoch seen by the replaced controller uint256 epoch = blockRelayInstance.getLastEpoch(); // Get the length of last epochs seen by the different controllers uint256 n = controllers.length; // If the the last epoch seen by the replaced controller is lower than the one already anotated e.g. 0 // just update the already anotated epoch with the new address, ignoring the previously inserted controller // Else, anotate the epoch from which the new controller should start receiving blocks if (epoch < controllers[n-1].lastEpoch) { controllers[n-1].blockRelayController = _newAddress; } else { controllers.push(ControllerInfo({lastEpoch: epoch+1, blockRelayController: _newAddress})); } // Update instance blockRelayAddress = _newAddress; blockRelayInstance = BlockRelayInterface(_newAddress); } /// @notice Gets the controller associated with the BR controller corresponding to the epoch provided /// @param _epoch the epoch to work with function getController(uint256 _epoch) public view returns(address _controller) { // Get length of all last epochs seen by controllers uint256 n = controllers.length; // Go backwards until we find the controller having that blockhash for (uint i = n; i > 0; i--) { if (_epoch >= controllers[i-1].lastEpoch) { return (controllers[i-1].blockRelayController); } } } }
12,602
34
// This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate. */ function _implementation() internal virtual view returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal { _beforeFallback(); _delegate(_implementation()); }
* and {_fallback} should delegate. */ function _implementation() internal virtual view returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal { _beforeFallback(); _delegate(_implementation()); }
12,548
185
// 10
string[] actinides = [ "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium",
string[] actinides = [ "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium",
6,242
17
// and then enumerate through them and get their respective bids...
function getGamesPlayerBids(uint256 gameId, address playerAddress) public view returns(uint256){ return games[gameId].PlayerBidMap[playerAddress]; }
function getGamesPlayerBids(uint256 gameId, address playerAddress) public view returns(uint256){ return games[gameId].PlayerBidMap[playerAddress]; }
21,202
107
// Since tokens have been granted, reduce the total amount available for vesting.
totalVesting = totalVesting.add(_value); NewGrant(msg.sender, _to, _value);
totalVesting = totalVesting.add(_value); NewGrant(msg.sender, _to, _value);
44,487
2
// FinalizableCrowdsale Extension of Crowsdale where an owner can do extra workafter finishing. By default, it will end token minting. /
contract FinalizableCrowdsale is Crowdsale, Ownable { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); // should be called after crowdsale ends, to do // some extra finalization work function finalize() onlyOwner { require(!isFinalized); require(hasEnded()); finalization(); Finalized(); isFinalized = true; } // end token minting on finalization // override this with custom logic if needed function finalization() internal { token.finishMinting(); } }
contract FinalizableCrowdsale is Crowdsale, Ownable { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); // should be called after crowdsale ends, to do // some extra finalization work function finalize() onlyOwner { require(!isFinalized); require(hasEnded()); finalization(); Finalized(); isFinalized = true; } // end token minting on finalization // override this with custom logic if needed function finalization() internal { token.finishMinting(); } }
46,332
88
// Burn liquidity tokens in exchange for base and fyToken./ The liquidity tokens need to be in this contract./baseTo Wallet receiving the base./fyTokenTo Wallet receiving the fyToken./minRatio Minimum ratio of base to fyToken in the pool./maxRatio Maximum ratio of base to fyToken in the pool./ return The amount of tokens burned and returned (tokensBurned, bases, fyTokens).
function burn(address baseTo, address fyTokenTo, uint256 minRatio, uint256 maxRatio) external override returns (uint256, uint256, uint256)
function burn(address baseTo, address fyTokenTo, uint256 minRatio, uint256 maxRatio) external override returns (uint256, uint256, uint256)
43,919
64
// validate _from,_to address and _value(Now allow with 0)
require(_from != 0 && _to != 0 && _value > 0);
require(_from != 0 && _to != 0 && _value > 0);
81,618
12
// return the root NFT of this tokenId/
function getRoot(uint256 tokenId) external view returns(uint256);
function getRoot(uint256 tokenId) external view returns(uint256);
4,452
361
// Emits an {Transfer} event to 0 address/
function burn(uint burnQuantity) public returns (bool) { _burn(msg.sender, burnQuantity); return true; }
function burn(uint burnQuantity) public returns (bool) { _burn(msg.sender, burnQuantity); return true; }
39,377
196
// Limited to a publicly set amount
require(_amount > 0, "Invalid amount is given"); require(_amount <= reserved, "Can't reserve more than set amount"); reserved -= _amount; for (uint256 i = 1; i <= _amount; i++) { _safeMint(msg.sender, _tokenIdCounter.current()); _tokenIdCounter.increment(); }
require(_amount > 0, "Invalid amount is given"); require(_amount <= reserved, "Can't reserve more than set amount"); reserved -= _amount; for (uint256 i = 1; i <= _amount; i++) { _safeMint(msg.sender, _tokenIdCounter.current()); _tokenIdCounter.increment(); }
25,084
2
// ! ],! "expected": [! "233"! ]
//! }, { //! "name": "three", //! "input": [ //! { //! "entry": "main", //! "calldata": [ //! "16" //! ] //! }
//! }, { //! "name": "three", //! "input": [ //! { //! "entry": "main", //! "calldata": [ //! "16" //! ] //! }
36,314
79
// Overrides parent by storing balances instead of issuing tokens right away. _beneficiary Token purchaser _tokenAmount Amount of tokens purchased /
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _balances[_beneficiary] = _balances[_beneficiary].add(_tokenAmount); }
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _balances[_beneficiary] = _balances[_beneficiary].add(_tokenAmount); }
25,483
0
// stores the reserve configuration
ReserveConfigurationMap configuration;
ReserveConfigurationMap configuration;
21,942
0
// prettier-ignore
interface IERC721 { function totalSupply() external view returns (uint256); function mint(address _to, uint256 _tokenId) external; function lock(uint256 tokenId_) external; }
interface IERC721 { function totalSupply() external view returns (uint256); function mint(address _to, uint256 _tokenId) external; function lock(uint256 tokenId_) external; }
22,259
4
// claim dividents/ _token token to claim
function claim(address _token){ Config memory cf = dvDetails[msg.sender][_token]; require(block.timestamp.sub(cf.start) > INTREVAL, "still in old period,please wait."); require(cf.toClaim > 0, "nothing to claim."); uint256 amount = cf.toClaim; cf.claimed += amount; cf.toClaim = 0; calculateNextDvd(msg.sender, cf); require(SecurityToken(_token).transfer(msg.sender, amount), "do transfer token errors"); }
function claim(address _token){ Config memory cf = dvDetails[msg.sender][_token]; require(block.timestamp.sub(cf.start) > INTREVAL, "still in old period,please wait."); require(cf.toClaim > 0, "nothing to claim."); uint256 amount = cf.toClaim; cf.claimed += amount; cf.toClaim = 0; calculateNextDvd(msg.sender, cf); require(SecurityToken(_token).transfer(msg.sender, amount), "do transfer token errors"); }
25,706
137
// This will suffice for checking _exists(nextTokenId),as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; }
if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; }
27,274
50
// Sets platform address, assigns symbol and name. Can be set only once._platform platform contract address. _symbol assigned symbol. _name assigned name. return success. /
function init(Platform _platform, string _symbol, string _name) public returns (bool) { if (address(platform) != 0x0) { return false; } platform = _platform; symbol = _symbol; smbl = stringToBytes32(_symbol); name = _name; return true; }
function init(Platform _platform, string _symbol, string _name) public returns (bool) { if (address(platform) != 0x0) { return false; } platform = _platform; symbol = _symbol; smbl = stringToBytes32(_symbol); name = _name; return true; }
11,617
42
// check if address interacting with contract already has an ein
function checkforReg(address _target) public returns(bool){ SnowflakeInterface snowfl = SnowflakeInterface(snowflakeAddress); IdentityRegistryInterface idRegistry= IdentityRegistryInterface(snowfl.identityRegistryAddress()); _target=msg.sender; bool hasId=idRegistry.hasIdentity(msg.sender); return hasId; }
function checkforReg(address _target) public returns(bool){ SnowflakeInterface snowfl = SnowflakeInterface(snowflakeAddress); IdentityRegistryInterface idRegistry= IdentityRegistryInterface(snowfl.identityRegistryAddress()); _target=msg.sender; bool hasId=idRegistry.hasIdentity(msg.sender); return hasId; }
38,693
20
// update storage with the modified slot
s.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
s.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
32,754
1
// registered
string name; address nicAddress; address nicDeNSRoot; address ownerAddress; uint256 ownerPublicKey;
string name; address nicAddress; address nicDeNSRoot; address ownerAddress; uint256 ownerPublicKey;
41,273
41
// Team reserve mint function/number number of tokens to mint
function reserveMint(uint256 number) external onlyOwner { require(number <= reserve); reserve -= number; bulkMint(number); }
function reserveMint(uint256 number) external onlyOwner { require(number <= reserve); reserve -= number; bulkMint(number); }
80,188
133
// Gets the official ENS reverse registrar.
function getEnsReverseRegistrar() public view returns (EnsReverseRegistrar) { return EnsReverseRegistrar(getEnsRegistry().owner(ADDR_REVERSE_NODE)); }
function getEnsReverseRegistrar() public view returns (EnsReverseRegistrar) { return EnsReverseRegistrar(getEnsRegistry().owner(ADDR_REVERSE_NODE)); }
1,111
337
// Resolution for the Multiple Withdrawal Attack on ERC20 Tokens (ISBN:978-1-7281-3027-9)Similar to ERC20 Transfer event, but also logs an address which executed transferFired in transfer(), transferFrom() and some other (non-ERC20) functions_by an address which performed the transfer _from an address tokens were consumed from _to an address tokens were sent to _value number of tokens transferred /
event Transferred(address indexed _by, address indexed _from, address indexed _to, uint256 _value);
event Transferred(address indexed _by, address indexed _from, address indexed _to, uint256 _value);
11,316
18
// |/ Burn _amount of tokens of a given token id _fromThe address to burn tokens from _idToken id to burn _amountThe amount to be burned /
function _burn(address _from, uint256 _id, uint256 _amount) internal
function _burn(address _from, uint256 _id, uint256 _amount) internal
6,996
3
// Should return whether the signature provided is valid for the provided datahashHash of the data to be signedsignature Signature byte array associated with _data/
function isValidSignature( bytes32 hash, bytes memory signature ) public view returns ( bytes4 magicValue )
function isValidSignature( bytes32 hash, bytes memory signature ) public view returns ( bytes4 magicValue )
40,920
135
// VARIABLES//locked time(in seconds)
uint public lockedTime = uint(3600*36);
uint public lockedTime = uint(3600*36);
39,289
21
// Funds an existing community if it hasn't enough funds /
function fundCommunity() external override onlyCommunities { ICommunity community = ICommunity(msg.sender); uint256 balance = cUSD.balanceOf(msg.sender); require( balance < community.minTranche(), "CommunityAdmin::fundCommunity: this community has enough funds" ); uint256 trancheAmount = calculateCommunityTrancheAmount(ICommunity(msg.sender)); if (trancheAmount > balance) { transferToCommunity(community, trancheAmount - balance); } }
function fundCommunity() external override onlyCommunities { ICommunity community = ICommunity(msg.sender); uint256 balance = cUSD.balanceOf(msg.sender); require( balance < community.minTranche(), "CommunityAdmin::fundCommunity: this community has enough funds" ); uint256 trancheAmount = calculateCommunityTrancheAmount(ICommunity(msg.sender)); if (trancheAmount > balance) { transferToCommunity(community, trancheAmount - balance); } }
18,396
4
// This is how we prevent replay by tracking the nonce
updateLastNonce(_msgSender(), voucher.nonce); if (voucher.currency == address(0)) { _handleEthPayment(voucher); } else {
updateLastNonce(_msgSender(), voucher.nonce); if (voucher.currency == address(0)) { _handleEthPayment(voucher); } else {
7,922
154
// Treasury accumulates LP yield
address public treasury;
address public treasury;
48,154
4
// Status of the Basset - has it broken its peg? /
enum BassetStatus { Default, Normal, BrokenBelowPeg, BrokenAbovePeg, Blacklisted, Liquidating, Liquidated, Failed }
enum BassetStatus { Default, Normal, BrokenBelowPeg, BrokenAbovePeg, Blacklisted, Liquidating, Liquidated, Failed }
21,945
9
// Set new trader risk threshold for trader liquidation, only set by owner. _newTraderRiskLiquidateThreshold The new trader risk threshold as percentage. /
function setTraderRiskLiquidateThreshold(uint256 _newTraderRiskLiquidateThreshold) external onlyOwner { require(_newTraderRiskLiquidateThreshold > 0, "0"); traderRiskLiquidateThreshold = Percentage.Percent(_newTraderRiskLiquidateThreshold); }
function setTraderRiskLiquidateThreshold(uint256 _newTraderRiskLiquidateThreshold) external onlyOwner { require(_newTraderRiskLiquidateThreshold > 0, "0"); traderRiskLiquidateThreshold = Percentage.Percent(_newTraderRiskLiquidateThreshold); }
19,245
63
// for each token holder: last ether balance was when requested dividends
mapping(address => uint256) public m_lastDividends; uint256 public m_totalHangingDividends; uint256 public m_totalDividends;
mapping(address => uint256) public m_lastDividends; uint256 public m_totalHangingDividends; uint256 public m_totalDividends;
16,178
96
// if propose status is waiting and enough time passed, change status
if (status == PROPOSE_STATUS_WAITING && now.sub(startAt) >= getConfig(_proposeTimelock_)) { setConfig(_proposeStatus_, ID, PROPOSE_STATUS_VOTING); status = PROPOSE_STATUS_VOTING; }
if (status == PROPOSE_STATUS_WAITING && now.sub(startAt) >= getConfig(_proposeTimelock_)) { setConfig(_proposeStatus_, ID, PROPOSE_STATUS_VOTING); status = PROPOSE_STATUS_VOTING; }
40,318
230
// Creates a new Masterpiece with the given name and artist.
function createMasterpiece( string _name, string _artist, uint256 _snatchWindow ) public onlyCurator returns (uint)
function createMasterpiece( string _name, string _artist, uint256 _snatchWindow ) public onlyCurator returns (uint)
41,944
88
// Facilitates a claim and ensures that the claim can only happen after claimBlockNumber
function _claim(address _claimant) private { require(claimableTokens[_claimant] > 0, "Nothing available"); require(claimed[_claimant] == false, "Already claimed"); require(block.number >= claimBlockNumber, "Cannot claim tokens yet"); claimed[_claimant] = true; token.transfer(_claimant, claimableTokens[_claimant]); emit TokensClaimed(_claimant, claimableTokens[_claimant]); }
function _claim(address _claimant) private { require(claimableTokens[_claimant] > 0, "Nothing available"); require(claimed[_claimant] == false, "Already claimed"); require(block.number >= claimBlockNumber, "Cannot claim tokens yet"); claimed[_claimant] = true; token.transfer(_claimant, claimableTokens[_claimant]); emit TokensClaimed(_claimant, claimableTokens[_claimant]); }
45,459
118
// Helper/wrapper around IRemoteAccessBitmask
library AccessHelper { function getAcl(IRemoteAccessBitmask remote, address subject) internal view returns (uint256) { return remote.queryAccessControlMask(subject, ~uint256(0)); } function queryAcl( IRemoteAccessBitmask remote, address subject, uint256 filterMask ) internal view returns (uint256) { return remote.queryAccessControlMask(subject, filterMask); } function hasAnyOf( IRemoteAccessBitmask remote, address subject, uint256 flags ) internal view returns (bool) { uint256 found = queryAcl(remote, subject, flags); return found & flags != 0; } function hasAny(IRemoteAccessBitmask remote, address subject) internal view returns (bool) { return remote.queryAccessControlMask(subject, 0) != 0; } function hasNone(IRemoteAccessBitmask remote, address subject) internal view returns (bool) { return remote.queryAccessControlMask(subject, 0) == 0; } function requireAnyOf( IRemoteAccessBitmask remote, address subject, uint256 flags, string memory text ) internal view { require(hasAnyOf(remote, subject, flags), text); } }
library AccessHelper { function getAcl(IRemoteAccessBitmask remote, address subject) internal view returns (uint256) { return remote.queryAccessControlMask(subject, ~uint256(0)); } function queryAcl( IRemoteAccessBitmask remote, address subject, uint256 filterMask ) internal view returns (uint256) { return remote.queryAccessControlMask(subject, filterMask); } function hasAnyOf( IRemoteAccessBitmask remote, address subject, uint256 flags ) internal view returns (bool) { uint256 found = queryAcl(remote, subject, flags); return found & flags != 0; } function hasAny(IRemoteAccessBitmask remote, address subject) internal view returns (bool) { return remote.queryAccessControlMask(subject, 0) != 0; } function hasNone(IRemoteAccessBitmask remote, address subject) internal view returns (bool) { return remote.queryAccessControlMask(subject, 0) == 0; } function requireAnyOf( IRemoteAccessBitmask remote, address subject, uint256 flags, string memory text ) internal view { require(hasAnyOf(remote, subject, flags), text); } }
58,493
6
// The allowances for withdrawals.
mapping(address => mapping(address => uint256)) withdrawAllowances;
mapping(address => mapping(address => uint256)) withdrawAllowances;
10,623
387
// pay referal percentage
if (referal > 0) referer.transfer(referal);
if (referal > 0) referer.transfer(referal);
20,768
2
// TODO: only_ancestors, only_parents, only_children, only_offspring, only_sibblings
constructor() public
constructor() public
5,546