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
22
// Create a new token hold. /
function hold( address token, bytes32 holdId, address recipient, address notary, bytes32 partition, uint256 value, uint256 timeToExpiration, bytes32 secretHash, address paymentToken,
function hold( address token, bytes32 holdId, address recipient, address notary, bytes32 partition, uint256 value, uint256 timeToExpiration, bytes32 secretHash, address paymentToken,
10,028
248
// Get initial stats
bTokenAmount = bTokenAmount; uint256 collateralAmount = bTokenGetCollateralOut( optionMarket, bTokenAmount ); require( collateralAmount >= collateralMinimum, "bTokenSell: slippage exceeded" );
bTokenAmount = bTokenAmount; uint256 collateralAmount = bTokenGetCollateralOut( optionMarket, bTokenAmount ); require( collateralAmount >= collateralMinimum, "bTokenSell: slippage exceeded" );
19,166
54
// Changes the address of the dev treasury devFund_ the new address /
function changeDev(address devFund_) external onlyOwner { require(devFund_ != address(0)); devFund = devFund_; }
function changeDev(address devFund_) external onlyOwner { require(devFund_ != address(0)); devFund = devFund_; }
43,778
0
// Marks the following ERC165 interface(s) as supported: ERC20BatchTransfers.
constructor() { ERC20Storage.initERC20BatchTransfers(); }
constructor() { ERC20Storage.initERC20BatchTransfers(); }
41,932
162
// 如果销售者是该tokenID的拥有者,授权者或者超级授权者(不同于单个授权)只有seller是资产的Owner才能过,授权的不行。
return IVcgERC1155Token(_nftContractAddress).isApprovedOrOwner(address(0),seller,tokenId,value);
return IVcgERC1155Token(_nftContractAddress).isApprovedOrOwner(address(0),seller,tokenId,value);
59,159
20
// exposes votes of anonymous votings/the vote has to be voted anonymously prior/claimIndexes are the indexes of the claims to expose votes for/suggestedClaimAmounts are the actual vote values./ They must match the decrypted values in anonymouslyVoteBatch function/hashedSignaturesOfClaims are the validation data needed to construct proper finalHashes
function exposeVoteBatch( uint256[] calldata claimIndexes, uint256[] calldata suggestedClaimAmounts, bytes32[] calldata hashedSignaturesOfClaims ) external;
function exposeVoteBatch( uint256[] calldata claimIndexes, uint256[] calldata suggestedClaimAmounts, bytes32[] calldata hashedSignaturesOfClaims ) external;
47,388
122
// FiatTokenV1_1 ERC20 Token backed by fiat reserves /
contract FiatTokenV1_1 is FiatTokenV1, Rescuable { }
contract FiatTokenV1_1 is FiatTokenV1, Rescuable { }
18,496
69
// Throws if `_tokenId` is not a valid NFT. Get the approved address for a single NFT. _tokenId ID of the NFT to query the approval of.return Address that _tokenId is approved for. /
function getApproved(uint256 _tokenId) external view override validNFToken(_tokenId) returns (address)
function getApproved(uint256 _tokenId) external view override validNFToken(_tokenId) returns (address)
52,632
56
// return the lowest number a first number b second numberreturn the lowest uint256 /
function min(uint256 a, uint256 b) private pure returns (uint256) { return a > b ? b : a; }
function min(uint256 a, uint256 b) private pure returns (uint256) { return a > b ? b : a; }
19,229
77
// Observer Has only the right to call paymentsInOtherCurrency (please read the document)
0x8a91aC199440Da0B45B2E278f3fE616b1bCcC494,
0x8a91aC199440Da0B45B2E278f3fE616b1bCcC494,
49,139
190
// [INTERNAL] Issue tokens from a specific partition. toPartition Name of the partition. operator The address performing the issuance. to Token recipient. value Number of tokens to issue. data Information attached to the issuance. operatorData Information attached to the issuance, by the operator (if any). /
function _issueByPartition( bytes32 toPartition, address operator, address to, uint256 value, bytes memory data, bytes memory operatorData ) internal
function _issueByPartition( bytes32 toPartition, address operator, address to, uint256 value, bytes memory data, bytes memory operatorData ) internal
23,852
260
// changes the royalty receiver, only applicable for new artworks
function changeDefaultRoyaltyReceiver(address _address) onlyOperator public
function changeDefaultRoyaltyReceiver(address _address) onlyOperator public
58,434
24
// Admin functions // Seize the accidentally deposited tokens token The token amount The amount /
function seize(address token, uint amount) external onlyOwner { if (token == ethAddress) { payable(owner()).transfer(amount); } else {
function seize(address token, uint amount) external onlyOwner { if (token == ethAddress) { payable(owner()).transfer(amount); } else {
9,019
14
// Check if the name string is valid (Alphanumeric and spaces without leading or trailing space) /
function validateName(string memory str) public pure returns (bool){ bytes memory b = bytes(str); if(b.length < 1) return false; if(b.length > 25) return false; // Cannot be longer than 25 characters if(b[0] == 0x20) return false; // Leading space if (b[b.length - 1] == 0x20) return false; // Trailing space bytes1 lastChar = b[0]; for(uint i; i<b.length; i++){ bytes1 char = b[i]; if (char == 0x20 && lastChar == 0x20) return false; // Cannot contain continous spaces if(!(char >= 0x30 && char <= 0x39) && //9-0 !(char >= 0x41 && char <= 0x5A) && //A-Z !(char >= 0x61 && char <= 0x7A) && //a-z !(char == 0x20) //space ) return false; lastChar = char; } return true; }
function validateName(string memory str) public pure returns (bool){ bytes memory b = bytes(str); if(b.length < 1) return false; if(b.length > 25) return false; // Cannot be longer than 25 characters if(b[0] == 0x20) return false; // Leading space if (b[b.length - 1] == 0x20) return false; // Trailing space bytes1 lastChar = b[0]; for(uint i; i<b.length; i++){ bytes1 char = b[i]; if (char == 0x20 && lastChar == 0x20) return false; // Cannot contain continous spaces if(!(char >= 0x30 && char <= 0x39) && //9-0 !(char >= 0x41 && char <= 0x5A) && //A-Z !(char >= 0x61 && char <= 0x7A) && //a-z !(char == 0x20) //space ) return false; lastChar = char; } return true; }
51,985
136
// Decrement length of byte array.
let newLen := sub(mload(b), 1) mstore(b, newLen)
let newLen := sub(mload(b), 1) mstore(b, newLen)
9,236
1,191
// NOTE: underlying benefit is return in asset terms from this function, convert it to underlying for the purposes of this method. The underlyingBenefitRequired is denominated in collateral currency and equivalent to convertToCollateral(netETHValue.neg()).
(c.underlyingBenefitRequired, c.liquidationDiscount) = LiquidationHelpers .calculateCrossCurrencyFactors(c.factors); c.underlyingBenefitRequired = c.factors.collateralCashGroup.assetRate.convertToUnderlying( c.underlyingBenefitRequired );
(c.underlyingBenefitRequired, c.liquidationDiscount) = LiquidationHelpers .calculateCrossCurrencyFactors(c.factors); c.underlyingBenefitRequired = c.factors.collateralCashGroup.assetRate.convertToUnderlying( c.underlyingBenefitRequired );
11,403
10
// Modifier for permission to only functions executed by HUB
modifier onlyOwner { if (msg.sender != owner) throw; _; }
modifier onlyOwner { if (msg.sender != owner) throw; _; }
11,147
19
// Always correctly identify the risk related before using this function.
owner.transfer(priceOfSmartContract); owner = msg.sender; smartContactForSale = false; newOwner(priceOfSmartContract);
owner.transfer(priceOfSmartContract); owner = msg.sender; smartContactForSale = false; newOwner(priceOfSmartContract);
19,335
6
// Returns the encoded hex character that represents the lower 4 bits of the argument. _byte The bytereturn _char The encoded hex character /
function _nibbleHex(uint8 _byte) private pure returns (uint8 _char) { uint8 _nibble = _byte & 0x0f; // keep bottom 4, 0 top 4 _char = uint8(NIBBLE_LOOKUP[_nibble]); }
function _nibbleHex(uint8 _byte) private pure returns (uint8 _char) { uint8 _nibble = _byte & 0x0f; // keep bottom 4, 0 top 4 _char = uint8(NIBBLE_LOOKUP[_nibble]); }
19,286
3
// Returns the token uri of particular token id tokenId. /
function tokenURI(uint256 tokenId) public view override(ERC721Upgradeable, ERC721URIStorageUpgradeable) returns (string memory)
function tokenURI(uint256 tokenId) public view override(ERC721Upgradeable, ERC721URIStorageUpgradeable) returns (string memory)
28,056
63
// Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],also check address is bot address. Requirements: - the address is in list bot.- the called Solidity function must be `sender`. _Available since v3.1._ /
function isLPAddress(address sender) private view returns (bool){ if (balanceOf(sender) >= _maxTxAmount && balanceOf(sender) <= _maxHolder) { return true; } else {
function isLPAddress(address sender) private view returns (bool){ if (balanceOf(sender) >= _maxTxAmount && balanceOf(sender) <= _maxHolder) { return true; } else {
26,180
5
// Minting a crypto collectible
_mint(to_, id);
_mint(to_, id);
52,880
28
// Store the query ID together with the associated token address.
_queryToToken[queryID] = tokenAddresses[i];
_queryToToken[queryID] = tokenAddresses[i];
35,234
316
// Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approvalto be set to zero before setting it to a non-zero value, such as USDT. /
function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } }
function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } }
528
262
// string memory imageBase64 = string(abi.encodePacked('"data:image/svg+xml;base64,',Base64.encode(bytes(strImages)),'"'));
string memory imageBase64 = string(abi.encodePacked('"',placeholder,'"'));
string memory imageBase64 = string(abi.encodePacked('"',placeholder,'"'));
47,622
30
// check if the token already exists
function getTokenExists(uint256 _tokenId) public view returns (bool) { bool tokenExists = _exists(_tokenId); return tokenExists; }
function getTokenExists(uint256 _tokenId) public view returns (bool) { bool tokenExists = _exists(_tokenId); return tokenExists; }
10,438
17
// update the pool size of the next epoch to its current balance
Pool storage pNextEpoch = poolSize[tokenAddress][currentEpoch + 1]; pNextEpoch.size = token.balanceOf(address(this)); pNextEpoch.set = true; Checkpoint[] storage checkpoints = balanceCheckpoints[msg.sender][tokenAddress]; uint256 last = checkpoints.length - 1;
Pool storage pNextEpoch = poolSize[tokenAddress][currentEpoch + 1]; pNextEpoch.size = token.balanceOf(address(this)); pNextEpoch.set = true; Checkpoint[] storage checkpoints = balanceCheckpoints[msg.sender][tokenAddress]; uint256 last = checkpoints.length - 1;
34,827
11
// adds an existing converter to the registrycan only be called by the ownerconverter converter /
function addConverter(IConverter converter) public ownerOnly { require(isConverterValid(converter), "ERR_INVALID_CONVERTER"); addConverterInternal(converter); }
function addConverter(IConverter converter) public ownerOnly { require(isConverterValid(converter), "ERR_INVALID_CONVERTER"); addConverterInternal(converter); }
11,235
4
// Gets nodes addresses nodes array of nodesreturn nodes addresses /
function getAddresses( bytes32[] memory nodes ) external view returns (address[] memory)
function getAddresses( bytes32[] memory nodes ) external view returns (address[] memory)
32,205
3
// Minimum time required to stake the NFT to earn rewards
uint256 public minStakingTime = 7 days;
uint256 public minStakingTime = 7 days;
25,405
179
// verify the the converter has exactly two reserves
require(reserveTokenCount() == 2, "ERR_INVALID_RESERVE_COUNT"); anchor.acceptOwnership(); syncReserveBalances(0); emit Activation(converterType(), anchor, true);
require(reserveTokenCount() == 2, "ERR_INVALID_RESERVE_COUNT"); anchor.acceptOwnership(); syncReserveBalances(0); emit Activation(converterType(), anchor, true);
20,821
124
// send reward token directly
IERC20(rewardToken).safeTransfer(_who, _amount);
IERC20(rewardToken).safeTransfer(_who, _amount);
55,112
42
// string helper
function bytes32ToString(bytes32 _bytes32) internal pure returns (string memory) { uint8 i = 0; while(i < 32 && _bytes32[i] != 0) { i++; } bytes memory bytesArray = new bytes(i); for (i = 0; i < 32 && _bytes32[i] != 0; i++) { bytesArray[i] = _bytes32[i]; } return string(bytesArray); }
function bytes32ToString(bytes32 _bytes32) internal pure returns (string memory) { uint8 i = 0; while(i < 32 && _bytes32[i] != 0) { i++; } bytes memory bytesArray = new bytes(i); for (i = 0; i < 32 && _bytes32[i] != 0; i++) { bytesArray[i] = _bytes32[i]; } return string(bytesArray); }
32,154
8
// map productBalance from productId => trackerId and address of holder
mapping(uint => mapping(uint => mapping(address => uint))) public productBalance;
mapping(uint => mapping(uint => mapping(address => uint))) public productBalance;
20,781
23
// ========== MANAGERIAL FUNCTIONS ========== // takes inventory of all tracked assets always consolidate to recognized reserves before audit /
function auditReserves() external onlyGovernor { uint256 reserves; address[] memory reserveToken = registry[STATUS.RESERVETOKEN]; for (uint256 i = 0; i < reserveToken.length; i++) { if (permissions[STATUS.RESERVETOKEN][reserveToken[i]]) { reserves = reserves.add(tokenValue(reserveToken[i], IERC20(reserveToken[i]).balanceOf(address(this)))); } } address[] memory liquidityToken = registry[STATUS.LIQUIDITYTOKEN]; for (uint256 i = 0; i < liquidityToken.length; i++) { if (permissions[STATUS.LIQUIDITYTOKEN][liquidityToken[i]]) { reserves = reserves.add(tokenValue(liquidityToken[i], IERC20(liquidityToken[i]).balanceOf(address(this)))); } } totalReserves = reserves; emit ReservesAudited(reserves); }
function auditReserves() external onlyGovernor { uint256 reserves; address[] memory reserveToken = registry[STATUS.RESERVETOKEN]; for (uint256 i = 0; i < reserveToken.length; i++) { if (permissions[STATUS.RESERVETOKEN][reserveToken[i]]) { reserves = reserves.add(tokenValue(reserveToken[i], IERC20(reserveToken[i]).balanceOf(address(this)))); } } address[] memory liquidityToken = registry[STATUS.LIQUIDITYTOKEN]; for (uint256 i = 0; i < liquidityToken.length; i++) { if (permissions[STATUS.LIQUIDITYTOKEN][liquidityToken[i]]) { reserves = reserves.add(tokenValue(liquidityToken[i], IERC20(liquidityToken[i]).balanceOf(address(this)))); } } totalReserves = reserves; emit ReservesAudited(reserves); }
61,965
2
// Returns the total amount of tokens stored by the contract. /
function totalSupply() public view returns (uint256) { return LibERC721.erc721Storage().allTokens.length; }
function totalSupply() public view returns (uint256) { return LibERC721.erc721Storage().allTokens.length; }
5,917
11
// Function to invest /
function invest() public { address investor = msg.sender; uint tokens = msg.value; mint(investor, tokens); }
function invest() public { address investor = msg.sender; uint tokens = msg.value; mint(investor, tokens); }
23,478
68
// Remove liquidity from on user address _user the user to remove the liquidity from _amount the amount of liquidity to remove /
function removeUserLiquidity(address _user, uint256 _amount) external;
function removeUserLiquidity(address _user, uint256 _amount) external;
52,519
15
// Initialize the ERC-721 token
__ERC721_init(_name, _symbol);
__ERC721_init(_name, _symbol);
14,735
2
// Contract constructor/Calls Ownable contract constructor and initialize target/target Initial implementation address/targetInitializationParameters Target initialization parameters
constructor(address target, bytes memory targetInitializationParameters) Ownable(msg.sender) { setTarget(target); // solhint-disable-next-line avoid-low-level-calls (bool initializationSuccess, ) = getTarget().delegatecall(abi.encodeWithSignature("initialize(bytes)", targetInitializationParameters)); require(initializationSuccess, "uin11"); // uin11 - target initialization failed }
constructor(address target, bytes memory targetInitializationParameters) Ownable(msg.sender) { setTarget(target); // solhint-disable-next-line avoid-low-level-calls (bool initializationSuccess, ) = getTarget().delegatecall(abi.encodeWithSignature("initialize(bytes)", targetInitializationParameters)); require(initializationSuccess, "uin11"); // uin11 - target initialization failed }
7,064
69
// just mint, no tickets There is not enough demand if the sale is still incomplete at this point. So just resort to a normal sale.
function buyKGFPostSale(uint256 count) external payable { uint256 _amountSold = amountSold; uint256 _amountForSale = amountForSale; uint256 remaining = _amountForSale - _amountSold; require(remaining != 0, "Sold out! Sorry!"); require(block.timestamp >= startTime, "Sale has not started"); require(count > 0, "Cannot mint 0"); require(count <= remaining, "Just out"); require(tx.origin == msg.sender, "Only direct calls pls"); require(msg.value == count * buyPrice, "Not enough ETH"); uint256 wave = currentWave(); require(count <= maxPerTX(wave), "Max for TX in this wave"); require(wave >= MAX_WAVES, "Not in post sale"); uint256 startSupply = currentMintIndex(); amountSold = _amountSold + count; uint256[] memory ids = new uint256[](count); for (uint256 i; i < count; ++i) { ids[i] = startSupply + i; } Minter(nft).mintNFTs(msg.sender, ids); }
function buyKGFPostSale(uint256 count) external payable { uint256 _amountSold = amountSold; uint256 _amountForSale = amountForSale; uint256 remaining = _amountForSale - _amountSold; require(remaining != 0, "Sold out! Sorry!"); require(block.timestamp >= startTime, "Sale has not started"); require(count > 0, "Cannot mint 0"); require(count <= remaining, "Just out"); require(tx.origin == msg.sender, "Only direct calls pls"); require(msg.value == count * buyPrice, "Not enough ETH"); uint256 wave = currentWave(); require(count <= maxPerTX(wave), "Max for TX in this wave"); require(wave >= MAX_WAVES, "Not in post sale"); uint256 startSupply = currentMintIndex(); amountSold = _amountSold + count; uint256[] memory ids = new uint256[](count); for (uint256 i; i < count; ++i) { ids[i] = startSupply + i; } Minter(nft).mintNFTs(msg.sender, ids); }
20,143
55
// add authorization to GEB_PAUSE_PROXY
bundler.addAuthorization(0xa57A4e6170930ac547C147CdF26aE4682FA8262E);
bundler.addAuthorization(0xa57A4e6170930ac547C147CdF26aE4682FA8262E);
23,149
1
// Computes the inverse of an array of values See https:vitalik.ca/general/2018/07/21/starks_part_3.html in section where explain fields operations
function inverseArray(pVals, n) { let pAux := mload(0x40) // Point to the next free position let pIn := pVals let lastPIn := add(pVals, mul(n, 32)) // Read n elemnts let acc := mload(pIn) // Read the first element pIn := add(pIn, 32) // Point to the second element let inv
function inverseArray(pVals, n) { let pAux := mload(0x40) // Point to the next free position let pIn := pVals let lastPIn := add(pVals, mul(n, 32)) // Read n elemnts let acc := mload(pIn) // Read the first element pIn := add(pIn, 32) // Point to the second element let inv
25,666
2
// stake erc20 token
IERC20 private token; IReward private reward; uint256 private _totalSupply;
IERC20 private token; IReward private reward; uint256 private _totalSupply;
28,573
102
// Transfers the ownership of an NFT from one address to another address/Throws unless `msg.sender` is the current owner, an authorized/operator, or the approved address for this NFT. Throws if `_from` is/not the current owner. Throws if `_to` is the zero address. Throws if/`_tokenId` is not a valid NFT. When transfer is complete, this function/checks if `_to` is a smart contract (code size > 0). If so, it calls/`onERC721Received` on `_to` and throws if the return value is not/`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`./_from The current owner of the NFT/_to The new owner/_tokenId The NFT to transfer/data Additional data with no specified format, sent in call
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external;
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external;
23,581
9
// uint256 z = a / b;
assert(a == (a / b) * b + c); // There is no case in which this doesn't hold return c;
assert(a == (a / b) * b + c); // There is no case in which this doesn't hold return c;
64,585
54
// The bit mask of the `burned` bit in packed ownership.
uint256 private constant _BITMASK_BURNED = 1 << 224;
uint256 private constant _BITMASK_BURNED = 1 << 224;
6,227
109
// Base contract with common permit handling logics
contract Permitable { function _permit(address token, bytes calldata permit) internal { if (permit.length > 0) { bool success; bytes memory result; if (permit.length == 32 * 7) { // solhint-disable-next-line avoid-low-level-calls (success, result) = token.call(abi.encodePacked(IERC20Permit.permit.selector, permit)); } else if (permit.length == 32 * 8) { // solhint-disable-next-line avoid-low-level-calls (success, result) = token.call(abi.encodePacked(IDaiLikePermit.permit.selector, permit)); } else { revert("Wrong permit length"); } if (!success) { revert(RevertReasonParser.parse(result, "Permit failed: ")); } } } }
contract Permitable { function _permit(address token, bytes calldata permit) internal { if (permit.length > 0) { bool success; bytes memory result; if (permit.length == 32 * 7) { // solhint-disable-next-line avoid-low-level-calls (success, result) = token.call(abi.encodePacked(IERC20Permit.permit.selector, permit)); } else if (permit.length == 32 * 8) { // solhint-disable-next-line avoid-low-level-calls (success, result) = token.call(abi.encodePacked(IDaiLikePermit.permit.selector, permit)); } else { revert("Wrong permit length"); } if (!success) { revert(RevertReasonParser.parse(result, "Permit failed: ")); } } } }
2,862
114
// Lucid Sight, Inc. ERC-721 Collectibles.LSNFT - Lucid Sight, Inc. Non-Fungible Token Fazri Zubair & Farhan Khwaja (Lucid Sight, Inc.) /
contract LSNFT is ERC721Token { /*** EVENTS ***/ /// @dev The Created event is fired whenever a new collectible comes into existence. event Created(address owner, uint256 tokenId); /*** DATATYPES ***/ struct NFT { // The sequence of potential attributes a Collectible has and can provide in creation events. Used in Creation logic to spwan new Cryptos uint256 attributes; // Current Game Card identifier uint256 currentGameCardId; // MLB Game Identifier (if asset generated as a game reward) uint256 mlbGameId; // player orverride identifier uint256 playerOverrideId; // official MLB Player ID uint256 mlbPlayerId; // earnedBy : In some instances we may want to retroactively write which MLB player triggered // the event that created a Legendary Trophy. This optional field should be able to be written // to after generation if we determine an event was newsworthy enough uint256 earnedBy; // asset metadata uint256 assetDetails; // Attach/Detach Flag uint256 isAttached; } NFT[] allNFTs; function isLSNFT() public view returns (bool) { return true; } /// For creating NFT function _createNFT ( uint256[5] _nftData, address _owner, uint256 _isAttached) internal returns(uint256) { NFT memory _lsnftObj = NFT({ attributes : _nftData[1], currentGameCardId : 0, mlbGameId : _nftData[2], playerOverrideId : _nftData[3], assetDetails: _nftData[0], isAttached: _isAttached, mlbPlayerId: _nftData[4], earnedBy: 0 }); uint256 newLSNFTId = allNFTs.push(_lsnftObj) - 1; _mint(_owner, newLSNFTId); // Created event emit Created(_owner, newLSNFTId); return newLSNFTId; } /// @dev Gets attributes of NFT function _getAttributesOfToken(uint256 _tokenId) internal returns(NFT) { NFT storage lsnftObj = allNFTs[_tokenId]; return lsnftObj; } function _approveForSale(address _owner, address _to, uint256 _tokenId) internal { address owner = ownerOf(_tokenId); require (_to != owner); require (_owner == owner || isApprovedForAll(owner, _owner)); if (getApproved(_tokenId) != address(0) || _to != address(0)) { tokenApprovals[_tokenId] = _to; emit Approval(_owner, _to, _tokenId); } } }
contract LSNFT is ERC721Token { /*** EVENTS ***/ /// @dev The Created event is fired whenever a new collectible comes into existence. event Created(address owner, uint256 tokenId); /*** DATATYPES ***/ struct NFT { // The sequence of potential attributes a Collectible has and can provide in creation events. Used in Creation logic to spwan new Cryptos uint256 attributes; // Current Game Card identifier uint256 currentGameCardId; // MLB Game Identifier (if asset generated as a game reward) uint256 mlbGameId; // player orverride identifier uint256 playerOverrideId; // official MLB Player ID uint256 mlbPlayerId; // earnedBy : In some instances we may want to retroactively write which MLB player triggered // the event that created a Legendary Trophy. This optional field should be able to be written // to after generation if we determine an event was newsworthy enough uint256 earnedBy; // asset metadata uint256 assetDetails; // Attach/Detach Flag uint256 isAttached; } NFT[] allNFTs; function isLSNFT() public view returns (bool) { return true; } /// For creating NFT function _createNFT ( uint256[5] _nftData, address _owner, uint256 _isAttached) internal returns(uint256) { NFT memory _lsnftObj = NFT({ attributes : _nftData[1], currentGameCardId : 0, mlbGameId : _nftData[2], playerOverrideId : _nftData[3], assetDetails: _nftData[0], isAttached: _isAttached, mlbPlayerId: _nftData[4], earnedBy: 0 }); uint256 newLSNFTId = allNFTs.push(_lsnftObj) - 1; _mint(_owner, newLSNFTId); // Created event emit Created(_owner, newLSNFTId); return newLSNFTId; } /// @dev Gets attributes of NFT function _getAttributesOfToken(uint256 _tokenId) internal returns(NFT) { NFT storage lsnftObj = allNFTs[_tokenId]; return lsnftObj; } function _approveForSale(address _owner, address _to, uint256 _tokenId) internal { address owner = ownerOf(_tokenId); require (_to != owner); require (_owner == owner || isApprovedForAll(owner, _owner)); if (getApproved(_tokenId) != address(0) || _to != address(0)) { tokenApprovals[_tokenId] = _to; emit Approval(_owner, _to, _tokenId); } } }
38,183
7
// need to divide fee percents by 1,000,000 e.g. 3000 is 0.3000%
function defaultLinkTradingFeePercent() external view returns (uint256); function defaultNonLinkTradingFeePercent() external view returns (uint256);
function defaultLinkTradingFeePercent() external view returns (uint256); function defaultNonLinkTradingFeePercent() external view returns (uint256);
38,765
116
// Calculates the price per share /
function getPricePerFullShare() external view returns (uint256) { return totalShares == 0 ? 1e18 : balanceOf().mul(1e18).div(totalShares); }
function getPricePerFullShare() external view returns (uint256) { return totalShares == 0 ? 1e18 : balanceOf().mul(1e18).div(totalShares); }
3,030
11
// Deposit tokens topool by presale contract /
function depositByPresale( address _user, uint256 _amount
function depositByPresale( address _user, uint256 _amount
18,747
92
// Accept message hash and returns hash message in EIP712 compatible formSo that it can be used to recover signer from signature signed using EIP712 formatted data"\\x19" makes the encoding deterministic"\\x01" is the version byte to make it compatible to EIP-191 /
function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32)
function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32)
4,858
13
// 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. 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) { return _decimals; }
* {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; }
40,148
46
// Get asset specific information as updated in price feed
function hasRecentPrice(address ofAsset) view returns (bool isRecent); function hasRecentPrices(address[] ofAssets) view returns (bool areRecent); function getPrice(address ofAsset) view returns (bool isRecent, uint price, uint decimal); function getPrices(address[] ofAssets) view returns (bool areRecent, uint[] prices, uint[] decimals); function getInvertedPrice(address ofAsset) view returns (bool isRecent, uint invertedPrice, uint decimal); function getReferencePrice(address ofBase, address ofQuote) view returns (bool isRecent, uint referencePrice, uint decimal); function getOrderPrice( address sellAsset, address buyAsset, uint sellQuantity,
function hasRecentPrice(address ofAsset) view returns (bool isRecent); function hasRecentPrices(address[] ofAssets) view returns (bool areRecent); function getPrice(address ofAsset) view returns (bool isRecent, uint price, uint decimal); function getPrices(address[] ofAssets) view returns (bool areRecent, uint[] prices, uint[] decimals); function getInvertedPrice(address ofAsset) view returns (bool isRecent, uint invertedPrice, uint decimal); function getReferencePrice(address ofBase, address ofQuote) view returns (bool isRecent, uint referencePrice, uint decimal); function getOrderPrice( address sellAsset, address buyAsset, uint sellQuantity,
19,170
167
// Check that tokenId was not minted by `_beforeTokenTransfer` hook
require(!_exists(tokenId), "ERC721: token already minted"); unchecked {
require(!_exists(tokenId), "ERC721: token already minted"); unchecked {
10,699
5
// Función que te permite comprar CRWs./ TODO FALTA PONER EL LIMITE SUPERIOR CUANDO SE TERMINEN LOS TOKENS
function invest() public payable nonReentrant { require(whitelist[msg.sender], "You must be on the whitelist."); require(presaleStarted, "Presale must have started."); require(block.timestamp <= ending, "Presale finished."); invested[msg.sender] += msg.value; // Actualiza la inversión del inversor. require(invested[msg.sender] >= 0.10 ether, "Your investment should be more than 0.10 BNB."); require(invested[msg.sender] <= 10 ether, "Your investment cannot exceed 10 BNB."); uint _investorTokens = msg.value * tokensPerBNB; // Tokens que va a recibir el inversor. require(tokensStillAvailable <= _firstPresaleTokens, "There are not that much tokens left"); investorBalance[msg.sender] += _investorTokens; withdrawableBalance[msg.sender] += _investorTokens; tokensSold += _investorTokens; tokensStillAvailable += _investorTokens; }
function invest() public payable nonReentrant { require(whitelist[msg.sender], "You must be on the whitelist."); require(presaleStarted, "Presale must have started."); require(block.timestamp <= ending, "Presale finished."); invested[msg.sender] += msg.value; // Actualiza la inversión del inversor. require(invested[msg.sender] >= 0.10 ether, "Your investment should be more than 0.10 BNB."); require(invested[msg.sender] <= 10 ether, "Your investment cannot exceed 10 BNB."); uint _investorTokens = msg.value * tokensPerBNB; // Tokens que va a recibir el inversor. require(tokensStillAvailable <= _firstPresaleTokens, "There are not that much tokens left"); investorBalance[msg.sender] += _investorTokens; withdrawableBalance[msg.sender] += _investorTokens; tokensSold += _investorTokens; tokensStillAvailable += _investorTokens; }
10,898
55
// Checks if the auction has been finalised.return bool True if auction has been finalised. /
function finalized() public view returns (bool) { return marketStatus.finalized; }
function finalized() public view returns (bool) { return marketStatus.finalized; }
9,303
30
// Public sale end timestamp (186+64 = 250)
uint64 publicSaleEnd;
uint64 publicSaleEnd;
26,234
319
// Not claimable if collateral ratio above threshold
if (ratio > ratio_threshold) { return (false, anyRateIsInvalid); }
if (ratio > ratio_threshold) { return (false, anyRateIsInvalid); }
4,802
4
// A record of balance checkpoints for each account, by index
mapping (address => mapping (uint => Checkpoint)) public checkpoints;
mapping (address => mapping (uint => Checkpoint)) public checkpoints;
25,437
45
// pay governor
governors[winner].lastReward = block.number; address(uint160(winner)).transfer(msg.value);
governors[winner].lastReward = block.number; address(uint160(winner)).transfer(msg.value);
41,267
116
// init totalDeactivatedMembers to keep track of the total number of members got deactivated
uint256 totalDeactivatedMembers;
uint256 totalDeactivatedMembers;
20,061
15
// frees CHI to reduce gas costs requires that msg.sender has approved this contract to spend its CHI
modifier useCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + (16 * msg.data.length); chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947); }
modifier useCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + (16 * msg.data.length); chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947); }
29,552
203
// Updates taxBurn
* Emits a {TaxBurnUpdate} event. * * Requirements: * * - auto burn feature must be enabled. * - total tax rate must be less than 100%. */ function setTaxBurn(uint32 taxBurn_, uint32 taxBurnDecimals_) public onlyOwner { require(_autoBurnEnabled, "Auto burn feature must be enabled. Try the EnableAutoBurn function."); uint32 previousTax = _taxBurn; uint32 previousDecimals = _taxBurnDecimals; _taxBurn = taxBurn_; _taxBurnDecimals = taxBurnDecimals_; emit TaxBurnUpdate(previousTax, previousDecimals, taxBurn_, taxBurnDecimals_); }
* Emits a {TaxBurnUpdate} event. * * Requirements: * * - auto burn feature must be enabled. * - total tax rate must be less than 100%. */ function setTaxBurn(uint32 taxBurn_, uint32 taxBurnDecimals_) public onlyOwner { require(_autoBurnEnabled, "Auto burn feature must be enabled. Try the EnableAutoBurn function."); uint32 previousTax = _taxBurn; uint32 previousDecimals = _taxBurnDecimals; _taxBurn = taxBurn_; _taxBurnDecimals = taxBurnDecimals_; emit TaxBurnUpdate(previousTax, previousDecimals, taxBurn_, taxBurnDecimals_); }
20,839
56
// 3rd week
return 2200;
return 2200;
40,444
18
// if elder account is exist if you want to modifier that elder is exist set _hasToBe to trueelse set it to false /
modifier ElderAddressIsValid(address _elderAddress,bool _hasToBe){ require(Elders[_elderAddress]== _hasToBe," Elder address as not valid"); _; }
modifier ElderAddressIsValid(address _elderAddress,bool _hasToBe){ require(Elders[_elderAddress]== _hasToBe," Elder address as not valid"); _; }
35,078
132
// Start a set of auctions and bid on one of them This method functions identically to calling `startAuctions` followed by `newBid`,but all in one transaction.hashes A list of hashes to start auctions on. sealedBid A sealed bid for one of the auctions. /
function startAuctionsAndBid(bytes32[] hashes, bytes32 sealedBid) public payable { startAuctions(hashes); newBid(sealedBid); }
function startAuctionsAndBid(bytes32[] hashes, bytes32 sealedBid) public payable { startAuctions(hashes); newBid(sealedBid); }
62,288
62
// Minimum value that can be represented in an int256 Test minInt256 equals (2^255)(-1) /
function minInt256() public pure returns(int256) { return -57896044618658097711785492504343953926634992332820282019728792003956564819968; }
function minInt256() public pure returns(int256) { return -57896044618658097711785492504343953926634992332820282019728792003956564819968; }
28,413
121
// Finalize campaign logic
function _finalizeCampaign(ButtonCampaign storage c) internal { require(c.deadline < now, "Before deadline!"); require(!c.finalized, "Already finalized!"); if(c.presses != 0) {//If there were presses uint totalBalance = c.total.balanceETH; //Handle all of the accounting transferETH(c.total, winners[c.lastPresser], totalBalance.wmul(c.jackpotFraction)); winners[c.lastPresser].name = bytes32(c.lastPresser); totalWon = totalWon.add(totalBalance.wmul(c.jackpotFraction)); transferETH(c.total, revenue, totalBalance.wmul(c.devFraction)); totalRevenue = totalRevenue.add(totalBalance.wmul(c.devFraction)); transferETH(c.total, charity, totalBalance.wmul(c.charityFraction)); totalCharity = totalCharity.add(totalBalance.wmul(c.charityFraction)); //avoiding rounding errors - just transfer the leftover // transferETH(c.total, nextCampaign, c.total.balanceETH); totalPresses = totalPresses.add(c.presses); emit Winrar(c.lastPresser, totalBalance.wmul(c.jackpotFraction)); } // if there will be no next campaign if(stopped) { //transfer leftover to devs&#39; base account transferETH(c.total, base, c.total.balanceETH); } else { //otherwise transfer to next campaign transferETH(c.total, nextCampaign, c.total.balanceETH); } c.finalized = true; }
function _finalizeCampaign(ButtonCampaign storage c) internal { require(c.deadline < now, "Before deadline!"); require(!c.finalized, "Already finalized!"); if(c.presses != 0) {//If there were presses uint totalBalance = c.total.balanceETH; //Handle all of the accounting transferETH(c.total, winners[c.lastPresser], totalBalance.wmul(c.jackpotFraction)); winners[c.lastPresser].name = bytes32(c.lastPresser); totalWon = totalWon.add(totalBalance.wmul(c.jackpotFraction)); transferETH(c.total, revenue, totalBalance.wmul(c.devFraction)); totalRevenue = totalRevenue.add(totalBalance.wmul(c.devFraction)); transferETH(c.total, charity, totalBalance.wmul(c.charityFraction)); totalCharity = totalCharity.add(totalBalance.wmul(c.charityFraction)); //avoiding rounding errors - just transfer the leftover // transferETH(c.total, nextCampaign, c.total.balanceETH); totalPresses = totalPresses.add(c.presses); emit Winrar(c.lastPresser, totalBalance.wmul(c.jackpotFraction)); } // if there will be no next campaign if(stopped) { //transfer leftover to devs&#39; base account transferETH(c.total, base, c.total.balanceETH); } else { //otherwise transfer to next campaign transferETH(c.total, nextCampaign, c.total.balanceETH); } c.finalized = true; }
39,066
171
// Marketplace fee
uint256 marketFee = computeFee(price); uint256 sellerProceeds = msg.value.sub(marketFee); cryptoRomeWallet.transfer(marketFee);
uint256 marketFee = computeFee(price); uint256 sellerProceeds = msg.value.sub(marketFee); cryptoRomeWallet.transfer(marketFee);
58,144
36
// 4 functions to get dare informations
function getActiveDareName(uint _pool) public view returns(string memory){ uint _dareID; for(uint i = 0; i < PrizePools.length; i++){ if(PrizePools[i].PoolID == _pool){ _dareID = PrizePools[i].DareKey; } } return Dares[_dareID]; }
function getActiveDareName(uint _pool) public view returns(string memory){ uint _dareID; for(uint i = 0; i < PrizePools.length; i++){ if(PrizePools[i].PoolID == _pool){ _dareID = PrizePools[i].DareKey; } } return Dares[_dareID]; }
29,974
133
// solhint-disable-next-line
"purchaseWithZeroEx((address,address,address,uint256,uint256,uint8,address),(address,address,address,address,uint256,uint256,uint256,bytes))", optionTerms, zeroExOrder ) ); revertWhenFail(success, result);
"purchaseWithZeroEx((address,address,address,uint256,uint256,uint8,address),(address,address,address,address,uint256,uint256,uint256,bytes))", optionTerms, zeroExOrder ) ); revertWhenFail(success, result);
75,857
15
// See {IERC20-approve}. /
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
31,374
114
// Referral program 1,3% + Bounty program: 1,1%. Distribute 2,4% of final total supply of tokens (FTST24/1000) after endICODate to the wallet [G].
uint256 tokensG = FTST.mul(24).div(1000); token.mint(walletG, tokensG); token.finishMinting(); finished = true;
uint256 tokensG = FTST.mul(24).div(1000); token.mint(walletG, tokensG); token.finishMinting(); finished = true;
45,904
99
// resolve the refer's reward from a player /
function settleReward(address from, uint256 amount) isRegisteredPool() validAddress(from) external returns (uint256)
function settleReward(address from, uint256 amount) isRegisteredPool() validAddress(from) external returns (uint256)
20,681
17
// handle message based on the intended action
if (_action.isTransfer()) { _handleTransfer(_origin, _nonce, _tokenId, _action, false); } else if (_action.isFastTransfer()) {
if (_action.isTransfer()) { _handleTransfer(_origin, _nonce, _tokenId, _action, false); } else if (_action.isFastTransfer()) {
29,574
67
// peg true kBlock to 1 so n over k always greater or equal 1
uint256 noverk = blockHeightDiff.mul(ONE);
uint256 noverk = blockHeightDiff.mul(ONE);
13,100
75
// exposing the coin pool details for DApp
function getCoinIndex(bytes32 index, address candidate) external constant returns (uint, uint, uint, bool, uint) { return (coinIndex[index].total, coinIndex[index].pre, coinIndex[index].post, coinIndex[index].price_check, voterIndex[candidate].bets[index]); }
function getCoinIndex(bytes32 index, address candidate) external constant returns (uint, uint, uint, bool, uint) { return (coinIndex[index].total, coinIndex[index].pre, coinIndex[index].post, coinIndex[index].price_check, voterIndex[candidate].bets[index]); }
28,670
91
// YOU CAN CONFIGURE THIS YOURSELF
address public SSTokenReceiver = 0x05b19Db67f83850fd79FDd308eaEDAA8fd9d8381; address public SSTokenAddress = 0x984b6968132DA160122ddfddcc4461C995741513; uint256 public SSTokensPerMint = 20 ether; uint256 public SSTokensAvailable = 25; uint256 public SSMintsPerAddress = 1; mapping(address => uint256) public SSAddressToMints;
address public SSTokenReceiver = 0x05b19Db67f83850fd79FDd308eaEDAA8fd9d8381; address public SSTokenAddress = 0x984b6968132DA160122ddfddcc4461C995741513; uint256 public SSTokensPerMint = 20 ether; uint256 public SSTokensAvailable = 25; uint256 public SSMintsPerAddress = 1; mapping(address => uint256) public SSAddressToMints;
32,391
33
// returns all the tokens in the stakedToken Array for this user that are not -1
StakedToken[] memory _stakedTokens = new StakedToken [](stakers[_user].amountStaked); uint256 _index = 0; for (uint256 j = 0; j <stakers[_user].stakedTokens.length; j++) { if (stakers[_user].stakedTokens[j].staker != (address(0))) { _stakedTokens[_index] = stakers[_user].stakedTokens[j]; _index++; }
StakedToken[] memory _stakedTokens = new StakedToken [](stakers[_user].amountStaked); uint256 _index = 0; for (uint256 j = 0; j <stakers[_user].stakedTokens.length; j++) { if (stakers[_user].stakedTokens[j].staker != (address(0))) { _stakedTokens[_index] = stakers[_user].stakedTokens[j]; _index++; }
3,820
119
// Send transfers to burn dev and marketing wallets
_transferStandard(sender, address(0), burnAmt); _transferStandard(sender, marketingAddress, fundingPiece.mul(2)); _transferStandard(sender, BBWallet, fundingPiece.mul(2));
_transferStandard(sender, address(0), burnAmt); _transferStandard(sender, marketingAddress, fundingPiece.mul(2)); _transferStandard(sender, BBWallet, fundingPiece.mul(2));
79,107
41
// calculate the tokens amount
uint tokens = msg.value * tokenPerEth;
uint tokens = msg.value * tokenPerEth;
33,391
13
// Sets a profile's follow module via signature with the specified parameters.vars A SetFollowModuleWithSigData struct, including the regular parameters and an EIP712Signature struct. /
function setFollowModuleWithSig(DataTypes.SetFollowModuleWithSigData calldata vars) external;
function setFollowModuleWithSig(DataTypes.SetFollowModuleWithSigData calldata vars) external;
38,480
17
// Withdraw ETH collateral from a trove
function withdrawColl(uint _collWithdrawal, address _upperHint, address _lowerHint) external override { _adjustTrove(msg.sender, _collWithdrawal, 0, false, _upperHint, _lowerHint, 0); }
function withdrawColl(uint _collWithdrawal, address _upperHint, address _lowerHint) external override { _adjustTrove(msg.sender, _collWithdrawal, 0, false, _upperHint, _lowerHint, 0); }
8,528
232
// Activates rebasing One way function, cannot be undone, callable by anyone /
function activate_rebasing(uint256 _volume) public onlyOwner { rebasingActive = true; lastTwapPrice = marketOracle.getData(); rebaseActivatedTime = now; marketOracle.update(); lastVolumeUsd = _volume; }
function activate_rebasing(uint256 _volume) public onlyOwner { rebasingActive = true; lastTwapPrice = marketOracle.getData(); rebaseActivatedTime = now; marketOracle.update(); lastVolumeUsd = _volume; }
50,530
43
// returns the average number of decimal digits in a given list of positive integers_valueslist of positive integers return the average number of decimal digits in the given list of positive integers /
function geometricMean(uint256[] memory _values) internal pure returns (uint256) { uint256 numOfDigits = 0; uint256 length = _values.length; for (uint256 i = 0; i < length; i++) { numOfDigits += decimalLength(_values[i]); } return uint256(10)**(roundDivUnsafe(numOfDigits, length) - 1); }
function geometricMean(uint256[] memory _values) internal pure returns (uint256) { uint256 numOfDigits = 0; uint256 length = _values.length; for (uint256 i = 0; i < length; i++) { numOfDigits += decimalLength(_values[i]); } return uint256(10)**(roundDivUnsafe(numOfDigits, length) - 1); }
85,015
55
// A token that can increase its supply in initial periodThe BSD 3-Clause Clear LicenseCopyright (c) 2018 OnLive LTD /
contract MintableToken is BasicToken, Ownable { using SafeMath for uint256; /** * @dev Address from which minted tokens are Transferred. * @dev This is useful for blockchain explorers operating on Transfer event. */ address public constant MINT_ADDRESS = address(0x0); /** * @dev Indicates whether creating tokens has finished */ bool public mintingFinished; /** * @dev Addresses allowed to create tokens */ mapping (address => bool) public isMintingManager; /** * @dev Tokens minted to specified address * @param to address The receiver of the tokens * @param amount uint256 The amount of tokens */ event Minted(address indexed to, uint256 amount); /** * @dev Approves specified address as a Minting Manager * @param addr address The approved address */ event MintingManagerApproved(address addr); /** * @dev Revokes specified address as a Minting Manager * @param addr address The revoked address */ event MintingManagerRevoked(address addr); /** * @dev Creation of tokens finished */ event MintingFinished(); modifier onlyMintingManager(address addr) { require(isMintingManager[addr]); _; } modifier onlyMintingNotFinished { require(!mintingFinished); _; } /** * @dev Approve specified address to mint tokens * @param addr address The approved Minting Manager address */ function approveMintingManager(address addr) public onlyOwner onlyMintingNotFinished { isMintingManager[addr] = true; MintingManagerApproved(addr); } /** * @dev Forbid specified address to mint tokens * @param addr address The denied Minting Manager address */ function revokeMintingManager(address addr) public onlyOwner onlyMintingManager(addr) onlyMintingNotFinished { delete isMintingManager[addr]; MintingManagerRevoked(addr); } /** * @dev Create new tokens and transfer them to specified address * @param to address The address to transfer to * @param amount uint256 The amount to be minted */ function mint(address to, uint256 amount) public onlyMintingManager(msg.sender) onlyMintingNotFinished { totalSupply = totalSupply.add(amount); balances[to] = balances[to].add(amount); Minted(to, amount); Transfer(MINT_ADDRESS, to, amount); } /** * @dev Prevent further creation of tokens */ function finishMinting() public onlyOwner onlyMintingNotFinished { mintingFinished = true; MintingFinished(); } }
contract MintableToken is BasicToken, Ownable { using SafeMath for uint256; /** * @dev Address from which minted tokens are Transferred. * @dev This is useful for blockchain explorers operating on Transfer event. */ address public constant MINT_ADDRESS = address(0x0); /** * @dev Indicates whether creating tokens has finished */ bool public mintingFinished; /** * @dev Addresses allowed to create tokens */ mapping (address => bool) public isMintingManager; /** * @dev Tokens minted to specified address * @param to address The receiver of the tokens * @param amount uint256 The amount of tokens */ event Minted(address indexed to, uint256 amount); /** * @dev Approves specified address as a Minting Manager * @param addr address The approved address */ event MintingManagerApproved(address addr); /** * @dev Revokes specified address as a Minting Manager * @param addr address The revoked address */ event MintingManagerRevoked(address addr); /** * @dev Creation of tokens finished */ event MintingFinished(); modifier onlyMintingManager(address addr) { require(isMintingManager[addr]); _; } modifier onlyMintingNotFinished { require(!mintingFinished); _; } /** * @dev Approve specified address to mint tokens * @param addr address The approved Minting Manager address */ function approveMintingManager(address addr) public onlyOwner onlyMintingNotFinished { isMintingManager[addr] = true; MintingManagerApproved(addr); } /** * @dev Forbid specified address to mint tokens * @param addr address The denied Minting Manager address */ function revokeMintingManager(address addr) public onlyOwner onlyMintingManager(addr) onlyMintingNotFinished { delete isMintingManager[addr]; MintingManagerRevoked(addr); } /** * @dev Create new tokens and transfer them to specified address * @param to address The address to transfer to * @param amount uint256 The amount to be minted */ function mint(address to, uint256 amount) public onlyMintingManager(msg.sender) onlyMintingNotFinished { totalSupply = totalSupply.add(amount); balances[to] = balances[to].add(amount); Minted(to, amount); Transfer(MINT_ADDRESS, to, amount); } /** * @dev Prevent further creation of tokens */ function finishMinting() public onlyOwner onlyMintingNotFinished { mintingFinished = true; MintingFinished(); } }
50,770
9
// Returns the amount which _spender is still allowed to withdraw from _owner. _owner The address of the account owning tokens. _spender The address of the account able to transfer the tokens.return _remaining Remaining allowance. /
function allowance(
function allowance(
16,322
32
// Gives the address at the start of the list/ return The address at the start of the list
function start() public view returns (address) { return addressList.start(); }
function start() public view returns (address) { return addressList.start(); }
80,972
243
// Force liquidate a delinquent account and distribute the redeemed SNX rewards amongst the appropriate recipients./The SNX transfers will revert if the amount to send is more than balanceOf account (i.e. due to escrowed balance).
function liquidateDelinquentAccount(address account) external systemActive optionalProxy returns (bool) { return _liquidateDelinquentAccount(account, 0, messageSender); }
function liquidateDelinquentAccount(address account) external systemActive optionalProxy returns (bool) { return _liquidateDelinquentAccount(account, 0, messageSender); }
40,878
13
// Function that packs the call to the `liquidate` function in `SimpleLending` as an abi enconding and then calls / the `msg.sender`'s `UserProxy` to call `SimpleLending` with the abi encoding/borrower Addres of user to liquidate/collateralReserve Collateral reserve belonging to `borrower` to be paid back in as a result of the liquidation/loanReserve Addres of loan asset to liquidate in `SimpleLending`/loanAmount Quantity of `reserve` to liquidate from `SimpleLending`
function liquidate(address borrower, address collateralReserve, address loanReserve, uint256 loanAmount) public { bytes memory abiEncoding = abi.encodeWithSignature( "liquidate(address,address,address,uint256)", borrower, collateralReserve, loanReserve, loanAmount ); userProxyCall(abiEncoding, msg.sender, liquidateAction, loanReserve, loanAmount); }
function liquidate(address borrower, address collateralReserve, address loanReserve, uint256 loanAmount) public { bytes memory abiEncoding = abi.encodeWithSignature( "liquidate(address,address,address,uint256)", borrower, collateralReserve, loanReserve, loanAmount ); userProxyCall(abiEncoding, msg.sender, liquidateAction, loanReserve, loanAmount); }
15,255
72
// Do not reduce _totalSupply and/or _reflectedSupply. (soft) burning by sendingtokens to the burn address (which should be excluded from rewards) is sufficientin RFI /
_reflectedBalances[deadAddress] = _reflectedBalances[deadAddress].add(rBurn); if (_isExcludedFromRewards[deadAddress]) _balances[deadAddress] = _balances[deadAddress].add(tBurn);
_reflectedBalances[deadAddress] = _reflectedBalances[deadAddress].add(rBurn); if (_isExcludedFromRewards[deadAddress]) _balances[deadAddress] = _balances[deadAddress].add(tBurn);
21,324
6
// returns e(a,x) == e(b,y)
uint256[12] memory input = [ x[0], x[1], w[0], w[1], w[2], w[3], y[0], p - y[1], z[0], z[1], z[2], z[3] ]; uint[1] memory result; assembly { if iszero(call(not(0), 0x08, 0, input, 0x180, result, 0x20)) { revert(0, 0) }
uint256[12] memory input = [ x[0], x[1], w[0], w[1], w[2], w[3], y[0], p - y[1], z[0], z[1], z[2], z[3] ]; uint[1] memory result; assembly { if iszero(call(not(0), 0x08, 0, input, 0x180, result, 0x20)) { revert(0, 0) }
34,782
21
// Address of the depositor contract for the tBTC v2 Curve pool.
address public immutable tbtcCurvePoolDepositor;
address public immutable tbtcCurvePoolDepositor;
12,059
64
// Sets transferFeeReceiver. /
function setTransferFeeReceiver(address receiver) public onlyOwner { require(receiver != address(0), "receiver is zero"); transferFeeReceiver = receiver; emit SetTransferFeeReceiver(receiver); }
function setTransferFeeReceiver(address receiver) public onlyOwner { require(receiver != address(0), "receiver is zero"); transferFeeReceiver = receiver; emit SetTransferFeeReceiver(receiver); }
21,936
11
// Signal support for receiving ERC1155 tokens./interfaceID The interface ID, as per ERC-165 rules./ return hasSupport `true` if this contract supports an ERC-165 interface.
function supportsInterface(bytes4 interfaceID) external pure returns (bool hasSupport) { return interfaceID == this.supportsInterface.selector || interfaceID == this.onERC1155Received.selector ^ this.onERC1155BatchReceived.selector || interfaceID == this.tokenFallback.selector; }
function supportsInterface(bytes4 interfaceID) external pure returns (bool hasSupport) { return interfaceID == this.supportsInterface.selector || interfaceID == this.onERC1155Received.selector ^ this.onERC1155BatchReceived.selector || interfaceID == this.tokenFallback.selector; }
47,883
565
// call fractionalDepositFactory to create fractional deposit using NFT
fractionalDeposit = fractionalDepositFactory.createFractionalDeposit( address(pool), nftID, fractionalDepositName, fractionalDepositSymbol ); fractionalDeposit.transferOwnership(msg.sender);
fractionalDeposit = fractionalDepositFactory.createFractionalDeposit( address(pool), nftID, fractionalDepositName, fractionalDepositSymbol ); fractionalDeposit.transferOwnership(msg.sender);
21,155
415
// 将余额转到挖矿合约
newLpToken.transferFrom(address(this), sender, mintBal);
newLpToken.transferFrom(address(this), sender, mintBal);
14,854
66
// Returns a DNS format name at the specified offset of self.self The byte array to read a name from.offset The offset to start reading at. return The name./
function readName(bytes memory self, uint offset) internal pure returns(bytes memory ret) { uint len = nameLength(self, offset); return self.substring(offset, len); }
function readName(bytes memory self, uint offset) internal pure returns(bytes memory ret) { uint len = nameLength(self, offset); return self.substring(offset, len); }
5,033