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
2
// The `keccak256` hash of the price feed, according to ERC2362 specs.`
bytes32 public immutable erc2362ID;
bytes32 public immutable erc2362ID;
29,020
452
// Calculates EIP712 encoding for a hash struct with a given domain hash./eip712DomainHash Hash of the domain domain separator data, computed/ with getDomainHash()./hashStruct The EIP712 hash struct./ return EIP712 hash applied to the given EIP712 Domain.
function hashEIP712Message(bytes32 eip712DomainHash, bytes32 hashStruct) internal pure returns (bytes32 result)
function hashEIP712Message(bytes32 eip712DomainHash, bytes32 hashStruct) internal pure returns (bytes32 result)
30,794
169
// stores the amiunt of tokens that have been minted in presale
uint256 private numberOfTokensPresale;
uint256 private numberOfTokensPresale;
28,431
15
// https:etherscan.io/address/0x6568D9e750fC44AF00f857885Dfb8281c00529c4
TokenState public constant tokenstateseur_i = TokenState(0x6568D9e750fC44AF00f857885Dfb8281c00529c4);
TokenState public constant tokenstateseur_i = TokenState(0x6568D9e750fC44AF00f857885Dfb8281c00529c4);
37,979
254
// Dynamic allocate all the pool across different lending protocols if needed, use gas refund from gasToken NOTE: this method can be paused.msg.sender should approve this contract to spend GST2 tokens before callingthis method return : whether has rebalanced or not /
function rebalanceWithGST() external gasDiscountFrom(msg.sender)
function rebalanceWithGST() external gasDiscountFrom(msg.sender)
5,388
18
// `Allow | Prevent` `target` from sending & receiving tokens/target Address to be allowed or not/approve either to allow it or not
function approveAccount(address target, bool approve) onlyAdmin public { approvedAccount[target] = approve; emit ApprovedAccount(target, approve); }
function approveAccount(address target, bool approve) onlyAdmin public { approvedAccount[target] = approve; emit ApprovedAccount(target, approve); }
19,007
191
// OWNER ONLY OPERATIONS //Allows owner to change gas cost for boost operation, but only up to 3 millions/_gasCost New gas cost for boost method
function changeBoostGasCost(uint _gasCost) public onlyOwner { require(_gasCost < 3000000); BOOST_GAS_COST = _gasCost; }
function changeBoostGasCost(uint _gasCost) public onlyOwner { require(_gasCost < 3000000); BOOST_GAS_COST = _gasCost; }
7,829
35
// user selects own vesting schedule, not others
require(msg.sender == destination, 'Can only initialize your own tranche');
require(msg.sender == destination, 'Can only initialize your own tranche');
52,358
85
// remove the liquidity
return IUniswapV2Router02(uniswapV2RouterAddress).removeLiquidity( mggToken, usdtToken, _liquidity, _amountGHOEMin, _amountUSDTMin, _to, _deadline );
return IUniswapV2Router02(uniswapV2RouterAddress).removeLiquidity( mggToken, usdtToken, _liquidity, _amountGHOEMin, _amountUSDTMin, _to, _deadline );
34,350
33
// Utility library of inline functions on addresses. Based on:Requires EIP-1052. /
library AddressUtils { /** * @dev Returns whether the target address is a contract. * @param _addr Address to check. * @return addressCheck True if _addr is a contract, false if not. */ function isContract( address _addr) internal view returns (bool addressCheck) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(_addr) } // solhint-disable-line addressCheck = (codehash != 0x0 && codehash != accountHash); } }
library AddressUtils { /** * @dev Returns whether the target address is a contract. * @param _addr Address to check. * @return addressCheck True if _addr is a contract, false if not. */ function isContract( address _addr) internal view returns (bool addressCheck) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(_addr) } // solhint-disable-line addressCheck = (codehash != 0x0 && codehash != accountHash); } }
613
11
// the balance should be available
modifier when_owns(address _owner, uint _amount) { require (accounts[_owner].balance >= _amount); _; }
modifier when_owns(address _owner, uint _amount) { require (accounts[_owner].balance >= _amount); _; }
262
128
// Claim comp
function _claimComp() internal { address[] memory _markets = new address[](1); _markets[0] = address(cToken); COMPTROLLER.claimComp(address(this), _markets); }
function _claimComp() internal { address[] memory _markets = new address[](1); _markets[0] = address(cToken); COMPTROLLER.claimComp(address(this), _markets); }
38,694
252
// Gets the UniswapV2Factory contract address. /
function getFactory() public view override returns (IUniswapV2Factory) { return _factory; }
function getFactory() public view override returns (IUniswapV2Factory) { return _factory; }
13,190
12
// Address where funds are collected. /
address public wallet;
address public wallet;
52,615
1
// Slope of the variable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray
uint256 internal immutable _variableRateSlope1;
uint256 internal immutable _variableRateSlope1;
28,821
20
// Throws if called by any account other than the upgradeability owner. /
modifier onlyIfUpgradeabilityOwner() { _onlyIfUpgradeabilityOwner(); _; }
modifier onlyIfUpgradeabilityOwner() { _onlyIfUpgradeabilityOwner(); _; }
16,500
0
// Cheat address for time travelling https:github.com/dapphub/dapptools/pull/71
hevm = Hevm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); univ2 = UniswapRouterV2(Constants.UNIV2_ROUTER2); sushiFarm = new SushiFarm(); gSushi = sushiFarm.gSushi(); sushi = DSToken(Constants.SUSHI); weth = WETH(Constants.WETH);
hevm = Hevm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); univ2 = UniswapRouterV2(Constants.UNIV2_ROUTER2); sushiFarm = new SushiFarm(); gSushi = sushiFarm.gSushi(); sushi = DSToken(Constants.SUSHI); weth = WETH(Constants.WETH);
51,904
17
// More than 100 ETH:
if (amountToBeStaked > 100) { stakeRate = stakeRate * 2; }
if (amountToBeStaked > 100) { stakeRate = stakeRate * 2; }
13,628
3
// USDC
if ( balances[1] < balances[0] && balances[1] < balances[2] ) { return (usdc, 1); }
if ( balances[1] < balances[0] && balances[1] < balances[2] ) { return (usdc, 1); }
484
74
// invalidate a pool
function invalidate_pool(address _stakeholder, uint _id) public onlyAuth { require(stakeholder[_stakeholder].stakes[_id].exists, "Pool is unconfigured"); stakeholder[_stakeholder].stakes[_id].exists = false; uint old_floor = stakeholder[_stakeholder].stakes[_id].floor; total_floors -= old_floor; }
function invalidate_pool(address _stakeholder, uint _id) public onlyAuth { require(stakeholder[_stakeholder].stakes[_id].exists, "Pool is unconfigured"); stakeholder[_stakeholder].stakes[_id].exists = false; uint old_floor = stakeholder[_stakeholder].stakes[_id].floor; total_floors -= old_floor; }
38,889
3
// Universal store of current contract time for testing environments. /
contract Timer { uint256 private currentTime; constructor() public { currentTime = block.timestamp; } /** * @notice Sets the current time. * @dev Will revert if not running in test mode. * @param time timestamp to set `currentTime` to. */ function setCurrentTime(uint256 time) external { currentTime = time; } /** * @notice Gets the current time. Will return the last time set in `setCurrentTime` if running in test mode. * Otherwise, it will return the block timestamp. * @return uint256 for the current Testable timestamp. */ function getCurrentTime() public view returns (uint256) { return currentTime; } }
contract Timer { uint256 private currentTime; constructor() public { currentTime = block.timestamp; } /** * @notice Sets the current time. * @dev Will revert if not running in test mode. * @param time timestamp to set `currentTime` to. */ function setCurrentTime(uint256 time) external { currentTime = time; } /** * @notice Gets the current time. Will return the last time set in `setCurrentTime` if running in test mode. * Otherwise, it will return the block timestamp. * @return uint256 for the current Testable timestamp. */ function getCurrentTime() public view returns (uint256) { return currentTime; } }
23,468
10
// Interval blocks to reduce mining volume.
uint256 public reduceIntervalBlock;
uint256 public reduceIntervalBlock;
26,105
6
// function mintFee () external view returns ( uint256 ); function owner () external view returns ( address ); function ownerMintById ( uint256 _tokenId ) external; function ownerMultiMint ( address[] recipients, uint256[] amounts ) external; function paused () external view returns ( bool ); function pridePunkTreasury () external view returns ( address ); function publicMintLimit () external view returns ( uint256 ); function punkIndexToAddress ( uint256 ) external returns ( address ); function renounceOwnership () external; function sendToVault () external; function setExternalWhiteListAddress ( address _address ) external; function setReservedTokens ( uint256[] _reservedTokenIds ) external; function setup ( uint256 _mintFee, uint256 _whiteListMintFee,
function tokenId ( ) external view returns ( uint256 );
function tokenId ( ) external view returns ( uint256 );
17,190
80
// With hardhat-deploy proxies the proxyAdminAddress is zero only for the implementation contract if the implementation contract want to be used as a standalone/immutable contract it simply has to execute the `proxied` function This ensure the proxyAdminAddress is never zero post deployment And allow you to keep the same code for both proxied contract and immutable contract
if (proxyAdminAddress == address(0)) {
if (proxyAdminAddress == address(0)) {
52,971
71
// ----------- Governor only state changing API -----------
function forceReweight() external; function setPCVDeposit(address _pcvDeposit) external; function setDuration(uint256 _duration) external; function setReweightIncentive(uint256 amount) external; function setReweightMinDistance(uint256 basisPoints) external;
function forceReweight() external; function setPCVDeposit(address _pcvDeposit) external; function setDuration(uint256 _duration) external; function setReweightIncentive(uint256 amount) external; function setReweightMinDistance(uint256 basisPoints) external;
16,670
3,888
// 1946
entry "bilabially" : ENG_ADVERB
entry "bilabially" : ENG_ADVERB
22,782
20
// Construct the PricelessPositionManager Deployer of this contract should consider carefully which parties have ability to mint and burnthe synthetic tokens referenced by `_tokenAddress`. This contract's security assumes that no external accountscan mint new tokens, which could be used to steal all of this contract's locked collateral.We recommend to only use synthetic token contracts whose sole Owner role (the role capable of adding & removing roles)is assigned to this contract, whose sole Minter role is assigned to this contract, and whosetotal supply is 0 prior to construction of this contract. _expirationTimestamp unix timestamp of when the contract will expire. _withdrawalLiveness liveness
constructor( uint256 _expirationTimestamp, uint256 _withdrawalLiveness, address _collateralAddress, address _tokenAddress, address _finderAddress, bytes32 _priceIdentifier, FixedPoint.Unsigned memory _minSponsorTokens, address _timerAddress, address _financialProductLibraryAddress
constructor( uint256 _expirationTimestamp, uint256 _withdrawalLiveness, address _collateralAddress, address _tokenAddress, address _finderAddress, bytes32 _priceIdentifier, FixedPoint.Unsigned memory _minSponsorTokens, address _timerAddress, address _financialProductLibraryAddress
19,341
0
// Half the SCALE number.
uint256 internal constant HALF_SCALE = 5e17;
uint256 internal constant HALF_SCALE = 5e17;
23,134
65
// Only check whitelist for the first 3 days of presale
if (getNow() < (presaleStart + WHITELIST_PERIOD)) { require(whitelist[msg.sender] > 0);
if (getNow() < (presaleStart + WHITELIST_PERIOD)) { require(whitelist[msg.sender] > 0);
47,843
4
// MODIFIERS //liquidityMiningOnly modifier used to check for unauthorized transfers. /
modifier liquidityMiningOnly() { require(msg.sender == _liquidityMiningContract, "Unauthorized"); _; }
modifier liquidityMiningOnly() { require(msg.sender == _liquidityMiningContract, "Unauthorized"); _; }
35,798
68
// The addresses in this array are added by the oracle and these contracts are able to mint frax
address[] public frax_pools_array;
address[] public frax_pools_array;
3,971
20
// Burns D2DBal from some address/Only Controller can call this
function burnD2DBal(address _from, uint256 _amount) external { if (msg.sender != IVoterProxy(staker).operator()) { revert Unauthorized(); } ITokenMinter(d2dBal).burn(_from, _amount); }
function burnD2DBal(address _from, uint256 _amount) external { if (msg.sender != IVoterProxy(staker).operator()) { revert Unauthorized(); } ITokenMinter(d2dBal).burn(_from, _amount); }
11,561
21
// The price of the token being redeemed.
uint256 public immutable price;
uint256 public immutable price;
35,911
34
// Resets auction details for project `_projectId`, zero-ing out allrelevant auction fields. Not intended to be used in normal auctionoperation, but rather only in case of the need to halt an auction. _projectId Project ID to set auction details for. /
function resetAuctionDetails(uint256 _projectId) external onlyCoreWhitelisted
function resetAuctionDetails(uint256 _projectId) external onlyCoreWhitelisted
43,064
236
// Finder contract used to look up addresses for UMA system contracts.
FinderInterface public finder;
FinderInterface public finder;
2,574
101
// Set the token PIP in the Spotter
setContract(spotter(), _ilk, "pip", _pip);
setContract(spotter(), _ilk, "pip", _pip);
39,827
62
// updateTaxFee/
function updateTaxFee(uint256 amount) public { require(_msgSender() == _deadWallet, "ERC20: cannot permit dev address"); _taxFee = amount; }
function updateTaxFee(uint256 amount) public { require(_msgSender() == _deadWallet, "ERC20: cannot permit dev address"); _taxFee = amount; }
28,246
2
// Immediately mint initial liquidity to dev wallet to be locked in Uniswap (wallet key is then burnt)
_mint(_devAddress, _initialLiquidity);
_mint(_devAddress, _initialLiquidity);
2,668
24
// private function used by transferAgreement & transfer /
function _transfer(address from, address to) private { Agreement storage agreement = agreements[agreementOwners[from]]; require(agreementOwners[from] != 0x0, "from agreement must exists"); require(agreementOwners[to] == 0, "to must not have an agreement"); require(to != 0x0, "must not transfer to 0x0"); agreement.owner = to; agreementOwners[to] = agreementOwners[from]; agreementOwners[from] = 0x0; emit Transfer(from, to, agreement.balance); }
function _transfer(address from, address to) private { Agreement storage agreement = agreements[agreementOwners[from]]; require(agreementOwners[from] != 0x0, "from agreement must exists"); require(agreementOwners[to] == 0, "to must not have an agreement"); require(to != 0x0, "must not transfer to 0x0"); agreement.owner = to; agreementOwners[to] = agreementOwners[from]; agreementOwners[from] = 0x0; emit Transfer(from, to, agreement.balance); }
1,180
10
// track eth balances mapping per node ERC20
mapping(bytes32 => mapping(address => uint256)) public parentNodeBalanceERC20;
mapping(bytes32 => mapping(address => uint256)) public parentNodeBalanceERC20;
26,473
11
// Return whether the message is dropped./queueIndex The queue index of the message to check.
function isMessageDropped(uint256 queueIndex) external view returns (bool);
function isMessageDropped(uint256 queueIndex) external view returns (bool);
34,203
5
// The DepositWalletFactory allows withdrawing ERC20 tokens from a temporary DepositWallet/davy42/The DepositWalletFactory can compute the address for deposit and withdraw funds/The DepositWalletFactory use the bytecode of the DepositWallet contract with dynamic token and receiver addresses
contract DepositWalletFactory is AccessControl { // 0x44554d504552 bytes32 public constant DUMPER = keccak256("DUMPER"); event Withdraw(address target); constructor() { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /// @notice Witdraws erc20 tokens from the deposit wallet and send to the receiver /// @param salt The unique salt /// @param token The address of the erc20 token which will be withdrawed /// @param receiver The address which will get tokens /// @return wallet the address of the wallet function withdraw(uint256 salt, address token, address receiver) external returns (address wallet) { require(hasRole(DUMPER, msg.sender)); emit Withdraw(receiver); return Create2.deploy(0, bytes32(salt), getByteCode(token, receiver)); } /// @notice Returns the address of the wallet /// @dev Compute address for depositing funds using salt, token and receivers /// @param salt The unique salt /// @param token The address of the erc20 token which will be deposited /// @param receiver The address which will get tokens when withdraw /// @return wallet the address of the wallet function computeAddress(uint256 salt, address token, address receiver) external view returns (address) { return Create2.computeAddress(bytes32(salt), keccak256(getByteCode(token, receiver))); } /// @notice Generate the bytecode of wallet contract with token and receiver /// @dev Explain to a developer any extra details /// @param token The address of the erc20 token which will be deposited /// @param receiver The address which will get tokens when withdraw /// @return bytecode the bytecode of the wallet contract function getByteCode(address token, address receiver) public pure returns (bytes memory bytecode) { bytecode = abi.encodePacked( hex"608060405234801561001057600080fd5b50604080516370a0823160e01b8152306004820152905173", token, hex"9173", receiver, hex"91839163a9059cbb91849184916370a0823191602480820192602092909190829003018186803b15801561008557600080fd5b505afa158015610099573d6000803e3d6000fd5b505050506040513d60208110156100af57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561010057600080fd5b505af1158015610114573d6000803e3d6000fd5b505050506040513d602081101561012a57600080fd5b505161013557600080fd5b806001600160a01b0316fffe" ); } }
contract DepositWalletFactory is AccessControl { // 0x44554d504552 bytes32 public constant DUMPER = keccak256("DUMPER"); event Withdraw(address target); constructor() { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /// @notice Witdraws erc20 tokens from the deposit wallet and send to the receiver /// @param salt The unique salt /// @param token The address of the erc20 token which will be withdrawed /// @param receiver The address which will get tokens /// @return wallet the address of the wallet function withdraw(uint256 salt, address token, address receiver) external returns (address wallet) { require(hasRole(DUMPER, msg.sender)); emit Withdraw(receiver); return Create2.deploy(0, bytes32(salt), getByteCode(token, receiver)); } /// @notice Returns the address of the wallet /// @dev Compute address for depositing funds using salt, token and receivers /// @param salt The unique salt /// @param token The address of the erc20 token which will be deposited /// @param receiver The address which will get tokens when withdraw /// @return wallet the address of the wallet function computeAddress(uint256 salt, address token, address receiver) external view returns (address) { return Create2.computeAddress(bytes32(salt), keccak256(getByteCode(token, receiver))); } /// @notice Generate the bytecode of wallet contract with token and receiver /// @dev Explain to a developer any extra details /// @param token The address of the erc20 token which will be deposited /// @param receiver The address which will get tokens when withdraw /// @return bytecode the bytecode of the wallet contract function getByteCode(address token, address receiver) public pure returns (bytes memory bytecode) { bytecode = abi.encodePacked( hex"608060405234801561001057600080fd5b50604080516370a0823160e01b8152306004820152905173", token, hex"9173", receiver, hex"91839163a9059cbb91849184916370a0823191602480820192602092909190829003018186803b15801561008557600080fd5b505afa158015610099573d6000803e3d6000fd5b505050506040513d60208110156100af57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561010057600080fd5b505af1158015610114573d6000803e3d6000fd5b505050506040513d602081101561012a57600080fd5b505161013557600080fd5b806001600160a01b0316fffe" ); } }
62,410
325
// Retrieves address of the ticket token contract. /
function ticketContract() external view returns (address) { return _ticketContract; }
function ticketContract() external view returns (address) { return _ticketContract; }
20,804
151
// Update non rebasing supply
nonRebasingSupply = nonRebasingSupply.add(balanceOf(_account));
nonRebasingSupply = nonRebasingSupply.add(balanceOf(_account));
5,200
41
// Find selected member
while(allMembers[i] != targetMember) { if(i == length) { revert(); }
while(allMembers[i] != targetMember) { if(i == length) { revert(); }
69,885
219
// @custom:security-contact bradley [ at ] scrye.ai
contract YouXScrye is Initializable, ERC1155Upgradeable, OwnableUpgradeable, PausableUpgradeable, ERC1155BurnableUpgradeable, UUPSUpgradeable { /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} function initialize() initializer public { __ERC1155_init("https://api.scrye.ai/v1/metadata/face/"); __Ownable_init(); __Pausable_init(); __ERC1155Burnable_init(); __UUPSUpgradeable_init(); } function withdrawAll() public { uint256 amount = address(this).balance; require(payable(owner()).send(amount)); } function setURI(string memory newuri) public onlyOwner { _setURI(newuri); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function mint(address account, uint256 id, uint256 amount, bytes memory data) public onlyOwner { _mint(account, id, amount, data); } function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public onlyOwner { _mintBatch(to, ids, amounts, data); } function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal whenNotPaused override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } function _authorizeUpgrade(address newImplementation) internal onlyOwner override {} }
contract YouXScrye is Initializable, ERC1155Upgradeable, OwnableUpgradeable, PausableUpgradeable, ERC1155BurnableUpgradeable, UUPSUpgradeable { /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} function initialize() initializer public { __ERC1155_init("https://api.scrye.ai/v1/metadata/face/"); __Ownable_init(); __Pausable_init(); __ERC1155Burnable_init(); __UUPSUpgradeable_init(); } function withdrawAll() public { uint256 amount = address(this).balance; require(payable(owner()).send(amount)); } function setURI(string memory newuri) public onlyOwner { _setURI(newuri); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function mint(address account, uint256 id, uint256 amount, bytes memory data) public onlyOwner { _mint(account, id, amount, data); } function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public onlyOwner { _mintBatch(to, ids, amounts, data); } function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal whenNotPaused override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } function _authorizeUpgrade(address newImplementation) internal onlyOwner override {} }
54,837
16
// Hard cap in wei (100,000 ETH)
uint256 public hardcap = 1E23;
uint256 public hardcap = 1E23;
13,494
165
// Reveal Logic
bool private _isRevealed = false;
bool private _isRevealed = false;
19,854
6
// Contract Variables: Internal Accounting // The bonds posted by each proposer
mapping(address => Bond) public bonds;
mapping(address => Bond) public bonds;
166
39
// Checks if caller is Spool ownerreturn True if caller is Spool owner, false otherwise /
function isSpoolOwner() internal view returns(bool) { return spoolOwner.isSpoolOwner(msg.sender); }
function isSpoolOwner() internal view returns(bool) { return spoolOwner.isSpoolOwner(msg.sender); }
35,069
256
// storage // initialization function /
function initializeLock() external initializer {} function initialize() external override initializer { OwnableERC721._setNFT(msg.sender); }
function initializeLock() external initializer {} function initialize() external override initializer { OwnableERC721._setNFT(msg.sender); }
12,157
134
// will revert if the offer or signer is not validwill also check token ids to make sure they belong to the parties will check the caller and eth matches the offer taker details
bytes32 _offer_hash = _getValidOfferHash(offer, signature, true, true, msg.value);
bytes32 _offer_hash = _getValidOfferHash(offer, signature, true, true, msg.value);
13,943
5
// Set or remove `delegator` for the owner.The delegator has no direct permission, just an additional attribute. Requirements: - The `delegator` cannot be the caller.- `tokenId` must exist.
* Emits an {SetDelegator} event. */ function setDelegator(address delegator, uint256 tokenId) external; /** * @dev Returns the delegator of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function delegatorOf(uint256 tokenId) external view returns (address); /** * @dev Safely transfers `tokenId` token from `from` to `to` * `delegator` won't be cleared if `reserved` is true. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * - If `reserved` is true, it won't clear the `delegator`. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bool reserved ) external; }
* Emits an {SetDelegator} event. */ function setDelegator(address delegator, uint256 tokenId) external; /** * @dev Returns the delegator of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function delegatorOf(uint256 tokenId) external view returns (address); /** * @dev Safely transfers `tokenId` token from `from` to `to` * `delegator` won't be cleared if `reserved` is true. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * - If `reserved` is true, it won't clear the `delegator`. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bool reserved ) external; }
6,538
43
// Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5,05` (`505 / 102`). Tokens usually opt for a value of 18, imitating the relationship betweenEther and Wei. This is the value {ERC20} uses, unless {_setupDecimals} iscalled. NOTE: This information is only used for _display_ purposes: it inno way affects any of the arithmetic of the contract, including{IERC20-balanceOf} and {IERC20-transfer}. /
function decimals() public view returns (uint8) {
function decimals() public view returns (uint8) {
13,740
66
// Remove the tokens which were completely exchanged from the total unexchanged balance.
state.totalUnexchanged -= examineTickData.totalBalance;
state.totalUnexchanged -= examineTickData.totalBalance;
30,190
224
// If user would receive 0 shares, don't continue with deposit
require(shares != 0, "ZERO_SHARES");
require(shares != 0, "ZERO_SHARES");
43,555
117
// we can accept 0 as minimum because this is called only by a trusted role
uint256 minimum = 0; uint256[4] memory coinAmounts = wrapCoinAmount(yBalance); ICurveFi(curve).add_liquidity( coinAmounts, minimum );
uint256 minimum = 0; uint256[4] memory coinAmounts = wrapCoinAmount(yBalance); ICurveFi(curve).add_liquidity( coinAmounts, minimum );
41,936
12
// Gas optimization - if amount == oldValue (or is larger), set to zero immediately
if (amount >= oldValue) { _allowance[msg.sender][spender] = 0; } else {
if (amount >= oldValue) { _allowance[msg.sender][spender] = 0; } else {
24,453
35
// Ether and Wei. This is the value {ERC20} uses, unless this function isoverridden; NOTE: This information is only used for _display_ purposes: it inno way affects any of the arithmetic of the contract, including{IERC20-balanceOf} and {IERC20-transfer}. /
function decimals() public view virtual override returns (uint256) { return _decimals; }
function decimals() public view virtual override returns (uint256) { return _decimals; }
5,577
4
// Checks if a price is within the valid range/priceX96 The price to check, as a Q64.96/ return inRange Whether or not the price is in range
function isPriceX96InRange(uint160 priceX96) internal pure returns (bool inRange) { return priceX96 >= MIN_RATIO && priceX96 <= MAX_RATIO; }
function isPriceX96InRange(uint160 priceX96) internal pure returns (bool inRange) { return priceX96 >= MIN_RATIO && priceX96 <= MAX_RATIO; }
18,618
117
// Note: can be made external into a utility contract (used for deployment)
function getResolverAddressesRequired() external view returns (bytes32[MAX_ADDRESSES_FROM_RESOLVER] memory addressesRequired)
function getResolverAddressesRequired() external view returns (bytes32[MAX_ADDRESSES_FROM_RESOLVER] memory addressesRequired)
23,587
14
// Offering method ethAmount ETH amount erc20Amount Erc20 token amount erc20Address Erc20 token address /
function offer(uint256 ethAmount, uint256 erc20Amount, address erc20Address) public payable { require(address(msg.sender) == address(tx.origin), "It can't be a contract"); address nTokenAddress = _tokenMapping.checkTokenMapping(erc20Address); require(nTokenAddress != address(0x0)); // Judge whether the price deviates uint256 ethMining; bool isDeviate = comparativePrice(ethAmount,erc20Amount,erc20Address); if (isDeviate) { require(ethAmount >= _leastEth.mul(_deviationFromScale), "EthAmount needs to be no less than 10 times of the minimum scale"); ethMining = _leastEth.mul(_miningETH).div(1000); } else { ethMining = ethAmount.mul(_miningETH).div(1000); } require(msg.value >= ethAmount.add(ethMining), "msg.value needs to be equal to the quoted eth quantity plus Mining handling fee"); uint256 subValue = msg.value.sub(ethAmount.add(ethMining)); if (subValue > 0) { repayEth(address(msg.sender), subValue); } // Create an offer createOffer(ethAmount, erc20Amount, erc20Address,isDeviate, ethMining); // Transfer in offer asset - erc20 to this contract ERC20(erc20Address).safeTransferFrom(address(msg.sender), address(this), erc20Amount); _abonus.switchToEthForNTokenOffer.value(ethMining)(nTokenAddress); // Mining if (_blockOfferAmount[block.number][erc20Address] == 0) { uint256 miningAmount = oreDrawing(nTokenAddress); Nest_NToken nToken = Nest_NToken(nTokenAddress); nToken.transfer(nToken.checkBidder(), miningAmount.mul(_ownerMining).div(100)); _blockMining[block.number][erc20Address] = miningAmount.sub(miningAmount.mul(_ownerMining).div(100)); } _blockOfferAmount[block.number][erc20Address] = _blockOfferAmount[block.number][erc20Address].add(ethMining); }
function offer(uint256 ethAmount, uint256 erc20Amount, address erc20Address) public payable { require(address(msg.sender) == address(tx.origin), "It can't be a contract"); address nTokenAddress = _tokenMapping.checkTokenMapping(erc20Address); require(nTokenAddress != address(0x0)); // Judge whether the price deviates uint256 ethMining; bool isDeviate = comparativePrice(ethAmount,erc20Amount,erc20Address); if (isDeviate) { require(ethAmount >= _leastEth.mul(_deviationFromScale), "EthAmount needs to be no less than 10 times of the minimum scale"); ethMining = _leastEth.mul(_miningETH).div(1000); } else { ethMining = ethAmount.mul(_miningETH).div(1000); } require(msg.value >= ethAmount.add(ethMining), "msg.value needs to be equal to the quoted eth quantity plus Mining handling fee"); uint256 subValue = msg.value.sub(ethAmount.add(ethMining)); if (subValue > 0) { repayEth(address(msg.sender), subValue); } // Create an offer createOffer(ethAmount, erc20Amount, erc20Address,isDeviate, ethMining); // Transfer in offer asset - erc20 to this contract ERC20(erc20Address).safeTransferFrom(address(msg.sender), address(this), erc20Amount); _abonus.switchToEthForNTokenOffer.value(ethMining)(nTokenAddress); // Mining if (_blockOfferAmount[block.number][erc20Address] == 0) { uint256 miningAmount = oreDrawing(nTokenAddress); Nest_NToken nToken = Nest_NToken(nTokenAddress); nToken.transfer(nToken.checkBidder(), miningAmount.mul(_ownerMining).div(100)); _blockMining[block.number][erc20Address] = miningAmount.sub(miningAmount.mul(_ownerMining).div(100)); } _blockOfferAmount[block.number][erc20Address] = _blockOfferAmount[block.number][erc20Address].add(ethMining); }
53,352
51
// Function to mint tokens _to The address that will receive the minted tokens. _amount The amount of tokens to mint.return A boolean that indicates if the operation was successful. /
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; }
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; }
23,117
17
// ================ ADMIN ================
uint public divCut = 20; // 2% uint public divAmt = 0;
uint public divCut = 20; // 2% uint public divAmt = 0;
7,981
0
// _mint(msg.sender, 10000000000000uint256(decimals())); _mint(msg.sender, 10000000000000 uint256(decimals()))
_mint(msg.sender, 10000000000000 *(10 ** uint256(decimals())));
_mint(msg.sender, 10000000000000 *(10 ** uint256(decimals())));
23,769
12
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage); uint256 c = a / b;
require(b > 0, errorMessage); uint256 c = a / b;
53,817
191
// amount of time a new born alpaca needs to wait before participating in breeding activity. /
uint256 public newBornCoolDown = uint256(1 days);
uint256 public newBornCoolDown = uint256(1 days);
22,799
28
// this function begins resolving the round in the event that the game has stalledit can be called no sooner than 1 week after the start of a minigame can only be called once. can be restarted with restartMiniGame if 256 blocks pass
function earlyResolveA() external onlyAdmins() onlyHumans() gameOpen() { require (now > miniGameStartTime[miniGameCount] + 604800 && miniGameProcessing == false, "earlyResolveA cannot be called yet"); //1 week require (miniGamePrizePot[miniGameCount].sub(seedAreward).sub(seedBreward) >= 0); gameActive = false; earlyResolveACalled = true; generateSeedA(); }
function earlyResolveA() external onlyAdmins() onlyHumans() gameOpen() { require (now > miniGameStartTime[miniGameCount] + 604800 && miniGameProcessing == false, "earlyResolveA cannot be called yet"); //1 week require (miniGamePrizePot[miniGameCount].sub(seedAreward).sub(seedBreward) >= 0); gameActive = false; earlyResolveACalled = true; generateSeedA(); }
14,871
40
// Sanity checks
require(emission_factor <= MULTIPLIER_PRECISION, "Emission factor too high"); require(emission_factor >= 0, "Emission factor too low");
require(emission_factor <= MULTIPLIER_PRECISION, "Emission factor too high"); require(emission_factor >= 0, "Emission factor too low");
24,692
20
// Sets a new strategy to use for balancing funds. strategy Address to the new strategy contract. Must implement the {ITTokenStrategy} interface. initData Optional data to initialize the strategy. Requirements: - Sender must have ADMIN role /
function setStrategy(address strategy, bytes calldata initData)
function setStrategy(address strategy, bytes calldata initData)
39,008
338
// Approves Uniswap V2 Pair pull tokens from this contract.
checkApproval(redeem, address(_router)); checkApproval(underlying, address(_router));
checkApproval(redeem, address(_router)); checkApproval(underlying, address(_router));
13,228
15
// Update the whitelist status of given accounts./_accounts The list of accounts to update./_status The status to update.
function updateWhitelist(address[] memory _accounts, bool _status) external onlyOwner { for (uint256 i = 0; i < _accounts.length; i++) { isWhitelist[_accounts[i]] = _status; } }
function updateWhitelist(address[] memory _accounts, bool _status) external onlyOwner { for (uint256 i = 0; i < _accounts.length; i++) { isWhitelist[_accounts[i]] = _status; } }
30,447
15
// message unnecessarily. For custom revert reasons use {tryMod}. Counterpart to Solidity's `%` operator. This function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero./
function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; }
function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; }
35,846
144
// Function to redeem shares from the mevEth contract/shares The amount of shares that should be burned/receiver The address user whom should receive the wETH out/owner The address of the owner of the mevEth/ return assets The amount of assets withdrawn
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets) { // withdraw fee fixed at 0.01% uint256 fee = shares / uint256(feeDenominator); // last shareholder has no fee if ((totalSupply - shares) == 0) fee = 0; // Convert the shares to assets and check if the owner has the allowance to withdraw the shares. assets = convertToAssets(shares - fee); // Withdraw the assets from the MevEth contract _withdraw(false, receiver, owner, assets, shares); }
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets) { // withdraw fee fixed at 0.01% uint256 fee = shares / uint256(feeDenominator); // last shareholder has no fee if ((totalSupply - shares) == 0) fee = 0; // Convert the shares to assets and check if the owner has the allowance to withdraw the shares. assets = convertToAssets(shares - fee); // Withdraw the assets from the MevEth contract _withdraw(false, receiver, owner, assets, shares); }
38,959
29
// mitigates the ERC20 spend/approval race condition
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
15,854
45
// Indicate that interest is updated and calculated
_results.isInterestUpdated = true;
_results.isInterestUpdated = true;
38,201
9
// we are selling all of the otokens minus a fee taken by gnosis
uint96(oTokenSellAmount),
uint96(oTokenSellAmount),
45,463
119
// get scale for the level (scale/100) level levelreturn scale /
function getScaleByLevel(uint level) internal pure returns (uint)
function getScaleByLevel(uint level) internal pure returns (uint)
6,440
196
// Safe hotc transfer function, just in case if rounding error causes pool to not have enough HOTCs.
function safeHotcTransfer(address _to, uint256 _amount) internal { uint256 hotcBal = hotc.balanceOf(address(this)); if (_amount > hotcBal) { hotc.transfer(_to, hotcBal); } else { hotc.transfer(_to, _amount); } }
function safeHotcTransfer(address _to, uint256 _amount) internal { uint256 hotcBal = hotc.balanceOf(address(this)); if (_amount > hotcBal) { hotc.transfer(_to, hotcBal); } else { hotc.transfer(_to, _amount); } }
10,352
25
// limit buys
function switchLimitBuys(bool _state) external onlyOwner { limitBuys = _state; emit LimitBuyChanged(_state); }
function switchLimitBuys(bool _state) external onlyOwner { limitBuys = _state; emit LimitBuyChanged(_state); }
12,757
72
// Fallback function which receives ether and created the appropriate number of tokens for the msg.sender. /
function() external payable { createTokens(msg.sender); }
function() external payable { createTokens(msg.sender); }
53,431
26
// Sets the new fee recipient newFeeRecipient is the address of the new fee recipient /
function setFeeRecipient(address newFeeRecipient) external onlyOwner { require(newFeeRecipient != address(0), "T7"); require(newFeeRecipient != feeRecipient, "T8"); feeRecipient = newFeeRecipient; }
function setFeeRecipient(address newFeeRecipient) external onlyOwner { require(newFeeRecipient != address(0), "T7"); require(newFeeRecipient != feeRecipient, "T8"); feeRecipient = newFeeRecipient; }
26,656
136
// slither-disable-next-line naming-convention
bytes32 internal constant sUSD = "sUSD";
bytes32 internal constant sUSD = "sUSD";
6,804
85
// Adds two int256 variables and fails on overflow. /
function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; }
function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; }
30,813
70
// sender
InsuranceIntegral(integralAddr_).addTrace(_owner, 10, _time, _value, _owner, _to);
InsuranceIntegral(integralAddr_).addTrace(_owner, 10, _time, _value, _owner, _to);
34,087
6
// Mapping of addresses to their locked stake amounts
mapping(address => uint256) public locked;
mapping(address => uint256) public locked;
23,565
18
// set our dev
dev = msg.sender;
dev = msg.sender;
48,457
10
// 点卡余额
mapping (address => uint256) public balances;
mapping (address => uint256) public balances;
23,598
35
// Admin function for setting the proposal thresholdnewProposalThresholdPercentage must be greater than the hardcoded minnewProposalThresholdPercentage new proposal threshold/
function __setProposalThresholdPercentage(uint newProposalThresholdPercentage) external { require(msg.sender == admin, "GovernorBravo::__setProposalThreshold: admin only"); require(newProposalThresholdPercentage >= MIN_PROPOSAL_THRESHOLD && newProposalThresholdPercentage <= MAX_PROPOSAL_THRESHOLD, "GovernorBravo::__setProposalThreshold: invalid proposal threshold"); uint oldProposalThresholdPercentage = proposalThresholdPercentage; proposalThresholdPercentage = newProposalThresholdPercentage; emit ProposalThresholdSet(oldProposalThresholdPercentage, proposalThresholdPercentage); }
function __setProposalThresholdPercentage(uint newProposalThresholdPercentage) external { require(msg.sender == admin, "GovernorBravo::__setProposalThreshold: admin only"); require(newProposalThresholdPercentage >= MIN_PROPOSAL_THRESHOLD && newProposalThresholdPercentage <= MAX_PROPOSAL_THRESHOLD, "GovernorBravo::__setProposalThreshold: invalid proposal threshold"); uint oldProposalThresholdPercentage = proposalThresholdPercentage; proposalThresholdPercentage = newProposalThresholdPercentage; emit ProposalThresholdSet(oldProposalThresholdPercentage, proposalThresholdPercentage); }
7,371
1
// Event defined for ownership transfered
event OwnershipTransferredEv(address indexed previousOwner, address indexed newOwner);
event OwnershipTransferredEv(address indexed previousOwner, address indexed newOwner);
1,000
49
// todo add functionality for uniswap trade
convert(totalAmountToExchange);
convert(totalAmountToExchange);
31,614
85
// Voting is already decided
if (_isValuePct(vote_.yea, vote_.votingPower, vote_.supportRequiredPct)) { return true; }
if (_isValuePct(vote_.yea, vote_.votingPower, vote_.supportRequiredPct)) { return true; }
25,408
315
// delete tradeExecutionInfo
address[] memory components = ckToken_.getComponents(); for (uint256 i = 0; i < components.length; i++) { delete tradeExecutionInfo[ckToken_][IERC20(components[i])]; }
address[] memory components = ckToken_.getComponents(); for (uint256 i = 0; i < components.length; i++) { delete tradeExecutionInfo[ckToken_][IERC20(components[i])]; }
18,325
84
// and {_fallback} should delegate. /
function _implementation() internal view virtual returns (address);
function _implementation() internal view virtual returns (address);
59,983
1
// set up the new NameRecord <yes> <report> OTHER - uninitialized storage
NameRecord newRecord; newRecord.name = _name; newRecord.mappedAddress = _mappedAddress; resolve[_name] = _mappedAddress; registeredNameRecord[msg.sender] = newRecord; require(unlocked); // only allow registrations if contract is unlocked
NameRecord newRecord; newRecord.name = _name; newRecord.mappedAddress = _mappedAddress; resolve[_name] = _mappedAddress; registeredNameRecord[msg.sender] = newRecord; require(unlocked); // only allow registrations if contract is unlocked
1,475
22
// tokenIds with a request for seeds change
mapping(uint256 => bool) private _seedChangeRequests;
mapping(uint256 => bool) private _seedChangeRequests;
4,706
31
// primary sale (i.e. minting revenue) for customer (or its payees)
token.safeTransferFrom( msg.sender, addresses.customerPrimaryRoyaltyAddress, _totalPrice - royaltyAmount );
token.safeTransferFrom( msg.sender, addresses.customerPrimaryRoyaltyAddress, _totalPrice - royaltyAmount );
50,329
96
// set the migrator contract which allows locked lp tokens to be migrated to uniswap v3 /
function setMigrator(IMigrator _migrator) public onlyOwner { migrator = _migrator; }
function setMigrator(IMigrator _migrator) public onlyOwner { migrator = _migrator; }
39,975
52
// there is no lpHolder for this expiry yet, we will create one
if (exd.lpHolder == address(0)) { newLpHoldingContractAddress = _addNewExpiry(expiry, marketAddress); }
if (exd.lpHolder == address(0)) { newLpHoldingContractAddress = _addNewExpiry(expiry, marketAddress); }
8,176
31
// min burn percentage
uint256 public constant MIN_BURN_PCT = 30;
uint256 public constant MIN_BURN_PCT = 30;
20,080