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
94
// Computes the EIP 712 domain separator which prevents user signed messages for this contract to be replayed in other contracts. https:eips.ethereum.org/EIPS/eip-712
DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name)), keccak256(bytes("1")), block.chainid, address(this) )
DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name)), keccak256(bytes("1")), block.chainid, address(this) )
10,789
102
// total purchased eth amount during ICO. The unit is wei
uint256 public totalPurchased = 0; uint256 start;
uint256 public totalPurchased = 0; uint256 start;
17,732
19
// ISuperTokenFactory// @inheritdoc ISuperTokenFactory
function getSuperTokenLogic() external view override returns (ISuperToken)
function getSuperTokenLogic() external view override returns (ISuperToken)
18,920
63
// This is the function that Chainlink VRF node calls /
function fulfillRandomWords(
function fulfillRandomWords(
3,070
39
// Enum is used to read only a specific part of the order pair from storage, since it is a bad idea to always perform 4 SLOADs.
enum OrderPairReadStrategy {SKIP, MAKER, TAKER, FULL}
enum OrderPairReadStrategy {SKIP, MAKER, TAKER, FULL}
13,848
25
// sets timecontract address and is callable by only contract owner_value new value /
function setTime(address _value) external onlyOwner { require(_value != address(0), "tIME: invalid value"); require(_value != time, "tIME: the same value"); time = _value; emit TimeUpdated(msg.sender, _value); }
function setTime(address _value) external onlyOwner { require(_value != address(0), "tIME: invalid value"); require(_value != time, "tIME: the same value"); time = _value; emit TimeUpdated(msg.sender, _value); }
58,929
4
// We're auctioning off tokens.
prizeToken = _prizeToken; prizeAmount = _prizeAmount;
prizeToken = _prizeToken; prizeAmount = _prizeAmount;
35,657
196
// adds minter role to and address. _address The address will be added.Needed in case the last minter renounces the role /
function adminAddMinter(address _address) public
function adminAddMinter(address _address) public
57,379
45
// Adding hqCount after one hop
s.metaCount[hq] += 1;
s.metaCount[hq] += 1;
31,437
0
// swap parameters used by function swap amountCalculated return amount from getAmountIn/Out is always positive but to avoid too much cast, is int fictiveReserveIn fictive reserve of the in-token of the pair fictiveReserveOut fictive reserve of the out-token of the pair priceAverageIn in-token ratio component of the price average priceAverageOut out-token ratio component of the price average token0 address of the token0 token1 address of the token1 balanceIn contract balance of the in-token balanceOut contract balance of the out-token /
struct SwapParams { int256 amountCalculated; uint256 fictiveReserveIn; uint256 fictiveReserveOut; uint256 priceAverageIn; uint256 priceAverageOut; address token0; address token1; uint256 balanceIn; uint256 balanceOut; }
struct SwapParams { int256 amountCalculated; uint256 fictiveReserveIn; uint256 fictiveReserveOut; uint256 priceAverageIn; uint256 priceAverageOut; address token0; address token1; uint256 balanceIn; uint256 balanceOut; }
45,276
127
// Toggle the staking functionality
bool public stakingStatus;
bool public stakingStatus;
2,542
78
// Below oracles are expressing tokens in USD with 8 decimals
daiOracle = 0x4746DeC9e833A82EC7C2C1356372CcF2cfcD2F3D; wethOracle = 0xF9680D99D6C9589e2a93a78A04A279e509205945; aaveOracle = 0x72484B12719E23115761D5DA1646945632979bB6; linkOracle = 0xd9FFdb71EbE7496cC440152d43986Aae0AB76665; usdtOracle = 0x0A6513e40db6EB1b165753AD52E80663aeA50545; usdcOracle = 0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7; tusdOracle = 0x7C5D415B64312D38c56B54358449d0a4058339d2; uniOracle = 0xdf0Fb4e4F928d2dCB76f438575fDD8682386e13C; yfiOracle = 0x9d3A43c111E7b2C6601705D9fcF7a70c95b1dc55; wbtcOracle = 0xDE31F8bFBD8c84b5360CFACCa3539B938dd78ae6;
daiOracle = 0x4746DeC9e833A82EC7C2C1356372CcF2cfcD2F3D; wethOracle = 0xF9680D99D6C9589e2a93a78A04A279e509205945; aaveOracle = 0x72484B12719E23115761D5DA1646945632979bB6; linkOracle = 0xd9FFdb71EbE7496cC440152d43986Aae0AB76665; usdtOracle = 0x0A6513e40db6EB1b165753AD52E80663aeA50545; usdcOracle = 0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7; tusdOracle = 0x7C5D415B64312D38c56B54358449d0a4058339d2; uniOracle = 0xdf0Fb4e4F928d2dCB76f438575fDD8682386e13C; yfiOracle = 0x9d3A43c111E7b2C6601705D9fcF7a70c95b1dc55; wbtcOracle = 0xDE31F8bFBD8c84b5360CFACCa3539B938dd78ae6;
33,964
26
// amountOut amount value of result ETHamountInMax maximum amount of source tokenpath array of token addresses, represent the path for swaps, (WETH for ETH)to send result token toref referral return amounts result token amount values/
function swapTokensForExactETH ( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, address ref ) external returns (uint256[] memory amounts)
function swapTokensForExactETH ( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, address ref ) external returns (uint256[] memory amounts)
46,850
214
// bubble up the error
revert(string(error));
revert(string(error));
14,446
113
// File: contracts\Token.soltruffle-flattener Token.sol
contract Blocks is ERC20Frozenable, ERC20Detailed { constructor() ERC20Detailed("Share Art Protocol", "SRP", 18) public { uint256 supply = 10000000000; uint256 initialSupply = supply * uint(10) ** decimals(); _mint(msg.sender, initialSupply); } }
contract Blocks is ERC20Frozenable, ERC20Detailed { constructor() ERC20Detailed("Share Art Protocol", "SRP", 18) public { uint256 supply = 10000000000; uint256 initialSupply = supply * uint(10) ** decimals(); _mint(msg.sender, initialSupply); } }
33,430
4
// The address of the ClockAuction contract that handles sales of Hauntoos. This/same contract handles both peer-to-peer sales as well as the gen0 sales which are/initiated every 15 minutes.
SaleClockAuction public saleAuction;
SaleClockAuction public saleAuction;
23,933
43
// Renounce ownership of the contract This function is overridden to prevent renouncing ownership /
function renounceOwnership() public view override onlyOwner { revert CannotRenounceOwnership(); }
function renounceOwnership() public view override onlyOwner { revert CannotRenounceOwnership(); }
20,085
149
// Set threshold/
function setThreshold( uint8 newThreshold, bytes[] calldata signatures
function setThreshold( uint8 newThreshold, bytes[] calldata signatures
44,493
76
// The msg.sender must be a listed agreement.
modifier onlyAgreement() virtual;
modifier onlyAgreement() virtual;
13,764
114
// initializes bond parameters_controlVariable uint_vestingTerm uint_minimumPrice uint_maxPayout uint_fee uint_maxDebt uint_initialDebt uint /
function initializeBondTerms( uint _controlVariable, uint _vestingTerm, uint _minimumPrice, uint _maxPayout, uint _fee, uint _maxDebt, uint _initialDebt
function initializeBondTerms( uint _controlVariable, uint _vestingTerm, uint _minimumPrice, uint _maxPayout, uint _fee, uint _maxDebt, uint _initialDebt
3,865
84
// An order can be compressed into 256 bits and saved using one SSTORE instruction The orders form a single-linked list. The preceding order points to the following order with nextID
struct Order { //total 256 bits address sender; //160 bits, sender creates this order uint32 price; // 32-bit decimal floating point number uint64 amount; // 42 bits are used, the stock amount to be sold or bought uint32 nextID; // 22 bits are used }
struct Order { //total 256 bits address sender; //160 bits, sender creates this order uint32 price; // 32-bit decimal floating point number uint64 amount; // 42 bits are used, the stock amount to be sold or bought uint32 nextID; // 22 bits are used }
38,743
60
// Return the front end's compounded stake. Given by the formula:D = D0P/P(0)where P(0) is the depositor's snapshot of the product P, taken at the last timewhen one of the front end's tagged deposits updated their deposit. The front end's compounded stake is equal to the sum of its depositors' compounded deposits. /
function getCompoundedFrontEndStake(address _frontEnd) public view override returns (uint256) { uint256 frontEndStake = frontEndStakes[_frontEnd]; if (frontEndStake == 0) { return 0; } Snapshots memory snapshots = frontEndSnapshots[_frontEnd]; uint256 compoundedFrontEndStake = _getCompoundedStakeFromSnapshots(frontEndStake, snapshots); return compoundedFrontEndStake; }
function getCompoundedFrontEndStake(address _frontEnd) public view override returns (uint256) { uint256 frontEndStake = frontEndStakes[_frontEnd]; if (frontEndStake == 0) { return 0; } Snapshots memory snapshots = frontEndSnapshots[_frontEnd]; uint256 compoundedFrontEndStake = _getCompoundedStakeFromSnapshots(frontEndStake, snapshots); return compoundedFrontEndStake; }
43,304
12
// Check available liquidity
for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) }
for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) }
880
30
// Returns the token symbol. /
function symbol() external view override returns (string memory) { return _symbol; }
function symbol() external view override returns (string memory) { return _symbol; }
2,480
69
// function to calculate token price based on an amount of incoming collateralIt's an scientific algorithm;Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. /
function collateralToToken_(address contractAddress, uint256 _tokens) internal view returns(uint256)
function collateralToToken_(address contractAddress, uint256 _tokens) internal view returns(uint256)
44,312
59
// keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
bytes32 private constant EIP712DOMAIN_HASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 private constant EIP712DOMAIN_HASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
7,025
29
// Update pool's lastRewardBlock to block.number/pool Pool's address
function updateLastRewardBlock(address pool) public { require(proxyTokens[msg.sender][pool], "CSTMinter: only farmingProxy"); PoolInfo storage pInfo = poolInfo[msg.sender][pool]; uint256 _lastRewardBlock = pInfo.lastRewardBlock; uint256 _lastPhase = _phase(_lastRewardBlock); uint256 _currPhase = _phase(block.number); if (_currPhase > _lastPhase) { emit PhaseChanged(pool, _currPhase, cstToken.totalSupply()); } poolInfo[msg.sender][pool].lastRewardBlock = block.number; }
function updateLastRewardBlock(address pool) public { require(proxyTokens[msg.sender][pool], "CSTMinter: only farmingProxy"); PoolInfo storage pInfo = poolInfo[msg.sender][pool]; uint256 _lastRewardBlock = pInfo.lastRewardBlock; uint256 _lastPhase = _phase(_lastRewardBlock); uint256 _currPhase = _phase(block.number); if (_currPhase > _lastPhase) { emit PhaseChanged(pool, _currPhase, cstToken.totalSupply()); } poolInfo[msg.sender][pool].lastRewardBlock = block.number; }
21,944
139
// v5 remove if (land2ResourceMineState[_landTokenId].maxMiners == 0) { land2ResourceMineState[_landTokenId].maxMiners = 5; }
require( land2ResourceMineState[_landTokenId].totalMiners <= maxMiners, "Land: EXCEED_MAXAMOUNT" ); address miner = IInterstellarEncoder( registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER) )
require( land2ResourceMineState[_landTokenId].totalMiners <= maxMiners, "Land: EXCEED_MAXAMOUNT" ); address miner = IInterstellarEncoder( registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER) )
18,998
105
// Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); }
function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); }
2,396
20
// module:reputation Voting power of an `account` at a specific `blockNumber` given additional encoded parameters. /
function getVotesWithParams(
function getVotesWithParams(
3,379
84
// Token Sale Stage 1 = Dates Start 10/15/18 End 10/31/18 35% discount
if(now >= saleStartDate && now <= saleStartDate.add(10 days)){ tokens = getTokensForWeiReceived(weiReceived); tokens = tokens.mul(100 + 60) / 100;
if(now >= saleStartDate && now <= saleStartDate.add(10 days)){ tokens = getTokensForWeiReceived(weiReceived); tokens = tokens.mul(100 + 60) / 100;
22,071
1
// Implementation address for the `UniswapV3TwapPriceOracleV2`. /
address immutable public logic;
address immutable public logic;
49,652
9
// Store hash in state.
hashTopic[topicHash] = topic;
hashTopic[topicHash] = topic;
42,670
54
// msg.sender is the App contract not the real owner. Calls ownable behind the scenes...sigh
require(_owner != address(0), "Invalid owner"); Pausable.initialize(_owner); require(_acceptedToken.isContract(), "The accepted token address must be a deployed contract"); acceptedToken = ERC20Interface(_acceptedToken); _requireERC721(_legacyNFTAddress); legacyNFTAddress = _legacyNFTAddress;
require(_owner != address(0), "Invalid owner"); Pausable.initialize(_owner); require(_acceptedToken.isContract(), "The accepted token address must be a deployed contract"); acceptedToken = ERC20Interface(_acceptedToken); _requireERC721(_legacyNFTAddress); legacyNFTAddress = _legacyNFTAddress;
50,548
18
// Give 1 Avax to vault
addPrizeToVault(1 ether);
addPrizeToVault(1 ether);
34,361
10
// withdraws all of your earnings.-functionhash- 0x3ccfd60b /
function withdraw() isHuman() public
function withdraw() isHuman() public
81,465
195
// checking if token exists in the _burn function (don't need to check here)
_burn(tokenId); emit Burned(tokenId, burner, totalSupply());
_burn(tokenId); emit Burned(tokenId, burner, totalSupply());
11,083
26
// Verifies that the signer is the owner of the signing contract. /
function isValidSignature(bytes32 _hash, bytes calldata _signature) external view override returns (bytes4)
function isValidSignature(bytes32 _hash, bytes calldata _signature) external view override returns (bytes4)
8,641
71
// Reverts if sender does not have the issuer role associated. /
modifier onlyIssuer() { require(isIssuer(msg.sender), "RaiseOperatorable: caller is not issuer"); _; }
modifier onlyIssuer() { require(isIssuer(msg.sender), "RaiseOperatorable: caller is not issuer"); _; }
46,614
3
// WARNING: Usage of transferFrom method is discouraged, use {safeTransferFrom} whenever possible.
function transferFrom( address from, address to, uint256 tokenId ) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom(
function transferFrom( address from, address to, uint256 tokenId ) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom(
55,481
58
// scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint256 balance0Adjusted = ( balance0.mul(10000).sub( amount0In.mul(liquidityFee.add(treasuryFee)) ) ); uint256 balance1Adjusted = ( balance1.mul(10000).sub( amount1In.mul(liquidityFee.add(treasuryFee)) ) );
uint256 balance0Adjusted = ( balance0.mul(10000).sub( amount0In.mul(liquidityFee.add(treasuryFee)) ) ); uint256 balance1Adjusted = ( balance1.mul(10000).sub( amount1In.mul(liquidityFee.add(treasuryFee)) ) );
24,211
32
// Function that will return the minimum amount from a swap, utilizing the getAmountsOut function.
function getAmountOutMin(address _tokenIn, address _tokenOut, uint256 _amountIn) internal view returns (uint256) { if (_tokenIn == _tokenOut) {return _amountIn;} if (_amountIn == 0) {return 0;} uint256[] memory amountOutMins = IUniswapV2Router(PANCAKESWAP_V2_ROUTER).getAmountsOut(_amountIn, createPath(_tokenIn, _tokenOut)); return amountOutMins[amountOutMins.length -1]; }
function getAmountOutMin(address _tokenIn, address _tokenOut, uint256 _amountIn) internal view returns (uint256) { if (_tokenIn == _tokenOut) {return _amountIn;} if (_amountIn == 0) {return 0;} uint256[] memory amountOutMins = IUniswapV2Router(PANCAKESWAP_V2_ROUTER).getAmountsOut(_amountIn, createPath(_tokenIn, _tokenOut)); return amountOutMins[amountOutMins.length -1]; }
25,340
1
// ============ Storage ============/ The wormhole id for the mirror network /
uint16 public immutable MIRROR_WORMHOLE_ID;
uint16 public immutable MIRROR_WORMHOLE_ID;
32,119
385
// Disables this Voting contract in favor of the migrated one. Can only be called by the contract owner. newVotingAddress the newly migrated contract address. /
function setMigrated(address newVotingAddress) external virtual;
function setMigrated(address newVotingAddress) external virtual;
51,790
6
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in the array, and then remove the last element (sometimes called as 'swap and pop'). This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1;
uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1;
16,717
0
// prevent double spend with the same tx
mapping (bytes32 => bool) private seenTransactions;
mapping (bytes32 => bool) private seenTransactions;
14,845
58
// Admin can change APY% (or reward rate %) Changing reward rate percent will also affect user's pending earnings Be careful while using this function
function setRewardRatePercentX100(uint _rewardRatePercentX100) public onlyOwner { rewardRatePercentX100 = _rewardRatePercentX100; }
function setRewardRatePercentX100(uint _rewardRatePercentX100) public onlyOwner { rewardRatePercentX100 = _rewardRatePercentX100; }
44,838
2
// emitted on a call to `onERC721Received`
event ERC721Received( address ERC721, address operator, address sender, uint256 tokenId, bytes data );
event ERC721Received( address ERC721, address operator, address sender, uint256 tokenId, bytes data );
38,071
301
// Sets the new redemption spread./newRedemptionSpread New redemption spread to be used.
function setRedemptionSpread(IERC20 collateralToken, uint256 newRedemptionSpread) external;
function setRedemptionSpread(IERC20 collateralToken, uint256 newRedemptionSpread) external;
21,898
152
// allow the pool to move your LP tokens
pool.lpToken.safeIncreaseAllowance(address(updated), withdrawable);
pool.lpToken.safeIncreaseAllowance(address(updated), withdrawable);
14,412
15
// U_statistics = [1] Utility Vault [2] Utility Profit [3] Utility Burn
address public Utility_address;
address public Utility_address;
12,237
50
// Sells Without Including Decimals /
function sellInWholeTokenAmounts(uint256 amount) external nonReentrant { _sell(amount.mul(10 ** _decimals), msg.sender); }
function sellInWholeTokenAmounts(uint256 amount) external nonReentrant { _sell(amount.mul(10 ** _decimals), msg.sender); }
29,612
80
// Caller liquidates the staker's Kine MCD and seize staker's collateral.Liquidate will fail if hasn't reach start time. staker The staker of Kine MCD to be liquidated. unstakeKMCDAmount The amount of Kine MCD to unstake. maxBurnKUSDAmount The max amount limit of KUSD of liquidator to be burned. kTokenCollateral The market in which to seize collateral from the staker. /
function liquidate(address staker, uint unstakeKMCDAmount, uint maxBurnKUSDAmount, address kTokenCollateral) external checkStart updateReward(staker) { address msgSender = _msgSender(); uint kMCDPriceMantissa = KineOracleInterface(controller.getOracle()).getUnderlyingPrice(address(kMCD)); require(kMCDPriceMantissa != 0, "Liquidate: get Kine MCD price zero"); CalculateVars memory vars; // KUSD has 18 decimals // KMCD has 18 decimals // kMCDPriceMantissa is KMCD's price (quoted by KUSD, has 6 decimals) scaled by 1e36 / KMCD's decimals = 1e36 / 1e18 = 1e18 // so the calculation of equivalent KUSD amount is as below // accountStakes kMCDPriceMantissa accountStakes * kMCDPriceMantissa // equivalentKUSDAmount = ------------- * ------------------ * 1e18 = --------------------------------- // 1e18 1e12 * 1e6 1e30 // vars.equivalentKUSDAmount = unstakeKMCDAmount.mul(kMCDPriceMantissa).div(1e18); require(maxBurnKUSDAmount >= vars.equivalentKUSDAmount, "Liquidate: reach out max burn KUSD amount limit"); // burn liquidator's KUSD kUSD.burn(msgSender, vars.equivalentKUSDAmount); // call KMCD contract to liquidate staker's Kine MCD and seize collateral kMCD.liquidateBorrowBehalf(msgSender, staker, unstakeKMCDAmount, kTokenCollateral); emit Liquidate(msgSender, staker, vars.equivalentKUSDAmount, unstakeKMCDAmount, accountStakes(staker), totalStakes()); }
function liquidate(address staker, uint unstakeKMCDAmount, uint maxBurnKUSDAmount, address kTokenCollateral) external checkStart updateReward(staker) { address msgSender = _msgSender(); uint kMCDPriceMantissa = KineOracleInterface(controller.getOracle()).getUnderlyingPrice(address(kMCD)); require(kMCDPriceMantissa != 0, "Liquidate: get Kine MCD price zero"); CalculateVars memory vars; // KUSD has 18 decimals // KMCD has 18 decimals // kMCDPriceMantissa is KMCD's price (quoted by KUSD, has 6 decimals) scaled by 1e36 / KMCD's decimals = 1e36 / 1e18 = 1e18 // so the calculation of equivalent KUSD amount is as below // accountStakes kMCDPriceMantissa accountStakes * kMCDPriceMantissa // equivalentKUSDAmount = ------------- * ------------------ * 1e18 = --------------------------------- // 1e18 1e12 * 1e6 1e30 // vars.equivalentKUSDAmount = unstakeKMCDAmount.mul(kMCDPriceMantissa).div(1e18); require(maxBurnKUSDAmount >= vars.equivalentKUSDAmount, "Liquidate: reach out max burn KUSD amount limit"); // burn liquidator's KUSD kUSD.burn(msgSender, vars.equivalentKUSDAmount); // call KMCD contract to liquidate staker's Kine MCD and seize collateral kMCD.liquidateBorrowBehalf(msgSender, staker, unstakeKMCDAmount, kTokenCollateral); emit Liquidate(msgSender, staker, vars.equivalentKUSDAmount, unstakeKMCDAmount, accountStakes(staker), totalStakes()); }
23,363
100
// tranfser accidentally sent underlying tokens back to vault
function withdrawAll() external override onlyAuthorized { uint bal = IERC20(underlying).balanceOf(address(this)); if (bal > 0) { IERC20(underlying).safeTransfer(vault, bal); } }
function withdrawAll() external override onlyAuthorized { uint bal = IERC20(underlying).balanceOf(address(this)); if (bal > 0) { IERC20(underlying).safeTransfer(vault, bal); } }
43,405
369
// SPDX-License-Identifier: GPL-3.0-or-laterHegicCopyright (C) 2021 Hegic This program is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version. This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See theGNU General Public License for more details. You should have received a copy of the GNU General Public License /
contract ERC20Mock is ERC20 { uint8 private immutable _decimals; constructor( string memory name, string memory symbol, uint8 __decimals ) ERC20(name, symbol) { _decimals = __decimals; } function decimals() public view override returns (uint8) { return _decimals; } function mintTo(address account, uint256 amount) public { _mint(account, amount); } function mint(uint256 amount) public { _mint(msg.sender, amount); } }
contract ERC20Mock is ERC20 { uint8 private immutable _decimals; constructor( string memory name, string memory symbol, uint8 __decimals ) ERC20(name, symbol) { _decimals = __decimals; } function decimals() public view override returns (uint8) { return _decimals; } function mintTo(address account, uint256 amount) public { _mint(account, amount); } function mint(uint256 amount) public { _mint(msg.sender, amount); } }
47,766
12
// Assuming each country is represented in ISO country codes
bytes memory country = new bytes(2); bytes memory countriesInBytes = bytes(campaign.filters.countries); uint countryLength = 0; for (uint i=0; i<countriesInBytes.length; i++){
bytes memory country = new bytes(2); bytes memory countriesInBytes = bytes(campaign.filters.countries); uint countryLength = 0; for (uint i=0; i<countriesInBytes.length; i++){
4,938
1
// A person can have maximum 2 branches
uint constant private REFERRER_1_LEVEL_LIMIT = 2;
uint constant private REFERRER_1_LEVEL_LIMIT = 2;
20,552
5
// Provides a safe ERC20.name version which returns '???' as fallback string./token The address of the ERC-20 token contract./ return (string) Token name.
function safeName(IERC20 token) internal view returns (string memory) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_NAME)); return success ? returnDataToString(data) : "???"; }
function safeName(IERC20 token) internal view returns (string memory) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_NAME)); return success ? returnDataToString(data) : "???"; }
23,486
243
// Determine if a user has sufficient unlocked tokens to transfer the requested amount This function is used by the transfer and transferFrom functions to determine if the transfer should beallowed. It does not check if the user has sufficient tokens to transfer, only if they have sufficient unlockedtokens. If the user does not have sufficient unlocked tokens, this function will return true but the transferwill fail due to low balance. address_ The address to check the timelock for amount The amount to check if can be transferredreturn True if the user has sufficient unlocked tokens to transfer the requested amount,
function checkTimelock(address address_, uint256 amount) public view returns (bool) { // get the address' token balance uint256 balance = balanceOf(address_); // if the user does not have enough tokens to send regardless of lock return true here // the failure will still fail but this should make it explicit that the transfer failure is not // due to locked tokens but because of too low token balance if (balance < amount) return true; // copy lockup data into memory LockupItem memory lockupItem = lockups[address_]; // return true if the lock is expired if (block.timestamp > lockupItem.releaseTime) return true; // get the user's token balance that is not locked uint256 nonLockedAmount = balance - lockupItem.amount; // return true if the user has enough unlocked tokens to send the requested amount, false if not return amount <= nonLockedAmount; }
function checkTimelock(address address_, uint256 amount) public view returns (bool) { // get the address' token balance uint256 balance = balanceOf(address_); // if the user does not have enough tokens to send regardless of lock return true here // the failure will still fail but this should make it explicit that the transfer failure is not // due to locked tokens but because of too low token balance if (balance < amount) return true; // copy lockup data into memory LockupItem memory lockupItem = lockups[address_]; // return true if the lock is expired if (block.timestamp > lockupItem.releaseTime) return true; // get the user's token balance that is not locked uint256 nonLockedAmount = balance - lockupItem.amount; // return true if the user has enough unlocked tokens to send the requested amount, false if not return amount <= nonLockedAmount; }
29,836
18
// The v1 price oracle, maintain by CREAM
V1PriceOracleInterface public v1PriceOracle; address public constant cyY3CRVAddress = 0x7589C9E17BCFcE1Ccaa1f921196FDa177F0207Fc; AggregatorV3Interface public constant ethUsdAggregator = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);
V1PriceOracleInterface public v1PriceOracle; address public constant cyY3CRVAddress = 0x7589C9E17BCFcE1Ccaa1f921196FDa177F0207Fc; AggregatorV3Interface public constant ethUsdAggregator = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);
11,465
27
// Anyone can transfer any ERC20 back to the origin after the trade has been closed/Escape hatch in case trading partner freezes up, or other unexpected events/ @custom:interaction CEI (and respects the state lock)
function transferToOriginAfterTradeComplete(IERC20 erc20) external { require(status == TradeStatus.CLOSED, "only after trade is closed"); IERC20Upgradeable(address(erc20)).safeTransfer(origin, erc20.balanceOf(address(this))); }
function transferToOriginAfterTradeComplete(IERC20 erc20) external { require(status == TradeStatus.CLOSED, "only after trade is closed"); IERC20Upgradeable(address(erc20)).safeTransfer(origin, erc20.balanceOf(address(this))); }
11,024
27
// Calculate the reward for the staked token.
uint256 _myReward = _calReward(msg.sender, _tokenType, _tokenId); if(_myReward > 0){
uint256 _myReward = _calReward(msg.sender, _tokenType, _tokenId); if(_myReward > 0){
11,640
11
// The update product function will be called to update the details of an existing function. In a regular course of a business, the following amounts may get updated.- quantity- productName- price- description TODO : Add an additional parameter for discountPercentage /
function updateProduct( uint productId, string productName, string productDesc, uint price,
function updateProduct( uint productId, string productName, string productDesc, uint price,
23,159
42
// address public rebaser;
address public rewardAddress;
address public rewardAddress;
20,821
227
// Removes specified index from array Resulting ordering is not guaranteed return Returns the new array and the removed entry/
function pop(address[] memory A, uint256 index) internal pure returns (address[] memory, address)
function pop(address[] memory A, uint256 index) internal pure returns (address[] memory, address)
17,428
182
// tokenAddress为Vcg ERC20的地址 //2021.8.18 如果提交上架时间早于块当前时间,以块上时间作为上架时间。/
if(startTime < block.timestamp) { startTime = block.timestamp; }
if(startTime < block.timestamp) { startTime = block.timestamp; }
59,164
4
// Start a new airdrop `_root` _root New airdrop merkle root /
function start(bytes32 _root) public { require(msg.sender == startAuth, "Not authorized"); _start(_root); }
function start(bytes32 _root) public { require(msg.sender == startAuth, "Not authorized"); _start(_root); }
72,822
75
// SafeMath is not required when dividing by a constant value > 0.
chiartFee = price.mul(chiartFeeBasisPoints) / BASIS_POINTS; ownerRev = price.sub(chiartFee).sub(creatorSecondaryFee);
chiartFee = price.mul(chiartFeeBasisPoints) / BASIS_POINTS; ownerRev = price.sub(chiartFee).sub(creatorSecondaryFee);
10,355
97
// transfer cash paid in by purchaser to issuer from whom bond is transferred to purchaser
address viaAddress = factory.getIssuer("ViaCash", paidInCashToken); if(viaAddress!=address(0x0)){
address viaAddress = factory.getIssuer("ViaCash", paidInCashToken); if(viaAddress!=address(0x0)){
26,147
20
// Structure for base message. /
struct BaseMessage { MessageType messageType; }
struct BaseMessage { MessageType messageType; }
36,725
9
// target and amountCollected are uint128 enough to store a value of 340282366920938463463374607431768211455.
uint128 target; uint128 amountCollected; uint128 amountWithdrawn;
uint128 target; uint128 amountCollected; uint128 amountWithdrawn;
17,605
208
// Transfer non-taxed amount
super._transfer(from, to, transferAmount);
super._transfer(from, to, transferAmount);
36,732
77
// Decrease the amount of tokens that an owner has allowed to a spender.spender The address which will spend the funds. subtractedValue The amount of tokens to decrease the allowance by. /
function decreaseAllowance( address spender, uint256 subtractedValue ) external returns (bool)
function decreaseAllowance( address spender, uint256 subtractedValue ) external returns (bool)
10,293
22
// method to get all the forwarder bridge adapters of a chain chainId id of the chain we want to get the adapters fromreturn an array of chain configurations where the bridge adapter can communicate /
function getForwarderBridgeAdaptersByChain(
function getForwarderBridgeAdaptersByChain(
17,419
10
// WARNING: OFF-BY-ONE -> LAST PIXEL NEVER MUTATED
uint8 pixelIndex = uint8((nonce >> 16) % 10); uint8 byteIndex = uint8(iWord % 3) + pixelIndex * 3; bytes32 nullMask = bytes32(~(0xFFFFFF << (byteIndex * 8))); bytes32 valueMask = bytes32(mutationColor << (byteIndex * 8)); emit DbgPrint("iWord", iWord); emit DbgPrint("pixelIndex", pixelIndex); emit DbgPrint("byteIndex", byteIndex); emit DbgPrint("nullMask", uint256(nullMask));
uint8 pixelIndex = uint8((nonce >> 16) % 10); uint8 byteIndex = uint8(iWord % 3) + pixelIndex * 3; bytes32 nullMask = bytes32(~(0xFFFFFF << (byteIndex * 8))); bytes32 valueMask = bytes32(mutationColor << (byteIndex * 8)); emit DbgPrint("iWord", iWord); emit DbgPrint("pixelIndex", pixelIndex); emit DbgPrint("byteIndex", byteIndex); emit DbgPrint("nullMask", uint256(nullMask));
12,879
91
// Yields the excess beyond the floor of x./Based on the odd function definition https:en.wikipedia.org/wiki/Fractional_part./x The unsigned 60.18-decimal fixed-point number to get the fractional part of./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) } }
function frac(uint256 x) internal pure returns (uint256 result) { assembly { result := mod(x, SCALE) } }
32,421
358
// Resolves the bet of the supplied player._playerAddress The address of the player whos bet we are resolving return int The total profit the player earned, positive or negative/
function finishBetFrom(address _playerAddress) internal returns (int);
function finishBetFrom(address _playerAddress) internal returns (int);
32,536
3
// Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend)./
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
44,965
6
// Check if the sender has enough require(balanceOf[fromAddress] >= amount); Check for overflows require(balanceOf[receiver] + amount > balanceOf[receiver]); Save this for an assertion in the future uint previousBalances = balanceOf[fromAddress] + balanceOf[receiver]; Subtract from the sender
balanceOf[fromAddress] -= amount;
balanceOf[fromAddress] -= amount;
12,151
21
// Release dates for adviors: one twelfth released each month.
uint256[12] public ADVISORS_LOCK_DATES = [1521072000, 1523750400, 1526342400, 1529020800, 1531612800, 1534291200, 1536969600, 1539561600, 1542240000, 1544832000, 1547510400, 1550188800];
uint256[12] public ADVISORS_LOCK_DATES = [1521072000, 1523750400, 1526342400, 1529020800, 1531612800, 1534291200, 1536969600, 1539561600, 1542240000, 1544832000, 1547510400, 1550188800];
8,557
64
// addresses that can make transfers before official launch
mapping (address => bool) private canTransferBeforeTradingIsEnabled; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 5000000 * 10**9; uint256 private numTokensSellToAddToLiquidity = 500000 * 10**9;
mapping (address => bool) private canTransferBeforeTradingIsEnabled; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 5000000 * 10**9; uint256 private numTokensSellToAddToLiquidity = 500000 * 10**9;
5,964
16
// 超级节点奖励余额
uint256 public superRewordAmount;
uint256 public superRewordAmount;
85,415
102
// Losing house
House memory losingHouse = wars[warIndex].firstHouse.houseTicker == _winningHouse ? wars[warIndex].secondHouse : wars[warIndex].firstHouse;
House memory losingHouse = wars[warIndex].firstHouse.houseTicker == _winningHouse ? wars[warIndex].secondHouse : wars[warIndex].firstHouse;
6,151
86
// internal function to calculate how much to give to owner of contract_sellingPrice the current price of the team_sellingTeam if you're selling a team or a player return payment amount the owner gets after commission./
function _calculatePaymentToOwner(uint _sellingPrice, bool _sellingTeam) private pure returns (uint payment) { uint multiplier = 1; if (! _sellingTeam) { multiplier = 2; } uint commissionAmount = 100; if (_sellingPrice < FIRST_PRICE_LIMIT) { commissionAmount = commissionAmount.sub(FIRST_COMMISSION_LEVEL.mul(multiplier)); payment = uint256(_sellingPrice.mul(commissionAmount).div(100)); } else if (_sellingPrice < SECOND_PRICE_LIMIT) { commissionAmount = commissionAmount.sub(SECOND_COMMISSION_LEVEL.mul(multiplier)); payment = uint256(_sellingPrice.mul(commissionAmount).div(100)); } else if (_sellingPrice < THIRD_PRICE_LIMIT) { commissionAmount = commissionAmount.sub(THIRD_COMMISSION_LEVEL.mul(multiplier)); payment = uint256(_sellingPrice.mul(commissionAmount).div(100)); } else { commissionAmount = commissionAmount.sub(FOURTH_COMMISSION_LEVEL.mul(multiplier)); payment = uint256(_sellingPrice.mul(commissionAmount).div(100)); } }
function _calculatePaymentToOwner(uint _sellingPrice, bool _sellingTeam) private pure returns (uint payment) { uint multiplier = 1; if (! _sellingTeam) { multiplier = 2; } uint commissionAmount = 100; if (_sellingPrice < FIRST_PRICE_LIMIT) { commissionAmount = commissionAmount.sub(FIRST_COMMISSION_LEVEL.mul(multiplier)); payment = uint256(_sellingPrice.mul(commissionAmount).div(100)); } else if (_sellingPrice < SECOND_PRICE_LIMIT) { commissionAmount = commissionAmount.sub(SECOND_COMMISSION_LEVEL.mul(multiplier)); payment = uint256(_sellingPrice.mul(commissionAmount).div(100)); } else if (_sellingPrice < THIRD_PRICE_LIMIT) { commissionAmount = commissionAmount.sub(THIRD_COMMISSION_LEVEL.mul(multiplier)); payment = uint256(_sellingPrice.mul(commissionAmount).div(100)); } else { commissionAmount = commissionAmount.sub(FOURTH_COMMISSION_LEVEL.mul(multiplier)); payment = uint256(_sellingPrice.mul(commissionAmount).div(100)); } }
13,896
12
// Check for the case where there is a bid from the new owner and refund it. Any other bid can stay in place.
Bid bid = punkBids[punkIndex]; if (bid.bidder == to) {
Bid bid = punkBids[punkIndex]; if (bid.bidder == to) {
21,998
1
// Configure access control
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(SNAPSHOT_ROLE, msg.sender); _setupRole(MINTER_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(SNAPSHOT_ROLE, msg.sender); _setupRole(MINTER_ROLE, msg.sender);
30,648
17
// This function is called for plain Ether transfers, i.e. for every call with empty calldata. /
receive() external payable {} /** * @dev Fallback function is executed if none of the other functions match the function * identifier or no data was provided with the function call. */ fallback() external payable {} /** * @notice Creates a new vesting schedule for a beneficiary. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start start time of the vesting period * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _slicePeriodSeconds duration of a slice period for the vesting in seconds * @param _revocable whether the vesting is revocable or not * @param _amount total amount of tokens to be released at the end of the vesting */ function createVestingSchedule( address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, uint256 _slicePeriodSeconds, bool _revocable, uint256 _amount ) external onlyOwner { require( getWithdrawableAmount() >= _amount, "TokenVesting: cannot create vesting schedule because not sufficient tokens" ); require(_duration > 0, "TokenVesting: duration must be > 0"); require(_amount > 0, "TokenVesting: amount must be > 0"); require( _slicePeriodSeconds >= 1, "TokenVesting: slicePeriodSeconds must be >= 1" ); require(_duration >= _cliff, "TokenVesting: duration must be >= cliff"); bytes32 vestingScheduleId = computeNextVestingScheduleIdForHolder( _beneficiary ); uint256 cliff = _start + _cliff; vestingSchedules[vestingScheduleId] = VestingSchedule( _beneficiary, cliff, _start, _duration, _slicePeriodSeconds, _revocable, _amount, 0, false ); vestingSchedulesTotalAmount = vestingSchedulesTotalAmount + _amount; vestingSchedulesIds.push(vestingScheduleId); uint256 currentVestingCount = holdersVestingCount[_beneficiary]; holdersVestingCount[_beneficiary] = currentVestingCount + 1; }
receive() external payable {} /** * @dev Fallback function is executed if none of the other functions match the function * identifier or no data was provided with the function call. */ fallback() external payable {} /** * @notice Creates a new vesting schedule for a beneficiary. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start start time of the vesting period * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _slicePeriodSeconds duration of a slice period for the vesting in seconds * @param _revocable whether the vesting is revocable or not * @param _amount total amount of tokens to be released at the end of the vesting */ function createVestingSchedule( address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, uint256 _slicePeriodSeconds, bool _revocable, uint256 _amount ) external onlyOwner { require( getWithdrawableAmount() >= _amount, "TokenVesting: cannot create vesting schedule because not sufficient tokens" ); require(_duration > 0, "TokenVesting: duration must be > 0"); require(_amount > 0, "TokenVesting: amount must be > 0"); require( _slicePeriodSeconds >= 1, "TokenVesting: slicePeriodSeconds must be >= 1" ); require(_duration >= _cliff, "TokenVesting: duration must be >= cliff"); bytes32 vestingScheduleId = computeNextVestingScheduleIdForHolder( _beneficiary ); uint256 cliff = _start + _cliff; vestingSchedules[vestingScheduleId] = VestingSchedule( _beneficiary, cliff, _start, _duration, _slicePeriodSeconds, _revocable, _amount, 0, false ); vestingSchedulesTotalAmount = vestingSchedulesTotalAmount + _amount; vestingSchedulesIds.push(vestingScheduleId); uint256 currentVestingCount = holdersVestingCount[_beneficiary]; holdersVestingCount[_beneficiary] = currentVestingCount + 1; }
20,763
11
// end index for trailing/leading 0's for very small/large numbers
uint8 zerosEndIndex;
uint8 zerosEndIndex;
1,565
5
// withdrawGasToken()
function withdrawGasToken() external onlyOwner
function withdrawGasToken() external onlyOwner
34,173
248
// The initial timestamp (in seconds) to start rotation
uint256 public startDate;
uint256 public startDate;
4,855
0
// Modifiers/
modifier onlyOwner()
modifier onlyOwner()
19,945
78
// Parses inputs and runs the single implemented action through a proxy/Used to save gas when executing a single action directly
function executeActionDirect(bytes[] memory _callData) public virtual payable;
function executeActionDirect(bytes[] memory _callData) public virtual payable;
7,694
6
// for testing purposes function transferFrom( address _from, address _to, uint256 _value
// ) public returns (bool success) { // require(address2balance[_from] >= _value, "not enough funds"); // address2balance[_to] += _value; // address2balance[_from] -= _value; // emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars // return true; // }
// ) public returns (bool success) { // require(address2balance[_from] >= _value, "not enough funds"); // address2balance[_to] += _value; // address2balance[_from] -= _value; // emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars // return true; // }
21,302
83
// refund
msg.sender.transfer(offerFetched.price);
msg.sender.transfer(offerFetched.price);
5,700
44
// Calculate square root of x.Return NaN on negative x excluding -0.x quadruple precision numberreturn quadruple precision number /
function sqrt(bytes16 x) internal pure returns (bytes16) { if (uint128(x) > 0x80000000000000000000000000000000) return NaN; else { uint256 xExponent = (uint128(x) >> 112) & 0x7FFF; if (xExponent == 0x7FFF) return x; else { uint256 xSignifier = uint128(x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF; if (xExponent == 0) xExponent = 1; else xSignifier |= 0x10000000000000000000000000000; if (xSignifier == 0) return POSITIVE_ZERO; bool oddExponent = xExponent & 0x1 == 0; xExponent = (xExponent + 16383) >> 1; if (oddExponent) { if (xSignifier >= 0x10000000000000000000000000000) xSignifier <<= 113; else { uint256 msb = msbFunc(xSignifier); uint256 shift = (226 - msb) & 0xFE; xSignifier <<= shift; xExponent -= (shift - 112) >> 1; } } else { if (xSignifier >= 0x10000000000000000000000000000) xSignifier <<= 112; else { uint256 msb = msbFunc(xSignifier); uint256 shift = (225 - msb) & 0xFE; xSignifier <<= shift; xExponent -= (shift - 112) >> 1; } } uint256 r = 0x10000000000000000000000000000; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; // Seven iterations should be enough uint256 r1 = xSignifier / r; if (r1 < r) r = r1; return bytes16( uint128( (xExponent << 112) | (r & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF) ) ); } } }
function sqrt(bytes16 x) internal pure returns (bytes16) { if (uint128(x) > 0x80000000000000000000000000000000) return NaN; else { uint256 xExponent = (uint128(x) >> 112) & 0x7FFF; if (xExponent == 0x7FFF) return x; else { uint256 xSignifier = uint128(x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF; if (xExponent == 0) xExponent = 1; else xSignifier |= 0x10000000000000000000000000000; if (xSignifier == 0) return POSITIVE_ZERO; bool oddExponent = xExponent & 0x1 == 0; xExponent = (xExponent + 16383) >> 1; if (oddExponent) { if (xSignifier >= 0x10000000000000000000000000000) xSignifier <<= 113; else { uint256 msb = msbFunc(xSignifier); uint256 shift = (226 - msb) & 0xFE; xSignifier <<= shift; xExponent -= (shift - 112) >> 1; } } else { if (xSignifier >= 0x10000000000000000000000000000) xSignifier <<= 112; else { uint256 msb = msbFunc(xSignifier); uint256 shift = (225 - msb) & 0xFE; xSignifier <<= shift; xExponent -= (shift - 112) >> 1; } } uint256 r = 0x10000000000000000000000000000; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; r = (r + xSignifier / r) >> 1; // Seven iterations should be enough uint256 r1 = xSignifier / r; if (r1 < r) r = r1; return bytes16( uint128( (xExponent << 112) | (r & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF) ) ); } } }
5,759
183
// This will pay 5% of the initial sale to this address (Ethvaders DAO Fund). You can remove this if you want, or keep it. =============================================================================
(bool hs, ) = payable(0xCd4dD5dcc7cDEAfA620B6C4b4B2bab86F7Cfca1c).call{value: address(this).balance * 5 / 100}("");
(bool hs, ) = payable(0xCd4dD5dcc7cDEAfA620B6C4b4B2bab86F7Cfca1c).call{value: address(this).balance * 5 / 100}("");
32,837
80
// Create a transaction. UNTRUSTED._amount The amount of tokens in this transaction._token The ERC20 token contract._timeoutPayment Time after which a party automatically loses a dispute._receiver The recipient of the transaction._metaEvidence Link to the meta-evidence. return The index of the transaction. /
function createTransaction( uint _amount, ERC20 _token, uint _timeoutPayment, address _receiver, string _metaEvidence
function createTransaction( uint _amount, ERC20 _token, uint _timeoutPayment, address _receiver, string _metaEvidence
40,643
55
// Whether `a` is less than or equal to `b`. a a FixedPoint.Signed. b an int256.return True if `a <= b`, or False. /
function isLessThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue <= fromUnscaledInt(b).rawValue; }
function isLessThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue <= fromUnscaledInt(b).rawValue; }
5,962
5
// BetId -> User -> Total bet per user
mapping(string => mapping(address => uint256)) public userPools;
mapping(string => mapping(address => uint256)) public userPools;
10,459
3
// Extend parent behavior requiring purchase to respect the funding cap. weiAmount Amount of wei contributed /
function _preValidatePurchase( address, /* beneficiary */ uint256 weiAmount
function _preValidatePurchase( address, /* beneficiary */ uint256 weiAmount
45,592