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
54
// The length of all farms on the platform /
function farmsLength() external view returns (uint256) { return farms.length(); }
function farmsLength() external view returns (uint256) { return farms.length(); }
37,671
68
// Tries to returns the value associated with `key`.O(1).Does not revert if `key` is not in the map. _Available since v3.4._ /
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); }
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); }
6,404
6
// Holds result of operation._value result of operation /
event Result (bool _value);
event Result (bool _value);
46,013
3
// Changes the admin of a proxy. proxy Proxy to change admin. newAdmin Address to transfer proxy administration to. /
function changeProxyAdmin(address proxy, address newAdmin) external;
function changeProxyAdmin(address proxy, address newAdmin) external;
13,741
263
// if the index was updated in the same block, no need to perform any calculation
return reserve.liquidityIndex;
return reserve.liquidityIndex;
15,295
7
// Calculates the square root of x, rounding down./Uses the Babylonian method https:en.wikipedia.org/wiki/Methods_of_computing_square_rootsBabylonian_method.// Caveats:/ - This function does not work with fixed-point numbers.//x The uint256 number for which to calculate the square root./ return result The result as an uint256.
function _sqrt(uint256 x) internal pure returns (uint256 result) { if (x == 0) { return 0; } // Set the initial guess to the closest power of two that is higher than x. uint256 xAux = uint256(x); result = 1; if (xAux >= 0x100000000000000000000000000000000) { xAux >>= 128; result <<= 64; } if (xAux >= 0x10000000000000000) { xAux >>= 64; result <<= 32; } if (xAux >= 0x100000000) { xAux >>= 32; result <<= 16; } if (xAux >= 0x10000) { xAux >>= 16; result <<= 8; } if (xAux >= 0x100) { xAux >>= 8; result <<= 4; } if (xAux >= 0x10) { xAux >>= 4; result <<= 2; } if (xAux >= 0x8) { result <<= 1; } // The operations can never overflow because the result is max 2^127 when it enters this block. unchecked { result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; // Seven iterations should be enough uint256 roundedDownResult = x / result; return result >= roundedDownResult ? roundedDownResult : result; } }
function _sqrt(uint256 x) internal pure returns (uint256 result) { if (x == 0) { return 0; } // Set the initial guess to the closest power of two that is higher than x. uint256 xAux = uint256(x); result = 1; if (xAux >= 0x100000000000000000000000000000000) { xAux >>= 128; result <<= 64; } if (xAux >= 0x10000000000000000) { xAux >>= 64; result <<= 32; } if (xAux >= 0x100000000) { xAux >>= 32; result <<= 16; } if (xAux >= 0x10000) { xAux >>= 16; result <<= 8; } if (xAux >= 0x100) { xAux >>= 8; result <<= 4; } if (xAux >= 0x10) { xAux >>= 4; result <<= 2; } if (xAux >= 0x8) { result <<= 1; } // The operations can never overflow because the result is max 2^127 when it enters this block. unchecked { result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; // Seven iterations should be enough uint256 roundedDownResult = x / result; return result >= roundedDownResult ? roundedDownResult : result; } }
55,698
36
// Cancels a request. Throws if already cancelled or executed.
function cancelRequest(uint32 _id, string _msg) public fromAdmin
function cancelRequest(uint32 _id, string _msg) public fromAdmin
1,170
14
// transfer the tokens to the smart contract that will hold token in escrow until end of flight
require(StableTokenInstance.transferFrom(msg.sender, address(this), price));
require(StableTokenInstance.transferFrom(msg.sender, address(this), price));
13,698
21
// Verify the signature using the Wanchain MPC contract
if (!IMPC(signatureVerifier).verify(curveID, sig.s, PKx, PKy, Rx, Ry, sig.sigHash)) { revert SignatureVerifyFailed({ smgID: sig.smgID, sigHash: sig.sigHash, r: sig.r, s: sig.s });
if (!IMPC(signatureVerifier).verify(curveID, sig.s, PKx, PKy, Rx, Ry, sig.sigHash)) { revert SignatureVerifyFailed({ smgID: sig.smgID, sigHash: sig.sigHash, r: sig.r, s: sig.s });
26,347
159
// Helper function for `xSNX.mint` that calculates token issuance snxBalanceBefore: SNX balance pre-mint ethContributed: ETH payable on mint, less fees nonSnxAssetValue: NAV of non-SNX slice of fund totalSupply: xSNX.totalSupply() /
function calculateTokensToMintWithEth( uint256 snxBalanceBefore, uint256 ethContributed, uint256 nonSnxAssetValue, uint256 totalSupply
function calculateTokensToMintWithEth( uint256 snxBalanceBefore, uint256 ethContributed, uint256 nonSnxAssetValue, uint256 totalSupply
38,960
0
// This is just some stable token to test subscription payments using an ERC20 token
contract SomeStableToken is ERC20Detailed("SomeStableToken", "SST", 18), ERC20Mintable { constructor() public { } }
contract SomeStableToken is ERC20Detailed("SomeStableToken", "SST", 18), ERC20Mintable { constructor() public { } }
27,277
0
// uint16 public _tokenId;
mapping(address => bool) claimedWithSKEY; mapping(address => uint8) amountPreMinted; mapping(bytes => bool) sigUsed; IERC721 constant old = IERC721(0x0D631e48f63C4d014667920d4a5a171A5Ab792Da); IERC721 constant baycContract = IERC721(0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D); IERC721 constant maycContract = IERC721(0x60E4d786628Fea6478F785A6d7e704777c86a7c6); IERC20 constant sKeysContractERC20 = IERC20(0xb849C1077072466317cE9d170119A6e68C0879E7);
mapping(address => bool) claimedWithSKEY; mapping(address => uint8) amountPreMinted; mapping(bytes => bool) sigUsed; IERC721 constant old = IERC721(0x0D631e48f63C4d014667920d4a5a171A5Ab792Da); IERC721 constant baycContract = IERC721(0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D); IERC721 constant maycContract = IERC721(0x60E4d786628Fea6478F785A6d7e704777c86a7c6); IERC20 constant sKeysContractERC20 = IERC20(0xb849C1077072466317cE9d170119A6e68C0879E7);
66,110
29
// This generates a public event on the blockchain that will notify clients // Initializes contract with initial supply tokens to the creator of the contract /
function PoliticoinToken( ) TokenERC20(31000000000, 'Politicoin', 'PBLC') public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); }
function PoliticoinToken( ) TokenERC20(31000000000, 'Politicoin', 'PBLC') public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); }
12,892
284
// Returns whether or not there's a duplicate. Runs in O(n^2). A Array to searchreturn Returns true if duplicate, false otherwise /
function hasDuplicate(address[] memory A) internal pure returns (bool) { if (A.length == 0) { return false; }
function hasDuplicate(address[] memory A) internal pure returns (bool) { if (A.length == 0) { return false; }
12,389
2
// Withdraw given bAsset from Lending platform /
function withdraw( address _receiver, address _bAsset, uint256 _amount,
function withdraw( address _receiver, address _bAsset, uint256 _amount,
15,908
10
// 删除数据
* @param countryName {string} 城市名 * @returns {bool} 是否成功 * @example * deleteCountry("AAA"); */ function deleteCountry(string memory countryName) public returns(bool success){ require(totalCountries > 0); for(uint256 i =0; i< totalCountries; i++){ if(compareStrings(countries[i].name , countryName)){ countries[i] = countries[totalCountries-1]; // pushing last into current arrray index which we gonna delete delete countries[totalCountries-1]; // now deleteing last index totalCountries--; //total count decrease countries.length--; // array length decrease //emit event emit CountryDelete(countryName); return true; } } return false; }
* @param countryName {string} 城市名 * @returns {bool} 是否成功 * @example * deleteCountry("AAA"); */ function deleteCountry(string memory countryName) public returns(bool success){ require(totalCountries > 0); for(uint256 i =0; i< totalCountries; i++){ if(compareStrings(countries[i].name , countryName)){ countries[i] = countries[totalCountries-1]; // pushing last into current arrray index which we gonna delete delete countries[totalCountries-1]; // now deleteing last index totalCountries--; //total count decrease countries.length--; // array length decrease //emit event emit CountryDelete(countryName); return true; } } return false; }
28,076
3
// sent from the L1 to the L2 after a successful debt update will trigger AURA to be sent to the L2 and the rate to get updated on the L2
FEES_CALLBACK
FEES_CALLBACK
43,345
586
// An overridable way to access the deployed WETH contract./Must be view to allow overrides to access state./ return wethContract The WETH contract instance.
function getWethContract() external view returns (IEtherToken wethContract);
function getWethContract() external view returns (IEtherToken wethContract);
14,525
36
// setAllowedTokens
@param _tokens {address} @param _allowed {bool} */ function setAllowedTokens( address[] calldata _tokens, bool[] calldata _allowed ) external onlyManager { for (uint256 i = 0; i < _tokens.length; i++) { allowedTokens[_tokens[i]] = _allowed[i]; } }
@param _tokens {address} @param _allowed {bool} */ function setAllowedTokens( address[] calldata _tokens, bool[] calldata _allowed ) external onlyManager { for (uint256 i = 0; i < _tokens.length; i++) { allowedTokens[_tokens[i]] = _allowed[i]; } }
43,382
27
// Get delegation registry contractreturn Delegation registry contract /
function delegationRegistry() external view returns (address);
function delegationRegistry() external view returns (address);
13,598
21
// Remove nextSnapshot entry
delete values[last]; values.length--; return;
delete values[last]; values.length--; return;
9,704
1
// Constructs the Basis Cash ERC-20 contract. /
constructor() public ERC20('iBAC', 'iBAC') { // Mints 1 Basis Cash to contract creator for initial Uniswap oracle deployment. // Will be burned after oracle deployment _mint(msg.sender, 2 * 10**18); }
constructor() public ERC20('iBAC', 'iBAC') { // Mints 1 Basis Cash to contract creator for initial Uniswap oracle deployment. // Will be burned after oracle deployment _mint(msg.sender, 2 * 10**18); }
4,851
22
// Get the effective time at which pendingMPC may become MPC
function effectiveTime() external view returns(uint256) { return _transferData.effectiveTime; }
function effectiveTime() external view returns(uint256) { return _transferData.effectiveTime; }
4,996
454
// Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.The call is not executed if the target address is not a contract.from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred _data bytes optional data to send along with the callreturn bool whether the call correctly returned the expected magic value /
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) {
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) {
424
34
// Add loan order details and ID in active orders
loanOrderDetails[currentLoanOrderId] = newOrder; currentActiveLoanOrderIds.push(currentLoanOrderId);
loanOrderDetails[currentLoanOrderId] = newOrder; currentActiveLoanOrderIds.push(currentLoanOrderId);
24,057
4
// don't use this code in production, will get hacked
function uniswapV2Call( address, uint256 _amount0, uint256, bytes calldata _data
function uniswapV2Call( address, uint256 _amount0, uint256, bytes calldata _data
32,567
19
// Withdraw Ether /
function withdraw() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No balance to withdraw"); (bool success, ) = msg.sender.call{value: balance}(""); require(success, "Failed to withdraw payment"); }
function withdraw() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No balance to withdraw"); (bool success, ) = msg.sender.call{value: balance}(""); require(success, "Failed to withdraw payment"); }
25,793
99
// as proposer
if ((proposal.proposer == _beneficiary)&&(proposal.winningVote == YES)&&(proposal.proposer != address(0))) { rewards[2] = params.proposingRepReward; proposal.proposer = address(0); }
if ((proposal.proposer == _beneficiary)&&(proposal.winningVote == YES)&&(proposal.proposer != address(0))) { rewards[2] = params.proposingRepReward; proposal.proposer = address(0); }
52,075
8
// Kyber srcToken => dstToken
IKyberNetworkProxy kyber = IKyberNetworkProxy(kyberAddress); srcToken.approve(address(kyber), amount); (uint rate, ) = kyber.getExpectedRate(srcToken, dstToken, amount); kyber.swapTokenToToken(srcToken, amount, dstToken, rate);
IKyberNetworkProxy kyber = IKyberNetworkProxy(kyberAddress); srcToken.approve(address(kyber), amount); (uint rate, ) = kyber.getExpectedRate(srcToken, dstToken, amount); kyber.swapTokenToToken(srcToken, amount, dstToken, rate);
4,441
81
// Adds multiple entries to DFSRegistry/_ids Ids used to fetch contract addresses/_contractAddrs Array of contract addresses matching the ids/_waitPeriods Array of wait periods (used for contract change)
function addMultipleEntries( bytes4[] calldata _ids, address[] calldata _contractAddrs, uint256[] calldata _waitPeriods
function addMultipleEntries( bytes4[] calldata _ids, address[] calldata _contractAddrs, uint256[] calldata _waitPeriods
48,319
38
// Startup TokenERC20 Startup Token (STT) STT Tokens are divisible by 8STT are displayed using 8 decimal places of precision. /
contract StartupToken is StandardToken, Pausable { string public constant name = 'Startup Token'; // Set the token name for display string public constant symbol = 'STT'; // Set the token symbol for display uint8 public constant decimals = 8; // Set the number of decimals for display uint256 public constant INITIAL_SUPPLY = 100000000000000000; // /** * @dev Startup Token Constructor * Runs only on initial contract creation. */ function StartupToken() { totalSupply = INITIAL_SUPPLY; // Set the total supply balances[msg.sender] = INITIAL_SUPPLY; // Creator address is assigned all } /** * @dev Transfer token for a specified address when not paused * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) whenNotPaused returns (bool) { require(_to != address(0)); return super.transfer(_to, _value); } /** * @dev Transfer tokens from one address to another when not paused * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) whenNotPaused returns (bool) { require(_to != address(0)); return super.transferFrom(_from, _to, _value); } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender when not paused. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) whenNotPaused returns (bool) { return super.approve(_spender, _value); } }
contract StartupToken is StandardToken, Pausable { string public constant name = 'Startup Token'; // Set the token name for display string public constant symbol = 'STT'; // Set the token symbol for display uint8 public constant decimals = 8; // Set the number of decimals for display uint256 public constant INITIAL_SUPPLY = 100000000000000000; // /** * @dev Startup Token Constructor * Runs only on initial contract creation. */ function StartupToken() { totalSupply = INITIAL_SUPPLY; // Set the total supply balances[msg.sender] = INITIAL_SUPPLY; // Creator address is assigned all } /** * @dev Transfer token for a specified address when not paused * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) whenNotPaused returns (bool) { require(_to != address(0)); return super.transfer(_to, _value); } /** * @dev Transfer tokens from one address to another when not paused * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) whenNotPaused returns (bool) { require(_to != address(0)); return super.transferFrom(_from, _to, _value); } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender when not paused. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) whenNotPaused returns (bool) { return super.approve(_spender, _value); } }
24,298
98
// car_address => bets on this car.
mapping (address => Bet[]) betsByCar;
mapping (address => Bet[]) betsByCar;
17,002
0
// Initial distribution
uint256 public constant SALE_TOKENS = 60; // 60% from totalSupply uint256 public constant TEAM_TOKENS = 10; // 10% from totalSupply uint256 public constant PRIZE_TOKENS = 10; // 10% from totalSupply uint256 public constant ADVISOR_TOKENS = 10; // 10% from totalSupply uint256 public constant AIRDROP_TOKENS = 5; // 5% from totalSupply uint256 public constant RESERVE_TOKENS = 5; // 5% from totalSupply uint256 public constant TEAM_LOCK_TIME = 15770000; // 6 months in seconds uint256 public constant RESERVE_LOCK_TIME = 31540000; // 1 year in seconds
uint256 public constant SALE_TOKENS = 60; // 60% from totalSupply uint256 public constant TEAM_TOKENS = 10; // 10% from totalSupply uint256 public constant PRIZE_TOKENS = 10; // 10% from totalSupply uint256 public constant ADVISOR_TOKENS = 10; // 10% from totalSupply uint256 public constant AIRDROP_TOKENS = 5; // 5% from totalSupply uint256 public constant RESERVE_TOKENS = 5; // 5% from totalSupply uint256 public constant TEAM_LOCK_TIME = 15770000; // 6 months in seconds uint256 public constant RESERVE_LOCK_TIME = 31540000; // 1 year in seconds
44,990
6
// events
event NewMember( address user); event NewProposal(uint proposalId,string metadataUri,address createdBy); event Voted(uint proposalId,bool vote); event VotingClosed(uint proposalId,uint yesVote,uint noVote);
event NewMember( address user); event NewProposal(uint proposalId,string metadataUri,address createdBy); event Voted(uint proposalId,bool vote); event VotingClosed(uint proposalId,uint yesVote,uint noVote);
21,966
24
// This is the case where bonusEndBlock is in the middle of _lastRewardBlock and _currentBlock block.
return bonusEndBlock.sub(_lastRewardBlock).mul(bonusMultiplier).add(_currentBlock.sub(bonusEndBlock));
return bonusEndBlock.sub(_lastRewardBlock).mul(bonusMultiplier).add(_currentBlock.sub(bonusEndBlock));
31,836
24
// Get the auction state /
function getAuctionState() public view override onlyLogin returns (AuctionState) { if (isCancelled) { return AuctionState.CANCELLED; } else if (isDirectBuy) { return AuctionState.DIRECT_BUY; } else if (block.timestamp >= endTime) { return AuctionState.ENDED; } else { return AuctionState.OPEN; } }
function getAuctionState() public view override onlyLogin returns (AuctionState) { if (isCancelled) { return AuctionState.CANCELLED; } else if (isDirectBuy) { return AuctionState.DIRECT_BUY; } else if (block.timestamp >= endTime) { return AuctionState.ENDED; } else { return AuctionState.OPEN; } }
13,228
23
// Returns the number of the first codepoint in the slice. self The slice to operate on.return The number of the first codepoint in the slice. /
function ord(slice self) internal returns (uint ret) { if (self._len == 0) { return 0; } uint word; uint len; uint div = 2 ** 248; // Load the rune into the MSBs of b assembly { word:= mload(mload(add(self, 32))) } var b = word / div; if (b < 0x80) { ret = b; len = 1; } else if(b < 0xE0) { ret = b & 0x1F; len = 2; } else if(b < 0xF0) { ret = b & 0x0F; len = 3; } else { ret = b & 0x07; len = 4; } // Check for truncated codepoints if (len > self._len) { return 0; } for (uint i = 1; i < len; i++) { div = div / 256; b = (word / div) & 0xFF; if (b & 0xC0 != 0x80) { // Invalid UTF-8 sequence return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; }
function ord(slice self) internal returns (uint ret) { if (self._len == 0) { return 0; } uint word; uint len; uint div = 2 ** 248; // Load the rune into the MSBs of b assembly { word:= mload(mload(add(self, 32))) } var b = word / div; if (b < 0x80) { ret = b; len = 1; } else if(b < 0xE0) { ret = b & 0x1F; len = 2; } else if(b < 0xF0) { ret = b & 0x0F; len = 3; } else { ret = b & 0x07; len = 4; } // Check for truncated codepoints if (len > self._len) { return 0; } for (uint i = 1; i < len; i++) { div = div / 256; b = (word / div) & 0xFF; if (b & 0xC0 != 0x80) { // Invalid UTF-8 sequence return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; }
19,812
142
// Unstake.
* Emits an {Unstake} event. * * Requirements: * - Dfinance account is connected. * - Account didn't unstake. */ function unstake() external override returns (bool) { require(_stakers[msg.sender].account != bytes32(0), 'Staking: Dfinance account is not connected'); require(_stakers[msg.sender].unstakedAt == 0, 'Staking: unstaked account'); _stakers[msg.sender].unstakedAt = block.timestamp; if (!_isXfiUnstakingDisabled) { uint256 unstakedXfiAmount = _stakers[msg.sender].xfiBalance; if (unstakedXfiAmount > 0) { _stakers[msg.sender].xfiBalance = 0; require(_token.transfer(msg.sender, unstakedXfiAmount), 'Staking: XFI transfer failed'); } } uint256 unstakedLptAmount = _stakers[msg.sender].lptBalance; if (unstakedLptAmount > 0) { _stakers[msg.sender].lptBalance = 0; require(_xfiEthPair.transfer(msg.sender, unstakedLptAmount), 'Staking: LPT transfer failed'); } emit Unstake(_stakers[msg.sender].account); return true; }
* Emits an {Unstake} event. * * Requirements: * - Dfinance account is connected. * - Account didn't unstake. */ function unstake() external override returns (bool) { require(_stakers[msg.sender].account != bytes32(0), 'Staking: Dfinance account is not connected'); require(_stakers[msg.sender].unstakedAt == 0, 'Staking: unstaked account'); _stakers[msg.sender].unstakedAt = block.timestamp; if (!_isXfiUnstakingDisabled) { uint256 unstakedXfiAmount = _stakers[msg.sender].xfiBalance; if (unstakedXfiAmount > 0) { _stakers[msg.sender].xfiBalance = 0; require(_token.transfer(msg.sender, unstakedXfiAmount), 'Staking: XFI transfer failed'); } } uint256 unstakedLptAmount = _stakers[msg.sender].lptBalance; if (unstakedLptAmount > 0) { _stakers[msg.sender].lptBalance = 0; require(_xfiEthPair.transfer(msg.sender, unstakedLptAmount), 'Staking: LPT transfer failed'); } emit Unstake(_stakers[msg.sender].account); return true; }
80,382
699
// burn claimed shares
_hypervisor.rewardSharesOutstanding = _hypervisor.rewardSharesOutstanding.sub(sharesToBurn);
_hypervisor.rewardSharesOutstanding = _hypervisor.rewardSharesOutstanding.sub(sharesToBurn);
33,726
368
// Compute final fee at time of liquidation.
finalFeeBond = _computeFinalFees();
finalFeeBond = _computeFinalFees();
3,760
13
// Arb a pair's pools: use supplied USDC to mint+sell or buy+redeem. Return USDC + profits to sender.compute optimal arb amount off-chainamount USDC to use for arbitragetokensToBuy Number of tokens to buy and redeem. If 0, mint and sell with supplied USDClsp LongShortPair for the target dominance pairrouter Address of Uniswap, Quickswap, etc. router.deadline Timestamp beyond which tx will revert.usdcSignature optional signature/
function arbitrage( uint amount, uint tokensToBuy, LongShortPair lsp, IUniswapV2Router02 router, uint deadline, Signature calldata usdcSignature
function arbitrage( uint amount, uint tokensToBuy, LongShortPair lsp, IUniswapV2Router02 router, uint deadline, Signature calldata usdcSignature
26,607
65
// Change value of treasury reward period. Call by only Governance. /
function changeTreasuryRewardPeriod(uint256 treasuryRewardPeriod_) external onlyGovernance
function changeTreasuryRewardPeriod(uint256 treasuryRewardPeriod_) external onlyGovernance
4,733
132
// makes incremental adjustment to control variable /
function adjust() internal { uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer ); if( adjustment.rate != 0 && block.number >= blockCanAdjust ) { uint initial = terms.controlVariable; if ( adjustment.add ) { terms.controlVariable = terms.controlVariable.add( adjustment.rate ); if ( terms.controlVariable >= adjustment.target ) { adjustment.rate = 0; } } else { terms.controlVariable = terms.controlVariable.sub( adjustment.rate ); if ( terms.controlVariable <= adjustment.target ) { adjustment.rate = 0; } } adjustment.lastBlock = block.number; emit ControlVariableAdjustment( initial, terms.controlVariable, adjustment.rate, adjustment.add ); } }
function adjust() internal { uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer ); if( adjustment.rate != 0 && block.number >= blockCanAdjust ) { uint initial = terms.controlVariable; if ( adjustment.add ) { terms.controlVariable = terms.controlVariable.add( adjustment.rate ); if ( terms.controlVariable >= adjustment.target ) { adjustment.rate = 0; } } else { terms.controlVariable = terms.controlVariable.sub( adjustment.rate ); if ( terms.controlVariable <= adjustment.target ) { adjustment.rate = 0; } } adjustment.lastBlock = block.number; emit ControlVariableAdjustment( initial, terms.controlVariable, adjustment.rate, adjustment.add ); } }
22,757
151
// Stats
bool public paused = false; bool public presale = true; bool public onlyWhitelisted = true;
bool public paused = false; bool public presale = true; bool public onlyWhitelisted = true;
18,445
52
// Metadata specific to an asset type scoped to a user /
struct AssetUserMetadata { address assetId; bool enteredMarket; uint256 supplyBalanceUsdc; uint256 borrowBalanceUsdc; uint256 borrowLimitUsdc; }
struct AssetUserMetadata { address assetId; bool enteredMarket; uint256 supplyBalanceUsdc; uint256 borrowBalanceUsdc; uint256 borrowLimitUsdc; }
85,408
52
// ============ For Owner ============
function grant(address[] calldata holderList, uint256[] calldata amountList) external onlyOwner
function grant(address[] calldata holderList, uint256[] calldata amountList) external onlyOwner
684
136
// A distinct URI (RFC 3986) for a given NFT. _tokenId Id for which we want uri.return URI of _tokenId. /
function tokenPayload( uint256 _tokenId ) external view validNFToken(_tokenId) returns (string memory)
function tokenPayload( uint256 _tokenId ) external view validNFToken(_tokenId) returns (string memory)
15,096
66
// Only manager can call this function Changes broken oracle type to the correct one asset The address of the main collateral token user The address of a position's owner newOracleType The new type of an oracle /
function changeOracleType(address asset, address user, uint newOracleType) external onlyManager { oracleType[asset][user] = newOracleType; }
function changeOracleType(address asset, address user, uint newOracleType) external onlyManager { oracleType[asset][user] = newOracleType; }
18,789
20
// Set as size of tranche as minimum sell volume.
current_tranche_start = uint40(now); proposal[id].proposal_start = uint40(now); top_param = 0; //reset top param. emit Reset(id);
current_tranche_start = uint40(now); proposal[id].proposal_start = uint40(now); top_param = 0; //reset top param. emit Reset(id);
36,126
18
// Derive the tail by adding one word per element (note that structs are written to memory with an offset per struct element).
let mPtrTail := add(mPtrHead, shl(OneWordShift, arrLength))
let mPtrTail := add(mPtrHead, shl(OneWordShift, arrLength))
21,014
92
// //Stake SUSHI `amount` into aXSUSHI for benefit of `to` by batching calls to `sushiBar` and `aave`.
function stakeSushiToAave(address to, uint256 amount) external { // SAAVE sushiToken.safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` SUSHI `amount` into this contract ISushiBarBridge(sushiBar).enter(amount); // stake deposited SUSHI into `sushiBar` xSUSHI aave.deposit(sushiBar, IERC20(sushiBar).safeBalanceOfSelf(), to, 0); // stake resulting xSUSHI into `aave` aXSUSHI for `to` }
function stakeSushiToAave(address to, uint256 amount) external { // SAAVE sushiToken.safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` SUSHI `amount` into this contract ISushiBarBridge(sushiBar).enter(amount); // stake deposited SUSHI into `sushiBar` xSUSHI aave.deposit(sushiBar, IERC20(sushiBar).safeBalanceOfSelf(), to, 0); // stake resulting xSUSHI into `aave` aXSUSHI for `to` }
24,012
5
// Mint prices
uint256 public publicMintPrice; uint256 public wlMintPrice;
uint256 public publicMintPrice; uint256 public wlMintPrice;
46,044
270
// Claimable number of tokens after first cliff period
uint256 cliffAmount1;
uint256 cliffAmount1;
33,284
134
// Add the market to the markets mapping and set it as listedAdmin function to set isListed and add support for the marketsToken The address of the market (token) to list return uint 0=success, otherwise a failure. (See enum Error for details)/
function _supportMarket(SToken sToken) external returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK); } if (markets[address(sToken)].isListed) { return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS); } sToken.isSToken(); // Sanity check to make sure its really a SToken markets[address(sToken)] = Market({isListed: true, isStriked: false, collateralFactorMantissa: 0}); _addMarketInternal(address(sToken)); _initializeMarket(address(sToken)); emit MarketListed(sToken); return uint(Error.NO_ERROR); }
function _supportMarket(SToken sToken) external returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK); } if (markets[address(sToken)].isListed) { return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS); } sToken.isSToken(); // Sanity check to make sure its really a SToken markets[address(sToken)] = Market({isListed: true, isStriked: false, collateralFactorMantissa: 0}); _addMarketInternal(address(sToken)); _initializeMarket(address(sToken)); emit MarketListed(sToken); return uint(Error.NO_ERROR); }
48,511
40
// Pop last byte to get token fee type
uint8 feeTokenTypeRaw = uint8(_g.feeTokenData.popLastByte());
uint8 feeTokenTypeRaw = uint8(_g.feeTokenData.popLastByte());
20,205
1
// Check that init has contract code
uint contractSize;
uint contractSize;
22,534
335
// Collects TRIBE tokens
IStakingRewards(rewards).getReward(); uint256 _tribe = IERC20(tribe).balanceOf(address(this)); uint256 _fei = IERC20(fei).balanceOf(address(this)); if (_tribe > 0 && performanceTreasuryFee > 0) { uint256 tribePerfomanceFeeAmount = _tribe .mul(performanceTreasuryFee) .div(performanceTreasuryMax); _swapUniswapWithPath(tribe_fei_path, tribePerfomanceFeeAmount); _fei = IERC20(fei).balanceOf(address(this));
IStakingRewards(rewards).getReward(); uint256 _tribe = IERC20(tribe).balanceOf(address(this)); uint256 _fei = IERC20(fei).balanceOf(address(this)); if (_tribe > 0 && performanceTreasuryFee > 0) { uint256 tribePerfomanceFeeAmount = _tribe .mul(performanceTreasuryFee) .div(performanceTreasuryMax); _swapUniswapWithPath(tribe_fei_path, tribePerfomanceFeeAmount); _fei = IERC20(fei).balanceOf(address(this));
50,974
36
// Logs changes in maximum profit
event MaxProfitChanged(uint _oldMaxProfit, uint _newMaxProfit);
event MaxProfitChanged(uint _oldMaxProfit, uint _newMaxProfit);
13,788
105
// accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed
return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0);
return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0);
11,789
2
// ----- VARIABLES -----
IAsset[] private _assets;
IAsset[] private _assets;
56,581
6
// updates the unclaimed array.
function _updateUnclaimed() internal { for (uint256 i = 0; i < tokenStatus.length; i++) { if(tokenStatus[i] == 0){ unclaimed.push(i); } } }
function _updateUnclaimed() internal { for (uint256 i = 0; i < tokenStatus.length; i++) { if(tokenStatus[i] == 0){ unclaimed.push(i); } } }
13,350
3
// can only mint a max of whatever the max public purchase is per transaction
pause();
pause();
84,257
46
// Internal function that burns an amount of the token of a givenaccount. account The account whose tokens will be burnt. amount The amount that will be burnt. /
function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "ERC20: value must be bigger than zero"); require(amount <= _balances[account], "ERC20: account balance is lower than amount"); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); emit Burn(account, amount); }
function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "ERC20: value must be bigger than zero"); require(amount <= _balances[account], "ERC20: account balance is lower than amount"); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); emit Burn(account, amount); }
39,472
76
// Allows the current owner to set the pendingOwner address. _newOwner The address to transfer ownership to. /
function transferOwnership(address _newOwner) public onlyOwner { pendingOwner = _newOwner; emit LogOwnerShipTransferInitiated(owner, _newOwner); }
function transferOwnership(address _newOwner) public onlyOwner { pendingOwner = _newOwner; emit LogOwnerShipTransferInitiated(owner, _newOwner); }
36,761
81
// currencyAvailableConstraint => -1
return ERR_CURRENCY_AVAILABLE;
return ERR_CURRENCY_AVAILABLE;
41,165
164
// Set max fungible tickets allowed to mint per pool
maxFungibleTicketsPerPool = _maxFungibleTicketsPerPool;
maxFungibleTicketsPerPool = _maxFungibleTicketsPerPool;
37,546
15
// Increase the total amount that&39;s been paid out to maintain invariance.
totalPayouts += (int256) (balance * scaleFactor);
totalPayouts += (int256) (balance * scaleFactor);
27,705
194
// the creator of the contract is the initial CEO, COO, CTO
ceoAddress = msg.sender; ctoAddress = msg.sender; cooAddress = msg.sender; oracleAddress = msg.sender;
ceoAddress = msg.sender; ctoAddress = msg.sender; cooAddress = msg.sender; oracleAddress = msg.sender;
1,807
227
// Fallbacks
receive() external payable { } fallback() external payable { } }
receive() external payable { } fallback() external payable { } }
34,642
27
// Short-circuit the process via regular sqrt if p is real.
if (p.y == 0) { (int256 root, bool real) = sqrt(p.x, rounds); if (real) { return Point({x: root, y: 0});
if (p.y == 0) { (int256 root, bool real) = sqrt(p.x, rounds); if (real) { return Point({x: root, y: 0});
39,144
58
// Transfer tokens for specified beneficiary (dispute, for example) _from Where tokens should be taken _to Tokens address destination _tokenAmount Amount of tokens added /
function transferTokens(address _from, address _to, uint256 _tokenAmount) public onlyOwner { if (balances[_from] > 0) { balances[_from] = balances[_from].sub(_tokenAmount); balances[_to] = balances[_to].add(_tokenAmount); } }
function transferTokens(address _from, address _to, uint256 _tokenAmount) public onlyOwner { if (balances[_from] > 0) { balances[_from] = balances[_from].sub(_tokenAmount); balances[_to] = balances[_to].add(_tokenAmount); } }
67,337
36
// Sets the LINK token address linkAddress The address of the LINK token contract /
function setChainlinkToken( address linkAddress ) internal
function setChainlinkToken( address linkAddress ) internal
14,593
15
// ====== POLICY FUNCTIONS ====== // set bounty to incentivize keepers _bounty uint256 /
function setBounty(uint256 _bounty) external override onlyGovernor { require(_bounty <= 2e9, "Too much"); bounty = _bounty; }
function setBounty(uint256 _bounty) external override onlyGovernor { require(_bounty <= 2e9, "Too much"); bounty = _bounty; }
38,777
11
// check if user is subscribed
if (!subscribed) return (false, 0, "User not subbed");
if (!subscribed) return (false, 0, "User not subbed");
21,244
628
// AmmUtil
library AmmUtil
library AmmUtil
44,826
14
// Returns reward information based on indexseason - Season index index - Reward list index /
function readRewardByIndex( uint256 season, uint256 index
function readRewardByIndex( uint256 season, uint256 index
18,927
131
// keccak256("SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)");
bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;
bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;
23,674
14
// Grouping token owner
uint256 public MYFILockedCommunityOne; uint256 public MYFILockedCommunityTwo; address public owner; ERC20 public MYFIToken;
uint256 public MYFILockedCommunityOne; uint256 public MYFILockedCommunityTwo; address public owner; ERC20 public MYFIToken;
53,067
79
// Fall back function ~50k-100k gas
function () payable onIcoRunning { buyTokens(msg.sender); }
function () payable onIcoRunning { buyTokens(msg.sender); }
26,426
15
// Track the whitelisted land owners
mapping(address => bool) landAllowed; mapping(address => bool) landMinted;
mapping(address => bool) landAllowed; mapping(address => bool) landMinted;
11,264
78
// Deposit pSpacebar tokens to SpaceChef for Reward allocation.
function deposit(uint256 _amount) public { require (_amount > 0, 'amount 0'); UserInfo storage user = userInfo[msg.sender]; updatePool(); pspacebar.safeTransferFrom(address(msg.sender), address(this), _amount); if (user.amount == 0 && user.rewardDebt == 0 && user.rewardPending ==0) { addressList.push(address(msg.sender)); } user.rewardPending = user.amount.mul(poolInfo.accRewardPerShare).div(1e12).sub(user.rewardDebt).add(user.rewardPending); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(poolInfo.accRewardPerShare).div(1e12); emit Deposit(msg.sender, _amount); }
function deposit(uint256 _amount) public { require (_amount > 0, 'amount 0'); UserInfo storage user = userInfo[msg.sender]; updatePool(); pspacebar.safeTransferFrom(address(msg.sender), address(this), _amount); if (user.amount == 0 && user.rewardDebt == 0 && user.rewardPending ==0) { addressList.push(address(msg.sender)); } user.rewardPending = user.amount.mul(poolInfo.accRewardPerShare).div(1e12).sub(user.rewardDebt).add(user.rewardPending); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(poolInfo.accRewardPerShare).div(1e12); emit Deposit(msg.sender, _amount); }
23,422
6
// Mints a new NFT. This is an internal function which should be called from user-implemented externalmint function. Its purpose is to show and properly initialize data structures when using thisimplementation. _to The address that will own the minted NFT. _tokenId of the NFT to be minted by the msg.sender. /
function _mint( address _to, uint256 _tokenId ) internal override(NFToken, NFTokenEnumerable) virtual
function _mint( address _to, uint256 _tokenId ) internal override(NFToken, NFTokenEnumerable) virtual
40,259
21
// Returns the integer division of two unsigned integers, reverting ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a`revert` opcode (which leaves remaining gas untouched) while Solidityuses an invalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero. /
function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; }
function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; }
240
2
// Get the first variable from Storage, which is the delegate address
let _target := sload(0)
let _target := sload(0)
47,570
73
// Max wallet & Transaction
uint256 public _maxTxAmount = rSupply.div(1000).mul(100); uint256 public _maxWalletToken = rSupply.div(1000).mul(100); function rebase_percentage(uint256 _percentage_base1000) public onlyMaster returns (uint256 newSupply)
uint256 public _maxTxAmount = rSupply.div(1000).mul(100); uint256 public _maxWalletToken = rSupply.div(1000).mul(100); function rebase_percentage(uint256 _percentage_base1000) public onlyMaster returns (uint256 newSupply)
28,204
57
// calculate liabilityToBurn and Fee
uint256 liabilityToBurn; (amount, liabilityToBurn, withdrawalHaircut) = CoreV3.quoteWithdrawAmount( asset, liquidity, ampFactor, _getGlobalEquilCovRatioForDepositWithdrawal(), withdrawalHaircutRate ); _checkAmount(minimumAmount, amount);
uint256 liabilityToBurn; (amount, liabilityToBurn, withdrawalHaircut) = CoreV3.quoteWithdrawAmount( asset, liquidity, ampFactor, _getGlobalEquilCovRatioForDepositWithdrawal(), withdrawalHaircutRate ); _checkAmount(minimumAmount, amount);
30,157
19
// 소유주가 차단되었는지
mapping(address => bool) public masterToIsBlocked;
mapping(address => bool) public masterToIsBlocked;
7,278
224
// Cleanup NOTE: We do not delete the pending transfer struct, because it only makes it more expensive since we already hit the gas refund limit. delete _pendingTransfers[_getOpKey(user, opHandle.opId)]; The difference is ~13k gas. Deleting the op handle is enough to invalidate an opId forever:
_deleteOpHandle(user, opHandle);
_deleteOpHandle(user, opHandle);
5,242
8
// this is a one-on-one transaction. Needs to be an auction in future
function buyFromIndividual(uint256 tokenId) public payable{ //works only if the given token is up for sale require(reSale[tokenId].isUpForResale == true, "This token hasn't been put for sale by the owner"); //set to a static value. This becomes an auction in future versions require(msg.value == reSale[tokenId].resalePrice, "Your price doesn't match the price given by the tokenOwner"); //Finding the commissionPercent from fileinfo, and then finding the concrete value of it //from msg.value and then storing in publisherBalance publisherBalance[fileinfo[reSale[tokenId].ISBN].publisherAddress] += msg.value*((fileinfo[reSale[tokenId].ISBN].saleCommission)/100); //finding the seller's cut, and instantly transferring it to the seller address payable sendTo; sendTo = address(uint160(_tokenOwner[tokenId])); sendTo.transfer(msg.value - (msg.value*((fileinfo[reSale[tokenId].ISBN].saleCommission)/100))); //updating token balances for both seller and buyer _ownedTokensCount[_tokenOwner[tokenId]].decrement(); _ownedTokensCount[msg.sender].increment(); emit Transfer(_tokenOwner[tokenId], msg.sender, tokenId); _tokenOwner[tokenId] = msg.sender; reSale[tokenId].isUpForResale = false; }
function buyFromIndividual(uint256 tokenId) public payable{ //works only if the given token is up for sale require(reSale[tokenId].isUpForResale == true, "This token hasn't been put for sale by the owner"); //set to a static value. This becomes an auction in future versions require(msg.value == reSale[tokenId].resalePrice, "Your price doesn't match the price given by the tokenOwner"); //Finding the commissionPercent from fileinfo, and then finding the concrete value of it //from msg.value and then storing in publisherBalance publisherBalance[fileinfo[reSale[tokenId].ISBN].publisherAddress] += msg.value*((fileinfo[reSale[tokenId].ISBN].saleCommission)/100); //finding the seller's cut, and instantly transferring it to the seller address payable sendTo; sendTo = address(uint160(_tokenOwner[tokenId])); sendTo.transfer(msg.value - (msg.value*((fileinfo[reSale[tokenId].ISBN].saleCommission)/100))); //updating token balances for both seller and buyer _ownedTokensCount[_tokenOwner[tokenId]].decrement(); _ownedTokensCount[msg.sender].increment(); emit Transfer(_tokenOwner[tokenId], msg.sender, tokenId); _tokenOwner[tokenId] = msg.sender; reSale[tokenId].isUpForResale = false; }
51,397
53
// Withdraw ether from this contract (Callable by owner)/
function withdraw() onlyOwner public { uint balance = address(this).balance; msg.sender.transfer(balance); }
function withdraw() onlyOwner public { uint balance = address(this).balance; msg.sender.transfer(balance); }
6,942
12
// Pay the winning
entries_addresses[i].transfer(win_amount);
entries_addresses[i].transfer(win_amount);
49,484
45
// Burnable Token Token that can be irreversibly burned (destroyed). /
contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } }
contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } }
1,053
180
// assign player their keys from ICO phase
plyrRnds_[_pID][_rID].keys = calcPlayerICOPhaseKeys(_pID, _rID);
plyrRnds_[_pID][_rID].keys = calcPlayerICOPhaseKeys(_pID, _rID);
76,528
41
// 0x07 id of precompiled bn256ScalarMul contract 0number of ether to transfer 96 size of call parameters, i.e. 96 bytes total (256 bit for x, 256 bit for y, 256 bit for scalar) 64 size of call return value, i.e. 64 bytes / 512 bit for a BN256 curve point
success := call(not(0), 0x07, 0, input, 96, result, 64)
success := call(not(0), 0x07, 0, input, 96, result, 64)
7,955
221
// calculations pulled directly from CVX's contract for minting CVX per CRV claimed
uint256 totalCliffs = 1000; uint256 maxSupply = 100 * 1000000 * 1e18; // 100mil uint256 reductionPerCliff = 100000000000000000000000; // 100,000 uint256 supply = convexToken.totalSupply(); uint256 cliff = supply.div(reductionPerCliff);
uint256 totalCliffs = 1000; uint256 maxSupply = 100 * 1000000 * 1e18; // 100mil uint256 reductionPerCliff = 100000000000000000000000; // 100,000 uint256 supply = convexToken.totalSupply(); uint256 cliff = supply.div(reductionPerCliff);
20,368
23
// Constructor that gives msg.sender all of existing tokens. /
function SETPointerToken() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); }
function SETPointerToken() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); }
35,612
118
// Updates `owner` s allowance for `spender` based on spent `amount`. Does not update the allowance amount in case of infinite allowance.Revert if not enough allowance is available.
* Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } }
* Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } }
25,630
28
// Internal functions, called when calculating balances/
function _getUserTokens(uint256 _amount) internal view returns (uint256) { return _amount.mul(tokensSold).div(ethRaised); }
function _getUserTokens(uint256 _amount) internal view returns (uint256) { return _amount.mul(tokensSold).div(ethRaised); }
30,396
15
// TODO
address tokenAddr = 0x5A947A3e5B62Cb571C056eC28293b32126E4d743; address pairAddr = address(0); address gameAddr = address(0);
address tokenAddr = 0x5A947A3e5B62Cb571C056eC28293b32126E4d743; address pairAddr = address(0); address gameAddr = address(0);
35,896
25
// Retrieve the value for the node./index The index that the node is part of./id The id for the node to be looked up.
function getNodeValue(Index storage index, bytes32 id) constant returns (int) { return index.nodes[id].value; }
function getNodeValue(Index storage index, bytes32 id) constant returns (int) { return index.nodes[id].value; }
50,521