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
3
// A struct for storing a snapshot of liquidity accumulations. The difference of a newer snapshot against an older snapshot can be used to derive time-weighted averageliquidities by dividing the difference in value by the difference in time. /
struct LiquidityAccumulator { /* * @notice Accumulates time-weighted average liquidity of the token in the form of a sumation of (price * time), * with time measured in seconds. * @dev Overflow is desired and results in correct behavior as long as the difference between two snap...
struct LiquidityAccumulator { /* * @notice Accumulates time-weighted average liquidity of the token in the form of a sumation of (price * time), * with time measured in seconds. * @dev Overflow is desired and results in correct behavior as long as the difference between two snap...
45,846
164
// Zero-value
require(uints[0] == 0);
require(uints[0] == 0);
23,193
19
// from now there is opponent
bool timeforaction = (now < bets[MyHash].timestamp + LimitOfMinutes*60) || (now < bets[bets[MyHash].OpponentHash].timestamp + LimitOfMinutes*60 ); if(bets[MyHash].Pick == 0 && timeforaction ) return "you can announce your SecretRand"; if(bets[MyHash].Pick == 0) ret...
bool timeforaction = (now < bets[MyHash].timestamp + LimitOfMinutes*60) || (now < bets[bets[MyHash].OpponentHash].timestamp + LimitOfMinutes*60 ); if(bets[MyHash].Pick == 0 && timeforaction ) return "you can announce your SecretRand"; if(bets[MyHash].Pick == 0) ret...
54,830
8
// Generates the calldata to delegate votes to another ETH address. Self and zero address allowed, which is equivalent to registering and revoking in Compoundlike governance systems._delegateeAddress of the delegatee return addressTarget contract addressreturn uint256Total quantity of ETH (Set to 0)return bytesPropose ...
function getDelegateCalldata(address _delegatee) external view returns (address, uint256, bytes memory) { // delegate(address _delegatee) bytes memory callData = abi.encodeWithSignature(DELEGATE_SIGNATURE, _delegatee); return (governanceToken, 0, callData); }
function getDelegateCalldata(address _delegatee) external view returns (address, uint256, bytes memory) { // delegate(address _delegatee) bytes memory callData = abi.encodeWithSignature(DELEGATE_SIGNATURE, _delegatee); return (governanceToken, 0, callData); }
29,753
48
// This event MUST emit when an address withdraws their dividend./to The address which withdraws ether from this contract./weiAmount The amount of withdrawn ether in wei.
event DividendWithdrawn( address indexed to, uint256 weiAmount );
event DividendWithdrawn( address indexed to, uint256 weiAmount );
16,482
12
// Merchant identifier hash
bytes32 public merchantIdHash;
bytes32 public merchantIdHash;
25,699
210
// Emitted by {_snapshot} when a snapshot identified by `id` is created. /
event Snapshot(uint256 id);
event Snapshot(uint256 id);
3,061
68
// Returns asset implementation contract for current caller. return asset implementation contract. /
function _getAsset() internal view returns (ATxAssetInterface) { return ATxAssetInterface(getLatestVersion()); }
function _getAsset() internal view returns (ATxAssetInterface) { return ATxAssetInterface(getLatestVersion()); }
575
4
// Maps a token ID to a Memo.
mapping (uint256 => Memo) public memoForToken;
mapping (uint256 => Memo) public memoForToken;
881
145
// See if there's enough collateral to add to the SAFE in order to save it
if (collateralTokenNeeded <= collateralFromLP) { return (sysCoinsFromLP, collateralTokenNeeded); } else {
if (collateralTokenNeeded <= collateralFromLP) { return (sysCoinsFromLP, collateralTokenNeeded); } else {
2,452
104
// Cannot recover the staking token or the rewards token
require( tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken) && !isCorrectToken, "Cannot withdraw the staking or rewards tokens" ); IERC20(tokenAddress).safeTransfer(owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount);
require( tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken) && !isCorrectToken, "Cannot withdraw the staking or rewards tokens" ); IERC20(tokenAddress).safeTransfer(owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount);
5,263
54
// View function to see pending Token/_pid The index of the pool. See `poolInfo`./_user Address of user./ return pending SUSHI reward for a given user.
function pendingToken(uint256 _pid, address _user) public view returns (uint256 pending) { PoolInfo memory pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accToken1PerShare = pool.accToken1PerShare; uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken...
function pendingToken(uint256 _pid, address _user) public view returns (uint256 pending) { PoolInfo memory pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accToken1PerShare = pool.accToken1PerShare; uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken...
25,372
39
// uint _id = getId(_account, _asset, _loaction);
uint _id = getKeyId(_account, _asset, _loaction); return getPosition(_id);
uint _id = getKeyId(_account, _asset, _loaction); return getPosition(_id);
48,449
16
// Function to simply retrieve block number This exists mainly for inheriting test contracts to stub this result. /
function getBlockNumber() internal view returns (uint) { return block.number; }
function getBlockNumber() internal view returns (uint) { return block.number; }
11,739
43
// The end time cannot be less than the start time for a sale
if (newStage.endTime <= newStage.startTime) revert EndTimeLessThanStartTime(); if (i > 0) { uint256 previousStageEndTime = stageMap[i - 1].endTime;
if (newStage.endTime <= newStage.startTime) revert EndTimeLessThanStartTime(); if (i > 0) { uint256 previousStageEndTime = stageMap[i - 1].endTime;
26,008
109
// Internal function to withdraw ERC721 tokens. to Address the tokens should be sent to. ERC721Address The contract address of the asset. id The ID of the ERC721 token. Used for all tokens type == 1. The function checks whether any other ERC721 is deposited in the Vault.If not, it pops the stored addresses and stored I...
function _withdrawERC721(address to, address ERC721Address, uint256 id) internal { uint256 tokenIdLength = erc721TokenIds.length; uint256 i; if (tokenIdLength == 1) { //There was only one ERC721 stored on the contract, safe to remove both lists. require(erc721TokenId...
function _withdrawERC721(address to, address ERC721Address, uint256 id) internal { uint256 tokenIdLength = erc721TokenIds.length; uint256 i; if (tokenIdLength == 1) { //There was only one ERC721 stored on the contract, safe to remove both lists. require(erc721TokenId...
15,119
3
// Struct to track Token template.
struct Token { bool exists; uint256 templateId; uint256 index; }
struct Token { bool exists; uint256 templateId; uint256 index; }
4,502
209
// Use a simple bonding curve. Increase 20% every 8 sold. Only use this curve on genesis. Alpha price will start from last genesis price
if(totalSoldCounter < 512) { if (totalSoldCounter % 8 == 0) { stnBkPremiumPrice += stnBkPremiumPrice / 20; }
if(totalSoldCounter < 512) { if (totalSoldCounter % 8 == 0) { stnBkPremiumPrice += stnBkPremiumPrice / 20; }
49,441
12
// We run that for loop because the only way to delete an item in an array is to pop its last index so we organize the items accordingly
for (uint i = index; i<exchanges.length-1; i++){ exchanges[i] = exchanges[i+1]; }
for (uint i = index; i<exchanges.length-1; i++){ exchanges[i] = exchanges[i+1]; }
22,426
0
// calcSpotPricesP = spotPrice bI = tokenBalanceIn( bI / wI ) 1 bO = tokenBalanceOut sP =---------------------wI = tokenWeightIn ( bO / wO ) ( 1 - sF )wO = tokenWeightOutsF = swapFee/
{ uint numer = bdiv(tokenBalanceIn, tokenWeightIn); uint denom = bdiv(tokenBalanceOut, tokenWeightOut); uint ratio = bdiv(numer, denom); uint scale = bdiv(BONE, bsub(BONE, swapFee)); return (spotPrice = bmul(ratio, scale)); }
{ uint numer = bdiv(tokenBalanceIn, tokenWeightIn); uint denom = bdiv(tokenBalanceOut, tokenWeightOut); uint ratio = bdiv(numer, denom); uint scale = bdiv(BONE, bsub(BONE, swapFee)); return (spotPrice = bmul(ratio, scale)); }
33,871
0
// Creates a request that can hold additional parameters _specId The Job Specification ID that the request will be created for _callbackAddress The callback address that the response will be sent to _callbackFunctionSignature The callback function signature to use for the callback addressreturn A Plugin Request struct ...
function buildPluginRequest( bytes32 _specId, address _callbackAddress, bytes4 _callbackFunctionSignature ) internal pure returns (Plugin.Request memory) { Plugin.Request memory req; return req.initialize(_specId, _callbackAddress, _callbackFunctionSignature); }
function buildPluginRequest( bytes32 _specId, address _callbackAddress, bytes4 _callbackFunctionSignature ) internal pure returns (Plugin.Request memory) { Plugin.Request memory req; return req.initialize(_specId, _callbackAddress, _callbackFunctionSignature); }
28,817
3
// 操作数组存取 查询数据库
function getData(uint n)public view returns(uint,string){ return (stringData.length,stringData[i]); }
function getData(uint n)public view returns(uint,string){ return (stringData.length,stringData[i]); }
11,765
4
// Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective...
function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective...
6,016
1
// Migrates pools which pids are given in array(pools). Can be called one time, when eTacoChef poolInfo is empty. oldPools Array which contains old master pids that must be migrated. newPools Array which contains new master pids that must be migrated. /
function migratePools(uint256[] memory oldPools, uint256[] memory newPools) external onlyOwner { uint256 poolsLength = oldPools.length; for (uint256 i = 0; i < poolsLength; i++) { (address lpToken, uint256 allocPoint, uint256 lastRewardBlock, uint256 accTacoPerShare) = o...
function migratePools(uint256[] memory oldPools, uint256[] memory newPools) external onlyOwner { uint256 poolsLength = oldPools.length; for (uint256 i = 0; i < poolsLength; i++) { (address lpToken, uint256 allocPoint, uint256 lastRewardBlock, uint256 accTacoPerShare) = o...
46,165
205
// found
return mid;
return mid;
31,500
10
// ADMIN FUNCTIONS/
{ _setupRole(AUTHORIZED_CALLER, adr); }
{ _setupRole(AUTHORIZED_CALLER, adr); }
15,543
2
// Require nym to be present, and fit into one data slot
if (attributes[0][0] != 1) { ValidationError(NYM, "must be present"); return false; }
if (attributes[0][0] != 1) { ValidationError(NYM, "must be present"); return false; }
23,065
1
// mapping(bytes32 => bytes[]) internal bytesArrayStorage;
mapping(bytes32 => bool[]) internal boolArrayStorage; mapping(bytes32 => int256[]) internal intArrayStorage; mapping(bytes32 => bytes32[]) internal bytes32ArrayStorage;
mapping(bytes32 => bool[]) internal boolArrayStorage; mapping(bytes32 => int256[]) internal intArrayStorage; mapping(bytes32 => bytes32[]) internal bytes32ArrayStorage;
47,377
19
// ------------------------------------------------------------------------ Token owner can approve for `spender` to transferFrom(...) `tokens` from the token owner's account ------------------------------------------------------------------------
function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; }
function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; }
9,221
14
// Structs // State Valiables // Events / Triggered when tokens are transferred.
event Transfer( address indexed _from, address indexed _to, uint256 _value);
event Transfer( address indexed _from, address indexed _to, uint256 _value);
8,470
160
// divides bytes signature into `uint8 v, bytes32 r, bytes32 s`./Make sure to peform a bounds check forpos, to avoid out of bounds access onsignatures/pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access/signatures concatenated rsv signatures
function signatureSplit(bytes memory signatures, uint256 pos) internal pure returns ( uint8 v, bytes32 r, bytes32 s )
function signatureSplit(bytes memory signatures, uint256 pos) internal pure returns ( uint8 v, bytes32 r, bytes32 s )
58,145
5
// a way to cheaply extract more results from a seed without re-rolling it example: (seed, 10000, 100, 25) skips last two digits of seed and gets a 0-24 from from the new end WARNING: distribution of results may not be even! For even distribution use whole multiples of mod for the number of decimals at work (ie 2 digit...
return seed.mod(slice).div(div).mod(mod);
return seed.mod(slice).div(div).mod(mod);
26,637
191
// amount = (ethValuedecimals) / tokenEthPrice
return ((10**decimals).mul(ethValue)).div(tokenEthPrice); //tokenAmount
return ((10**decimals).mul(ethValue)).div(tokenEthPrice); //tokenAmount
3,107
29
// -------------------- Verification functions : ---------------------- / from user acc (!) Gas requirement: infinite
function uploadSignedString(string _fingerprint, bytes20 _fingerprintBytes20, string _signedString) public payable { // check length of the uploaded string, // it expected to be a 64 chars string signed with OpenPGP standard signature // bytes: Dynamically-sized byte array, // see: ...
function uploadSignedString(string _fingerprint, bytes20 _fingerprintBytes20, string _signedString) public payable { // check length of the uploaded string, // it expected to be a 64 chars string signed with OpenPGP standard signature // bytes: Dynamically-sized byte array, // see: ...
18,023
11
// Then fill in request details
if (_paysValue > 0) { _req.paysValue = _paysValue; }
if (_paysValue > 0) { _req.paysValue = _paysValue; }
24,076
57
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature unique. Appendix F in the Ethereum Yellow paper (https:ethereum.github.io/yellowpaper/paper.pdf), defines the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most signat...
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); }
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); }
414
5
// Event emitted when a liquidity mining incentive has been created/rewardToken The token being distributed as a reward/bonusRewardToken The token being distributed as a bonus reward/pool The Algebra pool/startTime The time when the incentive program begins/endTime The time when rewards stop accruing/reward The amount ...
event LimitFarmingCreated( IERC20Minimal indexed rewardToken, IERC20Minimal indexed bonusRewardToken, IAlgebraPool indexed pool, uint256 startTime, uint256 endTime, uint256 reward, uint256 bonusReward, Tiers tiers, address multiplierToken,
event LimitFarmingCreated( IERC20Minimal indexed rewardToken, IERC20Minimal indexed bonusRewardToken, IAlgebraPool indexed pool, uint256 startTime, uint256 endTime, uint256 reward, uint256 bonusReward, Tiers tiers, address multiplierToken,
14,020
25
// Implement template method of BaseAccount. Uses a modified version of `SignatureChecker.isValidSignatureNow` inwhich the digest is wrapped with an "Ethereum Signed Message" envelopefor the EOA-owner case but not in the ERC-1271 contract-owner case. /
function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash) internal virtual override returns (uint256 validationData)
function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash) internal virtual override returns (uint256 validationData)
18,712
200
// Release funds to the factory/_token The ERC20 to transfer/_amount The amount to transfer
function withdraw(IERC20 _token, uint256 _amount) external onlyFactory { SafeERC20.safeTransfer(_token, msg.sender, _amount); }
function withdraw(IERC20 _token, uint256 _amount) external onlyFactory { SafeERC20.safeTransfer(_token, msg.sender, _amount); }
60,289
74
// interest amounts accrued
uint accruedInterest;
uint accruedInterest;
9,351
5
// Increment it so next time it's correct when we call .current()
_tokenIdCounter.increment();
_tokenIdCounter.increment();
407
416
// you can't set per token royalties if using "contract wide" ones
require( !_useContractRoyalties, '!ERC2981Royalties:ROYALTIES_CONTRACT_WIDE!' ); require(value <= 10000, '!ERC2981Royalties:TOO_HIGH!'); _royalties[id] = RoyaltyData(recipient, uint96(value));
require( !_useContractRoyalties, '!ERC2981Royalties:ROYALTIES_CONTRACT_WIDE!' ); require(value <= 10000, '!ERC2981Royalties:TOO_HIGH!'); _royalties[id] = RoyaltyData(recipient, uint96(value));
75,236
80
// Transfer `amount` of token `token` to `smartWallet`, providing theinitial user signing key `initialUserSigningKey` as proof that thespecified smart wallet is indeed a Dharma Smart Wallet - this assumes thatthe address is derived and deployed using the Dharma Smart Wallet FactoryV1. Only the owner or the designated d...
function finalizeTokenDeposit( address smartWallet, address initialUserSigningKey, ERC20Interface token, uint256 amount
function finalizeTokenDeposit( address smartWallet, address initialUserSigningKey, ERC20Interface token, uint256 amount
35,652
10
// these storage values are unknown but fixed
uint256 value; uint256 data; uint256 count; function checkSignatures( GnosisSafe gnosis, Executor executor, // to avoid multiple instances uint256 signatures ) public
uint256 value; uint256 data; uint256 count; function checkSignatures( GnosisSafe gnosis, Executor executor, // to avoid multiple instances uint256 signatures ) public
51,074
6
// Get the weight of the current voter based on number of tokens they own
uint weight = balances[msg.sender];
uint weight = balances[msg.sender];
56,554
272
// Similar to the rawCollateral in PositionData, this value should not be used directly. _getFeeAdjustedCollateral(), _addCollateral() and _removeCollateral() must be used to access and adjust.
FixedPoint.Unsigned public rawTotalPositionCollateral;
FixedPoint.Unsigned public rawTotalPositionCollateral;
34,831
15
// Caller deposits the staking token to start earning rewards _amount amount of staking token to deposit /
function deposit(uint256 _amount) external override notStopped nonReentrant
function deposit(uint256 _amount) external override notStopped nonReentrant
48,070
5
// Emitted when issuance SupplyThrottle params are set
event IssuanceThrottleSet(ThrottleLib.Params oldVal, ThrottleLib.Params newVal);
event IssuanceThrottleSet(ThrottleLib.Params oldVal, ThrottleLib.Params newVal);
4,683
79
// List of all tokens
Token[] tokens;
Token[] tokens;
80,926
81
// Liquidity zap into CHEF.
function zapToMasterChef( address to, address _FromTokenContractAddress, uint256 _amount, uint256 _minPoolTokens, uint256 pid, address _swapTarget, bytes calldata swapData
function zapToMasterChef( address to, address _FromTokenContractAddress, uint256 _amount, uint256 _minPoolTokens, uint256 pid, address _swapTarget, bytes calldata swapData
18,673
12
// 玄武 奖池 40%, 所有持KEY玩家 -40%, 推荐 - 10%, 开发团队 - 5%, 空投 - 5%
fees_[3] = F3Ddatasets.TeamFee(40,0);
fees_[3] = F3Ddatasets.TeamFee(40,0);
14,936
121
// For purchase with NUX token only. Available only for tokensale nuxAmount Amount of the NUX token /
function purchaseDHVwithNUX(uint256 nuxAmount) external onlyPreSale whenNotPaused correctGas { require(nuxAmount > 0, "Zero amount"); uint256 purchaseAmount = _calcPurchaseAmount(NUXToken, nuxAmount); require(purchaseAmount.add(purchased[msg.sender]) <= maxTokensAmount, "Maximum allowed exce...
function purchaseDHVwithNUX(uint256 nuxAmount) external onlyPreSale whenNotPaused correctGas { require(nuxAmount > 0, "Zero amount"); uint256 purchaseAmount = _calcPurchaseAmount(NUXToken, nuxAmount); require(purchaseAmount.add(purchased[msg.sender]) <= maxTokensAmount, "Maximum allowed exce...
37,762
4
// A mapping of the number of Collection minted per collectionId per user assetMintedPerCollectionId[msg.sender][collectionId] => number of minted Asset
mapping(address => mapping(uint256 => uint256)) private assetMintedPerCollectionId;
mapping(address => mapping(uint256 => uint256)) private assetMintedPerCollectionId;
66,373
6
// computes e ^ (x / FIXED_1)FIXED_1 input range: 0 <= x <= OPT_EXP_MAX_VAL - 1 auto-generated via 'PrintFunctionOptimalExp.py' Detailed description: - Rewrite the input as a sum of binary exponents and a single residual r, as small as possible - The exponentiation of each binary exponent is given (pre-calculated) - Th...
function optimalExp(uint256 x) public pure returns (uint256) { uint256 res = 0; uint256 y; uint256 z; z = y = x % 0x10000000000000000000000000000000; // get the input modulo 2^(-3) z = (z * y) / FIXED_1; res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!) ...
function optimalExp(uint256 x) public pure returns (uint256) { uint256 res = 0; uint256 y; uint256 z; z = y = x % 0x10000000000000000000000000000000; // get the input modulo 2^(-3) z = (z * y) / FIXED_1; res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!) ...
35,558
89
// we go from 1 to 0 : we swap ether to tether
uint256 wholeEtherBalance = this.getEtherBalance(); this.swap(_maticWEther,_maticTether,wholeEtherBalance,0,address(this)); _cashMode = true;
uint256 wholeEtherBalance = this.getEtherBalance(); this.swap(_maticWEther,_maticTether,wholeEtherBalance,0,address(this)); _cashMode = true;
48,952
24
// For querying balance of a particular account/_owner The address for balance query/Required for ERC-721 compliance.
function balanceOf(address _owner) public view returns (uint balance)
function balanceOf(address _owner) public view returns (uint balance)
23,737
23
// SAFE database
SAFEEngineLike public safeEngine;
SAFEEngineLike public safeEngine;
47,434
95
// cc:III. MintAllowed Setting2;Mint Allowed Switch;1; SETTING: Mint Allowed Switch (bool) Boundary: true or false Enables or disables token minting ability globally (even for custodian).
bool private mintAllowed = false;
bool private mintAllowed = false;
45,087
3
// Call TransferProxy contract to transfer user tokens to Vault
state.transferProxyInstance.transfer( _token, _quantity, msg.sender, state.vault );
state.transferProxyInstance.transfer( _token, _quantity, msg.sender, state.vault );
18,054
5
// / Validate configWord cleaness for future compatibility, or else may introduce undefined future behavior
function isConfigWordClean(uint256 configWord) internal pure returns (bool) { return (configWord & ~(APP_LEVEL_MASK | APP_JAIL_BIT | AGREEMENT_CALLBACK_NOOP_BITMASKS)) == uint256(0); }
function isConfigWordClean(uint256 configWord) internal pure returns (bool) { return (configWord & ~(APP_LEVEL_MASK | APP_JAIL_BIT | AGREEMENT_CALLBACK_NOOP_BITMASKS)) == uint256(0); }
16,895
6
// ============================= INITIALIZER ============================= / Set params of nft collection _uri For nft metadata _containerName Plain text representation, 'symbol' on chain _containerLabel Integer value _containerSerial keccak256 hash representing container off-chain _defaultAdmin Default admin address _...
function initialize( string memory _uri, string memory _containerName, string memory _containerLabel, bytes32 _containerSerial, address _defaultAdmin, address _royaltyWallet, address _minter ) external payable { require(initialized == false, 'Contract already initialized!');
function initialize( string memory _uri, string memory _containerName, string memory _containerLabel, bytes32 _containerSerial, address _defaultAdmin, address _royaltyWallet, address _minter ) external payable { require(initialized == false, 'Contract already initialized!');
8,102
64
// only allow admins to execute buy and sell proposals early
return true;
return true;
10,792
17
// Thrown on configurator attempting to add more than 256 collateral tokens
error TooManyTokensException();
error TooManyTokensException();
20,230
69
// exclude owner and this contract from fee.
excludeAccountFromFee(owner()); excludeAccountFromFee(address(this));
excludeAccountFromFee(owner()); excludeAccountFromFee(address(this));
12,956
44
// calculate the expected root based on the proof
bytes32 _calculatedRoot = MerkleLib.branchRoot(_leaf, _proof, _index);
bytes32 _calculatedRoot = MerkleLib.branchRoot(_leaf, _proof, _index);
51,335
11
// Request the description based on the login
Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(_jobId), address(this), this.fullfillVerification.selector); req.add("login", _login); req.add("action", "verify");
Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(_jobId), address(this), this.fullfillVerification.selector); req.add("login", _login); req.add("action", "verify");
4,514
33
// Increase the amount of tokens that an owner allowed to a spender._spender The address which will spend the funds._addedValue The amount of tokens to increase the allowance by./
function increaseApproval( address _spender, uint _addedValue ) public returns (bool)
function increaseApproval( address _spender, uint _addedValue ) public returns (bool)
21,700
18
// only valid before tally
function matchable(address token) private view returns (uint) { uint donations = fundraiser.tokenBalance(token); uint granted = tokenBalance(token); return donations > granted ? granted : donations; }
function matchable(address token) private view returns (uint) { uint donations = fundraiser.tokenBalance(token); uint granted = tokenBalance(token); return donations > granted ? granted : donations; }
38,130
10
// Checks that the mapping key is valid (unique)
function _isMappingKeyValid(string calldata key) internal view { require(pools[key] == address(0), "PF:POOL_ID_ALREADY_EXISTS"); }
function _isMappingKeyValid(string calldata key) internal view { require(pools[key] == address(0), "PF:POOL_ID_ALREADY_EXISTS"); }
18,627
10
// updates duration (in seconds for the moment)
if( endTime - block.timestamp < 5 ){ endTime += 3; // will be more in real contract, just testing behavior claimTime += 3; // update claim time too }
if( endTime - block.timestamp < 5 ){ endTime += 3; // will be more in real contract, just testing behavior claimTime += 3; // update claim time too }
34,198
137
// Overrides Crowdsale fund forwarding, sending funds to escrow. /
function _forwardFunds() internal { _escrow.deposit.value(msg.value)(_msgSender()); }
function _forwardFunds() internal { _escrow.deposit.value(msg.value)(_msgSender()); }
24,443
54
// eth:dge2 pairs, @_ethAmount = input eth amount, return @_amounts = get dge1 amount
function getEthExDgeAmount(uint256 _ethAmount) public view returns(uint[] memory _dgeAmounts) { IUniswapV2Router02 uniswpair = IUniswapV2Router02(uniswapV2Router02Addr); address[] memory path; path = new address[](2); path[0] = weth; path[1] = dgeContractAddr1; return...
function getEthExDgeAmount(uint256 _ethAmount) public view returns(uint[] memory _dgeAmounts) { IUniswapV2Router02 uniswpair = IUniswapV2Router02(uniswapV2Router02Addr); address[] memory path; path = new address[](2); path[0] = weth; path[1] = dgeContractAddr1; return...
9,413
3
// return string The string "Name"
function name() external view returns (string memory);
function name() external view returns (string memory);
53,915
200
// Withdraw LP tokens. Only non-locked LP and Locked LP after lock period can be withdrawed
function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); require(now > user.lastDepositTime + user.timelock, "Your LP is LOCKed for the ...
function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); require(now > user.lastDepositTime + user.timelock, "Your LP is LOCKed for the ...
8,625
349
// Create a new bytes structure around [from, to) in-place.
assembly { result := add(b, from) mstore(result, sub(to, from)) }
assembly { result := add(b, from) mstore(result, sub(to, from)) }
16,112
9
// Returns the number of referral links used by a sender_campaignId id of the campaign _senderAddress address of the tokenreturn the number of referral links used by a sender /
function campaignReferralLinks(uint256 _campaignId, address _senderAddress) external view override returns (uint256)
function campaignReferralLinks(uint256 _campaignId, address _senderAddress) external view override returns (uint256)
24,211
0
// Abstract Storage Contract to pad the first 32 slots of storage/Superfluid/MUST be the FIRST contract inherited to pad the first 32 slots. The slots are padded to/ ensure the implementation contract (SuperToken.sol) does not override any auxiliary state/ variables. For more info see `./docs/StorageLayout.md`.
abstract contract SuperTokenStorage { uint256[32] internal _storagePaddings; }
abstract contract SuperTokenStorage { uint256[32] internal _storagePaddings; }
2,264
293
// 1 token causes rounding error with withdrawUnderlying
if (balanceOfToken(address(cToken)) > 1) { _withdrawSome(deposits.sub(borrows)); }
if (balanceOfToken(address(cToken)) > 1) { _withdrawSome(deposits.sub(borrows)); }
44,690
1
// approve rewarder to spend
liquidityToken.approve(address(rewardPool), type(uint256).max);
liquidityToken.approve(address(rewardPool), type(uint256).max);
35,583
335
// Redeemed amount represented in decimals of asset
uint256 redeemAmount;
uint256 redeemAmount;
43,150
4
// Get the address of the owner/ return The address of the owner.
function owner() external view returns (address);
function owner() external view returns (address);
10,921
211
// IGarden Interface for operating with a Garden. /
interface ICoreGarden { /* ============ Constructor ============ */ /* ============ View ============ */ function privateGarden() external view returns (bool); function publicStrategists() external view returns (bool); function publicStewards() external view returns (bool); function control...
interface ICoreGarden { /* ============ Constructor ============ */ /* ============ View ============ */ function privateGarden() external view returns (bool); function publicStrategists() external view returns (bool); function publicStewards() external view returns (bool); function control...
67,893
100
// multiply by e^2^(-2)
if ((x & 0x040000000000000000000000000000000) != 0) res = (res * 0x1368b2fc6f9609fe7aceb46aa619baed5) / 0x0bc5ab1b16779be3575bd8f0520a9f21f;
if ((x & 0x040000000000000000000000000000000) != 0) res = (res * 0x1368b2fc6f9609fe7aceb46aa619baed5) / 0x0bc5ab1b16779be3575bd8f0520a9f21f;
1,254
93
// Keep track of user ticket ids for a given lotteryId
mapping(address => mapping(uint256 => uint256[])) private _userTicketIdsPerLotteryId;
mapping(address => mapping(uint256 => uint256[])) private _userTicketIdsPerLotteryId;
10,101
90
// subtract send balanced
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
35,895
155
// Swap Index mapping & remap the latest group ID if this is not the last group
groups[ein][_groupIndex] = groups[ein][currentGroupIndex]; groupCount[ein] = _stichSortOrder(groupOrder[ein], _groupIndex, currentGroupIndex, 0);
groups[ein][_groupIndex] = groups[ein][currentGroupIndex]; groupCount[ein] = _stichSortOrder(groupOrder[ein], _groupIndex, currentGroupIndex, 0);
36,929
0
// wallet of developer
address public developer;
address public developer;
5,351
0
// 0x80ac58cd ===bytes4(keccak256('balanceOf(address)')) ^bytes4(keccak256('ownerOf(uint256)')) ^bytes4(keccak256('approve(address,uint256)')) ^bytes4(keccak256('getApproved(uint256)')) ^bytes4(keccak256('setApprovalForAll(address,bool)')) ^bytes4(keccak256('isApprovedForAll(address,address)')) ^bytes4(keccak256('trans...
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
5,473
5
// We only want to do work in the case where the agent whose Revoke the agent's authorization.
delete self.authorized[agent];
delete self.authorized[agent];
23,099
68
// |
function initializedComplete() external returns (bool) { // Controller Role Required require(hasRole(CONTROLLER_ROLE, msg.sender)); // Citadel Unitialized require(CITADEL_INITIALIZED == false); // Toggle Citadel Intialized CITADEL_INITIALIZED = true; return...
function initializedComplete() external returns (bool) { // Controller Role Required require(hasRole(CONTROLLER_ROLE, msg.sender)); // Citadel Unitialized require(CITADEL_INITIALIZED == false); // Toggle Citadel Intialized CITADEL_INITIALIZED = true; return...
81,790
63
// Upgrade radbros from v1. Public function for users to upgrade from v1 contract./5% chance of winning a radbro/10% chance of winning 100 $RAD
function upgradeFromV1( uint256[] calldata radbroIds, bool claimRadcoin, uint256 radcoinToUpgrade
function upgradeFromV1( uint256[] calldata radbroIds, bool claimRadcoin, uint256 radcoinToUpgrade
38,748
36
// locked token structure /
struct lockToken { uint256 amount; uint256 validity; bool claimed; }
struct lockToken { uint256 amount; uint256 validity; bool claimed; }
14,587
72
// return the bucket's share
return MathHelpers.getPartialAmount( lentPrincipal, principalTotal, owedAmount );
return MathHelpers.getPartialAmount( lentPrincipal, principalTotal, owedAmount );
20,697
46
// Using this function might breaks CORE functionally - be careful
function renounceCanTransfer() public { _removeCanTransfer(_msgSender()); }
function renounceCanTransfer() public { _removeCanTransfer(_msgSender()); }
32,102
38
// Checks whether the cap has been reached.return Whether the cap was reached /
function capReached() public view returns (bool) { return tokensRaised >= cap; }
function capReached() public view returns (bool) { return tokensRaised >= cap; }
5,468
9
// Revert with a standard message if `account` is missing `role`. The format of the revert reason is given by the following regular expression:
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( 'AccessControl: account ', Strings.toHexStrin...
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( 'AccessControl: account ', Strings.toHexStrin...
10,436
1
// This message defenition shoult be autogenerated from ROS message description language.TODO: message generator implementation. /
contract StdString is Message { string public data; function StdString(string _data) { data = _data; } }
contract StdString is Message { string public data; function StdString(string _data) { data = _data; } }
10,926
691
// UserInfo storage user = userInfo[msg.sender];
IERC20(pToken).safeTransferFrom(address(msg.sender), address(this), amount);
IERC20(pToken).safeTransferFrom(address(msg.sender), address(this), amount);
30,903
9
// the curve LP token address for the particular pool
IERC20 public curveLPToken;
IERC20 public curveLPToken;
49,289
136
// remove a winner project from the registy
function _removeWinnerProject(address holderAddress) private onlyMinter { // delete from _projects array delete _projects[_projectsData[holderAddress].projectID]; // delete from _projectsData mapping delete _projectsData[holderAddress]; }
function _removeWinnerProject(address holderAddress) private onlyMinter { // delete from _projects array delete _projects[_projectsData[holderAddress].projectID]; // delete from _projectsData mapping delete _projectsData[holderAddress]; }
21,932