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
// Minimal safety check for cardano address Address specifications can be found here: https:cips.cardano.org/cips/cip19/ TODO - discuss how indepth this should be do we check it starts with addr1q, addr1v or addr1w do we ensure lowercase alphanumeric (excluding b,i,o and 1 (except for addr1))
function validateCardanoAddress(string memory cardanoAddress) internal pure returns (bool) { bytes memory addressBytes = bytes(cardanoAddress); // No substrings in solidity, and a generic solution would cost extra gas bool startsWithAddr = addressBytes[0] == "a" && addressBytes[1] == "d" && addressBytes[2] == "d" && addressBytes[3] == "r"; // Shorthand is payment only, longhand is payment + staking return startsWithAddr && (addressBytes.length == 58 || addressBytes.length == 103); }
function validateCardanoAddress(string memory cardanoAddress) internal pure returns (bool) { bytes memory addressBytes = bytes(cardanoAddress); // No substrings in solidity, and a generic solution would cost extra gas bool startsWithAddr = addressBytes[0] == "a" && addressBytes[1] == "d" && addressBytes[2] == "d" && addressBytes[3] == "r"; // Shorthand is payment only, longhand is payment + staking return startsWithAddr && (addressBytes.length == 58 || addressBytes.length == 103); }
42,595
9
// The reviewer can approve a completion request from the milestone manager When he does, the milestone's state is set to completed and the funds can be withdrawn by the recipient.
function approveCompleted() isInitialized onlyReviewer external { require(!isCanceled()); require(state == MilestoneState.NEEDS_REVIEW); state = MilestoneState.COMPLETED; emit ApproveCompleted(liquidPledging, idProject); }
function approveCompleted() isInitialized onlyReviewer external { require(!isCanceled()); require(state == MilestoneState.NEEDS_REVIEW); state = MilestoneState.COMPLETED; emit ApproveCompleted(liquidPledging, idProject); }
21,487
68
// If it points to where it's expected.
if (idToThing[idHash] == _oldIndex) {
if (idToThing[idHash] == _oldIndex) {
56,736
9
// A token tracker that limits the token supply and increments token IDs on each new mint.
abstract contract AddLimitedSupply { using Counters for Counters.Counter; // Keeps track of how many we have minted Counters.Counter private _tokenCount; /// @dev The maximum count of tokens this token tracker will hold. uint256 private _totalSupply; /// Instanciate the contract /// @param totalSupply_ how many tokens this collection should hold constructor (uint256 totalSupply_) { _totalSupply = totalSupply_; } /// @dev Get the max Supply /// @return the maximum token count function totalSupply() public virtual view returns (uint256) { return _totalSupply; } /// @dev Get the current token count /// @return the created token count function tokenCount() public view returns (uint256) { return _tokenCount.current(); } /// @dev Check whether tokens are still available /// @return the available token count function availableTokenCount() public view returns (uint256) { return totalSupply() - tokenCount(); } /// @dev Increment the token count and fetch the latest count /// @return the next token id function nextToken() internal virtual ensureAvailability returns (uint256) { uint256 token = _tokenCount.current(); _tokenCount.increment(); return token; } /// @dev Check whether another token is still available modifier ensureAvailability() { require(availableTokenCount() > 0, "No more tokens available"); _; } /// @param amount Check whether number of tokens are still available /// @dev Check whether tokens are still available modifier ensureAvailabilityFor(uint256 amount) { require(availableTokenCount() >= amount, "Requested number of tokens not available"); _; } }
abstract contract AddLimitedSupply { using Counters for Counters.Counter; // Keeps track of how many we have minted Counters.Counter private _tokenCount; /// @dev The maximum count of tokens this token tracker will hold. uint256 private _totalSupply; /// Instanciate the contract /// @param totalSupply_ how many tokens this collection should hold constructor (uint256 totalSupply_) { _totalSupply = totalSupply_; } /// @dev Get the max Supply /// @return the maximum token count function totalSupply() public virtual view returns (uint256) { return _totalSupply; } /// @dev Get the current token count /// @return the created token count function tokenCount() public view returns (uint256) { return _tokenCount.current(); } /// @dev Check whether tokens are still available /// @return the available token count function availableTokenCount() public view returns (uint256) { return totalSupply() - tokenCount(); } /// @dev Increment the token count and fetch the latest count /// @return the next token id function nextToken() internal virtual ensureAvailability returns (uint256) { uint256 token = _tokenCount.current(); _tokenCount.increment(); return token; } /// @dev Check whether another token is still available modifier ensureAvailability() { require(availableTokenCount() > 0, "No more tokens available"); _; } /// @param amount Check whether number of tokens are still available /// @dev Check whether tokens are still available modifier ensureAvailabilityFor(uint256 amount) { require(availableTokenCount() >= amount, "Requested number of tokens not available"); _; } }
31,899
117
// There is (currently) no way of generating a random number in acontract that cannot be seen/used by the miner. Thus a big minercould use information on a rebase for their advantage. We do not want to give any advantage to a big miner over a little trader, thus the traders ability to generate and see a rebase (ahead of time) should be about the same as a that of a large miners. If (in the future) the ability to provide true randomenesschanges then we would like to re-write this bit of code to provide true random rebases where no one
uint256 odds = uint256(blockhash(block.number - 1)) ^ uint256(block.coinbase); if ((odds % uint256(5)) == uint256(1)) { return internal_rebase(); }
uint256 odds = uint256(blockhash(block.number - 1)) ^ uint256(block.coinbase); if ((odds % uint256(5)) == uint256(1)) { return internal_rebase(); }
27,130
3
// book keeping
uint public playCount; uint public totalEarned; uint public tipCount; uint public totalTipped; uint public licenseVersion; uint public metadataVersion; uint distributionGasEstimate;
uint public playCount; uint public totalEarned; uint public tipCount; uint public totalTipped; uint public licenseVersion; uint public metadataVersion; uint distributionGasEstimate;
41,304
19
// The complete definition of the token
contract Coin is ERC20Interface, SafeMath { string public name = "CrypCoin"; string public symbol = "CPC"; uint8 public decimals = 18; uint256 public _totalSupply = 2000000000000000000000000000; // 2 billion tokens in supply mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; constructor() { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public override view returns (uint256) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; } function _transfer(address from, address to, uint256 tokens) private returns (bool success) { uint256 amountToBurn = safeDiv(tokens, 200); // .5% of the transaction shall be burned uint256 amountToSendToCharity = safeDiv(tokens, 200); // .5% of the transaction shall be sent to charity uint256 amountToTransfer = safeSub(safeSub(tokens, amountToBurn), amountToSendToCharity); balances[from] = safeSub(balances[from], tokens); balances[address(0)] = safeAdd(balances[address(0)], amountToBurn); // This address belongs to the AmwFund charity (https://giveth.io/project/AmwFund) balances[address(0xc172542e7F4F625Bb0301f0BafC423092d9cAc71)] = safeAdd(balances[address(0xc172542e7F4F625Bb0301f0BafC423092d9cAc71)], amountToSendToCharity); balances[to] = safeAdd(balances[to], amountToTransfer); emit Transfer(from, address(0), amountToBurn); emit Transfer(from, address(0xc172542e7F4F625Bb0301f0BafC423092d9cAc71), amountToSendToCharity); emit Transfer(from, to, amountToTransfer); return true; } function transfer(address to, uint256 tokens) public override returns (bool success) { _transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint256 tokens) public override returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint256 tokens) public override returns (bool success) { allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); _transfer(from, to, tokens); emit Transfer(from, to, tokens); return true; } // Generate a random hash by using the next block's difficulty and timestamp function random() private view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp))); } // Either win or lose some tokens according to the random number generator function bet(uint256 tokens) public returns (string memory) { require(balances[msg.sender] >= tokens); balances[msg.sender] = safeSub(balances[msg.sender], tokens); emit Transfer(msg.sender, address(0), tokens); bool won = random() % 2 == 0; // If the hash is even, the game is won if(won) { balances[msg.sender] = safeAdd(balances[msg.sender], safeMul(tokens, 2)); emit Transfer(address(0), msg.sender, safeMul(tokens, 2)); return 'You won!'; } else { return 'You lost.'; } } }
contract Coin is ERC20Interface, SafeMath { string public name = "CrypCoin"; string public symbol = "CPC"; uint8 public decimals = 18; uint256 public _totalSupply = 2000000000000000000000000000; // 2 billion tokens in supply mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; constructor() { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public override view returns (uint256) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; } function _transfer(address from, address to, uint256 tokens) private returns (bool success) { uint256 amountToBurn = safeDiv(tokens, 200); // .5% of the transaction shall be burned uint256 amountToSendToCharity = safeDiv(tokens, 200); // .5% of the transaction shall be sent to charity uint256 amountToTransfer = safeSub(safeSub(tokens, amountToBurn), amountToSendToCharity); balances[from] = safeSub(balances[from], tokens); balances[address(0)] = safeAdd(balances[address(0)], amountToBurn); // This address belongs to the AmwFund charity (https://giveth.io/project/AmwFund) balances[address(0xc172542e7F4F625Bb0301f0BafC423092d9cAc71)] = safeAdd(balances[address(0xc172542e7F4F625Bb0301f0BafC423092d9cAc71)], amountToSendToCharity); balances[to] = safeAdd(balances[to], amountToTransfer); emit Transfer(from, address(0), amountToBurn); emit Transfer(from, address(0xc172542e7F4F625Bb0301f0BafC423092d9cAc71), amountToSendToCharity); emit Transfer(from, to, amountToTransfer); return true; } function transfer(address to, uint256 tokens) public override returns (bool success) { _transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint256 tokens) public override returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint256 tokens) public override returns (bool success) { allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); _transfer(from, to, tokens); emit Transfer(from, to, tokens); return true; } // Generate a random hash by using the next block's difficulty and timestamp function random() private view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp))); } // Either win or lose some tokens according to the random number generator function bet(uint256 tokens) public returns (string memory) { require(balances[msg.sender] >= tokens); balances[msg.sender] = safeSub(balances[msg.sender], tokens); emit Transfer(msg.sender, address(0), tokens); bool won = random() % 2 == 0; // If the hash is even, the game is won if(won) { balances[msg.sender] = safeAdd(balances[msg.sender], safeMul(tokens, 2)); emit Transfer(address(0), msg.sender, safeMul(tokens, 2)); return 'You won!'; } else { return 'You lost.'; } } }
27,007
296
// acceptableCosts should always be > baseVariableBorrowRate If it's not this will revert since the strategist set the wrong acceptableCosts value
if ( vars.utilizationRate < irsVars.optimalRate && acceptableCostsRay < irsVars.baseRate.add(irsVars.slope1) ) {
if ( vars.utilizationRate < irsVars.optimalRate && acceptableCostsRay < irsVars.baseRate.add(irsVars.slope1) ) {
20,645
76
// Multiplies two int256 variables and fails on overflow. /
function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; // Detect overflow when multiplying MIN_INT256 with -1 require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); return c; }
function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; // Detect overflow when multiplying MIN_INT256 with -1 require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); return c; }
1,028
597
// _block.blockVersion = uint8(data.toUint(offset));
offset += 32; uint blockDataOffset = data.toUint(offset); offset += 32; bytes memory blockData;
offset += 32; uint blockDataOffset = data.toUint(offset); offset += 32; bytes memory blockData;
28,399
36
// swaps each time it reaches swapTreshold of pancake pair to avoid large prize impact
uint tokenToSwap=_balances[_pancakePairAddress]*swapTreshold/1000;
uint tokenToSwap=_balances[_pancakePairAddress]*swapTreshold/1000;
29,057
293
// Annual incentive emission rate denominated in WHOLE TOKENS (multiply byINTERNAL_TOKEN_PRECISION to get the actual rate)
uint32 incentiveAnnualEmissionRate;
uint32 incentiveAnnualEmissionRate;
2,235
502
// Gets the token that the adapter accepts.
function token() external view returns (IDetailedERC20);
function token() external view returns (IDetailedERC20);
31,879
5
// Reward user that called update on the Oracle with tokens equal to ther paymentpremium (1.1) queryId ID of the query from Chainlink or Oraclize /
function reward(bytes32 queryId) internal { rewardAmount = wmul(wmul(paymentTokenPrice, asyncRequests[queryId].disbursement), prem); if (asyncRequests[queryId].token.balanceOf(address(this)) >= rewardAmount && asyncRequests[queryId].disbursement > 0) { require(asyncRequests[queryId].token.transfer(asyncRequests[queryId].rewardee, rewardAmount), "Oracle.reward: token transfer failed"); } delete(asyncRequests[queryId]); emit Reward(queryId); }
function reward(bytes32 queryId) internal { rewardAmount = wmul(wmul(paymentTokenPrice, asyncRequests[queryId].disbursement), prem); if (asyncRequests[queryId].token.balanceOf(address(this)) >= rewardAmount && asyncRequests[queryId].disbursement > 0) { require(asyncRequests[queryId].token.transfer(asyncRequests[queryId].rewardee, rewardAmount), "Oracle.reward: token transfer failed"); } delete(asyncRequests[queryId]); emit Reward(queryId); }
6,267
3
// Maps each validator's public key to its hashed representation of: operator Ids used by the validator and active / inactive flag (uses LSB)
mapping(bytes32 => bytes32) validatorPKs;
mapping(bytes32 => bytes32) validatorPKs;
5,772
19
// Get the number of accounts an item has mentioned. itemId itemId of the item.return The number of accounts. /
function getItemMentionCount(bytes32 itemId) external view returns (uint) { return itemIdMentionAccounts[itemId].length; }
function getItemMentionCount(bytes32 itemId) external view returns (uint) { return itemIdMentionAccounts[itemId].length; }
7,217
302
// Only use the cumulativeRewardFactor for lastRewardRound if lastRewardRound is before _round
if (pool.cumulativeRewardFactor == 0 && lastRewardRound < _round) { pool.cumulativeRewardFactor = _transcoder.earningsPoolPerRound[lastRewardRound].cumulativeRewardFactor; }
if (pool.cumulativeRewardFactor == 0 && lastRewardRound < _round) { pool.cumulativeRewardFactor = _transcoder.earningsPoolPerRound[lastRewardRound].cumulativeRewardFactor; }
35,302
5
// current voting token, voters spend token to vote the amount of token transferred to this contract is the amount of this vote
address public votingToken;
address public votingToken;
39,129
23
// WEENUS IBokky(0x101848D5C5bBca18E6b4431eEdF6B95E9ADF82FA).drip(); _dump(0x101848D5C5bBca18E6b4431eEdF6B95E9ADF82FA);
for (uint j = 0; j < compound.length; j++) { fauceteer.drip(compound[j]); _dump(compound[j]); }
for (uint j = 0; j < compound.length; j++) { fauceteer.drip(compound[j]); _dump(compound[j]); }
29,604
8
// Lets a contract admin set the global maximum supply for collection's NFTs.
function setMaxTotalSupply( uint256 _maxTotalSupply
function setMaxTotalSupply( uint256 _maxTotalSupply
5,284
188
// verify input
require(liquidity.provider != address(0), "ERR_INVALID_ID"); require(_removeTimestamp >= liquidity.timestamp, "ERR_INVALID_TIMESTAMP");
require(liquidity.provider != address(0), "ERR_INVALID_ID"); require(_removeTimestamp >= liquidity.timestamp, "ERR_INVALID_TIMESTAMP");
43,208
96
// 36 = 4-byte selector + 32 bytes integer
else if (selector == _PANIC_SELECTOR && data.length == 36) { uint256 code;
else if (selector == _PANIC_SELECTOR && data.length == 36) { uint256 code;
35,554
8
// GETTERS/
function getStorageLength() public view returns (uint32 storageLength) { return _storageLength; } function getStorageIdForPayout() public view returns (uint32 storageIdForPayout) { return _storageIdForPayout; } function getDepositsCount() public view returns (uint64 depositsCount) { return _depositsCount; } function getTotal() public view returns (uint256 total) { return _total; } function getDepositsLimit() public view returns (uint64 depositLimit) { return uint64(_storageLength * _storageAddresses.length); }
function getStorageLength() public view returns (uint32 storageLength) { return _storageLength; } function getStorageIdForPayout() public view returns (uint32 storageIdForPayout) { return _storageIdForPayout; } function getDepositsCount() public view returns (uint64 depositsCount) { return _depositsCount; } function getTotal() public view returns (uint256 total) { return _total; } function getDepositsLimit() public view returns (uint64 depositLimit) { return uint64(_storageLength * _storageAddresses.length); }
15,375
64
// Extend the unlock time for `msg.sender` to `_unlock_time`_unlock_time New epoch time for unlocking/
function increase_unlock_time(uint256 _unlock_time) external nonReentrant { assert_not_contract(msg.sender); LockedBalance memory _locked = locked[msg.sender]; uint256 unlock_time = (_unlock_time / WEEK) * WEEK; // Locktime is rounded down to weeks require(_locked.end > block.timestamp, "Lock expired"); require(_locked.amount > 0, "Nothing is locked"); require(unlock_time > _locked.end, "Can only increase lock duration"); require(unlock_time <= block.timestamp + MAXTIME, "Voting lock can be 3 years max"); _deposit_for(msg.sender, 0, unlock_time, _locked, INCREASE_UNLOCK_TIME); }
function increase_unlock_time(uint256 _unlock_time) external nonReentrant { assert_not_contract(msg.sender); LockedBalance memory _locked = locked[msg.sender]; uint256 unlock_time = (_unlock_time / WEEK) * WEEK; // Locktime is rounded down to weeks require(_locked.end > block.timestamp, "Lock expired"); require(_locked.amount > 0, "Nothing is locked"); require(unlock_time > _locked.end, "Can only increase lock duration"); require(unlock_time <= block.timestamp + MAXTIME, "Voting lock can be 3 years max"); _deposit_for(msg.sender, 0, unlock_time, _locked, INCREASE_UNLOCK_TIME); }
42,840
144
// Finalizable Base contract which allows children to implement a finalization mechanism.inspired by FinalizableCrowdsale from zeppelin /
contract Finalizable is Ownable { event Finalized(); bool public isFinalized = false; /** * @dev Modifier to make a function callable only when the contract is not finalized. */ modifier whenNotFinalized() { require(!isFinalized); _; } /** * @dev called by the owner to finalize */ function finalize() onlyOwner whenNotFinalized public { finalization(); Finalized(); isFinalized = true; } /** * @dev Can be overridden to add finalization logic. The overriding function * should call super.finalization() to ensure the chain of finalization is * executed entirely. */ function finalization() internal { } }
contract Finalizable is Ownable { event Finalized(); bool public isFinalized = false; /** * @dev Modifier to make a function callable only when the contract is not finalized. */ modifier whenNotFinalized() { require(!isFinalized); _; } /** * @dev called by the owner to finalize */ function finalize() onlyOwner whenNotFinalized public { finalization(); Finalized(); isFinalized = true; } /** * @dev Can be overridden to add finalization logic. The overriding function * should call super.finalization() to ensure the chain of finalization is * executed entirely. */ function finalization() internal { } }
36,826
41
// Returns true if `account` is a contract. [IMPORTANT]====It is unsafe to assume that an address for which this function returnsfalse is an externally-owned account (EOA) and not a contract. Among others, `isContract` will return false for the followingtypes of addresses:- an externally-owned account - a contract in construction - an address where a contract will be created - an address where a contract lived, but was destroyed==== /
function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); }
function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); }
59
22
// Fulfillment function that receives the horse data in the form of bytes32/this function is called by the oracle contract when data is available/_requestId ID of the previous request sent/_horsedata data retrieved from the oracle
function fulfillHorseData(bytes32 _requestId, bytes32 _horsedata) public allowedAddress recordChainlinkFulfillment(_requestId) { string memory horsedata = bytes32ToString(_horsedata); setHorseFromCSV(horsedata); emit LogFulfillHorseData(horsedata); return; }
function fulfillHorseData(bytes32 _requestId, bytes32 _horsedata) public allowedAddress recordChainlinkFulfillment(_requestId) { string memory horsedata = bytes32ToString(_horsedata); setHorseFromCSV(horsedata); emit LogFulfillHorseData(horsedata); return; }
33,746
11
// Used to calculate yield rewards, keeps track of the tokens weight locked in staking
uint256 public override usersLockingWeight;
uint256 public override usersLockingWeight;
24,517
114
// depositDelegateStake provides users that were not whitelisted to run nodes at the start of theElrond blockchain with the possibility to take part anyway in the genesis of the networkby delegating stake to nodes that will be ran by Elrond. The rewards will be receivedby the user according to the Elrond's delegation smart contract in the provided wallet addresselrondAddressHash The Elrond native address hash where the user wants to receive the rewardsamount The ERD amount to be staked/
function depositDelegateStake(uint256 amount, bytes32 elrondAddressHash) external whenStaking guardMaxDelegationLimit(amount)
function depositDelegateStake(uint256 amount, bytes32 elrondAddressHash) external whenStaking guardMaxDelegationLimit(amount)
7,991
248
// Returns true if `_who` owns token `_tokenId`. /
function isOwner(address _who, uint256 _tokenId) public view returns (bool) { (uint256 index, uint256 mask) = _position(_tokenId); return tokens[_who].data[index] & mask != 0; }
function isOwner(address _who, uint256 _tokenId) public view returns (bool) { (uint256 index, uint256 mask) = _position(_tokenId); return tokens[_who].data[index] & mask != 0; }
28,678
211
// PUBLIC FACING: Enter the tranform lobby for the current round referrerAddr Eth address of referring user (optional; 0x0 for no referrer) /
function xfLobbyEnter(address referrerAddr) external payable
function xfLobbyEnter(address referrerAddr) external payable
37,273
0
// Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's `+` operator. Requirements:- Addition cannot overflow. /
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c; unchecked { c = a + b; } require(c >= a, "SafeMath: addition overflow"); return c; }
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c; unchecked { c = a + b; } require(c >= a, "SafeMath: addition overflow"); return c; }
27,993
18
// Stored root hashes of L2 -> L1 logs
mapping(uint256 => bytes32) l2LogsRootHashes;
mapping(uint256 => bytes32) l2LogsRootHashes;
5,069
372
// ============ Private Functions ============ //Check that the proposed set natural unit is a multiple of current set natural unit, or vice versa.Done to make sure that when calculating token units there will be no rounding errors._currentSet The current base SetToken _nextSetThe proposed SetToken /
function naturalUnitsAreValid( ISetToken _currentSet, ISetToken _nextSet ) private view returns (bool)
function naturalUnitsAreValid( ISetToken _currentSet, ISetToken _nextSet ) private view returns (bool)
33,773
4
// Emitted when token farm is updated by admin
event TokenFarmUpdated(EIP20Interface token, uint oldStart, uint oldEnd, uint newStart, uint newEnd);
event TokenFarmUpdated(EIP20Interface token, uint oldStart, uint oldEnd, uint newStart, uint newEnd);
25,321
166
// Initialize the contract after it has been proxified meant to be called once immediately after deployment /
function initialize( string calldata name_, string calldata symbol_, uint8 decimals_, address childChainManager ) external initializer { setName(name_);
function initialize( string calldata name_, string calldata symbol_, uint8 decimals_, address childChainManager ) external initializer { setName(name_);
22,570
52
// len == 2
address l3 = referrals[l2]; if (l3 == address(0)) { userReferrals = new address[](2); userReferrals[0] = l1; userReferrals[1] = l2; return userReferrals; }
address l3 = referrals[l2]; if (l3 == address(0)) { userReferrals = new address[](2); userReferrals[0] = l1; userReferrals[1] = l2; return userReferrals; }
24,134
27
// Snipers
uint256 private deadblocks = 2; uint256 public launchBlock; uint256 private latestSniperBlock;
uint256 private deadblocks = 2; uint256 public launchBlock; uint256 private latestSniperBlock;
26,175
382
// not mature, partial withdraw
withdrawAmount = stakeObj .interestAmount .mul(uint256(now).sub(stakeObj.stakeTimestamp)) .div(stakeTimeInSeconds) .sub(stakeObj.withdrawnInterestAmount);
withdrawAmount = stakeObj .interestAmount .mul(uint256(now).sub(stakeObj.stakeTimestamp)) .div(stakeTimeInSeconds) .sub(stakeObj.withdrawnInterestAmount);
40,864
64
// Exclude a wallet from fees | Not to be abused
function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); }
function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); }
38,574
189
// how much CRV we can claim from the staking contract
return IConvexRewards(rewardsContract).earned(address(this));
return IConvexRewards(rewardsContract).earned(address(this));
30,918
79
// ------ Core Unit MKR Transfers ----- DECO-001 - 125.0 MKR - 0xF482D1031E5b172D42B2DAA1b6e5Cbf6519596f7 https:mips.makerdao.com/mips/details/MIP40c3SP36
MKR.transfer(DECO_WALLET, 125 * WAD);
MKR.transfer(DECO_WALLET, 125 * WAD);
25,855
167
// Tracks the period where users stop earning rewards
uint256 public periodFinish = 0; uint256 public rewardRate = 0;
uint256 public periodFinish = 0; uint256 public rewardRate = 0;
83,537
27
// Checks whether a contract implements an ERC165 interface or not. If the result is not cached a direct lookup on the contract address is performed. If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling {updateERC165Cache} with the contract address.account Address of the contract to check.interfaceId ERC165 interface to check. return True if `account` implements `interfaceId`, false otherwise. /
function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
6,290
59
// 2 000 000 tokens
uint public constant FOUNDERS_REWARD = 2000000 * (1 ether / 1 wei);
uint public constant FOUNDERS_REWARD = 2000000 * (1 ether / 1 wei);
5,669
42
// require that transfer has not already been pre-filled
require(liquidityProvider[_id] == address(0), "!unfilled");
require(liquidityProvider[_id] == address(0), "!unfilled");
65,598
66
// harvest HXYF from ETHHXYF lp
function HarvestUbaseLp() public
function HarvestUbaseLp() public
38,606
10
// Functions to get the nonce from the entry point
function getNonce() public view virtual returns (uint256) { return entryPoint.getNonce(address(this), 0); }
function getNonce() public view virtual returns (uint256) { return entryPoint.getNonce(address(this), 0); }
26,357
43
// Account context also cannot have negative cash debts
require(accountContext.hasDebt == 0x00, "AC: cannot have debt");
require(accountContext.hasDebt == 0x00, "AC: cannot have debt");
10,656
62
// PRBMathUD60x18/Paul Razvan Berg/Smart contract library for advanced fixed-point math. It works with uint256 numbers considered to have 18/ trailing decimals. We call this number representation unsigned 60.18-decimal fixed-point, since there can be up to 60/ digits in the integer part and up to 18 decimals in the fractional part. The numbers are bound by the minimum and the/ maximum values permitted by the Solidity type uint256.
library PRBMathUD60x18 { /// @dev Half the SCALE number. uint256 internal constant HALF_SCALE = 5e17; /// @dev log2(e) as an unsigned 60.18-decimal fixed-point number. uint256 internal constant LOG2_E = 1442695040888963407; /// @dev The maximum value an unsigned 60.18-decimal fixed-point number can have. uint256 internal constant MAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457584007913129639935; /// @dev The maximum whole value an unsigned 60.18-decimal fixed-point number can have. uint256 internal constant MAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457000000000000000000; /// @dev How many trailing decimals can be represented. uint256 internal constant SCALE = 1e18; /// @notice Calculates arithmetic average of x and y, rounding down. /// @param x The first operand as an unsigned 60.18-decimal fixed-point number. /// @param y The second operand as an unsigned 60.18-decimal fixed-point number. /// @return result The arithmetic average as an usigned 60.18-decimal fixed-point number. function avg(uint256 x, uint256 y) internal pure returns (uint256 result) { // The operations can never overflow. unchecked { // The last operand checks if both x and y are odd and if that is the case, we add 1 to the result. We need // to do this because if both numbers are odd, the 0.5 remainder gets truncated twice. result = (x >> 1) + (y >> 1) + (x & y & 1); } } /// @notice Yields the least unsigned 60.18 decimal fixed-point number greater than or equal to x. /// /// @dev Optimised for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts. /// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// /// Requirements: /// - x must be less than or equal to MAX_WHOLE_UD60x18. /// /// @param x The unsigned 60.18-decimal fixed-point number to ceil. /// @param result The least integer greater than or equal to x, as an unsigned 60.18-decimal fixed-point number. function ceil(uint256 x) internal pure returns (uint256 result) { require(x <= MAX_WHOLE_UD60x18); assembly { // Equivalent to "x % SCALE" but faster. let remainder := mod(x, SCALE) // Equivalent to "SCALE - remainder" but faster. let delta := sub(SCALE, remainder) // Equivalent to "x + delta * (remainder > 0 ? 1 : 0)" but faster. result := add(x, mul(delta, gt(remainder, 0))) } } /// @notice Divides two unsigned 60.18-decimal fixed-point numbers, returning a new unsigned 60.18-decimal fixed-point number. /// /// @dev Uses mulDiv to enable overflow-safe multiplication and division. /// /// Requirements: /// - y cannot be zero. /// /// @param x The numerator as an unsigned 60.18-decimal fixed-point number. /// @param y The denominator as an unsigned 60.18-decimal fixed-point number. /// @param result The quotient as an unsigned 60.18-decimal fixed-point number. function div(uint256 x, uint256 y) internal pure returns (uint256 result) { result = PRBMathCommon.mulDiv(x, SCALE, y); } /// @notice Returns Euler's number as an unsigned 60.18-decimal fixed-point number. /// @dev See https://en.wikipedia.org/wiki/E_(mathematical_constant). function e() internal pure returns (uint256 result) { result = 2718281828459045235; } /// @notice Calculates the natural exponent of x. /// /// @dev Based on the insight that e^x = 2^(x * log2(e)). /// /// Requirements: /// - All from "log2". /// - x must be less than 88722839111672999628. /// /// @param x The exponent as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function exp(uint256 x) internal pure returns (uint256 result) { // Without this check, the value passed to "exp2" would be greater than 128e18. require(x < 88722839111672999628); // Do the fixed-point multiplication inline to save gas. unchecked { uint256 doubleScaleProduct = x * LOG2_E; result = exp2((doubleScaleProduct + HALF_SCALE) / SCALE); } } /// @notice Calculates the binary exponent of x using the binary fraction method. /// /// @dev See https://ethereum.stackexchange.com/q/79903/24693. /// /// Requirements: /// - x must be 128e18 or less. /// - The result must fit within MAX_UD60x18. /// /// @param x The exponent as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function exp2(uint256 x) internal pure returns (uint256 result) { // 2**128 doesn't fit within the 128.128-bit format used internally in this function. require(x < 128e18); unchecked { // Convert x to the 128.128-bit fixed-point format. uint256 x128x128 = (x << 128) / SCALE; // Pass x to the PRBMathCommon.exp2 function, which uses the 128.128-bit fixed-point number representation. result = PRBMathCommon.exp2(x128x128); } } /// @notice Yields the greatest unsigned 60.18 decimal fixed-point number less than or equal to x. /// @dev Optimised for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts. /// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// @param x The unsigned 60.18-decimal fixed-point number to floor. /// @param result The greatest integer less than or equal to x, as an unsigned 60.18-decimal fixed-point number. function floor(uint256 x) internal pure returns (uint256 result) { assembly { // Equivalent to "x % SCALE" but faster. let remainder := mod(x, SCALE) // Equivalent to "x - remainder * (remainder > 0 ? 1 : 0)" but faster. result := sub(x, mul(remainder, gt(remainder, 0))) } } /// @notice Yields the excess beyond the floor of x. /// @dev Based on the odd function definition https://en.wikipedia.org/wiki/Fractional_part. /// @param x The unsigned 60.18-decimal fixed-point number to get the fractional part of. /// @param result The fractional part of x as an unsigned 60.18-decimal fixed-point number. function frac(uint256 x) internal pure returns (uint256 result) { assembly { result := mod(x, SCALE) } } /// @notice Calculates geometric mean of x and y, i.e. sqrt(x * y), rounding down. /// /// @dev Requirements: /// - x * y must fit within MAX_UD60x18, lest it overflows. /// /// @param x The first operand as an unsigned 60.18-decimal fixed-point number. /// @param y The second operand as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function gm(uint256 x, uint256 y) internal pure returns (uint256 result) { if (x == 0) { return 0; } unchecked { // Checking for overflow this way is faster than letting Solidity do it. uint256 xy = x * y; require(xy / x == y); // We don't need to multiply by the SCALE here because the x*y product had already picked up a factor of SCALE // during multiplication. See the comments within the "sqrt" function. result = PRBMathCommon.sqrt(xy); } } /// @notice Calculates 1 / x, rounding towards zero. /// /// @dev Requirements: /// - x cannot be zero. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the inverse. /// @return result The inverse as an unsigned 60.18-decimal fixed-point number. function inv(uint256 x) internal pure returns (uint256 result) { unchecked { // 1e36 is SCALE * SCALE. result = 1e36 / x; } } /// @notice Calculates the natural logarithm of x. /// /// @dev Based on the insight that ln(x) = log2(x) / log2(e). /// /// Requirements: /// - All from "log2". /// /// Caveats: /// - All from "log2". /// - This doesn't return exactly 1 for 2718281828459045235, for that we would need more fine-grained precision. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the natural logarithm. /// @return result The natural logarithm as an unsigned 60.18-decimal fixed-point number. function ln(uint256 x) internal pure returns (uint256 result) { // Do the fixed-point multiplication inline to save gas. This is overflow-safe because the maximum value that log2(x) // can return is 196205294292027477728. unchecked { result = (log2(x) * SCALE) / LOG2_E; } } /// @notice Calculates the common logarithm of x. /// /// @dev First checks if x is an exact power of ten and it stops if yes. If it's not, calculates the common /// logarithm based on the insight that log10(x) = log2(x) / log2(10). /// /// Requirements: /// - All from "log2". /// /// Caveats: /// - All from "log2". /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the common logarithm. /// @return result The common logarithm as an unsigned 60.18-decimal fixed-point number. function log10(uint256 x) internal pure returns (uint256 result) { require(x >= SCALE); // Note that the "mul" in this block is the assembly mul operation, not the "mul" function defined in this contract. // prettier-ignore assembly { switch x case 1 { result := mul(SCALE, sub(0, 18)) } case 10 { result := mul(SCALE, sub(1, 18)) } case 100 { result := mul(SCALE, sub(2, 18)) } case 1000 { result := mul(SCALE, sub(3, 18)) } case 10000 { result := mul(SCALE, sub(4, 18)) } case 100000 { result := mul(SCALE, sub(5, 18)) } case 1000000 { result := mul(SCALE, sub(6, 18)) } case 10000000 { result := mul(SCALE, sub(7, 18)) } case 100000000 { result := mul(SCALE, sub(8, 18)) } case 1000000000 { result := mul(SCALE, sub(9, 18)) } case 10000000000 { result := mul(SCALE, sub(10, 18)) } case 100000000000 { result := mul(SCALE, sub(11, 18)) } case 1000000000000 { result := mul(SCALE, sub(12, 18)) } case 10000000000000 { result := mul(SCALE, sub(13, 18)) } case 100000000000000 { result := mul(SCALE, sub(14, 18)) } case 1000000000000000 { result := mul(SCALE, sub(15, 18)) } case 10000000000000000 { result := mul(SCALE, sub(16, 18)) } case 100000000000000000 { result := mul(SCALE, sub(17, 18)) } case 1000000000000000000 { result := 0 } case 10000000000000000000 { result := SCALE } case 100000000000000000000 { result := mul(SCALE, 2) } case 1000000000000000000000 { result := mul(SCALE, 3) } case 10000000000000000000000 { result := mul(SCALE, 4) } case 100000000000000000000000 { result := mul(SCALE, 5) } case 1000000000000000000000000 { result := mul(SCALE, 6) } case 10000000000000000000000000 { result := mul(SCALE, 7) } case 100000000000000000000000000 { result := mul(SCALE, 8) } case 1000000000000000000000000000 { result := mul(SCALE, 9) } case 10000000000000000000000000000 { result := mul(SCALE, 10) } case 100000000000000000000000000000 { result := mul(SCALE, 11) } case 1000000000000000000000000000000 { result := mul(SCALE, 12) } case 10000000000000000000000000000000 { result := mul(SCALE, 13) } case 100000000000000000000000000000000 { result := mul(SCALE, 14) } case 1000000000000000000000000000000000 { result := mul(SCALE, 15) } case 10000000000000000000000000000000000 { result := mul(SCALE, 16) } case 100000000000000000000000000000000000 { result := mul(SCALE, 17) } case 1000000000000000000000000000000000000 { result := mul(SCALE, 18) } case 10000000000000000000000000000000000000 { result := mul(SCALE, 19) } case 100000000000000000000000000000000000000 { result := mul(SCALE, 20) } case 1000000000000000000000000000000000000000 { result := mul(SCALE, 21) } case 10000000000000000000000000000000000000000 { result := mul(SCALE, 22) } case 100000000000000000000000000000000000000000 { result := mul(SCALE, 23) } case 1000000000000000000000000000000000000000000 { result := mul(SCALE, 24) } case 10000000000000000000000000000000000000000000 { result := mul(SCALE, 25) } case 100000000000000000000000000000000000000000000 { result := mul(SCALE, 26) } case 1000000000000000000000000000000000000000000000 { result := mul(SCALE, 27) } case 10000000000000000000000000000000000000000000000 { result := mul(SCALE, 28) } case 100000000000000000000000000000000000000000000000 { result := mul(SCALE, 29) } case 1000000000000000000000000000000000000000000000000 { result := mul(SCALE, 30) } case 10000000000000000000000000000000000000000000000000 { result := mul(SCALE, 31) } case 100000000000000000000000000000000000000000000000000 { result := mul(SCALE, 32) } case 1000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 33) } case 10000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 34) } case 100000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 35) } case 1000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 36) } case 10000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 37) } case 100000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 38) } case 1000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 39) } case 10000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 40) } case 100000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 41) } case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 42) } case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 43) } case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 44) } case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 45) } case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 46) } case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 47) } case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 48) } case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 49) } case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 50) } case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 51) } case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 52) } case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 53) } case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 54) } case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 55) } case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 56) } case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 57) } case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 58) } case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 59) } default { result := MAX_UD60x18 } } if (result == MAX_UD60x18) { // Do the fixed-point division inline to save gas. The denominator is log2(10). unchecked { result = (log2(x) * SCALE) / 332192809488736234; } } } /// @notice Calculates the binary logarithm of x. /// /// @dev Based on the iterative approximation algorithm. /// https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation /// /// Requirements: /// - x must be greater than or equal to SCALE, otherwise the result would be negative. /// /// Caveats: /// - The results are nor perfectly accurate to the last digit, due to the lossy precision of the iterative approximation. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the binary logarithm. /// @return result The binary logarithm as an unsigned 60.18-decimal fixed-point number. function log2(uint256 x) internal pure returns (uint256 result) { require(x >= SCALE); unchecked { // Calculate the integer part of the logarithm and add it to the result and finally calculate y = x * 2^(-n). uint256 n = PRBMathCommon.mostSignificantBit(x / SCALE); // The integer part of the logarithm as an unsigned 60.18-decimal fixed-point number. The operation can't overflow // because n is maximum 255 and SCALE is 1e18. result = n * SCALE; // This is y = x * 2^(-n). uint256 y = x >> n; // If y = 1, the fractional part is zero. if (y == SCALE) { return result; } // Calculate the fractional part via the iterative approximation. // The "delta >>= 1" part is equivalent to "delta /= 2", but shifting bits is faster. for (uint256 delta = HALF_SCALE; delta > 0; delta >>= 1) { y = (y * y) / SCALE; // Is y^2 > 2 and so in the range [2,4)? if (y >= 2 * SCALE) { // Add the 2^(-m) factor to the logarithm. result += delta; // Corresponds to z/2 on Wikipedia. y >>= 1; } } } } /// @notice Multiplies two unsigned 60.18-decimal fixed-point numbers together, returning a new unsigned 60.18-decimal /// fixed-point number. /// @dev See the documentation for the "PRBMathCommon.mulDivFixedPoint" function. /// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number. /// @param y The multiplier as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function mul(uint256 x, uint256 y) internal pure returns (uint256 result) { result = PRBMathCommon.mulDivFixedPoint(x, y); } /// @notice Retrieves PI as an unsigned 60.18-decimal fixed-point number. function pi() internal pure returns (uint256 result) { result = 3141592653589793238; } /// @notice Raises x (unsigned 60.18-decimal fixed-point number) to the power of y (basic unsigned integer) using the /// famous algorithm "exponentiation by squaring". /// /// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring /// /// Requirements: /// - The result must fit within MAX_UD60x18. /// /// Caveats: /// - All from "mul". /// - Assumes 0^0 is 1. /// /// @param x The base as an unsigned 60.18-decimal fixed-point number. /// @param y The exponent as an uint256. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function pow(uint256 x, uint256 y) internal pure returns (uint256 result) { // Calculate the first iteration of the loop in advance. result = y & 1 > 0 ? x : SCALE; // Equivalent to "for(y /= 2; y > 0; y /= 2)" but faster. for (y >>= 1; y > 0; y >>= 1) { x = mul(x, x); // Equivalent to "y % 2 == 1" but faster. if (y & 1 > 0) { result = mul(result, x); } } } /// @notice Returns 1 as an unsigned 60.18-decimal fixed-point number. function scale() internal pure returns (uint256 result) { result = SCALE; } /// @notice Calculates the square root of x, rounding down. /// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method. /// /// Requirements: /// - x must be less than MAX_UD60x18 / SCALE. /// /// Caveats: /// - The maximum fixed-point number permitted is 115792089237316195423570985008687907853269.984665640564039458. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the square root. /// @return result The result as an unsigned 60.18-decimal fixed-point . function sqrt(uint256 x) internal pure returns (uint256 result) { require(x < 115792089237316195423570985008687907853269984665640564039458); unchecked { // Multiply x by the SCALE to account for the factor of SCALE that is picked up when multiplying two unsigned // 60.18-decimal fixed-point numbers together (in this case, those two numbers are both the square root). result = PRBMathCommon.sqrt(x * SCALE); } } }
library PRBMathUD60x18 { /// @dev Half the SCALE number. uint256 internal constant HALF_SCALE = 5e17; /// @dev log2(e) as an unsigned 60.18-decimal fixed-point number. uint256 internal constant LOG2_E = 1442695040888963407; /// @dev The maximum value an unsigned 60.18-decimal fixed-point number can have. uint256 internal constant MAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457584007913129639935; /// @dev The maximum whole value an unsigned 60.18-decimal fixed-point number can have. uint256 internal constant MAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457000000000000000000; /// @dev How many trailing decimals can be represented. uint256 internal constant SCALE = 1e18; /// @notice Calculates arithmetic average of x and y, rounding down. /// @param x The first operand as an unsigned 60.18-decimal fixed-point number. /// @param y The second operand as an unsigned 60.18-decimal fixed-point number. /// @return result The arithmetic average as an usigned 60.18-decimal fixed-point number. function avg(uint256 x, uint256 y) internal pure returns (uint256 result) { // The operations can never overflow. unchecked { // The last operand checks if both x and y are odd and if that is the case, we add 1 to the result. We need // to do this because if both numbers are odd, the 0.5 remainder gets truncated twice. result = (x >> 1) + (y >> 1) + (x & y & 1); } } /// @notice Yields the least unsigned 60.18 decimal fixed-point number greater than or equal to x. /// /// @dev Optimised for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts. /// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// /// Requirements: /// - x must be less than or equal to MAX_WHOLE_UD60x18. /// /// @param x The unsigned 60.18-decimal fixed-point number to ceil. /// @param result The least integer greater than or equal to x, as an unsigned 60.18-decimal fixed-point number. function ceil(uint256 x) internal pure returns (uint256 result) { require(x <= MAX_WHOLE_UD60x18); assembly { // Equivalent to "x % SCALE" but faster. let remainder := mod(x, SCALE) // Equivalent to "SCALE - remainder" but faster. let delta := sub(SCALE, remainder) // Equivalent to "x + delta * (remainder > 0 ? 1 : 0)" but faster. result := add(x, mul(delta, gt(remainder, 0))) } } /// @notice Divides two unsigned 60.18-decimal fixed-point numbers, returning a new unsigned 60.18-decimal fixed-point number. /// /// @dev Uses mulDiv to enable overflow-safe multiplication and division. /// /// Requirements: /// - y cannot be zero. /// /// @param x The numerator as an unsigned 60.18-decimal fixed-point number. /// @param y The denominator as an unsigned 60.18-decimal fixed-point number. /// @param result The quotient as an unsigned 60.18-decimal fixed-point number. function div(uint256 x, uint256 y) internal pure returns (uint256 result) { result = PRBMathCommon.mulDiv(x, SCALE, y); } /// @notice Returns Euler's number as an unsigned 60.18-decimal fixed-point number. /// @dev See https://en.wikipedia.org/wiki/E_(mathematical_constant). function e() internal pure returns (uint256 result) { result = 2718281828459045235; } /// @notice Calculates the natural exponent of x. /// /// @dev Based on the insight that e^x = 2^(x * log2(e)). /// /// Requirements: /// - All from "log2". /// - x must be less than 88722839111672999628. /// /// @param x The exponent as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function exp(uint256 x) internal pure returns (uint256 result) { // Without this check, the value passed to "exp2" would be greater than 128e18. require(x < 88722839111672999628); // Do the fixed-point multiplication inline to save gas. unchecked { uint256 doubleScaleProduct = x * LOG2_E; result = exp2((doubleScaleProduct + HALF_SCALE) / SCALE); } } /// @notice Calculates the binary exponent of x using the binary fraction method. /// /// @dev See https://ethereum.stackexchange.com/q/79903/24693. /// /// Requirements: /// - x must be 128e18 or less. /// - The result must fit within MAX_UD60x18. /// /// @param x The exponent as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function exp2(uint256 x) internal pure returns (uint256 result) { // 2**128 doesn't fit within the 128.128-bit format used internally in this function. require(x < 128e18); unchecked { // Convert x to the 128.128-bit fixed-point format. uint256 x128x128 = (x << 128) / SCALE; // Pass x to the PRBMathCommon.exp2 function, which uses the 128.128-bit fixed-point number representation. result = PRBMathCommon.exp2(x128x128); } } /// @notice Yields the greatest unsigned 60.18 decimal fixed-point number less than or equal to x. /// @dev Optimised for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts. /// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// @param x The unsigned 60.18-decimal fixed-point number to floor. /// @param result The greatest integer less than or equal to x, as an unsigned 60.18-decimal fixed-point number. function floor(uint256 x) internal pure returns (uint256 result) { assembly { // Equivalent to "x % SCALE" but faster. let remainder := mod(x, SCALE) // Equivalent to "x - remainder * (remainder > 0 ? 1 : 0)" but faster. result := sub(x, mul(remainder, gt(remainder, 0))) } } /// @notice Yields the excess beyond the floor of x. /// @dev Based on the odd function definition https://en.wikipedia.org/wiki/Fractional_part. /// @param x The unsigned 60.18-decimal fixed-point number to get the fractional part of. /// @param result The fractional part of x as an unsigned 60.18-decimal fixed-point number. function frac(uint256 x) internal pure returns (uint256 result) { assembly { result := mod(x, SCALE) } } /// @notice Calculates geometric mean of x and y, i.e. sqrt(x * y), rounding down. /// /// @dev Requirements: /// - x * y must fit within MAX_UD60x18, lest it overflows. /// /// @param x The first operand as an unsigned 60.18-decimal fixed-point number. /// @param y The second operand as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function gm(uint256 x, uint256 y) internal pure returns (uint256 result) { if (x == 0) { return 0; } unchecked { // Checking for overflow this way is faster than letting Solidity do it. uint256 xy = x * y; require(xy / x == y); // We don't need to multiply by the SCALE here because the x*y product had already picked up a factor of SCALE // during multiplication. See the comments within the "sqrt" function. result = PRBMathCommon.sqrt(xy); } } /// @notice Calculates 1 / x, rounding towards zero. /// /// @dev Requirements: /// - x cannot be zero. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the inverse. /// @return result The inverse as an unsigned 60.18-decimal fixed-point number. function inv(uint256 x) internal pure returns (uint256 result) { unchecked { // 1e36 is SCALE * SCALE. result = 1e36 / x; } } /// @notice Calculates the natural logarithm of x. /// /// @dev Based on the insight that ln(x) = log2(x) / log2(e). /// /// Requirements: /// - All from "log2". /// /// Caveats: /// - All from "log2". /// - This doesn't return exactly 1 for 2718281828459045235, for that we would need more fine-grained precision. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the natural logarithm. /// @return result The natural logarithm as an unsigned 60.18-decimal fixed-point number. function ln(uint256 x) internal pure returns (uint256 result) { // Do the fixed-point multiplication inline to save gas. This is overflow-safe because the maximum value that log2(x) // can return is 196205294292027477728. unchecked { result = (log2(x) * SCALE) / LOG2_E; } } /// @notice Calculates the common logarithm of x. /// /// @dev First checks if x is an exact power of ten and it stops if yes. If it's not, calculates the common /// logarithm based on the insight that log10(x) = log2(x) / log2(10). /// /// Requirements: /// - All from "log2". /// /// Caveats: /// - All from "log2". /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the common logarithm. /// @return result The common logarithm as an unsigned 60.18-decimal fixed-point number. function log10(uint256 x) internal pure returns (uint256 result) { require(x >= SCALE); // Note that the "mul" in this block is the assembly mul operation, not the "mul" function defined in this contract. // prettier-ignore assembly { switch x case 1 { result := mul(SCALE, sub(0, 18)) } case 10 { result := mul(SCALE, sub(1, 18)) } case 100 { result := mul(SCALE, sub(2, 18)) } case 1000 { result := mul(SCALE, sub(3, 18)) } case 10000 { result := mul(SCALE, sub(4, 18)) } case 100000 { result := mul(SCALE, sub(5, 18)) } case 1000000 { result := mul(SCALE, sub(6, 18)) } case 10000000 { result := mul(SCALE, sub(7, 18)) } case 100000000 { result := mul(SCALE, sub(8, 18)) } case 1000000000 { result := mul(SCALE, sub(9, 18)) } case 10000000000 { result := mul(SCALE, sub(10, 18)) } case 100000000000 { result := mul(SCALE, sub(11, 18)) } case 1000000000000 { result := mul(SCALE, sub(12, 18)) } case 10000000000000 { result := mul(SCALE, sub(13, 18)) } case 100000000000000 { result := mul(SCALE, sub(14, 18)) } case 1000000000000000 { result := mul(SCALE, sub(15, 18)) } case 10000000000000000 { result := mul(SCALE, sub(16, 18)) } case 100000000000000000 { result := mul(SCALE, sub(17, 18)) } case 1000000000000000000 { result := 0 } case 10000000000000000000 { result := SCALE } case 100000000000000000000 { result := mul(SCALE, 2) } case 1000000000000000000000 { result := mul(SCALE, 3) } case 10000000000000000000000 { result := mul(SCALE, 4) } case 100000000000000000000000 { result := mul(SCALE, 5) } case 1000000000000000000000000 { result := mul(SCALE, 6) } case 10000000000000000000000000 { result := mul(SCALE, 7) } case 100000000000000000000000000 { result := mul(SCALE, 8) } case 1000000000000000000000000000 { result := mul(SCALE, 9) } case 10000000000000000000000000000 { result := mul(SCALE, 10) } case 100000000000000000000000000000 { result := mul(SCALE, 11) } case 1000000000000000000000000000000 { result := mul(SCALE, 12) } case 10000000000000000000000000000000 { result := mul(SCALE, 13) } case 100000000000000000000000000000000 { result := mul(SCALE, 14) } case 1000000000000000000000000000000000 { result := mul(SCALE, 15) } case 10000000000000000000000000000000000 { result := mul(SCALE, 16) } case 100000000000000000000000000000000000 { result := mul(SCALE, 17) } case 1000000000000000000000000000000000000 { result := mul(SCALE, 18) } case 10000000000000000000000000000000000000 { result := mul(SCALE, 19) } case 100000000000000000000000000000000000000 { result := mul(SCALE, 20) } case 1000000000000000000000000000000000000000 { result := mul(SCALE, 21) } case 10000000000000000000000000000000000000000 { result := mul(SCALE, 22) } case 100000000000000000000000000000000000000000 { result := mul(SCALE, 23) } case 1000000000000000000000000000000000000000000 { result := mul(SCALE, 24) } case 10000000000000000000000000000000000000000000 { result := mul(SCALE, 25) } case 100000000000000000000000000000000000000000000 { result := mul(SCALE, 26) } case 1000000000000000000000000000000000000000000000 { result := mul(SCALE, 27) } case 10000000000000000000000000000000000000000000000 { result := mul(SCALE, 28) } case 100000000000000000000000000000000000000000000000 { result := mul(SCALE, 29) } case 1000000000000000000000000000000000000000000000000 { result := mul(SCALE, 30) } case 10000000000000000000000000000000000000000000000000 { result := mul(SCALE, 31) } case 100000000000000000000000000000000000000000000000000 { result := mul(SCALE, 32) } case 1000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 33) } case 10000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 34) } case 100000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 35) } case 1000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 36) } case 10000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 37) } case 100000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 38) } case 1000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 39) } case 10000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 40) } case 100000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 41) } case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 42) } case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 43) } case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 44) } case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 45) } case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 46) } case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 47) } case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 48) } case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 49) } case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 50) } case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 51) } case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 52) } case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 53) } case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 54) } case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 55) } case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 56) } case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 57) } case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 58) } case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 59) } default { result := MAX_UD60x18 } } if (result == MAX_UD60x18) { // Do the fixed-point division inline to save gas. The denominator is log2(10). unchecked { result = (log2(x) * SCALE) / 332192809488736234; } } } /// @notice Calculates the binary logarithm of x. /// /// @dev Based on the iterative approximation algorithm. /// https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation /// /// Requirements: /// - x must be greater than or equal to SCALE, otherwise the result would be negative. /// /// Caveats: /// - The results are nor perfectly accurate to the last digit, due to the lossy precision of the iterative approximation. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the binary logarithm. /// @return result The binary logarithm as an unsigned 60.18-decimal fixed-point number. function log2(uint256 x) internal pure returns (uint256 result) { require(x >= SCALE); unchecked { // Calculate the integer part of the logarithm and add it to the result and finally calculate y = x * 2^(-n). uint256 n = PRBMathCommon.mostSignificantBit(x / SCALE); // The integer part of the logarithm as an unsigned 60.18-decimal fixed-point number. The operation can't overflow // because n is maximum 255 and SCALE is 1e18. result = n * SCALE; // This is y = x * 2^(-n). uint256 y = x >> n; // If y = 1, the fractional part is zero. if (y == SCALE) { return result; } // Calculate the fractional part via the iterative approximation. // The "delta >>= 1" part is equivalent to "delta /= 2", but shifting bits is faster. for (uint256 delta = HALF_SCALE; delta > 0; delta >>= 1) { y = (y * y) / SCALE; // Is y^2 > 2 and so in the range [2,4)? if (y >= 2 * SCALE) { // Add the 2^(-m) factor to the logarithm. result += delta; // Corresponds to z/2 on Wikipedia. y >>= 1; } } } } /// @notice Multiplies two unsigned 60.18-decimal fixed-point numbers together, returning a new unsigned 60.18-decimal /// fixed-point number. /// @dev See the documentation for the "PRBMathCommon.mulDivFixedPoint" function. /// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number. /// @param y The multiplier as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function mul(uint256 x, uint256 y) internal pure returns (uint256 result) { result = PRBMathCommon.mulDivFixedPoint(x, y); } /// @notice Retrieves PI as an unsigned 60.18-decimal fixed-point number. function pi() internal pure returns (uint256 result) { result = 3141592653589793238; } /// @notice Raises x (unsigned 60.18-decimal fixed-point number) to the power of y (basic unsigned integer) using the /// famous algorithm "exponentiation by squaring". /// /// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring /// /// Requirements: /// - The result must fit within MAX_UD60x18. /// /// Caveats: /// - All from "mul". /// - Assumes 0^0 is 1. /// /// @param x The base as an unsigned 60.18-decimal fixed-point number. /// @param y The exponent as an uint256. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function pow(uint256 x, uint256 y) internal pure returns (uint256 result) { // Calculate the first iteration of the loop in advance. result = y & 1 > 0 ? x : SCALE; // Equivalent to "for(y /= 2; y > 0; y /= 2)" but faster. for (y >>= 1; y > 0; y >>= 1) { x = mul(x, x); // Equivalent to "y % 2 == 1" but faster. if (y & 1 > 0) { result = mul(result, x); } } } /// @notice Returns 1 as an unsigned 60.18-decimal fixed-point number. function scale() internal pure returns (uint256 result) { result = SCALE; } /// @notice Calculates the square root of x, rounding down. /// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method. /// /// Requirements: /// - x must be less than MAX_UD60x18 / SCALE. /// /// Caveats: /// - The maximum fixed-point number permitted is 115792089237316195423570985008687907853269.984665640564039458. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the square root. /// @return result The result as an unsigned 60.18-decimal fixed-point . function sqrt(uint256 x) internal pure returns (uint256 result) { require(x < 115792089237316195423570985008687907853269984665640564039458); unchecked { // Multiply x by the SCALE to account for the factor of SCALE that is picked up when multiplying two unsigned // 60.18-decimal fixed-point numbers together (in this case, those two numbers are both the square root). result = PRBMathCommon.sqrt(x * SCALE); } } }
48,041
5
// Constructor to create two pictures in its deployment
constructor() public { pictures[1] = Picture(1, "Picture 1", 0); pictures[2] = Picture(2, "Picture 2", 0); }
constructor() public { pictures[1] = Picture(1, "Picture 1", 0); pictures[2] = Picture(2, "Picture 2", 0); }
25,638
403
// Define the contract's constructor parameters as a struct to enable more variables to be specified. This is required to enable more params, over and above Solidity's limits.
struct ConstructorParams { // Params for PricelessPositionManager only. uint256 expirationTimestamp; uint256 withdrawalLiveness; address collateralAddress; address finderAddress; address tokenFactoryAddress; address timerAddress; address excessTokenBeneficiary; bytes32 priceFeedIdentifier; string syntheticName; string syntheticSymbol; FixedPoint.Unsigned minSponsorTokens; // Params specifically for Liquidatable. uint256 liquidationLiveness; FixedPoint.Unsigned collateralRequirement; FixedPoint.Unsigned disputeBondPct; FixedPoint.Unsigned sponsorDisputeRewardPct; FixedPoint.Unsigned disputerDisputeRewardPct; }
struct ConstructorParams { // Params for PricelessPositionManager only. uint256 expirationTimestamp; uint256 withdrawalLiveness; address collateralAddress; address finderAddress; address tokenFactoryAddress; address timerAddress; address excessTokenBeneficiary; bytes32 priceFeedIdentifier; string syntheticName; string syntheticSymbol; FixedPoint.Unsigned minSponsorTokens; // Params specifically for Liquidatable. uint256 liquidationLiveness; FixedPoint.Unsigned collateralRequirement; FixedPoint.Unsigned disputeBondPct; FixedPoint.Unsigned sponsorDisputeRewardPct; FixedPoint.Unsigned disputerDisputeRewardPct; }
37,008
2
// Error for if no tokens are staked.
error NoTokensStaked();
error NoTokensStaked();
29,651
74
// Sends `amount_` of `_collateral` to `destination_`.
function _removeCollateral(uint256 amount_, address destination_) internal { _collateral -= amount_; require(ERC20Helper.transfer(_collateralAsset, destination_, amount_), "MLI:RC:TRANSFER_FAILED"); require(_isCollateralMaintained(), "MLI:RC:INSUFFICIENT_COLLATERAL"); }
function _removeCollateral(uint256 amount_, address destination_) internal { _collateral -= amount_; require(ERC20Helper.transfer(_collateralAsset, destination_, amount_), "MLI:RC:TRANSFER_FAILED"); require(_isCollateralMaintained(), "MLI:RC:INSUFFICIENT_COLLATERAL"); }
1,890
272
// event emitted when DigitalaxAccessControls is updated
event AccessControlsUpdated( address indexed newAdress );
event AccessControlsUpdated( address indexed newAdress );
10,677
2
// User -> Order Id list
mapping(address => uint256[]) public ordersByUser;
mapping(address => uint256[]) public ordersByUser;
24,294
16
// Contract "Ownable"Purpose: Defines Owner for contract and provide functionality to transfer ownership to another account /
contract Ownable { //owner variable to store contract owner account address public owner; //add another owner to transfer ownership address oldOwner; //Constructor for the contract to store owner's account on deployement function Ownable() public { owner = msg.sender; oldOwner = msg.sender; } //modifier to check transaction initiator is only owner modifier onlyOwner() { require (msg.sender == owner || msg.sender == oldOwner); _; } //ownership can be transferred to provided newOwner. Function can only be initiated by contract owner's account function transferOwnership(address newOwner) public onlyOwner { require (newOwner != address(0)); owner = newOwner; } }
contract Ownable { //owner variable to store contract owner account address public owner; //add another owner to transfer ownership address oldOwner; //Constructor for the contract to store owner's account on deployement function Ownable() public { owner = msg.sender; oldOwner = msg.sender; } //modifier to check transaction initiator is only owner modifier onlyOwner() { require (msg.sender == owner || msg.sender == oldOwner); _; } //ownership can be transferred to provided newOwner. Function can only be initiated by contract owner's account function transferOwnership(address newOwner) public onlyOwner { require (newOwner != address(0)); owner = newOwner; } }
17,320
12
// Max period for which pool can stay not active before it can be closed by governor (in seconds)
uint256 public maxInactivePeriod;
uint256 public maxInactivePeriod;
32,414
51
// timestamp where token release is enabled
uint releaseTime;
uint releaseTime;
19,106
2
// MathUtils library A library to be used in conjunction with SafeMath. Contains functions for calculatingdifferences between two uint256. /
library MathUtils { /** * @notice Compares a and b and returns true if the difference between a and b * is less than 1 or equal to each other. * @param a uint256 to compare with * @param b uint256 to compare with * @return True if the difference between a and b is less than 1 or equal, * otherwise return false */ function within1(uint256 a, uint256 b) internal pure returns (bool) { return (difference(a, b) <= 1); } /** * @notice Calculates absolute difference between a and b * @param a uint256 to compare with * @param b uint256 to compare with * @return Difference between a and b */ function difference(uint256 a, uint256 b) internal pure returns (uint256) { if (a > b) { return a - b; } return b - a; } }
library MathUtils { /** * @notice Compares a and b and returns true if the difference between a and b * is less than 1 or equal to each other. * @param a uint256 to compare with * @param b uint256 to compare with * @return True if the difference between a and b is less than 1 or equal, * otherwise return false */ function within1(uint256 a, uint256 b) internal pure returns (bool) { return (difference(a, b) <= 1); } /** * @notice Calculates absolute difference between a and b * @param a uint256 to compare with * @param b uint256 to compare with * @return Difference between a and b */ function difference(uint256 a, uint256 b) internal pure returns (uint256) { if (a > b) { return a - b; } return b - a; } }
30,092
18
// ! ],! "expected": [! "1"! ]
//! }, { //! "name": "min_to_negative_ordinar", //! "input": [ //! { //! "entry": "main", //! "calldata": [ //! "-127", "3" //! ] //! }
//! }, { //! "name": "min_to_negative_ordinar", //! "input": [ //! { //! "entry": "main", //! "calldata": [ //! "-127", "3" //! ] //! }
47,895
67
// lib/dss-test/lib/dss-interfaces/src/dss/IlkRegistryAbstract.sol/ pragma solidity >=0.5.12; / https:github.com/makerdao/ilk-registry
interface IlkRegistryAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function vat() external view returns (address); function dog() external view returns (address); function cat() external view returns (address); function spot() external view returns (address); function ilkData(bytes32) external view returns ( uint96, address, address, uint8, uint96, address, address, string memory, string memory ); function ilks() external view returns (bytes32[] memory); function ilks(uint) external view returns (bytes32); function add(address) external; function remove(bytes32) external; function update(bytes32) external; function removeAuth(bytes32) external; function file(bytes32, address) external; function file(bytes32, bytes32, address) external; function file(bytes32, bytes32, uint256) external; function file(bytes32, bytes32, string calldata) external; function count() external view returns (uint256); function list() external view returns (bytes32[] memory); function list(uint256, uint256) external view returns (bytes32[] memory); function get(uint256) external view returns (bytes32); function info(bytes32) external view returns ( string memory, string memory, uint256, uint256, address, address, address, address ); function pos(bytes32) external view returns (uint256); function class(bytes32) external view returns (uint256); function gem(bytes32) external view returns (address); function pip(bytes32) external view returns (address); function join(bytes32) external view returns (address); function xlip(bytes32) external view returns (address); function dec(bytes32) external view returns (uint256); function symbol(bytes32) external view returns (string memory); function name(bytes32) external view returns (string memory); function put(bytes32, address, address, uint256, uint256, address, address, string calldata, string calldata) external; }
interface IlkRegistryAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function vat() external view returns (address); function dog() external view returns (address); function cat() external view returns (address); function spot() external view returns (address); function ilkData(bytes32) external view returns ( uint96, address, address, uint8, uint96, address, address, string memory, string memory ); function ilks() external view returns (bytes32[] memory); function ilks(uint) external view returns (bytes32); function add(address) external; function remove(bytes32) external; function update(bytes32) external; function removeAuth(bytes32) external; function file(bytes32, address) external; function file(bytes32, bytes32, address) external; function file(bytes32, bytes32, uint256) external; function file(bytes32, bytes32, string calldata) external; function count() external view returns (uint256); function list() external view returns (bytes32[] memory); function list(uint256, uint256) external view returns (bytes32[] memory); function get(uint256) external view returns (bytes32); function info(bytes32) external view returns ( string memory, string memory, uint256, uint256, address, address, address, address ); function pos(bytes32) external view returns (uint256); function class(bytes32) external view returns (uint256); function gem(bytes32) external view returns (address); function pip(bytes32) external view returns (address); function join(bytes32) external view returns (address); function xlip(bytes32) external view returns (address); function dec(bytes32) external view returns (uint256); function symbol(bytes32) external view returns (string memory); function name(bytes32) external view returns (string memory); function put(bytes32, address, address, uint256, uint256, address, address, string calldata, string calldata) external; }
10,542
38
// Ask a new question and return the ID/Template data is only stored in the event logs, but its block number is kept in contract storage./template_id The ID number of the template the question will use/question A string containing the parameters that will be passed into the template to make the question/arbitrator The arbitration contract that will have the final word on the answer if there is a dispute/timeout How long the contract should wait after the answer is changed before finalizing on that answer/opening_ts If set, the earliest time it should be possible to answer the question./nonce A user-specified nonce
function askQuestionWithMinBondERC20(uint256 template_id, string memory question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, uint256 tokens)
function askQuestionWithMinBondERC20(uint256 template_id, string memory question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, uint256 tokens)
51,710
124
// events
event UpdatedMaxTransaction(uint256 newMax); event UpdatedMaxWallet(uint256 newMax); event SetExemptFromFees(address _address, bool _isExempt); event SetExemptFromLimits(address _address, bool _isExempt); event RemovedLimits(); event UpdatedBuyTax(uint256 newAmt); event UpdatedSellTax(uint256 newAmt); event UpdatedTaxReceiver(address receiver); event EnabledTrading();
event UpdatedMaxTransaction(uint256 newMax); event UpdatedMaxWallet(uint256 newMax); event SetExemptFromFees(address _address, bool _isExempt); event SetExemptFromLimits(address _address, bool _isExempt); event RemovedLimits(); event UpdatedBuyTax(uint256 newAmt); event UpdatedSellTax(uint256 newAmt); event UpdatedTaxReceiver(address receiver); event EnabledTrading();
7,029
9
// Relayed action params relayers List of addresses to be marked as allowed executors and in particular as authorized relayers gasPriceLimit Gas price limit to be used for the relayed action txCostLimit Total transaction cost limit to be used for the relayed action /
struct RelayedActionParams { address[] relayers; uint256 gasPriceLimit; uint256 txCostLimit; }
struct RelayedActionParams { address[] relayers; uint256 gasPriceLimit; uint256 txCostLimit; }
19,257
2
// bytes4(keccak256("SenderNotAuthorizedError(address)"))
bytes4 internal constant SENDER_NOT_AUTHORIZED_ERROR_SELECTOR = 0xb65a25b9;
bytes4 internal constant SENDER_NOT_AUTHORIZED_ERROR_SELECTOR = 0xb65a25b9;
25,149
3
// Verify the block's deadline has passed
node.requirePastDeadline(); getNode(latest).requirePastChildConfirmDeadline(); removeOldZombies(0);
node.requirePastDeadline(); getNode(latest).requirePastChildConfirmDeadline(); removeOldZombies(0);
47,344
20
// Transfer back the nft to the land owner
erc721.safeTransferFrom(address(this), msg.sender, tokenId);
erc721.safeTransferFrom(address(this), msg.sender, tokenId);
19,670
10
// ERC20: Returns the name of the token.ERC20: 토큰의 이름 반환
function name() external view returns (string memory) { return NAME; }
function name() external view returns (string memory) { return NAME; }
49,093
5
// Transfer ETH
uint256 ethBalance = address(this).balance; if (ethBalance > 0) { IWETH weth = IWETH(ethAddress); weth.deposit{value: ethBalance}();
uint256 ethBalance = address(this).balance; if (ethBalance > 0) { IWETH weth = IWETH(ethAddress); weth.deposit{value: ethBalance}();
19,098
36
// Send _value amount of tokens from address _from to address _to Reentry protection prevents attacks upon the state
function transferFrom(address _from, address _to, uint256 _value) public noReentry returns (bool)
function transferFrom(address _from, address _to, uint256 _value) public noReentry returns (bool)
8,485
19
// Calculate Claimable Amount _user userAddress to calculate Tokens /
function calculateTokens(address _user) external view returns (uint256) { UserInfo memory uInfo = userInfo[_user]; if (!uInfo.isDone) { return 0; } if (uInfo.endTime <= uInfo.lastClaimedTime) { return 0; } uint256 _endTime = block.timestamp; if (_endTime > uInfo.endTime) { _endTime = uInfo.endTime; } return _calculateTokens(_endTime, _user); }
function calculateTokens(address _user) external view returns (uint256) { UserInfo memory uInfo = userInfo[_user]; if (!uInfo.isDone) { return 0; } if (uInfo.endTime <= uInfo.lastClaimedTime) { return 0; } uint256 _endTime = block.timestamp; if (_endTime > uInfo.endTime) { _endTime = uInfo.endTime; } return _calculateTokens(_endTime, _user); }
68,893
75
// Increment _totalMintable.
_totalMintable += totalMintableKong;
_totalMintable += totalMintableKong;
2,456
74
// do trade
require(external_call(exchanges[i], etherValues[i], offsets[i], offsets[i + 1] - offsets[i], data), 'External Call Failed');
require(external_call(exchanges[i], etherValues[i], offsets[i], offsets[i + 1] - offsets[i], data), 'External Call Failed');
2,870
56
// Checks whether a storage slot has already been modified, and marks it as modified if not. _contract Address of the contract to check. _key 32 byte storage slot key.return Whether or not the slot was already modified. /
function testAndSetContractStorageChanged( address _contract, bytes32 _key ) override public authenticated returns ( bool )
function testAndSetContractStorageChanged( address _contract, bytes32 _key ) override public authenticated returns ( bool )
67,489
56
// calculate trade amounts and price
_actualDestAmount = getBalance(_destToken, address(this)).sub(beforeDestBalance); _actualSrcAmount = beforeSrcBalance.sub(getBalance(_srcToken, address(this))); require(_actualDestAmount > 0 && _actualSrcAmount > 0); _destPriceInSrc = calcRateFromQty(_actualDestAmount, _actualSrcAmount, getDecimals(_destToken), getDecimals(_srcToken)); _srcPriceInDest = calcRateFromQty(_actualSrcAmount, _actualDestAmount, getDecimals(_srcToken), getDecimals(_destToken));
_actualDestAmount = getBalance(_destToken, address(this)).sub(beforeDestBalance); _actualSrcAmount = beforeSrcBalance.sub(getBalance(_srcToken, address(this))); require(_actualDestAmount > 0 && _actualSrcAmount > 0); _destPriceInSrc = calcRateFromQty(_actualDestAmount, _actualSrcAmount, getDecimals(_destToken), getDecimals(_srcToken)); _srcPriceInDest = calcRateFromQty(_actualSrcAmount, _actualDestAmount, getDecimals(_srcToken), getDecimals(_destToken));
40,807
18
// Unpauses the contract - allowing minting via the public mint function/Only the owner can call this function
/// Emit handled by {OpenZeppelin Pausable} function unpause() external onlyOwner { _unpause(); }
/// Emit handled by {OpenZeppelin Pausable} function unpause() external onlyOwner { _unpause(); }
7,215
7
// The Ownable constructor sets the original `owner` of the contract to the sender account. /
constructor() public { owner = msg.sender; }
constructor() public { owner = msg.sender; }
10,918
6
// Info of each user that stakes LP tokens
mapping(address => UserInfo) public userInfo; event Deposit(address indexed user, uint256 amount); event Withdraw(address indexed user, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 amount); event UpdateEmissionRate(address indexed user, uint256 _rJoePerSec);
mapping(address => UserInfo) public userInfo; event Deposit(address indexed user, uint256 amount); event Withdraw(address indexed user, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 amount); event UpdateEmissionRate(address indexed user, uint256 _rJoePerSec);
5,471
49
// If the highest bid included ETH: Transfer it to the DAO treasury
if (highestBid != 0) _handleOutgoingTransfer(settings.treasury, highestBid);
if (highestBid != 0) _handleOutgoingTransfer(settings.treasury, highestBid);
14,372
11
// the interest fee percentage in basis points (1/100 of a percent) /
function interestFee() external view returns (uint256);
function interestFee() external view returns (uint256);
2,795
56
// This is internal function is equivalent to {transfer}, and can be used toe.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. /
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); }
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); }
50,642
101
// 查看用户
function Get_User(address userAddress) public view returns (address, uint, bool, uint[8] memory, uint[8] memory, uint, uint[8] memory){ return ( //用户地址 user_Mpping[userAddress].User_Address, //用户抵押数量 user_Mpping[userAddress].Stacking_Amount, //用户是否注册 user_Mpping[userAddress].Registered, //用户抵押数量数组 user_Mpping[userAddress].Stacking_Amounts, //用户开始质押区块 user_Mpping[userAddress].Start_Staking_Block, //最新操作区块 user_Mpping[userAddress].Latest_Operation_Block, //用户奖励总和数组 user_Mpping[userAddress].Reward_Sum_Array ); }
function Get_User(address userAddress) public view returns (address, uint, bool, uint[8] memory, uint[8] memory, uint, uint[8] memory){ return ( //用户地址 user_Mpping[userAddress].User_Address, //用户抵押数量 user_Mpping[userAddress].Stacking_Amount, //用户是否注册 user_Mpping[userAddress].Registered, //用户抵押数量数组 user_Mpping[userAddress].Stacking_Amounts, //用户开始质押区块 user_Mpping[userAddress].Start_Staking_Block, //最新操作区块 user_Mpping[userAddress].Latest_Operation_Block, //用户奖励总和数组 user_Mpping[userAddress].Reward_Sum_Array ); }
7,984
16
// The historical record of all previously set configs by feedId
mapping(bytes32 => Config) s_verificationDataConfigs;
mapping(bytes32 => Config) s_verificationDataConfigs;
19,109
248
// The hero contract.
CryptoSagaHero public heroContract;
CryptoSagaHero public heroContract;
9,399
45
// Function to get applicant details by address
function getApplicantDetails(address applicantAddress) public view returns (string memory, uint, string memory, address) { // Ensure the applicant exists require(applicants[applicantAddress].age > 0, "Applicant does not exist."); // Return the applicant details return (applicants[applicantAddress].name, applicants[applicantAddress].age, applicants[applicantAddress].resumeHash, applicants[applicantAddress].applicantAddress); }
function getApplicantDetails(address applicantAddress) public view returns (string memory, uint, string memory, address) { // Ensure the applicant exists require(applicants[applicantAddress].age > 0, "Applicant does not exist."); // Return the applicant details return (applicants[applicantAddress].name, applicants[applicantAddress].age, applicants[applicantAddress].resumeHash, applicants[applicantAddress].applicantAddress); }
25,873
151
// Named Templates
mapping(string => address) public templates;
mapping(string => address) public templates;
58,398
8
// Required interface of an ERC721 compliant contract. /
contract IERC721 is IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of NFTs in `owner`'s account. */ function balanceOf(address owner) public view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) public view returns (address owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) public; function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; }
contract IERC721 is IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of NFTs in `owner`'s account. */ function balanceOf(address owner) public view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) public view returns (address owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) public; function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; }
200
61
// new
uint256 total_income = price;
uint256 total_income = price;
29,122
21
// Uniswap
interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
68,393
399
// Calculates the payment for existing and non-existing HEX stake instance (HSI) loans. borrower Address which has mapped ownership the HSI contract. hsiIndex Index of the HSI contract address in the sender's HSI list.(see hsiLists -> HEXStakeInstanceManager.sol) hsiAddress Address of the HSI contract which coinsides with the index.return Payment amount with principal and interest as serparate values. /
function calcLoanPayment ( address borrower, uint256 hsiIndex, address hsiAddress ) external view returns (uint256, uint256)
function calcLoanPayment ( address borrower, uint256 hsiIndex, address hsiAddress ) external view returns (uint256, uint256)
27,402
2
// Uniswap router contract address.
IUniswapV2Router02 public uniswapRouter;
IUniswapV2Router02 public uniswapRouter;
30,597
373
// copy buffer 2 into buffer
for(uint256 j = buf1.length; j < buf2.length; j++) { buf[j] = buf2[j - buf1.length]; }
for(uint256 j = buf1.length; j < buf2.length; j++) { buf[j] = buf2[j - buf1.length]; }
24,945
26
// Total number of disputes ever opened.
uint256 public totalDisputes;
uint256 public totalDisputes;
2,344
28
// As defined in the 'ERC777TokensRecipient And The tokensReceived Hook' section of https:eips.ethereum.org/EIPS/eip-777
interface IERC777Recipient { function tokensReceived(address operator, address from, address to, uint256 amount, bytes calldata data, bytes calldata operatorData) external; }
interface IERC777Recipient { function tokensReceived(address operator, address from, address to, uint256 amount, bytes calldata data, bytes calldata operatorData) external; }
63,840
59
// Overloaded decimal count /
function decimals() public view virtual override returns (uint8) { return 4; }
function decimals() public view virtual override returns (uint8) { return 4; }
67,412
78
// Returns the current balance of the SupraFund contract./ return The current balance of the SupraFund contract.
function checkSupraFund() external view returns (uint256) { require( msg.sender == owner() || msg.sender == developer, "Unauthorized Access: Cannot check supra funds" ); return supraFund; }
function checkSupraFund() external view returns (uint256) { require( msg.sender == owner() || msg.sender == developer, "Unauthorized Access: Cannot check supra funds" ); return supraFund; }
13,093
4
// Quote synth to synth
function quoteSynth(address synthIn, address synthOut, uint amount) external view returns (uint amountReceived) { if (synthIn == synthOut) return amount; (amountReceived,,) = sexViewer.getAmountsForAtomicExchange(amount, synthId(synthIn), synthId(synthOut)); }
function quoteSynth(address synthIn, address synthOut, uint amount) external view returns (uint amountReceived) { if (synthIn == synthOut) return amount; (amountReceived,,) = sexViewer.getAmountsForAtomicExchange(amount, synthId(synthIn), synthId(synthOut)); }
19,924
47
// Do not allow transfer to 0x0 or the token contract itself
require((_to != 0) && (_to != address(this)));
require((_to != 0) && (_to != address(this)));
18,432
602
// Send back excess eth
if (excessETH > 0) { msg.sender.transfer(excessETH); }
if (excessETH > 0) { msg.sender.transfer(excessETH); }
49,408