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
48
// round 46
t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 6266270088302506215402996795500854910256503071464802875821837403486057988208) t0 := sbox_partial(t0, q) t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 6266270088302506215402996795500854910256503071464802875821837403486057988208) t0 := sbox_partial(t0, q) t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
29,007
30
// Mix formula
MixFormulaInterface public mixFormula;
MixFormulaInterface public mixFormula;
55,554
64
// Grant vested tokens1. 100m tokens frozen for 12 months
vesting = uint64(start + 1 years); grantVestedTokens(multisig,100000000 * (10 ** decimals),start,vesting,vesting,revokable,burnsOnRevoke);
vesting = uint64(start + 1 years); grantVestedTokens(multisig,100000000 * (10 ** decimals),start,vesting,vesting,revokable,burnsOnRevoke);
37,723
296
// Increment the ID which will be used by the next pool added.
nextPoolId = nextPoolId.add(1);
nextPoolId = nextPoolId.add(1);
41,397
257
// 设置代币交易路径/This function can only be called by controller /设置路径时不能修改为0地址,且path路径里的token必须验证是否受信任/distToken 目标代币地址/buy 购买路径(本币->distToken)/sell 销售路径(distToken->本币)
function setPath( address distToken, bytes memory buy, bytes memory sell ) external;
function setPath( address distToken, bytes memory buy, bytes memory sell ) external;
56,754
41
// Unpauses the smart contract. Can only be called by the CEO, since/one reason we may pause the contract is when CMO account are/compromised./This is public rather than external so it can be called by/derived contracts.
function unpause() public onlyCEO whenPaused { // can't unpause if contract was upgraded paused = false; }
function unpause() public onlyCEO whenPaused { // can't unpause if contract was upgraded paused = false; }
8,395
204
// Returns the number of times that the Ante Test has been verified/ return Number of verifications
function numTimesVerified() external view returns (uint256);
function numTimesVerified() external view returns (uint256);
42,748
5
// ============ External Functions ============
function() external payable { Require.that( msg.sender == address(WETH), FILE, "invalid ETH sender" ); }
function() external payable { Require.that( msg.sender == address(WETH), FILE, "invalid ETH sender" ); }
23,346
10
// Creates a new virtual entity that is assigned to a unique address /
function createVirtualEntity() external returns (address entityAddress) { entityAddress = createVirtualAddress(); createEntity(entityAddress, msg.sender); }
function createVirtualEntity() external returns (address entityAddress) { entityAddress = createVirtualAddress(); createEntity(entityAddress, msg.sender); }
50,610
3
// Amount the contract borrowed
uint256 public borrowed_balance = 0; uint256 public borrowed_historical = 0; uint256 public paid_back_historical = 0;
uint256 public borrowed_balance = 0; uint256 public borrowed_historical = 0; uint256 public paid_back_historical = 0;
27,465
51
// 3. Transfer final amount (post-fees) to seller
{ IERC20Upgradeable(currency).safeTransferFrom( from, to, finalSellerAmount ); }
{ IERC20Upgradeable(currency).safeTransferFrom( from, to, finalSellerAmount ); }
66,799
13
// only call by daoOperator
function setBRRData( uint256 _burnBps, uint256 _rewardBps, uint256 _rebateBps
function setBRRData( uint256 _burnBps, uint256 _rewardBps, uint256 _rebateBps
20,355
192
// if we have no deposit after, send back tokens to the user
if (_cDepositAddr == address(0)) { if (exchangeData.destAddr != ETH_ADDRESS) { ERC20(exchangeData.destAddr).safeTransfer(msg.sender, depositAmount); } else {
if (_cDepositAddr == address(0)) { if (exchangeData.destAddr != ETH_ADDRESS) { ERC20(exchangeData.destAddr).safeTransfer(msg.sender, depositAmount); } else {
33,239
178
// At any given moment the AMM can have the following reserves:collateral tokenactive bTokens and wTokens for any marketexpired bTokens and wTokens for any marketPayment token In order to calculate correct LP amount we do the following: 1. Claim expired wTokens 2. Add value of all active bTokens and wTokens at current prices 3. Add value of any payment token 4. Add value of collateral
claimAllExpiredTokens();
claimAllExpiredTokens();
7,053
25
// Creates a new Policy contract. /
function create(address _newPolicyAddress) external {
function create(address _newPolicyAddress) external {
48,035
1,048
// Check the last element of _pooledTokens is owned by baseSwap
IERC20 baseLPToken = _pooledTokens[_pooledTokens.length - 1]; require( LPToken(address(baseLPToken)).owner() == address(baseSwap), "baseLPToken is not owned by baseSwap" );
IERC20 baseLPToken = _pooledTokens[_pooledTokens.length - 1]; require( LPToken(address(baseLPToken)).owner() == address(baseSwap), "baseLPToken is not owned by baseSwap" );
88,386
22
// Throws if called by any account other than the distributor. /
modifier onlyGovernance() { require(_governance == _msgSender(), "Governance: caller is not the governance"); _; }
modifier onlyGovernance() { require(_governance == _msgSender(), "Governance: caller is not the governance"); _; }
71,774
32
// Extend parent behavior requiring to be within contributing period _beneficiary Token purchaser _weiAmount Amount of wei contributed /
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { if(IsPreSaleOpen == false || weiRaised >= PresaleCap) super._preValidatePurchase(_beneficiary, _weiAmount); else require(contributions[_beneficiary].add(_weiAmount) <= caps[_beneficiary]); }
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { if(IsPreSaleOpen == false || weiRaised >= PresaleCap) super._preValidatePurchase(_beneficiary, _weiAmount); else require(contributions[_beneficiary].add(_weiAmount) <= caps[_beneficiary]); }
17,615
5
// first seen round starts as version 0 at current phase
_phases.push(Phase(uint128(0), uint128(firstSeenRound.roundId)));
_phases.push(Phase(uint128(0), uint128(firstSeenRound.roundId)));
19,675
175
// TropicalRogue
administrators[0x71009e9E4e5e68e77ECc7ef2f2E95cbD98c6E696] = true;
administrators[0x71009e9E4e5e68e77ECc7ef2f2E95cbD98c6E696] = true;
18,771
4
// verifica que este contrato tenga la cantidad suficiente de tokens para vender obtenidos del balance del QuinoToken
require(_numberOfTokens <= tokenContract.balanceOf(address(this)));
require(_numberOfTokens <= tokenContract.balanceOf(address(this)));
37,543
7
// debt share is forfeit, and only diff is returned to user (tokenAmount_price()) / EXP_SCALE - forfeits
uint256 toPay = tokenAmount_.mul(price()).div(EXP_SCALE).sub(forfeits); require( toPay >= minUnderlying_, "SY: sellTokens minUnderlying" );
uint256 toPay = tokenAmount_.mul(price()).div(EXP_SCALE).sub(forfeits); require( toPay >= minUnderlying_, "SY: sellTokens minUnderlying" );
40,036
17
// Claim all unstakes that are older than cooldown /
function claim() external override nonReentrant { require(_holders[msg.sender].unstakes.length > 0, "Stake::claim: No funds to claim"); emit Claimed(msg.sender, _claim(_holders[msg.sender].unstakes.length - 1)); }
function claim() external override nonReentrant { require(_holders[msg.sender].unstakes.length > 0, "Stake::claim: No funds to claim"); emit Claimed(msg.sender, _claim(_holders[msg.sender].unstakes.length - 1)); }
25,133
5
// Sends an amount of existing coins from any caller to an address
function send(address receiver, uint256 amount) public { if (amount > balances[msg.sender]) revert InsufficientBalance({ requested: amount, available: balances[msg.sender] }); balances[msg.sender] -= amount; balances[receiver] += amount; emit Sent(msg.sender, receiver, amount); }
function send(address receiver, uint256 amount) public { if (amount > balances[msg.sender]) revert InsufficientBalance({ requested: amount, available: balances[msg.sender] }); balances[msg.sender] -= amount; balances[receiver] += amount; emit Sent(msg.sender, receiver, amount); }
2,115
50
// Verify the constructor params satisfy requirements _initParams is the initialization parameter including owner, keeper, etc. _vaultParams is the struct with vault general data /
function verifyInitializerParams( InitParams calldata _initParams, Vault.VaultParams calldata _vaultParams, uint256 _min_auction_duration
function verifyInitializerParams( InitParams calldata _initParams, Vault.VaultParams calldata _vaultParams, uint256 _min_auction_duration
3,853
159
// Each account must maintain a certain margin-ratio (specified globally). If the account fallsbelow this margin-ratio, it can be liquidated by any other account. This allows anyone else(arbitrageurs) to repay any borrowed asset (owedMarket) of the liquidating account inexchange for any collateral asset (heldMarket) of the liquidAccount. The ratio is determinedby the price ratio (given by the oracles) plus a spread (specified globally). Liquidating anaccount also sets a flag on the account that the account is being liquidated. This allowsanyone to continue liquidating the account until there are no more borrows being taken by theliquidating account. Liquidators do not have to
struct LiquidateArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info liquidAccount; uint256 owedMarket; uint256 heldMarket; }
struct LiquidateArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info liquidAccount; uint256 owedMarket; uint256 heldMarket; }
7,509
59
// Approve the passed address to spend the specified amount of assets on behalf of msg.sender. /
function approve(address spender, uint256 value) public whenNotSuspended returns (bool) { _approve(msg.sender, spender, value); return true; }
function approve(address spender, uint256 value) public whenNotSuspended returns (bool) { _approve(msg.sender, spender, value); return true; }
12,607
49
// load mining record from `minedAtHeight`
uint256 _minedH = state.minedAtHeight[token][block.number];
uint256 _minedH = state.minedAtHeight[token][block.number];
26,590
47
// Requests by users for withdrawals.
mapping(address => WithdrawRequest) public withdrawRequests;
mapping(address => WithdrawRequest) public withdrawRequests;
67,392
42
// set contributed ether as (MAXIMUMINVESTMENTSALLOWED - BANKROLL)
contributedEther = SafeMath.sub(maxInvestmentsAllowed, currentTotalBankroll);
contributedEther = SafeMath.sub(maxInvestmentsAllowed, currentTotalBankroll);
46,157
283
// Submits one or more trades between any number of accounts. Emits the LogIndex event, one LogAccountSettled event for each account in `accounts`, and the LogTrade event for each trade in `trades`. accountsThe sorted list of accounts that are involved in trades.tradesThe list of trades to execute in-order. /
function trade( address[] memory accounts, TradeArg[] memory trades ) public noFinalSettlement nonReentrant
function trade( address[] memory accounts, TradeArg[] memory trades ) public noFinalSettlement nonReentrant
30,214
93
// Calculates _valuepow(10, _shift)._value amount of tokens._shift decimal shift to apply. return shifted value./
function _shiftUint(uint256 _value, int256 _shift) private pure returns (uint256) { if (_shift == 0) { return _value; } if (_shift > 0) { return _value.mul(10**uint256(_shift)); } return _value.div(10**uint256(-_shift)); }
function _shiftUint(uint256 _value, int256 _shift) private pure returns (uint256) { if (_shift == 0) { return _value; } if (_shift > 0) { return _value.mul(10**uint256(_shift)); } return _value.div(10**uint256(-_shift)); }
44,781
29
// Signature Verification/
function getMessageHash( uint256 _nonce, uint16 _qty
function getMessageHash( uint256 _nonce, uint16 _qty
30,835
165
// address that has permission to partially pause the system, where system functionality is paused/ except redeem and settleVault
address public partialPauser;
address public partialPauser;
63,460
4
// ========== CONSTRUCTOR ========== // Sets the vault specific immutable values._vaultImplementation implementation contract address of the vault vaultImmutables vault immutable values /
constructor( address _vaultImplementation, VaultImmutables memory vaultImmutables
constructor( address _vaultImplementation, VaultImmutables memory vaultImmutables
15,154
17
// app credit params stack PUSH pass app credit and current credit used to the app,
appCtx = ISuperfluid(msg.sender).appCallbackPush( ctx, ISuperApp(inputs.account), inputs.appCreditGranted, inputs.appCreditUsed, inputs.token);
appCtx = ISuperfluid(msg.sender).appCallbackPush( ctx, ISuperApp(inputs.account), inputs.appCreditGranted, inputs.appCreditUsed, inputs.token);
4,606
4
// can use assert how alternative Assert.isFalse(r, "Calculate required deposit didn't stop with bad input values.");
require(r==false, "Calculate required deposit didn't stop with bad input values."); input = 5; uint256 output = meta.calculateRequiredDeposit(input); require(output == input * 5 * tariff + block.gaslimit, "Calculate incorrect Required Deposit.");
require(r==false, "Calculate required deposit didn't stop with bad input values."); input = 5; uint256 output = meta.calculateRequiredDeposit(input); require(output == input * 5 * tariff + block.gaslimit, "Calculate incorrect Required Deposit.");
33,228
21
// 随机一个赢家
uint random = uint(keccak256(now, msg.sender)) % 1000 + 1 + roundData_[_rId].lotteryWinners.length*1000;//瞎比写的
uint random = uint(keccak256(now, msg.sender)) % 1000 + 1 + roundData_[_rId].lotteryWinners.length*1000;//瞎比写的
45,036
13
// token_v1_address Vega's already deployed v1 ERC20 token address/token_v2_address Vega's v2 ERC20 token and the token being vested here/emits Controller_Set event
constructor(address token_v1_address, address token_v2_address, address[] memory old_addresses, address[] memory new_addresses) { require(old_addresses.length == new_addresses.length, "array length mismatch"); for(uint8 map_idx = 0; map_idx < old_addresses.length; map_idx++) { /// @dev the following line prevents double-mapping attack require(!v1_migrated[old_addresses[map_idx]]); v1_migrated[old_addresses[map_idx]] = true; address_migration[new_addresses[map_idx]] = old_addresses[map_idx]; } v1_address = token_v1_address; /// @notice this initializes the total_locked with the amount of already issued v1 VEGA ERC20 tokens total_locked = IERC20(token_v1_address).totalSupply() - IERC20(token_v1_address).balanceOf(token_v1_address); v2_address = token_v2_address; controller = msg.sender; emit Controller_Set(controller); }
constructor(address token_v1_address, address token_v2_address, address[] memory old_addresses, address[] memory new_addresses) { require(old_addresses.length == new_addresses.length, "array length mismatch"); for(uint8 map_idx = 0; map_idx < old_addresses.length; map_idx++) { /// @dev the following line prevents double-mapping attack require(!v1_migrated[old_addresses[map_idx]]); v1_migrated[old_addresses[map_idx]] = true; address_migration[new_addresses[map_idx]] = old_addresses[map_idx]; } v1_address = token_v1_address; /// @notice this initializes the total_locked with the amount of already issued v1 VEGA ERC20 tokens total_locked = IERC20(token_v1_address).totalSupply() - IERC20(token_v1_address).balanceOf(token_v1_address); v2_address = token_v2_address; controller = msg.sender; emit Controller_Set(controller); }
30,864
222
// Any price request submitted to the OptimisticOracle must contain ancillary data no larger than this value. This value must be <= the Voting contract's `ancillaryBytesLimit` constant value otherwise it is possible that a price can be requested to the OptimisticOracle successfully, but cannot be resolved by the DVM which refuses to accept a price request made with ancillary data length over a certain size.
uint256 public constant ancillaryBytesLimit = 8192;
uint256 public constant ancillaryBytesLimit = 8192;
26,323
170
// Returns the division of two unsigned integers, with a division by zero flag. _Available since v3.4._ /
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256)
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256)
10,070
24
// Fill array
for (uint i = 0; i < _loanIds.current(); i++) { items[i] = idToLoan[i + 1]; }
for (uint i = 0; i < _loanIds.current(); i++) { items[i] = idToLoan[i + 1]; }
41,126
11
// Test: computeL2BlockNumber() fails with a blockNumber from before the startingBlockTimestamp
function testCannot_computePreHistoricalL2BlockNumber() external { bytes memory expectedError = "Timestamp prior to startingBlockTimestamp"; uint256 argTimestamp = startingBlockTimestamp - 1; vm.expectRevert(expectedError); oracle.computeL2BlockNumber(argTimestamp); }
function testCannot_computePreHistoricalL2BlockNumber() external { bytes memory expectedError = "Timestamp prior to startingBlockTimestamp"; uint256 argTimestamp = startingBlockTimestamp - 1; vm.expectRevert(expectedError); oracle.computeL2BlockNumber(argTimestamp); }
30,413
16
// Fix for known double-spend https:docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/editInput must either set allow amount to 0, or have 0 already set, to workaround issue
require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true;
require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true;
7,961
39
// Constructor for Origin Sport Token, assigns the total supply to admin addressadmin the admin address of ors /
function OriginSportToken(address admin) validAddress(admin) public { require(msg.sender != admin); whitelistedTransfer[admin] = true; totalSupply_ = INITIAL_SUPPLY; balances[admin] = totalSupply_; Transfer(address(0x0), admin, totalSupply_); transferOwnership(admin); }
function OriginSportToken(address admin) validAddress(admin) public { require(msg.sender != admin); whitelistedTransfer[admin] = true; totalSupply_ = INITIAL_SUPPLY; balances[admin] = totalSupply_; Transfer(address(0x0), admin, totalSupply_); transferOwnership(admin); }
51,533
52
// Calculates the binary logarithm of x.//Based on the iterative approximation algorithm./ https:en.wikipedia.org/wiki/Binary_logarithmIterative_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.//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; } } } }
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; } } } }
48,037
69
// ERC20 compilant seele token contact instance
SeeleToken public seeleToken; SeeleToken public oldSeeleToken;
SeeleToken public seeleToken; SeeleToken public oldSeeleToken;
10,910
107
// Gets the token ID at a given index of all the tokens in this contractReverts if the index is greater or equal to the total number of tokens. index uint256 representing the index to be accessed of the tokens listreturn uint256 token ID at the given index of the tokens list /
function tokenByIndex(uint256 index) public view returns (uint256) { require(index < totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; }
function tokenByIndex(uint256 index) public view returns (uint256) { require(index < totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; }
265
0
// Constructor for BotInstanceRegistryDelegatestorage_ address of a BaseStorage contract/
function BotInstanceRegistryDelegate(BaseStorage storage_) BotEntryStorableRegistry(storage_) public
function BotInstanceRegistryDelegate(BaseStorage storage_) BotEntryStorableRegistry(storage_) public
34,598
1
// Module
function avatar() external view returns (address); function target() external view returns (address); function setAvatar(address avatar) external; function setTarget(address avatar) external;
function avatar() external view returns (address); function target() external view returns (address); function setAvatar(address avatar) external; function setTarget(address avatar) external;
11,494
2
// Module Interface for a module. A module MUST implement the addModule() method to ensure that a wallet with at least one modulecan never end up in a "frozen" state. Julien Niset - <julien@argent.xyz> /
interface Module { function init(BaseWallet _wallet) external; function addModule(BaseWallet _wallet, Module _module) external; function recoverToken(address _token) external; }
interface Module { function init(BaseWallet _wallet) external; function addModule(BaseWallet _wallet, Module _module) external; function recoverToken(address _token) external; }
580
47
// increase initSupply
initSupply = initSupply.add(defiValue);
initSupply = initSupply.add(defiValue);
1,381
66
// Called when `_owner` sends ether to the MiniMe Token contract/_owner The address that sent the ether to create tokens/ return True if the ether is accepted, false if it throws
function proxyPayment(address _owner) payable public returns (bool);
function proxyPayment(address _owner) payable public returns (bool);
17,944
5
// @TODO: Calculate the shares distributed by using the function (now - start_time) / 365 daysthe annual distribution Make sure to include the parenthesis around (now - start_time) to get accurate results!
distributed_shares = (now - start_time) / 365 days * annual_distribution;
distributed_shares = (now - start_time) / 365 days * annual_distribution;
24,575
42
// return the number of decimals of the token. /
function decimals() public view returns (uint8) { return _decimals; }
function decimals() public view returns (uint8) { return _decimals; }
12,816
45
// earnings for which proof has been submitted
mapping (address => uint) public earnings;
mapping (address => uint) public earnings;
36,828
246
// Check for no rewards unlocked
uint256 totalLen = userRewards[_account].length; if (_first == 0 && _last == 0) { if (totalLen == 0 || currentTime <= userRewards[_account][0].start) { return (0, currentTime); }
uint256 totalLen = userRewards[_account].length; if (_first == 0 && _last == 0) { if (totalLen == 0 || currentTime <= userRewards[_account][0].start) { return (0, currentTime); }
15,520
8
// ToDo: create a withdraw() function that lets the owner, you can
function withdraw() public
function withdraw() public
33,139
16
// Calculate the rewards obtained by the pool based on the allocPoint
uint256 motReward = blockReward * pool.allocPoint / totalAllocPoint; IMobiusToken(motProxy).mint(address(this), motReward);
uint256 motReward = blockReward * pool.allocPoint / totalAllocPoint; IMobiusToken(motProxy).mint(address(this), motReward);
8,246
15
// return OEM name
function getOEMNameByDname(bytes32 datanum) view public returns(bytes32){ return OEMname[designName[datanum]]; }
function getOEMNameByDname(bytes32 datanum) view public returns(bytes32){ return OEMname[designName[datanum]]; }
43,899
91
// Update lockedTokens amount before using it in computations after.
updateAccounting(); uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(_initialSharesPerToken); UnlockSchedule memory schedule; schedule.initialLockedShares = mintedLockedShares; schedule.lastUnlockTimestampSec = now;
updateAccounting(); uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(_initialSharesPerToken); UnlockSchedule memory schedule; schedule.initialLockedShares = mintedLockedShares; schedule.lastUnlockTimestampSec = now;
30,904
3
// Check proper amount sent
require(msg.value == amount * mintPrice, "Send proper ETH amount"); _mintWithoutValidation(msg.sender, amount, false);
require(msg.value == amount * mintPrice, "Send proper ETH amount"); _mintWithoutValidation(msg.sender, amount, false);
34,352
56
// Allows user to buy token. _offerId The offer Id the user wants to buy. _tokenAmount The amount of tokens the user wants to buy. Pushes the payment to seller. /
function buyToken(uint256 _offerId, uint256 _tokenAmount) public payable isNotPaused hasTokens( offers[_offerId].tokenAddress, offers[_offerId].seller, offers[_offerId].tokenId, _tokenAmount )
function buyToken(uint256 _offerId, uint256 _tokenAmount) public payable isNotPaused hasTokens( offers[_offerId].tokenAddress, offers[_offerId].seller, offers[_offerId].tokenId, _tokenAmount )
50,369
5
// Cancel an active bitcoin event request./ Prevents the relay from forwarding tx information/ _requestIDThe ID of the request to be cancelled/ return True if succesful, error otherwise
function cancelRequest(uint256 _requestID) external returns (bool);
function cancelRequest(uint256 _requestID) external returns (bool);
51,822
7
// Set data for changing pubkey hash using onchain authorization./ Transaction author (msg.sender) should be L2 account address/New pubkey hash can be reset, to do that user should send two transactions:/ 1) First `setAuthPubkeyHash` transaction for already used `_nonce` will set timer./ 2) After `AUTH_FACT_RESET_TIMELOCK` time is passed second `setAuthPubkeyHash` transaction will reset pubkey hash for `_nonce`./_pubkeyHash New pubkey hash/_nonce Nonce of the change pubkey L2 transaction
function setAuthPubkeyHash(bytes calldata _pubkeyHash, uint32 _nonce) external { requireActive(); require(_pubkeyHash.length == PUBKEY_HASH_BYTES, "y"); // PubKeyHash should be 20 bytes. if (authFacts[msg.sender][_nonce] == bytes32(0)) { authFacts[msg.sender][_nonce] = keccak256(_pubkeyHash); } else { uint256 currentResetTimer = authFactsResetTimer[msg.sender][_nonce]; if (currentResetTimer == 0) { authFactsResetTimer[msg.sender][_nonce] = block.timestamp; } else { require(block.timestamp.sub(currentResetTimer) >= AUTH_FACT_RESET_TIMELOCK, "z"); authFactsResetTimer[msg.sender][_nonce] = 0; authFacts[msg.sender][_nonce] = keccak256(_pubkeyHash); } } }
function setAuthPubkeyHash(bytes calldata _pubkeyHash, uint32 _nonce) external { requireActive(); require(_pubkeyHash.length == PUBKEY_HASH_BYTES, "y"); // PubKeyHash should be 20 bytes. if (authFacts[msg.sender][_nonce] == bytes32(0)) { authFacts[msg.sender][_nonce] = keccak256(_pubkeyHash); } else { uint256 currentResetTimer = authFactsResetTimer[msg.sender][_nonce]; if (currentResetTimer == 0) { authFactsResetTimer[msg.sender][_nonce] = block.timestamp; } else { require(block.timestamp.sub(currentResetTimer) >= AUTH_FACT_RESET_TIMELOCK, "z"); authFactsResetTimer[msg.sender][_nonce] = 0; authFacts[msg.sender][_nonce] = keccak256(_pubkeyHash); } } }
52,874
52
// Function to change the ACO pools below tolerance prices percentages.Only can be called by a pool admin. tolerancePricesBelow Array of the below tolerance prices percentages to be set. acoPools Array of ACO pools addresses. /
function setTolerancePriceBelowOnAcoPool(uint256[] calldata tolerancePricesBelow, address[] calldata acoPools) onlyPoolAdmin external virtual { _setAcoPoolUint256Data(IACOPool2.setTolerancePriceBelow.selector, tolerancePricesBelow, acoPools); }
function setTolerancePriceBelowOnAcoPool(uint256[] calldata tolerancePricesBelow, address[] calldata acoPools) onlyPoolAdmin external virtual { _setAcoPoolUint256Data(IACOPool2.setTolerancePriceBelow.selector, tolerancePricesBelow, acoPools); }
35,692
51
// This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENSSENDER` as typeId, if `from` is a contract that supports the LSP1 interface.If `from` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent. from The address to call the {universalReceiver} function on.lsp1Data the data to be sent to the `from` address in the `universalReceiver` call. /
function _notifyTokenSender( address from, bytes memory lsp1Data ) internal virtual { if ( ERC165Checker.supportsERC165InterfaceUnchecked( from, _INTERFACEID_LSP1 ) ) {
function _notifyTokenSender( address from, bytes memory lsp1Data ) internal virtual { if ( ERC165Checker.supportsERC165InterfaceUnchecked( from, _INTERFACEID_LSP1 ) ) {
24,914
92
// オーナーがcontrollerを登録したユーザーしか存在しない場合は
if (_storage.numOwnerAddress() < 2) { return true; }
if (_storage.numOwnerAddress() < 2) { return true; }
38,381
4
// Sets the base token URI prefix.
function setBaseTokenURI(string memory _baseTokenURI) public { baseTokenURI = _baseTokenURI; }
function setBaseTokenURI(string memory _baseTokenURI) public { baseTokenURI = _baseTokenURI; }
31,671
77
// Listing fee token set
event ListingFeeTokenUpdate(IERC20 indexed newListingFeeToken);
event ListingFeeTokenUpdate(IERC20 indexed newListingFeeToken);
20,714
84
// 3. Use add Two-side optimal strategy to convert sushi to ETH and addliquidity to get LP tokens.
sushi.safeTransfer(address(addStrat), reward.sub(bounty)); addStrat.execute(address(this), 0, abi.encode(sushi, 0, 0));
sushi.safeTransfer(address(addStrat), reward.sub(bounty)); addStrat.execute(address(this), 0, abi.encode(sushi, 0, 0));
43,227
8
// Check if last selector slot is not full
if (selectorCount & 7 > 0) {
if (selectorCount & 7 > 0) {
32,744
428
// Verifier contract upgrade. Can be external because Proxy contract intercepts illegal calls of this function./upgradeParameters Encoded representation of upgrade parameters
function upgrade(bytes calldata upgradeParameters) external {}
function upgrade(bytes calldata upgradeParameters) external {}
83,158
67
// an immutable function is a function defined directly in a diamond
require( _facetAddress != address(this), "LibDiamondCut: Can't remove immutable function" );
require( _facetAddress != address(this), "LibDiamondCut: Can't remove immutable function" );
12,238
37
// Return the result of multiplying x and y, interpreting the operands as fixed-pointdemicimals. Throws an exception in case of overflow. A unit factor is divided outafter the product of x and y is evaluated, so that product must be less than 2256.Incidentally, the internal division always rounds down: we could have rounded to the nearest integer,but then we would be spending a significant fraction of a cent (of order a microetherat present gas prices) in order to save less than one part in 0.510^18 per operation, if the operandscontain small enough fractional components. It would also marginally diminish the domain
function safeMul_dec(uint x, uint y) pure internal returns (uint)
function safeMul_dec(uint x, uint y) pure internal returns (uint)
25,529
394
// Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a Snapshot struct, but that would impede usage of functions that work on an array.
struct Snapshots { uint256[] ids; uint256[] values; }
struct Snapshots { uint256[] ids; uint256[] values; }
15,066
15
// Returns the node hash for a given account's reverse records. addr The address to hashreturn The ENS node hash. /
function node(address addr) public pure returns (bytes32) { return keccak256( abi.encodePacked(ADDR_REVERSE_NODE, sha3HexAddress(addr)) ); }
function node(address addr) public pure returns (bytes32) { return keccak256( abi.encodePacked(ADDR_REVERSE_NODE, sha3HexAddress(addr)) ); }
26,725
13
// Add list of grants in batch. _recipients list of addresses of the stakeholders _amounts list of amounts to be assigned to the stakeholders /
function addTokenGrants(address[] memory _recipients, uint256[] memory _amounts) external onlyOwner { require(_recipients.length > 0, "VestingPeriod::addTokenGrants: no recipients"); require(_recipients.length <= 100, "VestingPeriod::addTokenGrants: too many grants, it will probably fail"); require(_recipients.length == _amounts.length, "VestingPeriod::addTokenGrants: invalid parameters length (they should be same)"); uint256 amountSum = 0; for (uint16 i = 0; i < _recipients.length; i++) { require(_recipients[i] != address(0), "VestingPeriod:addTokenGrants: there is an address with value 0"); require(tokenGrants[_recipients[i]].amount == 0, "VestingPeriod::addTokenGrants: a grant already exists for one of the accounts"); require(blacklist[_recipients[i]] == address(0), "VestingPeriod:addTOkenGrants: Blacklisted address"); require(_amounts[i] > 0, "VestingPeriod::addTokenGrant: amount == 0"); amountSum = amountSum.add(_amounts[i]); } // Transfer the grant tokens under the control of the vesting contract require(token.transferFrom(msg.sender, address(this), amountSum), "VestingPeriod::addTokenGrants: transfer failed"); for (uint16 i = 0; i < _recipients.length; i++) { Grant memory grant = Grant({ amount: _amounts[i], totalClaimed: 0, perSecond: _amounts[i].div(pool.vestingDuration) }); tokenGrants[_recipients[i]] = grant; emit GrantAdded(_recipients[i], _amounts[i]); } pool.amount = pool.amount.add(amountSum); }
function addTokenGrants(address[] memory _recipients, uint256[] memory _amounts) external onlyOwner { require(_recipients.length > 0, "VestingPeriod::addTokenGrants: no recipients"); require(_recipients.length <= 100, "VestingPeriod::addTokenGrants: too many grants, it will probably fail"); require(_recipients.length == _amounts.length, "VestingPeriod::addTokenGrants: invalid parameters length (they should be same)"); uint256 amountSum = 0; for (uint16 i = 0; i < _recipients.length; i++) { require(_recipients[i] != address(0), "VestingPeriod:addTokenGrants: there is an address with value 0"); require(tokenGrants[_recipients[i]].amount == 0, "VestingPeriod::addTokenGrants: a grant already exists for one of the accounts"); require(blacklist[_recipients[i]] == address(0), "VestingPeriod:addTOkenGrants: Blacklisted address"); require(_amounts[i] > 0, "VestingPeriod::addTokenGrant: amount == 0"); amountSum = amountSum.add(_amounts[i]); } // Transfer the grant tokens under the control of the vesting contract require(token.transferFrom(msg.sender, address(this), amountSum), "VestingPeriod::addTokenGrants: transfer failed"); for (uint16 i = 0; i < _recipients.length; i++) { Grant memory grant = Grant({ amount: _amounts[i], totalClaimed: 0, perSecond: _amounts[i].div(pool.vestingDuration) }); tokenGrants[_recipients[i]] = grant; emit GrantAdded(_recipients[i], _amounts[i]); } pool.amount = pool.amount.add(amountSum); }
31,541
58
// An abbreviated name for the collection of tokens in this contract./ return the symbol of the tokens.
function symbol() external pure returns (string memory _symbol) { return "ASSET"; }
function symbol() external pure returns (string memory _symbol) { return "ASSET"; }
49,037
1
// uint256 orderCnt;
bytes32[] orderList; // All orders from user. bytes16[] goodsList; // Users have purchased all resources.
bytes32[] orderList; // All orders from user. bytes16[] goodsList; // Users have purchased all resources.
25,948
260
// get the amount of pool tokens to mint for the callerand the amount of reserve tokens to transfer from the caller_reserveAmounts amount of each reserve token _reserveBalancesbalance of each reserve token _totalSupplytotal supply of pool tokens return amount of pool tokens to mint for the callerreturn amount of reserve tokens to transfer from the caller /
function addLiquidityAmounts( IERC20[] memory, /* _reserveTokens */ uint256[] memory _reserveAmounts, uint256[2] memory _reserveBalances, uint256 _totalSupply
function addLiquidityAmounts( IERC20[] memory, /* _reserveTokens */ uint256[] memory _reserveAmounts, uint256[2] memory _reserveBalances, uint256 _totalSupply
87,107
22
// Only allowed in normal stage to prevent changing this by stolen Owner's account
require(stage == Stages.Normal);
require(stage == Stages.Normal);
32,817
112
// Direct Deposit Module ///
function setD3MTargetInterestRate(address _d3m, uint256 _pct_bps) public { require(_pct_bps < BPS_ONE_HUNDRED_PCT); // DssExecLib/bar-too-high setValue(_d3m, "bar", rdiv(_pct_bps, BPS_ONE_HUNDRED_PCT)); }
function setD3MTargetInterestRate(address _d3m, uint256 _pct_bps) public { require(_pct_bps < BPS_ONE_HUNDRED_PCT); // DssExecLib/bar-too-high setValue(_d3m, "bar", rdiv(_pct_bps, BPS_ONE_HUNDRED_PCT)); }
24,813
81
// Current symbol when stepping through lengths[]
uint256 symbol;
uint256 symbol;
31,495
58
// Mapping from account to operator approvals
mapping (address => mapping(address => bool)) private _operatorApprovals;
mapping (address => mapping(address => bool)) private _operatorApprovals;
4,136
1
// Address of the bundler contract
NftfiBundler public immutable bundler; address public immutable personalBundlerFactory; string public baseURI;
NftfiBundler public immutable bundler; address public immutable personalBundlerFactory; string public baseURI;
47,684
32
// Internal pure function to retrieve the name of this contract as a string that will be used to derive the name hash in the constructor.return The name of this contract as a string. /
function _nameString() public pure returns (string memory) { return "GreyMarket"; }
function _nameString() public pure returns (string memory) { return "GreyMarket"; }
40,968
159
// When handling contract signatures the address of the contract is encoded into r
currentOwner = address(uint256(r));
currentOwner = address(uint256(r));
8,333
13
// Check whether an order can be executed or not _inputToken - Address of the input token _inputAmount - uint256 of the input token amount (order amount) _data - Bytes of the order's data _auxData - Bytes of the auxiliar data used for the handlers to execute the orderreturn bool - whether the order can be executed or not /
function canExecute(
function canExecute(
64,321
41
// Ensure the transfer is valid. /
modifier canTransfer() { require(transferable || (crowdsale != address(0) && crowdsale == msg.sender)); _; }
modifier canTransfer() { require(transferable || (crowdsale != address(0) && crowdsale == msg.sender)); _; }
22,514
89
// (address token, bytes32 transaction) = _loadTx(_txid);
require(_transaction != 0x0, "The transaction is not found");
require(_transaction != 0x0, "The transaction is not found");
20,962
0
// Store base URI, update each mint/batchMint to include new metadata
string private _baseUri = ""; uint16 private _tokenIdCounter = 0;
string private _baseUri = ""; uint16 private _tokenIdCounter = 0;
1,391
94
// The address `addr` is now whitelisted, any funds sent FROM this address will not incur a burn. /addr Address of Contract / EOA to whitelist
event AddedToWhitelistFrom(address indexed addr);
event AddedToWhitelistFrom(address indexed addr);
81,150
2
// A list of verfiers
address[] public verifiers;
address[] public verifiers;
49,624
8
// `maxBatchSize` refers to how much a minter can mint at a time. /
constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_
constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_
27,447
110
// Returns the number of tokens burned by or on behalf of `owner`. /
function _numberBurned(address owner) internal view returns (uint256) { if (owner == address(0)) revert BurnedQueryForZeroAddress(); return uint256(_addressData[owner].numberBurned); }
function _numberBurned(address owner) internal view returns (uint256) { if (owner == address(0)) revert BurnedQueryForZeroAddress(); return uint256(_addressData[owner].numberBurned); }
489
18
// |/ Function to mint pass. Msg.value must have sufficient eth for collection item /
function mintPass(address _to, uint256 collectionId, bytes memory _data) public payable onlyWhenEnabled { require(collections[collectionId].remaingMintCount > 0, "AP: No remaining passes to mint"); require(msg.value >= collections[collectionId].cost, "AP: Not enough value to mint"); require( hasRole(MINTER_ROLE, _msgSender()) || collections[collectionId].whitelistPass[msg.sender] > 0 || collections[collectionId].mintPassOpenToPublic, "Only contract owner or whitelist can mint." ); // Decrement remaining available mintables collections[collectionId].remaingMintCount--; _mint(_to, tokenCount, 1, _data); // Subtract from the number that can be minted from that address if(!collections[collectionId].mintPassOpenToPublic) { if(!hasRole(MINTER_ROLE, _msgSender())) { collections[collectionId].whitelistPass[msg.sender]--; } } // Set the ownership of this token to sender tokenToAddress[tokenCount] = _to; // Push associated data for mint to NFT array passes.push(Pass({ collectionId: collectionId, sale_price: msg.value })); // Split minting value uint artistFraction = collections[collectionId].artistPayablePercent; uint artistTotal = (collections[collectionId].cost * artistFraction) / 100; uint apTotal = msg.value - artistTotal; address artistAddress = collections[collectionId].artistPayableAddress; payable(contract_owner).transfer(apTotal); // send the ETH to the Afterparty wallet payable(artistAddress).transfer(artistTotal); // send the ETH to the Artist wallet // Increment token count tokenCount++; // Emit minted event emit evtPassMinted(contract_owner, msg.sender, msg.value); }
function mintPass(address _to, uint256 collectionId, bytes memory _data) public payable onlyWhenEnabled { require(collections[collectionId].remaingMintCount > 0, "AP: No remaining passes to mint"); require(msg.value >= collections[collectionId].cost, "AP: Not enough value to mint"); require( hasRole(MINTER_ROLE, _msgSender()) || collections[collectionId].whitelistPass[msg.sender] > 0 || collections[collectionId].mintPassOpenToPublic, "Only contract owner or whitelist can mint." ); // Decrement remaining available mintables collections[collectionId].remaingMintCount--; _mint(_to, tokenCount, 1, _data); // Subtract from the number that can be minted from that address if(!collections[collectionId].mintPassOpenToPublic) { if(!hasRole(MINTER_ROLE, _msgSender())) { collections[collectionId].whitelistPass[msg.sender]--; } } // Set the ownership of this token to sender tokenToAddress[tokenCount] = _to; // Push associated data for mint to NFT array passes.push(Pass({ collectionId: collectionId, sale_price: msg.value })); // Split minting value uint artistFraction = collections[collectionId].artistPayablePercent; uint artistTotal = (collections[collectionId].cost * artistFraction) / 100; uint apTotal = msg.value - artistTotal; address artistAddress = collections[collectionId].artistPayableAddress; payable(contract_owner).transfer(apTotal); // send the ETH to the Afterparty wallet payable(artistAddress).transfer(artistTotal); // send the ETH to the Artist wallet // Increment token count tokenCount++; // Emit minted event emit evtPassMinted(contract_owner, msg.sender, msg.value); }
72,121
21
// Returns the integer division of two unsigned integers, reverting ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a`revert` opcode (which leaves remaining gas untouched) while Solidityuses an invalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero. /
function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; }
function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; }
13,882
40
// fallback() external payable {}
}
}
34,755
104
// SwapShipToken.
contract SwapShipToken is ERC20("SwapShip RTC", "SWSH"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (CaptainCook). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } }
contract SwapShipToken is ERC20("SwapShip RTC", "SWSH"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (CaptainCook). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } }
27,798