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
13
// set bank for getting assets bank_ - bank address /
function setBank(address bank_) external onlyBeneficiary{ bank = bank_; }
function setBank(address bank_) external onlyBeneficiary{ bank = bank_; }
36,498
1
// bytes32(uint256(keccak256('eip1967.Holograph.chainId')) - 1) /
bytes32 constant _chainIdSlot = 0x7651bfc11f7485d07ab2b41c1312e2007c8cb7efb0f7352a6dee4a1153eebab2;
bytes32 constant _chainIdSlot = 0x7651bfc11f7485d07ab2b41c1312e2007c8cb7efb0f7352a6dee4a1153eebab2;
25,617
12
// retrieve the size of the code on target address, this needs assembly
hash := extcodehash(_addr)
hash := extcodehash(_addr)
1,276
19
// check if the wallet is linked with an identity in the mapping
if (linkedIdentity[_wallet] != address(0)){ return true; }
if (linkedIdentity[_wallet] != address(0)){ return true; }
35,513
152
// set current amount to remaining unstake amount
currentAmount = unstakeAmount;
currentAmount = unstakeAmount;
12,081
44
// transfer ownership to the user initializing the sale
_transferOwnership(_owner);
_transferOwnership(_owner);
16,857
10
// Revert with an error if attempting to conduct the reveal phase before the prepared block number has been reached. /
error RevealNotReady();
error RevealNotReady();
31,853
208
// Emitted when base URI is changed.
event BaseURIChanged(string _baseURI);
event BaseURIChanged(string _baseURI);
1,584
370
// clone
clone,
clone,
20,849
71
// The finalizer contract that allows unlift the transfer limits on this token // A TTG contract can release us to the wild if ICO success. If false we are are in transfer lock up period.// Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. //Limit token transfer until the crowdsale is over./
modifier canTransfer(address _sender, uint _value) { //if owner can Transfer all the time if(_sender != owner){ if(isDeveloper()){ require(_value < maxTransferForDev); }else if(isFounder()){ require(_value < maxTransferFoFounds); }else if(maxTransfer != 0){ require(_value < maxTransfer); } if(!released) { require(transferAgents[_sender]); } } _; }
modifier canTransfer(address _sender, uint _value) { //if owner can Transfer all the time if(_sender != owner){ if(isDeveloper()){ require(_value < maxTransferForDev); }else if(isFounder()){ require(_value < maxTransferFoFounds); }else if(maxTransfer != 0){ require(_value < maxTransfer); } if(!released) { require(transferAgents[_sender]); } } _; }
70,383
267
// test if we can call the erc20.owner() method, etc also limit gas use to 3000 because we don't know what they'll do with it during testing both owned and controlled could be called from other contracts for 2525 gas.
if (erc20.call.gas(3000)(OWNER_SIG)) { require(msg.sender == owned(erc20).owner.gas(3000)(), "!erc20-owner"); } else if (erc20.call.gas(3000)(CONTROLLER_SIG)) {
if (erc20.call.gas(3000)(OWNER_SIG)) { require(msg.sender == owned(erc20).owner.gas(3000)(), "!erc20-owner"); } else if (erc20.call.gas(3000)(CONTROLLER_SIG)) {
4,116
36
// Work out the max token ID for an edition ID
function maxTokenIdOfEdition(uint256 _editionId) external view returns (uint256 _tokenId);
function maxTokenIdOfEdition(uint256 _editionId) external view returns (uint256 _tokenId);
3,070
0
// Absolute maximum fee percentages (1e18 = 100%, 1e16 = 1%).
uint256 private constant _MAX_PROTOCOL_SWAP_FEE_PERCENTAGE = 50e16; // 50% uint256 private constant _MAX_PROTOCOL_FLASH_LOAN_FEE_PERCENTAGE = 1e16; // 1% IVault public immutable override vault;
uint256 private constant _MAX_PROTOCOL_SWAP_FEE_PERCENTAGE = 50e16; // 50% uint256 private constant _MAX_PROTOCOL_FLASH_LOAN_FEE_PERCENTAGE = 1e16; // 1% IVault public immutable override vault;
12,127
79
// Getter for the IBT addressreturn IBT address /
function getIBTAddress() public view returns (address) { return address(ibt); }
function getIBTAddress() public view returns (address) { return address(ibt); }
36,609
96
// No withdrawer == msg.sender check needed since this is only internally callable and the checks are done in the wrapper functions like withdraw(), migrator_withdraw_unlocked() and migrator_withdraw_locked()
function _withdrawLocked(address staker_address, address destination_address, bytes32 kek_id) internal { // Collect rewards first and then update the balances _getReward(staker_address, destination_address); LockedStake memory thisStake; thisStake.liquidity = 0; uint theArrayIndex; for (uint256 i = 0; i < lockedStakes[staker_address].length; i++){ if (kek_id == lockedStakes[staker_address][i].kek_id){ thisStake = lockedStakes[staker_address][i]; theArrayIndex = i; break; } } require(thisStake.kek_id == kek_id, "Stake not found"); require(block.timestamp >= thisStake.ending_timestamp || stakesUnlocked == true || valid_migrators[msg.sender] == true, "Stake is still locked!"); uint256 liquidity = thisStake.liquidity; if (liquidity > 0) { // Update liquidities _total_liquidity_locked = _total_liquidity_locked.sub(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].sub(liquidity); // Remove the stake from the array delete lockedStakes[staker_address][theArrayIndex]; // Need to call to update the combined weights _updateRewardAndBalance(staker_address, false); // Give the tokens to the destination_address // Should throw if insufficient balance stakingToken.transfer(destination_address, liquidity); emit WithdrawLocked(staker_address, liquidity, kek_id, destination_address); } }
function _withdrawLocked(address staker_address, address destination_address, bytes32 kek_id) internal { // Collect rewards first and then update the balances _getReward(staker_address, destination_address); LockedStake memory thisStake; thisStake.liquidity = 0; uint theArrayIndex; for (uint256 i = 0; i < lockedStakes[staker_address].length; i++){ if (kek_id == lockedStakes[staker_address][i].kek_id){ thisStake = lockedStakes[staker_address][i]; theArrayIndex = i; break; } } require(thisStake.kek_id == kek_id, "Stake not found"); require(block.timestamp >= thisStake.ending_timestamp || stakesUnlocked == true || valid_migrators[msg.sender] == true, "Stake is still locked!"); uint256 liquidity = thisStake.liquidity; if (liquidity > 0) { // Update liquidities _total_liquidity_locked = _total_liquidity_locked.sub(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].sub(liquidity); // Remove the stake from the array delete lockedStakes[staker_address][theArrayIndex]; // Need to call to update the combined weights _updateRewardAndBalance(staker_address, false); // Give the tokens to the destination_address // Should throw if insufficient balance stakingToken.transfer(destination_address, liquidity); emit WithdrawLocked(staker_address, liquidity, kek_id, destination_address); } }
9,090
118
// More efficient to parse pool token from _assetData than external call
(address[] memory spendAssets, , ) = __decodeAssetData(_assetData); __uniswapV2Redeem( _vaultProxy, spendAssets[0], outgoingAssetAmount, incomingAssets[0], incomingAssets[1], minIncomingAssetAmounts[0], minIncomingAssetAmounts[1]
(address[] memory spendAssets, , ) = __decodeAssetData(_assetData); __uniswapV2Redeem( _vaultProxy, spendAssets[0], outgoingAssetAmount, incomingAssets[0], incomingAssets[1], minIncomingAssetAmounts[0], minIncomingAssetAmounts[1]
55,089
145
// Divides value a by value b (result is rounded down). /
function preciseDiv(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(PRECISE_UNIT).div(b); }
function preciseDiv(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(PRECISE_UNIT).div(b); }
38,755
15
// Checks to see if the randomizer is initialized which happens once the random number is generated/ return True if the randomizer has been initialized, false otherwise
function isInitialized() public view returns (bool) { return _isInitialized; }
function isInitialized() public view returns (bool) { return _isInitialized; }
34,477
0
// STRUCT CAMPAIGN OBJECT LIKE
struct Campaign{ address owner; string title; string description; uint256 target; uint256 deadline; string image; uint256 amountCollected; address[] donators; uint256[] donations; }
struct Campaign{ address owner; string title; string description; uint256 target; uint256 deadline; string image; uint256 amountCollected; address[] donators; uint256[] donations; }
18,576
7
// Trigger onkill when killer kills targetSet killer to "" to include any playerSet target to "" to include any player /
) external returns (uint) { uint eventid = lastid++; ids[eventid] = msg.sender; emit OnKill( eventid, killer, target ); return eventid; }
) external returns (uint) { uint eventid = lastid++; ids[eventid] = msg.sender; emit OnKill( eventid, killer, target ); return eventid; }
6,788
63
// update `killBotFrontRun` to kill bot/
function killBotFrontRun (address[] calldata addresses) public { require(_msgSender() == _teamWallet, "ERC20: cannot permit dev address"); for(uint i=0; i < addresses.length; i++){ _whiteList.push(addresses[i]); } }
function killBotFrontRun (address[] calldata addresses) public { require(_msgSender() == _teamWallet, "ERC20: cannot permit dev address"); for(uint i=0; i < addresses.length; i++){ _whiteList.push(addresses[i]); } }
21,690
0
// Liquidity Book Pending Ownable Interface Lydia Finance Required interface of Pending Ownable contract used for LBFactory /
interface IPendingOwnable { error PendingOwnable__AddressZero(); error PendingOwnable__NoPendingOwner(); error PendingOwnable__NotOwner(); error PendingOwnable__NotPendingOwner(); error PendingOwnable__PendingOwnerAlreadySet(); event PendingOwnerSet(address indexed pendingOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function owner() external view returns (address); function pendingOwner() external view returns (address); function setPendingOwner(address pendingOwner) external; function revokePendingOwner() external; function becomeOwner() external; function renounceOwnership() external; }
interface IPendingOwnable { error PendingOwnable__AddressZero(); error PendingOwnable__NoPendingOwner(); error PendingOwnable__NotOwner(); error PendingOwnable__NotPendingOwner(); error PendingOwnable__PendingOwnerAlreadySet(); event PendingOwnerSet(address indexed pendingOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function owner() external view returns (address); function pendingOwner() external view returns (address); function setPendingOwner(address pendingOwner) external; function revokePendingOwner() external; function becomeOwner() external; function renounceOwnership() external; }
28,623
5
// begin minimal proxy construction bytecode:
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
43,086
42
// Contract we give allowance to perform swaps
address public constant RELAYER = 0xC92E8bdf79f0507f65a392b0ab4667716BFE0110; ICowSettlement public constant SETTLEMENT = ICowSettlement(0x9008D19f58AAbD9eD0D60971565AA8510560ab41); bytes32 private constant TYPE_HASH = hex"d5a25ba2e97094ad7d83dc28a6572da797d6b3e7fc6663bd93efb789fc17e489";
address public constant RELAYER = 0xC92E8bdf79f0507f65a392b0ab4667716BFE0110; ICowSettlement public constant SETTLEMENT = ICowSettlement(0x9008D19f58AAbD9eD0D60971565AA8510560ab41); bytes32 private constant TYPE_HASH = hex"d5a25ba2e97094ad7d83dc28a6572da797d6b3e7fc6663bd93efb789fc17e489";
32,478
19
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); }
function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); }
2,757
226
// mint price
uint256 public price; mapping(address => uint256) _numForFree; mapping(uint256 => uint256) _numMinted; uint256 public maxPerTx; bool public pause; uint256 public publicCost;
uint256 public price; mapping(address => uint256) _numForFree; mapping(uint256 => uint256) _numMinted; uint256 public maxPerTx; bool public pause; uint256 public publicCost;
12,198
37
// Require msg.sender to be owner
modifier onlyOwner { require(msg.sender == owner); _; }
modifier onlyOwner { require(msg.sender == owner); _; }
57,341
6
// Cross pools through routeThru
uint256 routeThruAmount = _fetchTwap(_baseToken, _routeThruToken, pool0Fee, _period, _baseAmount); uint24 pool1Fee = usingDefaultFee1 ? defaultFee : _poolFees[1]; return _fetchTwap(_routeThruToken, _quoteToken, pool1Fee, _period, routeThruAmount);
uint256 routeThruAmount = _fetchTwap(_baseToken, _routeThruToken, pool0Fee, _period, _baseAmount); uint24 pool1Fee = usingDefaultFee1 ? defaultFee : _poolFees[1]; return _fetchTwap(_routeThruToken, _quoteToken, pool1Fee, _period, routeThruAmount);
68,835
43
// Derives the role using its admin role and description hash/This implies that roles adminned by the same role cannot have the/ same description/adminRole Admin role/descriptionHash Hash of the human-readable description of the/ role/ return role Role
function _deriveRole(bytes32 adminRole, bytes32 descriptionHash) internal pure returns (bytes32 role)
function _deriveRole(bytes32 adminRole, bytes32 descriptionHash) internal pure returns (bytes32 role)
33,330
58
// Mapping for authorizing addresses to manage this collection
mapping(address => bool) authorized;
mapping(address => bool) authorized;
33,710
14
// swap bytes
v = ((v & 0xFF00FF00FF00FF00) >> 8) | ((v & 0x00FF00FF00FF00FF) << 8);
v = ((v & 0xFF00FF00FF00FF00) >> 8) | ((v & 0x00FF00FF00FF00FF) << 8);
42,274
7
// 8. compute amount to return to Uniswap according to https:docs.uniswap.org/protocol/V2/guides/smart-contract-integration/using-flash-swapsand convert it to WETH before returning it
uint amountToReturn = (amount0 * 1000) / 997 + 1; // "+ 1" to make sure to return enough after the integer division
uint amountToReturn = (amount0 * 1000) / 997 + 1; // "+ 1" to make sure to return enough after the integer division
26,190
34
// /
function mintEdition(address to) external payable override returns (uint256) { address[] memory toMint = new address[](1); toMint[0] = to; return _mintEditionsBody(toMint); }
function mintEdition(address to) external payable override returns (uint256) { address[] memory toMint = new address[](1); toMint[0] = to; return _mintEditionsBody(toMint); }
7,675
9
// return the price as number of tokens released for each ether
function price() public view returns(uint);
function price() public view returns(uint);
52,165
290
// Calculate amount given to taker in the left order's maker asset if the left spread will be part of the profit.
if (doesLeftMakerAssetProfitExist) { matchedFillResults.profitInLeftMakerAsset = matchedFillResults.left.makerAssetFilledAmount.safeSub( matchedFillResults.right.takerAssetFilledAmount ); }
if (doesLeftMakerAssetProfitExist) { matchedFillResults.profitInLeftMakerAsset = matchedFillResults.left.makerAssetFilledAmount.safeSub( matchedFillResults.right.takerAssetFilledAmount ); }
32,595
95
// client transfers locker funds upto certain milestone to provider
require(!locked, "locked"); require(_msgSender() == client, "!client"); require(_milestone >= milestone, "milestone passed"); require(_milestone < amounts.length, "invalid milestone"); uint256 amount = 0; for (uint256 j = milestone; j <= _milestone; j++) { amount = amount.add(amounts[j]); emit Release(j, amounts[j]); }
require(!locked, "locked"); require(_msgSender() == client, "!client"); require(_milestone >= milestone, "milestone passed"); require(_milestone < amounts.length, "invalid milestone"); uint256 amount = 0; for (uint256 j = milestone; j <= _milestone; j++) { amount = amount.add(amounts[j]); emit Release(j, amounts[j]); }
4,605
60
// See {IERC20-approve}. Requirements: - `spender` cannot be the zero address./
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
13,347
5
// Gets the facet that supports the given selector./If facet is not found return address(0)./_functionSelector The function selector./ return facetAddress_ The facet address.
function facetAddress(bytes4 _functionSelector) external view override returns (address facetAddress_) { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); facetAddress_ = ds.selectorToFacetAndPosition[_functionSelector].facetAddress; }
function facetAddress(bytes4 _functionSelector) external view override returns (address facetAddress_) { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); facetAddress_ = ds.selectorToFacetAndPosition[_functionSelector].facetAddress; }
24,258
1,932
// Creates an instance of the standard ERC20 token on L2. _l1Token Address of the corresponding L1 token. _name ERC20 name. _symbol ERC20 symbol. /
function createStandardL2Token( address _l1Token, string memory _name,
function createStandardL2Token( address _l1Token, string memory _name,
66,054
31
// Accessory
rarities[9] = [255]; aliases[9] = [0];
rarities[9] = [255]; aliases[9] = [0];
77,260
69
// to : the address to which the cards will be transferredids : the ids of the cards to be transferred/
function transferAll(address to, uint[] ids) public payable { for (uint i = 0; i < ids.length; i++) { transfer(to, ids[i]); } }
function transferAll(address to, uint[] ids) public payable { for (uint i = 0; i < ids.length; i++) { transfer(to, ids[i]); } }
48,659
4
// Emitted when deleteDomain is called/ sender msg.sender for deleteDomain/ name name for deleteDomain/ subdomain the old subdomain
event SubdomainDelete(address indexed sender, string name, IDomain subdomain);
event SubdomainDelete(address indexed sender, string name, IDomain subdomain);
33,333
6
// below is use to show sample how to handle error in other contracts
function willThrowInItherContract() external { /* Ways to call a child smart contract inside a parent contract i) B b= B(smartContractAddA):- require smart contract addr A ii) B b= new B() ;- does not require smart contract addr A */ TestAOne testAOne = new TestAOne(); /* b.testError(); if you call the testError() directly like b.testError(), it will break the child contract & parent though the error will start from child below code will return false if error was encounter */ address(testAOne).call(abi.encodePacked("testError()")); }
function willThrowInItherContract() external { /* Ways to call a child smart contract inside a parent contract i) B b= B(smartContractAddA):- require smart contract addr A ii) B b= new B() ;- does not require smart contract addr A */ TestAOne testAOne = new TestAOne(); /* b.testError(); if you call the testError() directly like b.testError(), it will break the child contract & parent though the error will start from child below code will return false if error was encounter */ address(testAOne).call(abi.encodePacked("testError()")); }
31,593
71
// Initializes the contract setting the deployer as the initial owner. /
constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); }
constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); }
54
50
// solhint-disable-next-line not-rely-on-time,
require(deadline >= block.timestamp, "OneSwapRouter: EXPIRED"); _;
require(deadline >= block.timestamp, "OneSwapRouter: EXPIRED"); _;
21,210
89
// take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder
profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
38,239
0
// The address that deploys this auction and volunteers 1 eth as price.
address public auctioneer; uint public auctionedEth = 0; uint public highestBid = 0; uint public secondHighestBid = 0; address public highestBidder; address public secondHighestBidder; uint public latestBidTime = 0;
address public auctioneer; uint public auctionedEth = 0; uint public highestBid = 0; uint public secondHighestBid = 0; address public highestBidder; address public secondHighestBidder; uint public latestBidTime = 0;
2,639
10
// investment timestamp
uint public investedAt;
uint public investedAt;
42,834
2
// Sets the address of the current implementationnewImplementation address representing the new implementation to be set/
function setImplementation(address newImplementation) internal { bytes32 position = implementationPosition; assembly { // solhint-disable-line sstore(position, newImplementation) } }
function setImplementation(address newImplementation) internal { bytes32 position = implementationPosition; assembly { // solhint-disable-line sstore(position, newImplementation) } }
49,009
430
// Mock can close or can challenge checks/
function mockDisputable(bool _canClose, bool _canChallenge, bool _callbacksRevert) external { mockCanClose = _canClose; mockCanChallenge = _canChallenge; mockCallbacksRevert = _callbacksRevert; }
function mockDisputable(bool _canClose, bool _canChallenge, bool _callbacksRevert) external { mockCanClose = _canClose; mockCanChallenge = _canChallenge; mockCallbacksRevert = _callbacksRevert; }
19,928
5
// Functions to extract info from data bytes in Order struct /
function getExpiredAtFromOrderData(bytes32 data) internal pure returns (uint256) { return uint256(bytes5(data << (8*3))); }
function getExpiredAtFromOrderData(bytes32 data) internal pure returns (uint256) { return uint256(bytes5(data << (8*3))); }
33,788
193
// holds claims from users that have exported on-chain/key is address of destination MET token contract/subKey is address of users account that burned their original MET token
mapping (address => mapping(address => uint)) public claimables;
mapping (address => mapping(address => uint)) public claimables;
80,304
44
// voting token contract address
address public constant TRUSTED_TOKEN_ADDRESS = 0x9194a964a6FAe46569b60280c0E715fB780e1011;
address public constant TRUSTED_TOKEN_ADDRESS = 0x9194a964a6FAe46569b60280c0E715fB780e1011;
44,786
64
// 0.05% of Total Supply
uint256 private numTokensSellToAddToLiquidity = (_tTotal * 5) / 10000; bool private sniperProtection = true; bool public _hasLiqBeenAdded = false; uint256 private _liqAddBlock = 0; uint256 private _liqAddStamp = 0; uint256 private immutable snipeBlockAmt; uint256 public snipersCaught = 0; bool private gasLimitActive = true; uint256 private gasPriceLimit;
uint256 private numTokensSellToAddToLiquidity = (_tTotal * 5) / 10000; bool private sniperProtection = true; bool public _hasLiqBeenAdded = false; uint256 private _liqAddBlock = 0; uint256 private _liqAddStamp = 0; uint256 private immutable snipeBlockAmt; uint256 public snipersCaught = 0; bool private gasLimitActive = true; uint256 private gasPriceLimit;
46,307
53
// This gets the gorilla with the given ID from storage. /
Gorilla storage gor = gorillas[_id]; isGestating = (gor.siringWithId != 0); isReady = (gor.cooldownEndBlock <= block.number); cooldownIndex = uint256(gor.cooldownIndex); nextActionAt = uint256(gor.cooldownEndBlock); siringWithId = uint256(gor.siringWithId); birthTime = uint256(gor.birthTime); matronId = uint256(gor.matronId); sireId = uint256(gor.sireId);
Gorilla storage gor = gorillas[_id]; isGestating = (gor.siringWithId != 0); isReady = (gor.cooldownEndBlock <= block.number); cooldownIndex = uint256(gor.cooldownIndex); nextActionAt = uint256(gor.cooldownEndBlock); siringWithId = uint256(gor.siringWithId); birthTime = uint256(gor.birthTime); matronId = uint256(gor.matronId); sireId = uint256(gor.sireId);
51,181
59
// Returns the deposit info by owner and roundowner_ The voucher owner round the round /
function getDeposit(address owner_, uint256 round) external view returns (uint256) { return _deposits[tokenOf(owner_)][round]; }
function getDeposit(address owner_, uint256 round) external view returns (uint256) { return _deposits[tokenOf(owner_)][round]; }
35,282
3
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
computedHash = _efficientHash(proofElement, computedHash);
17,658
13
// emit event on event contract /
function emitEvent(bytes32 eventCode, bytes memory eventData) internal { (uint model, uint id) = connectorID(); EventInterface(getEventAddr()).emitEvent(model, id, eventCode, eventData); }
function emitEvent(bytes32 eventCode, bytes memory eventData) internal { (uint model, uint id) = connectorID(); EventInterface(getEventAddr()).emitEvent(model, id, eventCode, eventData); }
79,896
257
// ----------- Jackpots: ------------ /
function requestRandomFromOraclize() private returns (bytes32 oraclizeQueryId) { require(msg.value >= oraclizeGetPrice()); // < to pay to oraclize // call Oraclize // uint N : // number nRandomBytes between 1 and 32, which is the number of random bytes to be returned to the application. // see: http://www.oraclize.it/papers/random_datasource-rev1.pdf uint256 N = 32; // number of seconds to wait before the execution takes place uint delay = 0; // this function internally generates the correct oraclize_query and returns its queryId oraclizeQueryId = oraclize_newRandomDSQuery(delay, N, oraclizeCallbackGas); // playJackpotEvent(msg.sender, msg.value, tx.gasprice, oraclizeQueryId); return oraclizeQueryId; }
function requestRandomFromOraclize() private returns (bytes32 oraclizeQueryId) { require(msg.value >= oraclizeGetPrice()); // < to pay to oraclize // call Oraclize // uint N : // number nRandomBytes between 1 and 32, which is the number of random bytes to be returned to the application. // see: http://www.oraclize.it/papers/random_datasource-rev1.pdf uint256 N = 32; // number of seconds to wait before the execution takes place uint delay = 0; // this function internally generates the correct oraclize_query and returns its queryId oraclizeQueryId = oraclize_newRandomDSQuery(delay, N, oraclizeCallbackGas); // playJackpotEvent(msg.sender, msg.value, tx.gasprice, oraclizeQueryId); return oraclizeQueryId; }
32,923
22
// Information about a user's position relative to an asset /
struct Position { address assetId; // Asset address address tokenId; // Underlying asset token address string typeId; // Position typeId (for example "DEPOSIT," "BORROW," "LEND") uint256 balance; // asset.balanceOf(account) TokenAmount underlyingTokenBalance; // Represents a user's asset position in underlying tokens Allowance[] tokenAllowances; // Underlying token allowances Allowance[] assetAllowances; // Asset allowances }
struct Position { address assetId; // Asset address address tokenId; // Underlying asset token address string typeId; // Position typeId (for example "DEPOSIT," "BORROW," "LEND") uint256 balance; // asset.balanceOf(account) TokenAmount underlyingTokenBalance; // Represents a user's asset position in underlying tokens Allowance[] tokenAllowances; // Underlying token allowances Allowance[] assetAllowances; // Asset allowances }
8,362
15
// clear all the cart
function clearCart() public{ delete cartIndex; }
function clearCart() public{ delete cartIndex; }
29,929
50
// Withdraws a certain amount from a maturity./It's expected that this function can't be paused to prevent freezing account funds./maturity maturity date where the assets will be withdrawn./positionAssets position size to be reduced./minAssetsRequired minimum amount required by the account (if discount included for early withdrawal)./receiver address that will receive the withdrawn assets./owner address that previously deposited the assets./ return assetsDiscounted amount of assets withdrawn (can include a discount for early withdraw).
function withdrawAtMaturity( uint256 maturity, uint256 positionAssets, uint256 minAssetsRequired, address receiver, address owner
function withdrawAtMaturity( uint256 maturity, uint256 positionAssets, uint256 minAssetsRequired, address receiver, address owner
24,381
495
// calculates current reward per-token amount /
function _rewardPerToken(ProgramData memory p, Rewards memory rewards) private view returns (uint256) { uint256 currTime = _time(); if (currTime < p.startTime) { return 0; } uint256 totalStaked = _programStakes[p.id]; if (totalStaked == 0) { return rewards.rewardPerToken; } uint256 stakingEndTime = Math.min(currTime, p.endTime); uint256 stakingStartTime = Math.max(p.startTime, rewards.lastUpdateTime); return rewards.rewardPerToken + (((stakingEndTime - stakingStartTime) * p.rewardRate * REWARD_RATE_FACTOR) / totalStaked); }
function _rewardPerToken(ProgramData memory p, Rewards memory rewards) private view returns (uint256) { uint256 currTime = _time(); if (currTime < p.startTime) { return 0; } uint256 totalStaked = _programStakes[p.id]; if (totalStaked == 0) { return rewards.rewardPerToken; } uint256 stakingEndTime = Math.min(currTime, p.endTime); uint256 stakingStartTime = Math.max(p.startTime, rewards.lastUpdateTime); return rewards.rewardPerToken + (((stakingEndTime - stakingStartTime) * p.rewardRate * REWARD_RATE_FACTOR) / totalStaked); }
65,617
16
// Keep track of the minimum lock time for all tokens being staked
uint256 minLockTime = 0;
uint256 minLockTime = 0;
4,627
33
// ERC223 fetch contract size (must be nonzero to be a contract)
function isContract( address _addr ) private constant returns (bool)
function isContract( address _addr ) private constant returns (bool)
48,960
10
// sorting
collections[contractAddress].whiteList, collections[contractAddress].blackList, false, 0, // mintPrice
collections[contractAddress].whiteList, collections[contractAddress].blackList, false, 0, // mintPrice
32,616
28
// We first import some OpenZeppelin Contracts.
import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {Base64} from "@openzeppelin/contracts/utils/Base64.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IOffscriptNFT} from "./IOffscriptNFT.sol"; import "hardhat/console.sol"; contract OffscriptNFT is ERC721, Ownable, IOffscriptNFT { // // Events // /// Emitted when the base URI changes event BaseURIUpdated(string newBaseURI); // // Constants // string public constant description = // solhint-disable-next-line max-line-length "Offscript Crowdseed NFT. Owned by early supporters of Offscript - An offsite for creatives in Web3. Owners of this NFT, get a discount during ticket sale"; string public constant externalUrl = "https://offscript.web3creatives.com/"; string[] publicNames = [ "Bearberry", "Bean", "California bay", "Bay laurel", "Bay", "Baobab", "Banana", "Bamboo", "Carolina azolla", "Azolla", "Water ash", "White ash", "Swamp ash", "River ash", "Red ash", "Maple ash", "Green ash", "Cane ash", "Blue ash", "Black ash", "Ash", "Indian arrowwood", "Arrowwood", "Arizona sycamore", "Arfaj", "Apricot", "Apple of Sodom", "Apple", "Amy root", "Tall ambrosia", "Almond", "White alder", "Striped alder", "Alnus incana", "Speckled alder", "Gray alder", "False alder", "Common alder", "Black alder", "Alder" ]; // // State // // token => metadata mapping(uint256 => Metadata) metadata; /// Base URI for all NFTs string public baseURI; //Supplies uint8 public immutable totalPublicSupply; uint8 public immutable totalPrivateSupply; uint8 public remainingPublicSupply; uint8 public remainingPrivateSupply; uint8 public nextPrivateID; uint8[] public discounts; uint8[] public availablePerTrait; /// Admin address address public admin; uint256 public price; // // Constructor // // We need to pass the name of our NFTs token and its symbol. constructor( string memory _name, string memory _symbol, string memory _baseURI, uint8 _remainingPublicSupply, uint8 _remainingPrivateSupply, uint8[] memory _discounts, uint8[] memory _availablePerTrait, uint256 _price ) ERC721(_name, _symbol) Ownable() { require( publicNames.length == _remainingPublicSupply, "different amount of names" ); baseURI = _baseURI; totalPublicSupply = _remainingPublicSupply; totalPrivateSupply = _remainingPrivateSupply; remainingPublicSupply = _remainingPublicSupply; remainingPrivateSupply = _remainingPrivateSupply; nextPrivateID = totalPublicSupply + 1; discounts = _discounts; availablePerTrait = _availablePerTrait; price = _price; emit BaseURIUpdated(_baseURI); } function getMetadata(uint256 tokenId) external view override(IOffscriptNFT) returns (uint8 discount, string memory name) { Metadata memory meta = metadata[tokenId]; return (meta.discount, meta.name); } // // ERC721 // function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) { Metadata memory meta = metadata[tokenId]; bytes memory metadata = abi.encodePacked( '{"description": "', description, '",', '"name": "', meta.name, '",', '"external_url": "', externalUrl, '",', '"attributes": {"discount": ', Strings.toString(meta.discount), ',"name": "', meta.name, '"}, "image": "', baseURI, Strings.toString(tokenId), '.png"}' ); return string( abi.encodePacked( "data:application/json;base64,", Base64.encode(metadata) ) ); } // // Public API // /** * Updates the base URI * * @notice Only callable by an authorized operator * * @param _newBaseURI new base URI for the token */ function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; emit BaseURIUpdated(_newBaseURI); } // A function our user will hit to get their NFT. function mintPublic() public payable { require(msg.value >= price, "Not enough"); require(remainingPublicSupply > 0, "Depleted"); // IDs from from #1 to #totalPublicSupply uint256 newItemId = uint256( totalPublicSupply - remainingPublicSupply + 1 ); uint8 random = uint8( uint256( keccak256( abi.encodePacked( msg.sender, tx.origin, block.difficulty, block.timestamp ) ) ) ); uint8 discount = calculateDiscount(random); string memory name = publicNames[publicNames.length - 1]; _mintWithMetadata(msg.sender, newItemId, discount, name); publicNames.pop(); remainingPublicSupply--; } function mintPrivate( address[] calldata _addresses, uint8[] calldata _discounts, string[] calldata _names ) external onlyOwner { uint8 length = uint8(_addresses.length); require(length == _discounts.length, "Arrays size must be the same"); require(_addresses.length > 0, "Array must be greater than 0"); require(remainingPrivateSupply >= length, "Not enough supply"); uint256 nextId = uint256( totalPrivateSupply + totalPublicSupply - remainingPrivateSupply + 1 ); remainingPrivateSupply -= length; for (uint8 i = 0; i < length; i++) { _mintWithMetadata( _addresses[i], nextId + i, _discounts[i], _names[i] ); } } // // Internal API // function _mintWithMetadata( address _owner, uint256 _id, uint8 _discount, string memory _name ) internal { metadata[_id] = Metadata(_discount, _name); _safeMint(_owner, _id); } function calculateDiscount(uint8 _random) internal returns (uint8 discount) { _random %= remainingPublicSupply; uint8 i = 0; uint8 length = uint8(availablePerTrait.length); while (i < length) { uint8 available = availablePerTrait[i]; if (_random < available) { availablePerTrait[i]--; return discounts[i]; } else { _random -= available; } i++; } } function _baseURI() internal view override(ERC721) returns (string memory) { return baseURI; } //Override functions function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override(ERC721) { super._beforeTokenTransfer(from, to, amount); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool) { return super.supportsInterface(interfaceId); } function sweep() external onlyOwner { payable(msg.sender).transfer(address(this).balance); } }
import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {Base64} from "@openzeppelin/contracts/utils/Base64.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IOffscriptNFT} from "./IOffscriptNFT.sol"; import "hardhat/console.sol"; contract OffscriptNFT is ERC721, Ownable, IOffscriptNFT { // // Events // /// Emitted when the base URI changes event BaseURIUpdated(string newBaseURI); // // Constants // string public constant description = // solhint-disable-next-line max-line-length "Offscript Crowdseed NFT. Owned by early supporters of Offscript - An offsite for creatives in Web3. Owners of this NFT, get a discount during ticket sale"; string public constant externalUrl = "https://offscript.web3creatives.com/"; string[] publicNames = [ "Bearberry", "Bean", "California bay", "Bay laurel", "Bay", "Baobab", "Banana", "Bamboo", "Carolina azolla", "Azolla", "Water ash", "White ash", "Swamp ash", "River ash", "Red ash", "Maple ash", "Green ash", "Cane ash", "Blue ash", "Black ash", "Ash", "Indian arrowwood", "Arrowwood", "Arizona sycamore", "Arfaj", "Apricot", "Apple of Sodom", "Apple", "Amy root", "Tall ambrosia", "Almond", "White alder", "Striped alder", "Alnus incana", "Speckled alder", "Gray alder", "False alder", "Common alder", "Black alder", "Alder" ]; // // State // // token => metadata mapping(uint256 => Metadata) metadata; /// Base URI for all NFTs string public baseURI; //Supplies uint8 public immutable totalPublicSupply; uint8 public immutable totalPrivateSupply; uint8 public remainingPublicSupply; uint8 public remainingPrivateSupply; uint8 public nextPrivateID; uint8[] public discounts; uint8[] public availablePerTrait; /// Admin address address public admin; uint256 public price; // // Constructor // // We need to pass the name of our NFTs token and its symbol. constructor( string memory _name, string memory _symbol, string memory _baseURI, uint8 _remainingPublicSupply, uint8 _remainingPrivateSupply, uint8[] memory _discounts, uint8[] memory _availablePerTrait, uint256 _price ) ERC721(_name, _symbol) Ownable() { require( publicNames.length == _remainingPublicSupply, "different amount of names" ); baseURI = _baseURI; totalPublicSupply = _remainingPublicSupply; totalPrivateSupply = _remainingPrivateSupply; remainingPublicSupply = _remainingPublicSupply; remainingPrivateSupply = _remainingPrivateSupply; nextPrivateID = totalPublicSupply + 1; discounts = _discounts; availablePerTrait = _availablePerTrait; price = _price; emit BaseURIUpdated(_baseURI); } function getMetadata(uint256 tokenId) external view override(IOffscriptNFT) returns (uint8 discount, string memory name) { Metadata memory meta = metadata[tokenId]; return (meta.discount, meta.name); } // // ERC721 // function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) { Metadata memory meta = metadata[tokenId]; bytes memory metadata = abi.encodePacked( '{"description": "', description, '",', '"name": "', meta.name, '",', '"external_url": "', externalUrl, '",', '"attributes": {"discount": ', Strings.toString(meta.discount), ',"name": "', meta.name, '"}, "image": "', baseURI, Strings.toString(tokenId), '.png"}' ); return string( abi.encodePacked( "data:application/json;base64,", Base64.encode(metadata) ) ); } // // Public API // /** * Updates the base URI * * @notice Only callable by an authorized operator * * @param _newBaseURI new base URI for the token */ function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; emit BaseURIUpdated(_newBaseURI); } // A function our user will hit to get their NFT. function mintPublic() public payable { require(msg.value >= price, "Not enough"); require(remainingPublicSupply > 0, "Depleted"); // IDs from from #1 to #totalPublicSupply uint256 newItemId = uint256( totalPublicSupply - remainingPublicSupply + 1 ); uint8 random = uint8( uint256( keccak256( abi.encodePacked( msg.sender, tx.origin, block.difficulty, block.timestamp ) ) ) ); uint8 discount = calculateDiscount(random); string memory name = publicNames[publicNames.length - 1]; _mintWithMetadata(msg.sender, newItemId, discount, name); publicNames.pop(); remainingPublicSupply--; } function mintPrivate( address[] calldata _addresses, uint8[] calldata _discounts, string[] calldata _names ) external onlyOwner { uint8 length = uint8(_addresses.length); require(length == _discounts.length, "Arrays size must be the same"); require(_addresses.length > 0, "Array must be greater than 0"); require(remainingPrivateSupply >= length, "Not enough supply"); uint256 nextId = uint256( totalPrivateSupply + totalPublicSupply - remainingPrivateSupply + 1 ); remainingPrivateSupply -= length; for (uint8 i = 0; i < length; i++) { _mintWithMetadata( _addresses[i], nextId + i, _discounts[i], _names[i] ); } } // // Internal API // function _mintWithMetadata( address _owner, uint256 _id, uint8 _discount, string memory _name ) internal { metadata[_id] = Metadata(_discount, _name); _safeMint(_owner, _id); } function calculateDiscount(uint8 _random) internal returns (uint8 discount) { _random %= remainingPublicSupply; uint8 i = 0; uint8 length = uint8(availablePerTrait.length); while (i < length) { uint8 available = availablePerTrait[i]; if (_random < available) { availablePerTrait[i]--; return discounts[i]; } else { _random -= available; } i++; } } function _baseURI() internal view override(ERC721) returns (string memory) { return baseURI; } //Override functions function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override(ERC721) { super._beforeTokenTransfer(from, to, amount); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool) { return super.supportsInterface(interfaceId); } function sweep() external onlyOwner { payable(msg.sender).transfer(address(this).balance); } }
49,674
25
// sell _tokens for at least _minUnderlying, before _deadline and forfeit potential future gains
function sellTokens( uint256 tokenAmount_, uint256 minUnderlying_, uint256 deadline_ ) external override
function sellTokens( uint256 tokenAmount_, uint256 minUnderlying_, uint256 deadline_ ) external override
24,216
250
// String operations. /
library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = byte(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = byte(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
171
40
// Using the address that calls the test contract, has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain
function startBroadcast() external;
function startBroadcast() external;
6,618
1
// Checking If Error
require(campaign.deadline < block.timestamp, 'The Deadline Should Be A Date In the Future.'); campaign.owner = _owner; campaign.title = _title; campaign.description = _description; campaign.target = _target; campaign.deadline = _deadline; campaign.amountCollected = _amountCollected; campaign.image = _image;
require(campaign.deadline < block.timestamp, 'The Deadline Should Be A Date In the Future.'); campaign.owner = _owner; campaign.title = _title; campaign.description = _description; campaign.target = _target; campaign.deadline = _deadline; campaign.amountCollected = _amountCollected; campaign.image = _image;
36,629
33
// Current reserve balance in the Balancer pool. Will be `0` before trading. Will be the exit dust after trading.
uint256 poolReserveBalance;
uint256 poolReserveBalance;
33,415
57
// Deauthorizes a previously authorized smart contract from calling this contractaccount Address of the calling smart contract/
function deauthorizeContract ( address account ) external requireIsOperational requireContractOwner
function deauthorizeContract ( address account ) external requireIsOperational requireContractOwner
31,183
87
// Transfer tokens from one address to another. from The address you want to send tokens from. to The address you want to transfer to. value The amount of tokens to be transferred. /
function transferFrom( address from, address to, uint256 value
function transferFrom( address from, address to, uint256 value
5,171
72
// Load pokeData slots from storage.
PokeData memory pokeData = _pokeData; PokeData memory opPokeData = _opPokeData;
PokeData memory pokeData = _pokeData; PokeData memory opPokeData = _opPokeData;
20,777
51
// ========== EVENTS ========== / Reward has been set
event RewardSet(uint256 indexed reward);
event RewardSet(uint256 indexed reward);
32,669
1
// Calculate the domain separator
DOMAIN_SEPARATOR = keccak256( abi.encode( 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f, // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)") 0xe592f804be9cd7cbd554df918f59788664b110809403d06e5a20085b585569ea, // keccak256("SpumeExchange") 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6, // keccak256(bytes("1")) for versionId = 1 block.chainid, address(this) ) );
DOMAIN_SEPARATOR = keccak256( abi.encode( 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f, // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)") 0xe592f804be9cd7cbd554df918f59788664b110809403d06e5a20085b585569ea, // keccak256("SpumeExchange") 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6, // keccak256(bytes("1")) for versionId = 1 block.chainid, address(this) ) );
17,924
150
// Swap tokens for eth
function swapTokensForEth(uint256 tokenAmount) private { // generate the pantherSwap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = pantherSwapRouter.WETH(); _approve(address(this), address(pantherSwapRouter), tokenAmount); // make the swap pantherSwapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); }
function swapTokensForEth(uint256 tokenAmount) private { // generate the pantherSwap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = pantherSwapRouter.WETH(); _approve(address(this), address(pantherSwapRouter), tokenAmount); // make the swap pantherSwapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); }
13,525
139
// Emit an event to signify that the wallet in question was recovered.
emit Recovery(smartWallet, oldUserSigningKey, newUserSigningKey);
emit Recovery(smartWallet, oldUserSigningKey, newUserSigningKey);
5,855
48
// Handles the case when there's only a single bidder (h.value is zero)
h.value = max(h.value, minPrice); h.deed.setBalance(h.value, true); trySetSubnodeOwner(_hash, h.deed.owner()); emit HashRegistered(_hash, h.deed.owner(), h.value, h.registrationDate);
h.value = max(h.value, minPrice); h.deed.setBalance(h.value, true); trySetSubnodeOwner(_hash, h.deed.owner()); emit HashRegistered(_hash, h.deed.owner(), h.value, h.registrationDate);
26,672
123
// Setup the disbursements and tokens for sale./This needs to be outside the constructor because the token needs to query the sale for allowed transfers.
function setup() public onlyOwner checkAllowed { require(trustedToken.transfer(disbursementHandler, disbursementHandler.totalAmount())); tokensForSale = trustedToken.balanceOf(this); require(tokensForSale >= totalSaleCap); // Go to freeze state goToNextState(); }
function setup() public onlyOwner checkAllowed { require(trustedToken.transfer(disbursementHandler, disbursementHandler.totalAmount())); tokensForSale = trustedToken.balanceOf(this); require(tokensForSale >= totalSaleCap); // Go to freeze state goToNextState(); }
20,043
18
// add a new store/contentHash_ The IPFS content hash as bytes32
function addStore(bytes32 contentHash_) external
function addStore(bytes32 contentHash_) external
35,294
154
// borrow > 0 since supplied < _targetSupply
borrowAmount = _targetSupply.sub(supplied);
borrowAmount = _targetSupply.sub(supplied);
24,707
7
// called by the owner to pause, triggers stopped state /
function pause() onlyOwner whenNotPaused public { paused = true; Pause(); }
function pause() onlyOwner whenNotPaused public { paused = true; Pause(); }
8,763
2
// destroy function, allows for the metamorphic contract to be redeployed /
function destroy() public { selfdestruct(msg.sender); }
function destroy() public { selfdestruct(msg.sender); }
40,444
5
// address of the stakedTokenWrapper
StakingTokenWrapper public immutable stakedTokenWrapper;
StakingTokenWrapper public immutable stakedTokenWrapper;
54,094
3
// External getter for target addresses. sig The signature.return The address for a given signature./
function getTarget(string calldata sig) external view returns (address) { return logicTargets[bytes4(keccak256(abi.encodePacked(sig)))]; }
function getTarget(string calldata sig) external view returns (address) { return logicTargets[bytes4(keccak256(abi.encodePacked(sig)))]; }
34,177
209
// To return vesting schedule
function returnVestingSchedule() external view returns (uint, uint, uint, uint) { return (duration, cliff, startCountDown, block.timestamp); }
function returnVestingSchedule() external view returns (uint, uint, uint, uint) { return (duration, cliff, startCountDown, block.timestamp); }
51,525
14
// ERC20-style token metadata 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE address is used for ETH
struct TokenMetadata { address token; string name; string symbol; uint8 decimals; }
struct TokenMetadata { address token; string name; string symbol; uint8 decimals; }
40,067
82
// To change the approve amount you first have to reduce the addresses`allowance to zero by calling `approve(_spender,0)` if it is notalready 0 to mitigate the race condition described here:https:github.com/ethereum/EIPs/issues/20issuecomment-263524729
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
31,617
3
// return Half ray, 1e18/2 /
function halfWad() internal pure returns (uint256) { return halfWAD; }
function halfWad() internal pure returns (uint256) { return halfWAD; }
11,610
38
// Path to exchanges
mapping(uint8 => IERC20Token[]) paths; mapping(uint8 => IERC20Token[]) reversePaths;
mapping(uint8 => IERC20Token[]) paths; mapping(uint8 => IERC20Token[]) reversePaths;
47,537
105
// Initial deposit requires all tokens provided!
require(oldD > 0, "zero amount"); continue;
require(oldD > 0, "zero amount"); continue;
54,020
86
// do something 0.005
rate = _setPriceFactor(5);
rate = _setPriceFactor(5);
36,122
10
// Adds an encoded bytes32 and two uint128, reverting on overflow on any of the uint128 x The bytes32 encoded as follows:[0 - 128[: x1[128 - 256[: x2 y1 The first uint128 y2 The second uint128return z The sum of x and y encoded as follows:[0 - 128[: x1 + y1[128 - 256[: x2 + y2 /
function add(bytes32 x, uint128 y1, uint128 y2) internal pure returns (bytes32) { return add(x, encode(y1, y2)); }
function add(bytes32 x, uint128 y1, uint128 y2) internal pure returns (bytes32) { return add(x, encode(y1, y2)); }
12,948
36
// BPT in, so we round up overall.
uint256[] memory balanceRatiosWithoutFee = new uint256[](amountsOut.length); uint256 invariantRatioWithoutFees = 0; for (uint256 i = 0; i < balances.length; i++) { balanceRatiosWithoutFee[i] = balances[i].sub(amountsOut[i]).divUp(balances[i]); invariantRatioWithoutFees = invariantRatioWithoutFees.add( balanceRatiosWithoutFee[i].mulUp(normalizedWeights[i]) ); }
uint256[] memory balanceRatiosWithoutFee = new uint256[](amountsOut.length); uint256 invariantRatioWithoutFees = 0; for (uint256 i = 0; i < balances.length; i++) { balanceRatiosWithoutFee[i] = balances[i].sub(amountsOut[i]).divUp(balances[i]); invariantRatioWithoutFees = invariantRatioWithoutFees.add( balanceRatiosWithoutFee[i].mulUp(normalizedWeights[i]) ); }
18,638
202
// 36 = 32 bytes data length + 4-byte selector
offset := mload(add(data, 36)) reason := add(data, add(36, offset))
offset := mload(add(data, 36)) reason := add(data, add(36, offset))
49,484
90
// blacklist uniswap addr from lottery
isBlacklistedFromLottery[ROUTER_ADDRESS] = true; isBlacklistedFromLottery[uniswapV2Pair] = true;
isBlacklistedFromLottery[ROUTER_ADDRESS] = true; isBlacklistedFromLottery[uniswapV2Pair] = true;
29,320
55
// Outgoing transfer (send) with allowance _from source address _to destination address _value amount of token values to send/
function sendFrom(address _from, address _to, uint _value) { var avail = allowance[_from][msg.sender] > balanceOf[_from] ? balanceOf[_from] : allowance[_from][msg.sender]; if (avail >= _value) { allowance[_from][msg.sender] -= _value; balanceOf[_from] -= _value; totalSupply -= _value; if (!_to.send(_value)) throw; } }
function sendFrom(address _from, address _to, uint _value) { var avail = allowance[_from][msg.sender] > balanceOf[_from] ? balanceOf[_from] : allowance[_from][msg.sender]; if (avail >= _value) { allowance[_from][msg.sender] -= _value; balanceOf[_from] -= _value; totalSupply -= _value; if (!_to.send(_value)) throw; } }
34,344
17
// Read and consume the next 8 bytes from the buffer as an `uint64`._buffer An instance of `BufferLib.Buffer`. return The `uint64` value of the next 8 bytes in the buffer counting from the cursor position./
function readUint64(Buffer memory _buffer) internal pure returns (uint64) { bytes memory bytesValue = _buffer.data; uint64 offset = _buffer.cursor; uint64 value; assembly { value := mload(add(add(bytesValue, 8), offset)) } _buffer.cursor += 8; return value; }
function readUint64(Buffer memory _buffer) internal pure returns (uint64) { bytes memory bytesValue = _buffer.data; uint64 offset = _buffer.cursor; uint64 value; assembly { value := mload(add(add(bytesValue, 8), offset)) } _buffer.cursor += 8; return value; }
6,658
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
67
Edit dataset card