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
154
// Effects Send TODL to the owner of the token ID
if(contractId == 0) { _mint(tokenOwner, todlForOgLoot); } else if (contractId == 1) {
if(contractId == 0) { _mint(tokenOwner, todlForOgLoot); } else if (contractId == 1) {
13,951
61
// Returns the interface hash for an `interfaceName`, as defined in thecorresponding /
function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
15,335
167
// get total amount of withdrawal requests
function totalWithdrawalRequestedAmount(uint256 _pool) public view returns(uint256) { uint256 total; for (uint256 i=0; i<requests[_pool].length; i++) { total = total.add(requests[_pool][i].amount); } return total; }
function totalWithdrawalRequestedAmount(uint256 _pool) public view returns(uint256) { uint256 total; for (uint256 i=0; i<requests[_pool].length; i++) { total = total.add(requests[_pool][i].amount); } return total; }
42,710
51
// Sells base and frees the proceeds of the sale.amountBase The amount of base to sell. /
function freeBase(uint amountBase) external override onlyOptionMarket { _require(amountBase <= lockedCollateral.base, Error.FreeingMoreBaseThanLocked); lockedCollateral.base = lockedCollateral.base.sub(amountBase); emit BaseFreed(amountBase, lockedCollateral.base); }
function freeBase(uint amountBase) external override onlyOptionMarket { _require(amountBase <= lockedCollateral.base, Error.FreeingMoreBaseThanLocked); lockedCollateral.base = lockedCollateral.base.sub(amountBase); emit BaseFreed(amountBase, lockedCollateral.base); }
9,675
45
// Calculate the tax
taxAmount = amount.mul(buyTax).div(100); if(to == uniswapV2Pair && from!= address(this) ){ taxAmount = amount.mul(sellTax).div(100); }
taxAmount = amount.mul(buyTax).div(100); if(to == uniswapV2Pair && from!= address(this) ){ taxAmount = amount.mul(sellTax).div(100); }
34,285
24
// allows admins to set the address of the token associated with the DAOtokenContractAddressthe address of the ERC20 asset /
function setNativeTokenAddress(address tokenContractAddress) public onlyOwner notShutdown
function setNativeTokenAddress(address tokenContractAddress) public onlyOwner notShutdown
37,503
17
// check allowance
if (IERC20(wUST).allowance(address(this), address(operation)) == 0) { IERC20(wUST).safeApprove(address(operation), type(uint256).max); IERC20(aUST).safeApprove(address(operation), type(uint256).max); }
if (IERC20(wUST).allowance(address(this), address(operation)) == 0) { IERC20(wUST).safeApprove(address(operation), type(uint256).max); IERC20(aUST).safeApprove(address(operation), type(uint256).max); }
73,652
20
// if there are mature deposits, treat them as staked
if (m.timestamp.add(timeToStake) <= block.timestamp) { return staked[_userAddress].add(m.amount); }
if (m.timestamp.add(timeToStake) <= block.timestamp) { return staked[_userAddress].add(m.amount); }
14,331
50
// Emitted when a distribution occurs amount Amount of TRU distributed to farm /
event Distributed(uint256 amount);
event Distributed(uint256 amount);
23,211
63
// some view functions which may need in case / to find free slot id in the given network unter particular plan index for given referrer id under main or sub tree
function findBlankSlot(uint256 _networkId,uint256 _planIndex,uint256 _referrerId,bool mainTree, uint256 _maxChild) public view returns(uint256)
function findBlankSlot(uint256 _networkId,uint256 _planIndex,uint256 _referrerId,bool mainTree, uint256 _maxChild) public view returns(uint256)
3,082
16
// prove that output metadata memory range is contained in epoch's output memory range
require( Merkle.getRootAfterReplacementInDrive( getIntraDrivePosition(_v.inputIndex, KECCAK_LOG2_SIZE), KECCAK_LOG2_SIZE, _outputEpochLog2Size, keccak256(abi.encodePacked(_v.outputHashesRootHash)), _v.outputHashesInEpochSiblings ) == _outputsEpochRootHash, "outputsEpochRootHash incorrect" );
require( Merkle.getRootAfterReplacementInDrive( getIntraDrivePosition(_v.inputIndex, KECCAK_LOG2_SIZE), KECCAK_LOG2_SIZE, _outputEpochLog2Size, keccak256(abi.encodePacked(_v.outputHashesRootHash)), _v.outputHashesInEpochSiblings ) == _outputsEpochRootHash, "outputsEpochRootHash incorrect" );
49,749
91
// Returns the balance of the want token on the strategy /
function balanceOfWant() public view override returns (uint256) { return IERC20(want).balanceOf(address(this)); }
function balanceOfWant() public view override returns (uint256) { return IERC20(want).balanceOf(address(this)); }
79,268
9
// set default minters
_minters.push(owner); __Context_init(); __EIP712_init(name_, VERSION);
_minters.push(owner); __Context_init(); __EIP712_init(name_, VERSION);
7,322
67
// Freeze and unfreeze. /
function freeze() onlyOwner() { freeze = true; }
function freeze() onlyOwner() { freeze = true; }
36,538
18
// Function to check the amount of tokens that an owner allowed to a spender.owner address The address which owns the funds.spender address The address which will spend the funds. return A uint256 specifying the amount of tokens still available for the spender./
function allowance( address owner, address spender ) public view returns (uint256)
function allowance( address owner, address spender ) public view returns (uint256)
33,233
238
// Update _totalBalance with interest
_updateTotalBalanceWithNewYBalance(tid, yBalanceUnnormalized.mul(_normalizeBalance(info))); uint256 targetCash = yBalanceUnnormalized.add(cashUnnormalized).div(10); if (cashUnnormalized > targetCash) { uint256 depositAmount = cashUnnormalized.sub(targetCash);
_updateTotalBalanceWithNewYBalance(tid, yBalanceUnnormalized.mul(_normalizeBalance(info))); uint256 targetCash = yBalanceUnnormalized.add(cashUnnormalized).div(10); if (cashUnnormalized > targetCash) { uint256 depositAmount = cashUnnormalized.sub(targetCash);
29,195
126
// See {ERC1155-_beforeTokenTransfer}. /
function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
3,252
353
// No need to check for stale rates as _removeFromDebtRegister calls effectiveValue which does this for us
{ // How much debt do they have? uint debt = debtBalanceOf(messageSender, currencyKey); require(debt > 0, "No debt to forgive"); // If they're trying to burn more debt than they actually owe, rather than fail the transaction, let's just // clear their debt and leave them be. uint amountToBurn = debt < amount ? debt : amount; // Remove their debt from the ledger _removeFromDebtRegister(currencyKey, amountToBurn); // synth.burn does a safe subtraction on balance (so it will revert if there are not enough synths). synths[currencyKey].burn(messageSender, amountToBurn); }
{ // How much debt do they have? uint debt = debtBalanceOf(messageSender, currencyKey); require(debt > 0, "No debt to forgive"); // If they're trying to burn more debt than they actually owe, rather than fail the transaction, let's just // clear their debt and leave them be. uint amountToBurn = debt < amount ? debt : amount; // Remove their debt from the ledger _removeFromDebtRegister(currencyKey, amountToBurn); // synth.burn does a safe subtraction on balance (so it will revert if there are not enough synths). synths[currencyKey].burn(messageSender, amountToBurn); }
79,827
30
// Sets the address of the owner/
function setUpgradeabilityOwner(address newUpgradeabilityOwner) internal { _upgradeabilityOwner = newUpgradeabilityOwner; }
function setUpgradeabilityOwner(address newUpgradeabilityOwner) internal { _upgradeabilityOwner = newUpgradeabilityOwner; }
3,793
42
// Swap user input ROT for MAGGOTS
swapROTforMAGGOTwithROTAmount(amountOfRot);
swapROTforMAGGOTwithROTAmount(amountOfRot);
18,223
57
// Sets the max pool size of a liquidity pool for the provided tokencan only be called by MANAGE_MAX_POOL_SIZE_ROLE tokenAddress the address of the token contract maxSize the max size of a liqui pool for a specific token emits event MaxPoolSizeUpdated /
function setMaxPoolSize(address tokenAddress, uint256 maxSize) external { require( hasRole(MANAGE_MAX_POOL_SIZE_ROLE, _msgSender()), 'LiquidityManager: must have MANAGE_MAX_POOL_SIZE_ROLE to execute this function' ); maxPoolSize[tokenAddress] = maxSize; emit MaxPoolSizeUpdated(tokenAddress, maxSize); }
function setMaxPoolSize(address tokenAddress, uint256 maxSize) external { require( hasRole(MANAGE_MAX_POOL_SIZE_ROLE, _msgSender()), 'LiquidityManager: must have MANAGE_MAX_POOL_SIZE_ROLE to execute this function' ); maxPoolSize[tokenAddress] = maxSize; emit MaxPoolSizeUpdated(tokenAddress, maxSize); }
66,947
27
// 12.5% - epic
else if (range < 1275) return 1;
else if (range < 1275) return 1;
27,901
2
// Internally, intermediate values are computed with higher precision as 20 decimal fixed point numbers, and in the case of ln36, 36 decimals.
int256 constant ONE_20 = 1e20; int256 constant ONE_36 = 1e36;
int256 constant ONE_20 = 1e20; int256 constant ONE_36 = 1e36;
38,808
365
// `isOperatorAllowed` always returns true if it does not revert.
if iszero(staticcall(gas(), _OPERATOR_FILTER_REGISTRY, 0x16, 0x44, 0x00, 0x00)) {
if iszero(staticcall(gas(), _OPERATOR_FILTER_REGISTRY, 0x16, 0x44, 0x00, 0x00)) {
587
28
// Call overridden function RequestLockerAccess in this contract
RequestLockerAccess(intendedPurpose);
RequestLockerAccess(intendedPurpose);
10,341
200
// TODO: how many storage reads is this?
currencyId = context.currencyId; incentiveAnnualEmissionRate = context.incentiveAnnualEmissionRate; lastInitializedTime = context.lastInitializedTime; assetArrayLength = context.assetArrayLength; parameters = context.nTokenParameters;
currencyId = context.currencyId; incentiveAnnualEmissionRate = context.incentiveAnnualEmissionRate; lastInitializedTime = context.lastInitializedTime; assetArrayLength = context.assetArrayLength; parameters = context.nTokenParameters;
37,624
47
// Contract funds are used to cover breeding fees and pay callee /
function () external payable {} /** * Owner can withdraw funds from contract */ function withdraw(uint256 amount) external onlyOwner { owner.transfer(amount); }
function () external payable {} /** * Owner can withdraw funds from contract */ function withdraw(uint256 amount) external onlyOwner { owner.transfer(amount); }
28,927
18
// updates record to store new response
voterHistory[j].response = resp; return true;
voterHistory[j].response = resp; return true;
229
28
// Integrator can collect fees calling this function _token The token to collect fees in /
function collectIntegratorFee(address _token) external nonReentrant { _collectIntegrator(msg.sender, _token); }
function collectIntegratorFee(address _token) external nonReentrant { _collectIntegrator(msg.sender, _token); }
31,189
21
// Delegate function execution to the implementation contract This is a low level function that doesn't return to its internalcall site. It will return whatever is returned by the implementation to theexternal caller, reverting and returning the revert data if implementationreverts. _implementation - Address to which the function execution is delegated /
function _delegate(address _implementation) private { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Delegatecall to the implementation, supplying calldata and gas. // Out and outsize are set to zero - instead, use the return buffer. let result := delegatecall(gas(), _implementation, 0, calldatasize(), 0, 0) // Copy the returned data from the return buffer. returndatacopy(0, 0, returndatasize()) switch result // Delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } }
function _delegate(address _implementation) private { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Delegatecall to the implementation, supplying calldata and gas. // Out and outsize are set to zero - instead, use the return buffer. let result := delegatecall(gas(), _implementation, 0, calldatasize(), 0, 0) // Copy the returned data from the return buffer. returndatacopy(0, 0, returndatasize()) switch result // Delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } }
6,192
80
// Returns true if the specified sponsor has enabled token usage for the specified token. token Address of the token. sponsor Address of the sponsor.return True if the specified sponsor has enabled token usage for the specified token. /
function getSponsorTokenUsage(address token, address sponsor) public view returns (bool) { return sponsorApprovals[_getSponsorTokenKey(token, sponsor)]; }
function getSponsorTokenUsage(address token, address sponsor) public view returns (bool) { return sponsorApprovals[_getSponsorTokenKey(token, sponsor)]; }
29,839
25
// claimApplicationDate: now,
claimDate: now, //_claimDate, votesPro: 0, votesContra: 0, amountToSettle: 0,
claimDate: now, //_claimDate, votesPro: 0, votesContra: 0, amountToSettle: 0,
34,339
80
// Check if the caller is the governor. /
modifier onlyGovernor { require(msg.sender == governor, "Only Governor can call"); _; }
modifier onlyGovernor { require(msg.sender == governor, "Only Governor can call"); _; }
3,584
52
// Wizard
if (role == 2) { for (uint256 i = renderPathIndex["wizard"].startIndex; i <= renderPathIndex["wizard"].endIndex; i++) { output = string.concat(output, makePath(i, tokenId)); }
if (role == 2) { for (uint256 i = renderPathIndex["wizard"].startIndex; i <= renderPathIndex["wizard"].endIndex; i++) { output = string.concat(output, makePath(i, tokenId)); }
25,057
11
// It receives a pk (an address) and maps to PKtechnicalUsers
function addPKTechnicalUsers (address _addr) private { PKtechnicalUsers[_addr] = true; PKtechnicalUsersCount++; }
function addPKTechnicalUsers (address _addr) private { PKtechnicalUsers[_addr] = true; PKtechnicalUsersCount++; }
47,716
6
// MUST return TokenMetadata struct with ERC20-style token info.
* struct TokenMetadata { * address token; * string name; * string symbol; * uint8 decimals; * }
* struct TokenMetadata { * address token; * string name; * string symbol; * uint8 decimals; * }
3,463
195
// _addr이 referral이 아니면 에러
require(users[_addr].grade == 2, "register: not referral address");
require(users[_addr].grade == 2, "register: not referral address");
24,173
69
// Returns item's information. Includes the total number of requests for the item _itemID The ID of the queried item.return status The current status of the item.return numberOfRequests Total number of requests for the item.return sumDeposit The total deposit made by the requester and the challenger (if any) /
function getItemInfo(bytes32 _itemID)
function getItemInfo(bytes32 _itemID)
58,978
168
// Constraint expression for cpu/operands/res: (1 - cpu__decode__opcode_rc__bit_9)column6_row12 - (cpu__decode__opcode_rc__bit_5(column3_row5 + column3_row13) + cpu__decode__opcode_rc__bit_6column6_row4 + cpu__decode__flag_res_op1_0column3_row13).
let val := addmod( mulmod( addmod( 1, sub(PRIME, /*intermediate_value/cpu/decode/opcode_rc/bit_9*/ mload(0x2ca0)), PRIME),
let val := addmod( mulmod( addmod( 1, sub(PRIME, /*intermediate_value/cpu/decode/opcode_rc/bit_9*/ mload(0x2ca0)), PRIME),
32,061
111
// Returns true if governance is locked.
function governanceIsLocked() external view returns (bool);
function governanceIsLocked() external view returns (bool);
56,327
5
// uint256 Transfer.value
typeLen := byte(0, calldataload(offset)) offset := add(offset, 1) calldatacopy(add(txPtr, sub(32, typeLen)), offset, typeLen) mstore(96, mload(txPtr)) offset := add(offset, typeLen) txPtr := add(txPtr, 32)
typeLen := byte(0, calldataload(offset)) offset := add(offset, 1) calldatacopy(add(txPtr, sub(32, typeLen)), offset, typeLen) mstore(96, mload(txPtr)) offset := add(offset, typeLen) txPtr := add(txPtr, 32)
7,816
54
// approves a given token and account address to make it available for airdropThis is necessary to avoid malicious contracts to be added. _airdropper is the account to add to the whitelist _tokenAddress is the token address to add to the whitelist /
function approveSubmission(address _airdropper, address _tokenAddress) public onlyAdmin { require(!airdropperBlacklist[_airdropper]); require(!tokenBlacklist[_tokenAddress]); tokenWhitelist[_tokenAddress] = true; }
function approveSubmission(address _airdropper, address _tokenAddress) public onlyAdmin { require(!airdropperBlacklist[_airdropper]); require(!tokenBlacklist[_tokenAddress]); tokenWhitelist[_tokenAddress] = true; }
50,343
20
// Event to fire every time someone is added or removed from members
event MembershipChanged(address member, bool isMember);
event MembershipChanged(address member, bool isMember);
35,173
230
// INTERNAL FUNCTIONS /
function _curveSwap( address _user, uint256[] memory _swapData, address _collToken, bool _collToUsd
function _curveSwap( address _user, uint256[] memory _swapData, address _collToken, bool _collToUsd
6,331
13
// increment token counter for sold token
_tokenIds.increment();
_tokenIds.increment();
53,895
7
// function getRequestAddress(uint i) view public returns(address)
// { // return requestsAddrList[i]; // }
// { // return requestsAddrList[i]; // }
13,787
21
// Calculate the number of (base) debt shares for this borrow amount. Ensure this is rounded down (same as EIP-4626)
uint128 _mintAmountUInt128 = _mintAmount.encodeUInt128(); uint128 newSharesAmount = _debtToShares( _mintAmountUInt128, _baseCache.totalPrincipalAndBaseInterest, _baseCache.baseShares, false );
uint128 _mintAmountUInt128 = _mintAmount.encodeUInt128(); uint128 newSharesAmount = _debtToShares( _mintAmountUInt128, _baseCache.totalPrincipalAndBaseInterest, _baseCache.baseShares, false );
18,945
32
// getNftDetails[msg.sender].owner = address(this); getNftDetails[msg.sender].seller = payable(msg.sender); getNftDetails[msg.sender].listed = true; getNftDetails[msg.sender].sold = false; getNftDetails[msg.sender].price = _price;
_nftsSold.decrement(); emit NFTListed(_tokenId, msg.sender, msg.sender, address(this), _price,nft.category);
_nftsSold.decrement(); emit NFTListed(_tokenId, msg.sender, msg.sender, address(this), _price,nft.category);
25,967
167
// Deploys a farm corresponding to the _templateId and transfers fees. _templateId Template id of the farm to create. _integratorFeeAccount Address to pay the fee to.return farm address. /
function deployFarm( uint256 _templateId, address payable _integratorFeeAccount ) public payable returns (address farm)
function deployFarm( uint256 _templateId, address payable _integratorFeeAccount ) public payable returns (address farm)
61,688
291
// set batch issuance setting
batchIssuanceSettings[_ckToken] = _batchIssuanceSetting;
batchIssuanceSettings[_ckToken] = _batchIssuanceSetting;
18,306
33
// Common trick to swap values -- does not work for non-value storage types.
(x, y) = (y, x);
(x, y) = (y, x);
19,507
299
// Inform Issuer to start recording for the new fee period
issuer().setCurrentPeriodId(uint128(newFeePeriodId)); emitFeePeriodClosed(_recentFeePeriodsStorage(1).feePeriodId);
issuer().setCurrentPeriodId(uint128(newFeePeriodId)); emitFeePeriodClosed(_recentFeePeriodsStorage(1).feePeriodId);
17,211
58
// Update records of deposited ETH to include the received amount.
balances[msg.sender] += msg.value;
balances[msg.sender] += msg.value;
18,341
91
// take child item off, because child item will be burned
if(childItem.onChamp){ takeOffItem(childItem.onChampId, childItem.itemType); }
if(childItem.onChamp){ takeOffItem(childItem.onChampId, childItem.itemType); }
65,496
241
// Delegate to library to save space
SmartPoolManager.updateWeight(IConfigurableRightsPool(address(this)), bPool, token, newWeight);
SmartPoolManager.updateWeight(IConfigurableRightsPool(address(this)), bPool, token, newWeight);
11,678
415
// Helper for Extension actions immediately after issuing shares./ Same comment applies from __preBuySharesHook() above.
function __postBuySharesHook( address _buyer, uint256 _investmentAmount, uint256 _sharesIssued, uint256 _preBuySharesGav
function __postBuySharesHook( address _buyer, uint256 _investmentAmount, uint256 _sharesIssued, uint256 _preBuySharesGav
44,147
223
// import "@openzeppelin/[email protected]/presets/ERC20PresetMinterPauser.sol";/
* @dev {ERC20} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - a pauser role that allows to stop all token transfers * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20Pausable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /** * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the * account that deploys the contract. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to, uint256 amount) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function pause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } }
* @dev {ERC20} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - a pauser role that allows to stop all token transfers * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20Pausable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /** * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the * account that deploys the contract. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to, uint256 amount) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function pause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } }
48,602
46
// Make sure proposal is open for votes
require( proposals[_proposalID].status == Statuses.Open, "Proposal isn't open for votes");
require( proposals[_proposalID].status == Statuses.Open, "Proposal isn't open for votes");
17,232
13
// Helper function to estimate the amount of tranches minted when a given amount of collateral/ is deposited into the bond./This function is used off-chain services (using callStatic) to preview tranches minted after/b The address of the bond contract./ return The tranche data, an array of tranche amounts and fees.
function previewDeposit(IBondController b, uint256 collateralAmount) internal view returns ( TrancheData memory, uint256[] memory, uint256[] memory )
function previewDeposit(IBondController b, uint256 collateralAmount) internal view returns ( TrancheData memory, uint256[] memory, uint256[] memory )
13,774
374
// checks on consent-driven trust channels that the end user and the relayer have in common
uint8 kycCanSendResult = shyftCacheGraph.getKycCanSend(msg.sender, _to, _amount, ShyftTokenType, true, false);
uint8 kycCanSendResult = shyftCacheGraph.getKycCanSend(msg.sender, _to, _amount, ShyftTokenType, true, false);
48,935
11
// Owner Set & change owner /
contract Owner { address private owner; bool public lotlive; uint256 public lotblock; uint randNonce = 0; uint rnd; // event for EVM logging event OwnerSet(address indexed oldOwner, address indexed newOwner); // modifier to check if caller is owner modifier isOwner() { // If the first argument of 'require' evaluates to 'false', execution terminates and all // changes to the state and to Ether balances are reverted. // This used to consume all gas in old EVM versions, but not anymore. // It is often a good idea to use 'require' to check if functions are called correctly. // As a second argument, you can also provide an explanation about what went wrong. require(msg.sender == owner, "Caller is not owner"); _; } /** * @dev Set contract deployer as owner */ constructor() { owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor emit OwnerSet(address(0), owner); } /** * @dev Change owner * @param newOwner address of new owner */ function changeOwner(address newOwner) public isOwner { emit OwnerSet(owner, newOwner); owner = newOwner; } /** * @dev Return owner address * @return address of owner */ function getOwner() external view returns (address) { return owner; } function setdata(bool jp) public isOwner { lotlive = jp; } function play() payable public { if (!lotlive) { revert("lottery is not live"); } } function randMod(uint _modulus) internal returns(uint) { // increase nonce randNonce++; return uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, randNonce))) % _modulus; } function aleatorio() public { rnd = (randMod(100)); } }
contract Owner { address private owner; bool public lotlive; uint256 public lotblock; uint randNonce = 0; uint rnd; // event for EVM logging event OwnerSet(address indexed oldOwner, address indexed newOwner); // modifier to check if caller is owner modifier isOwner() { // If the first argument of 'require' evaluates to 'false', execution terminates and all // changes to the state and to Ether balances are reverted. // This used to consume all gas in old EVM versions, but not anymore. // It is often a good idea to use 'require' to check if functions are called correctly. // As a second argument, you can also provide an explanation about what went wrong. require(msg.sender == owner, "Caller is not owner"); _; } /** * @dev Set contract deployer as owner */ constructor() { owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor emit OwnerSet(address(0), owner); } /** * @dev Change owner * @param newOwner address of new owner */ function changeOwner(address newOwner) public isOwner { emit OwnerSet(owner, newOwner); owner = newOwner; } /** * @dev Return owner address * @return address of owner */ function getOwner() external view returns (address) { return owner; } function setdata(bool jp) public isOwner { lotlive = jp; } function play() payable public { if (!lotlive) { revert("lottery is not live"); } } function randMod(uint _modulus) internal returns(uint) { // increase nonce randNonce++; return uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, randNonce))) % _modulus; } function aleatorio() public { rnd = (randMod(100)); } }
4,089
14
// If we got an error, revert data to sender. Otherwise, return data
switch res
switch res
44,321
248
// Transfers `amount` in `idPledge` back to the `oldPledge` that/that sent it there in the first place, a Ctrl-z /idPledge Id of the pledge that is to be canceled/amount Quantity of ether (in wei) to be transfered to the /`oldPledge`
function cancelPledge(uint64 idPledge, uint amount) public { idPledge = normalizePledge(idPledge); Pledge storage p = _findPledge(idPledge); require(p.oldPledge != 0); require(p.pledgeState == PledgeState.Pledged); _checkAdminOwner(p.owner); uint64 oldPledge = _getOldestPledgeNotCanceled(p.oldPledge); _doTransfer(idPledge, oldPledge, amount); }
function cancelPledge(uint64 idPledge, uint amount) public { idPledge = normalizePledge(idPledge); Pledge storage p = _findPledge(idPledge); require(p.oldPledge != 0); require(p.pledgeState == PledgeState.Pledged); _checkAdminOwner(p.owner); uint64 oldPledge = _getOldestPledgeNotCanceled(p.oldPledge); _doTransfer(idPledge, oldPledge, amount); }
2,545
61
// transfer token to receiver address
TransferHelper.safeTransfer(tokenTo, to, amountFrom); amountTo = IERC20(tokenTo).balanceOf(to) - balanceBefore;
TransferHelper.safeTransfer(tokenTo, to, amountFrom); amountTo = IERC20(tokenTo).balanceOf(to) - balanceBefore;
487
6
// Emitted when the owner of router is proposed router - The address of the added router prevProposed- The address of the previous proposed newProposed- The address of the new proposed /
event RouterOwnerProposed(address indexed router, address indexed prevProposed, address indexed newProposed);
event RouterOwnerProposed(address indexed router, address indexed prevProposed, address indexed newProposed);
23,779
110
// ensure that it's been long enough since the last update
require(timeElapsed >= MIN_TWAP_TIME, "OTC: MIN_TWAP_TIME NOT ELAPSED"); price_cumulative_last = sell_token_priceCumulative; block_timestamp_last = blockTimestamp;
require(timeElapsed >= MIN_TWAP_TIME, "OTC: MIN_TWAP_TIME NOT ELAPSED"); price_cumulative_last = sell_token_priceCumulative; block_timestamp_last = blockTimestamp;
51,899
1
// Vote Keys to Vote
mapping (bytes32 => Vote) votes;
mapping (bytes32 => Vote) votes;
20,551
31
// delete the rest of the data in the record
delete self.proposal_[_whatProposal];
delete self.proposal_[_whatProposal];
31,564
36
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder)
prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder)
10,996
287
// [DEPRECATED] trancheIdealWeightRatio ± idealRanges, used in updateIncentives
uint256 public idealRange;
uint256 public idealRange;
29,511
20
// Allows seller to retrieve the token if the buyer closed the stream to early/ or ran out of funds./ Allows buyer to retrieve token if the debt was fully paid off. Also closes the stream/ automatically after the buyer retrieved the token./id the ID of the agreement
function retrieveToken(bytes32 id) external { // we could use a modifier to only allow the buyer and seller to call the function. // But, then we would have to still sepearte between seller and buyer // since both take a different path. Thus, using a modifier is gas waste here. Agreement memory agreement = agreements[id]; if (msg.sender == agreement.seller) { sellerRetrieveToken(agreement, id); } else if (msg.sender == agreement.buyer) { buyerRetrieveToken(agreement, id); } else { revert("Caller has to be either buyer or seller"); } }
function retrieveToken(bytes32 id) external { // we could use a modifier to only allow the buyer and seller to call the function. // But, then we would have to still sepearte between seller and buyer // since both take a different path. Thus, using a modifier is gas waste here. Agreement memory agreement = agreements[id]; if (msg.sender == agreement.seller) { sellerRetrieveToken(agreement, id); } else if (msg.sender == agreement.buyer) { buyerRetrieveToken(agreement, id); } else { revert("Caller has to be either buyer or seller"); } }
9,651
6
// Unpack balance & state
Balance memory balance = abi.decode(encodedBalance, (Balance)); TransferState memory state = abi.decode(encodedState, (TransferState)); Rate memory rate = state.rate;
Balance memory balance = abi.decode(encodedBalance, (Balance)); TransferState memory state = abi.decode(encodedState, (TransferState)); Rate memory rate = state.rate;
5,387
3
// membershipId -> tokenUri.
mapping(string => string) public _uriOf;
mapping(string => string) public _uriOf;
13,531
197
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } }
function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } }
76,701
127
// Modifiers // Modifier to verify if token is issuable. /
modifier isIssuableToken() { require(_isIssuable, "55"); // 0x55 funds locked (lockup period) _; }
modifier isIssuableToken() { require(_isIssuable, "55"); // 0x55 funds locked (lockup period) _; }
28,270
16
// Remove an address from the accredited list. /
function removeAccreditedInvestor(address investor) public onlyOwner { require(investor != address(0)); delete accredited[investor]; }
function removeAccreditedInvestor(address investor) public onlyOwner { require(investor != address(0)); delete accredited[investor]; }
34,078
70
// eg. USDT - AVAX
joeOut = _toJOE(wavax, _swap(token0, wavax, amount0, address(this)).add(amount1));
joeOut = _toJOE(wavax, _swap(token0, wavax, amount0, address(this)).add(amount1));
7,194
382
// Sets liquidationIncentiveAdmin function to set liquidationIncentivenewLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18 return uint 0=success, otherwise a failure. (See ErrorReporter for details)/
function _setLiquidationIncentive(uint newLiquidationIncentiveMantissa) external returns (uint) { // Check caller is admin OR currently initialzing as new unitroller implementation if (!adminOrInitializing()) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK); } // Check de-scaled 1 <= newLiquidationDiscount <= 1.5 Exp memory newLiquidationIncentive = Exp({mantissa: newLiquidationIncentiveMantissa}); Exp memory minLiquidationIncentive = Exp({mantissa: liquidationIncentiveMinMantissa}); if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) { return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION); } Exp memory maxLiquidationIncentive = Exp({mantissa: liquidationIncentiveMaxMantissa}); if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) { return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION); } // Save current value for use in log uint oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa; // Set liquidation incentive to new incentive liquidationIncentiveMantissa = newLiquidationIncentiveMantissa; // Emit event with old incentive, new incentive emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa); return uint(Error.NO_ERROR); }
function _setLiquidationIncentive(uint newLiquidationIncentiveMantissa) external returns (uint) { // Check caller is admin OR currently initialzing as new unitroller implementation if (!adminOrInitializing()) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK); } // Check de-scaled 1 <= newLiquidationDiscount <= 1.5 Exp memory newLiquidationIncentive = Exp({mantissa: newLiquidationIncentiveMantissa}); Exp memory minLiquidationIncentive = Exp({mantissa: liquidationIncentiveMinMantissa}); if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) { return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION); } Exp memory maxLiquidationIncentive = Exp({mantissa: liquidationIncentiveMaxMantissa}); if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) { return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION); } // Save current value for use in log uint oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa; // Set liquidation incentive to new incentive liquidationIncentiveMantissa = newLiquidationIncentiveMantissa; // Emit event with old incentive, new incentive emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa); return uint(Error.NO_ERROR); }
6,191
18
// - ERC20 functionality - //Transfer tokens to a specified address.to The address to transfer to.value The amount to be transferred. return True on success, false otherwise./
function transfer(address to, uint256 value) external validRecipient(to) returns (bool)
function transfer(address to, uint256 value) external validRecipient(to) returns (bool)
5,900
24
// Return the borrow balance of account based on stored data account The address whose balance should be calculatedreturn the calculated balance or 0 if error code is non-zero /
function borrowBalanceStoredInternal(address account) internal view returns (uint) { /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return 0; } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ uint principalTimesIndex = mul_(borrowSnapshot.principal, borrowIndex); uint result = div_(principalTimesIndex, borrowSnapshot.interestIndex); return result; }
function borrowBalanceStoredInternal(address account) internal view returns (uint) { /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return 0; } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ uint principalTimesIndex = mul_(borrowSnapshot.principal, borrowIndex); uint result = div_(principalTimesIndex, borrowSnapshot.interestIndex); return result; }
43,313
45
// transfer coin and token
coin.safeTransferFrom(_msgSender(), address(this), coinAmount); xGovToken.safeTransfer(_msgSender(), tokenAmount);
coin.safeTransferFrom(_msgSender(), address(this), coinAmount); xGovToken.safeTransfer(_msgSender(), tokenAmount);
65,370
11
// ticketOwner[uint32(_ticketId)] = _to;
_safeTransferFrom(_from, _to, _ticketId, _ticketsAmount, ""); emit OnTicketTransfer(_ticketId, _from, _to, _ticketsAmount);
_safeTransferFrom(_from, _to, _ticketId, _ticketsAmount, ""); emit OnTicketTransfer(_ticketId, _from, _to, _ticketsAmount);
25,101
110
// flag indicating swapAll enabled
bool public swapFees = true;
bool public swapFees = true;
1,866
21
// Update all pools NOTE: This could fail with out-of-gas if too many tokens are added
function updateAllPools() public { uint256 length = pools.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pools[pid]); } }
function updateAllPools() public { uint256 length = pools.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pools[pid]); } }
20,415
422
// Get token manager /
function _tokenManager(uint256 tokenId) internal view returns (address manager) { manager = _tokensManager[tokenId]; require(manager != address(this), "No manager for token"); require(!_blacklistedManagers.contains(manager), "Manager blacklisted"); return manager; }
function _tokenManager(uint256 tokenId) internal view returns (address manager) { manager = _tokensManager[tokenId]; require(manager != address(this), "No manager for token"); require(!_blacklistedManagers.contains(manager), "Manager blacklisted"); return manager; }
56,296
165
// Sets redeem to true _tokenId Which NFT we want to remove. /
function redeem( uint256 _tokenId ) external onlyOwner
function redeem( uint256 _tokenId ) external onlyOwner
16,403
220
// Returns the amount of time a token has been participating in the specified quest
function getTimeOnQuest(uint256 tokenId, address adventure, uint256 questId) public override view returns (uint256) { (bool participatingInQuest, uint256 startTimestamp,) = isParticipatingInQuest(tokenId, adventure, questId); return participatingInQuest ? (block.timestamp - startTimestamp) : 0; }
function getTimeOnQuest(uint256 tokenId, address adventure, uint256 questId) public override view returns (uint256) { (bool participatingInQuest, uint256 startTimestamp,) = isParticipatingInQuest(tokenId, adventure, questId); return participatingInQuest ? (block.timestamp - startTimestamp) : 0; }
37,123
31
// For every asset
for (index = 0; index < IAssetManager(registry.assetManager()).getAssetLength(); ++index) { category = IAssetManager(registry.assetManager()).getAssetCategory(index); uint256 currentBalance = userBalance[who_][category].currentBalance; uint256 futureBalance = userBalance[who_][category].futureBalance;
for (index = 0; index < IAssetManager(registry.assetManager()).getAssetLength(); ++index) { category = IAssetManager(registry.assetManager()).getAssetCategory(index); uint256 currentBalance = userBalance[who_][category].currentBalance; uint256 futureBalance = userBalance[who_][category].futureBalance;
36,125
29
// Destroys `amount` tokens from `account`, reducing thetotal supply.
* Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), 'ERC20: Burn to the zero address'); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); }
* Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), 'ERC20: Burn to the zero address'); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); }
182
54
// Set feesLPTokensForNode
feesLPTokensForNode = 0;
feesLPTokensForNode = 0;
3,955
3
// ERC20 functions and events
function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint _value);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint _value);
25,289
52
// emergency claim functions
function manualSwap() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); }
function manualSwap() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); }
27,902
0
// 定义ERC-20标准接口
contract ERC20Interface { // 代币名称 string public name; // 代币符号或者说简写 string public symbol; // 代币小数点位数,代币的最小单位 uint8 public decimals; // 代币的发行总量 uint public totalSupply; // 实现代币交易,用于给某个地址转移代币 function transfer(address to, uint tokens) public returns (bool success); // 实现代币用户之间的交易,从一个地址转移代币到另一个地址 function transferFrom(address from, address to, uint tokens) public returns (bool success); // 允许spender多次从你的账户取款,并且最多可取tokens个,主要用于某些场景下授权委托其他用户从你的账户上花费代币 function approve(address spender, uint tokens) public returns (bool success); // 查询spender允许从tokenOwner上花费的代币数量 function allowance(address tokenOwner, address spender) public view returns (uint remaining); // 代币交易时触发的事件,即调用transfer方法时触发 event Transfer(address indexed from, address indexed to, uint tokens); // 允许其他用户从你的账户上花费代币时触发的事件,即调用approve方法时触发 event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
contract ERC20Interface { // 代币名称 string public name; // 代币符号或者说简写 string public symbol; // 代币小数点位数,代币的最小单位 uint8 public decimals; // 代币的发行总量 uint public totalSupply; // 实现代币交易,用于给某个地址转移代币 function transfer(address to, uint tokens) public returns (bool success); // 实现代币用户之间的交易,从一个地址转移代币到另一个地址 function transferFrom(address from, address to, uint tokens) public returns (bool success); // 允许spender多次从你的账户取款,并且最多可取tokens个,主要用于某些场景下授权委托其他用户从你的账户上花费代币 function approve(address spender, uint tokens) public returns (bool success); // 查询spender允许从tokenOwner上花费的代币数量 function allowance(address tokenOwner, address spender) public view returns (uint remaining); // 代币交易时触发的事件,即调用transfer方法时触发 event Transfer(address indexed from, address indexed to, uint tokens); // 允许其他用户从你的账户上花费代币时触发的事件,即调用approve方法时触发 event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
19,427
82
// The minimum tick that may be passed to getSqrtRatioAtTick computed from log base 1.0001 of 2-128
int24 internal constant MIN_TICK = -887272;
int24 internal constant MIN_TICK = -887272;
72,881
48
// Emitted when RFQ gets filled
event OrderFilledRFQ( bytes32 orderHash, uint256 makingAmount );
event OrderFilledRFQ( bytes32 orderHash, uint256 makingAmount );
18,687
46
// Returns the last bounty id that was createdreturn bountyId uint256 The last bounty id/
function getLastBountyId() public view returns (uint256) { return bountyId.current; }
function getLastBountyId() public view returns (uint256) { return bountyId.current; }
1,403
57
// FROM https:github.com/abdk-consulting/abdk-libraries-solidity/blob/16d7e1dd8628dfa2f88d5dadab731df7ada70bdd/ABDKMath64x64.solL687
function sqrt(uint256 _x) public pure returns (uint128) { if (_x == 0) return 0; else { uint256 xx = _x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; // Seven iterations should be enough uint256 r1 = _x / r; return uint128 (r < r1 ? r : r1); } }
function sqrt(uint256 _x) public pure returns (uint128) { if (_x == 0) return 0; else { uint256 xx = _x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; r = (r + _x / r) >> 1; // Seven iterations should be enough uint256 r1 = _x / r; return uint128 (r < r1 ? r : r1); } }
20,566
24
// Allows the CEO to capture the balance available to the contract.
function withdrawBalance() external onlyCFO { address tmp = address(this); cfoAddress.transfer(tmp.balance); }
function withdrawBalance() external onlyCFO { address tmp = address(this); cfoAddress.transfer(tmp.balance); }
63,942
19
// /
contract MyToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ELON MUSKET"; name = "ELON MUSKET Token"; decimals = 1; _totalSupply = 8000000000; balances[0x46A0e6ee0b14DebFa818600687A7762D308D63F2] = _totalSupply; emit Transfer(address(0), 0x46A0e6ee0b14DebFa818600687A7762D308D63F2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
contract MyToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ELON MUSKET"; name = "ELON MUSKET Token"; decimals = 1; _totalSupply = 8000000000; balances[0x46A0e6ee0b14DebFa818600687A7762D308D63F2] = _totalSupply; emit Transfer(address(0), 0x46A0e6ee0b14DebFa818600687A7762D308D63F2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
1,741
159
// The current nonce of the provided `owner`. This `owner` should be the signer for any gasless transactions. /
function nonceOf(address owner) external view returns (uint);
function nonceOf(address owner) external view returns (uint);
27,501