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
7
// Keep track of tokensSold
tokensSold += _numberOfTokens;
tokensSold += _numberOfTokens;
22,348
27
// setProvenance allows admin to set the provenance of a user
function setProvenance(address user, uint provenance) onlyOwner external returns (bool)
function setProvenance(address user, uint provenance) onlyOwner external returns (bool)
55,509
140
// Calculate geometric average of x and y, i.e. sqrt (xy) rounding down.Revert on overflow or in case xy is negative.x signed 64.64-bit fixed point number y signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number /
function gavg (int128 x, int128 y) internal pure returns (int128) { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m))); }
function gavg (int128 x, int128 y) internal pure returns (int128) { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m))); }
10,744
10
// The threshold must be checked against the claimable balance, not against the amount out. The amount out is computed considering both the claimable balance and the smart vault balance in case of a swap, but if the token in is ignored, the smart vault balance must be ignored. We can leverage the call information to ra...
uint256 wrappedNativeTokenPrice = amountIn.divUp(expectedAmountOut); uint256 wrappedNativeTokenClaimableBalance = claimableBalance(tokenIn).divDown(wrappedNativeTokenPrice); _validateThreshold(wrappedNativeToken, wrappedNativeTokenClaimableBalance); _claim(tokenIn); ...
uint256 wrappedNativeTokenPrice = amountIn.divUp(expectedAmountOut); uint256 wrappedNativeTokenClaimableBalance = claimableBalance(tokenIn).divDown(wrappedNativeTokenPrice); _validateThreshold(wrappedNativeToken, wrappedNativeTokenClaimableBalance); _claim(tokenIn); ...
32,006
39
// Transfers the xTokens between two users. Validates the transfer(ie checks for valid HF after the transfer) if required from The source address to The destination address amount The amount getting transferred validate `true` if the transfer needs to be validated /
) internal updateReward(from) updateReward(to) { uint256 index = POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS); uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index); uint256 toBalanceBefore = super.balanceOf(to).rayMul(index); super._transfer(from...
) internal updateReward(from) updateReward(to) { uint256 index = POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS); uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index); uint256 toBalanceBefore = super.balanceOf(to).rayMul(index); super._transfer(from...
77,768
5
// Send allocated base to the dev
if (base_allocated > max_base_allocated) { base_allocated = max_base_allocated; }
if (base_allocated > max_base_allocated) { base_allocated = max_base_allocated; }
7,115
121
// Destroys `tokenId`.The approval is cleared when the token is burned. Requirements: - `tokenId` must exist.
* Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), to...
* Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), to...
44,201
12
// list of flags determines whether the SecondaryTradingLimit & TransactionCountLimit are enabled.bool-values which will show if the limits have to be switch-ON (see contract {Limits}):enableLimits[0] - true: the SecondaryTradingLimit will be switchON, false: switchOFFenableLimits[1] - true: the TransactionCountLimit w...
bool[2] memory _enableLimits,
bool[2] memory _enableLimits,
24,115
4
// Creating an array of campaigns
Campaign[] memory campaignList = new Campaign[](numberOfCampaigns); for(uint i = 0; i < numberOfCampaigns; i++) { Campaign storage item = campaigns[i]; campaignList[i] = item; }
Campaign[] memory campaignList = new Campaign[](numberOfCampaigns); for(uint i = 0; i < numberOfCampaigns; i++) { Campaign storage item = campaigns[i]; campaignList[i] = item; }
13,641
468
// Upgrades from old implementations will perform a rollback test. This test requires the new implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else {
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else {
74,178
63
// Transfer the wrapped ether to this address from the Vault
coreInstance.withdrawModule( address(this), address(this), address(weth), currentComponentQuantity );
coreInstance.withdrawModule( address(this), address(this), address(weth), currentComponentQuantity );
44,340
10
// MAINNET uint256 public tombPerSecond = 0.11574 ether;10000 TOMB / (24h60min60s) uint256 public runningTime = 1 days;1 days uint256 public constant TOTAL_REWARDS = 10000 ether; END MAINNET
event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event RewardPaid(address indexed user, uint256 amount); construct...
event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event RewardPaid(address indexed user, uint256 amount); construct...
26,391
61
// check the purchase record of the buyer
uint newPurchaseRecord = flashSaleIDToPurchaseRecord[_saleID][msg.sender].add(_amount); require(newPurchaseRecord <= flashSale.purchaseLimitation, "total amount to purchase exceeds the limitation of an address");
uint newPurchaseRecord = flashSaleIDToPurchaseRecord[_saleID][msg.sender].add(_amount); require(newPurchaseRecord <= flashSale.purchaseLimitation, "total amount to purchase exceeds the limitation of an address");
1,119
15
// Allows the current owner to relinquish control of the contract. Renouncing to ownership will leave the contract without an owner.It will not be possible to call the functions with the `onlyOwner`modifier anymore. /
function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); }
function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); }
21,489
11
// Returns the crowdsale status. If the crowdsale has not started, returns NOT_STARTED./if crowdsale had been initialized, calls underlying crowdsale.status()./ return CrowdsaleStatus enum value.
function crowdsaleStatus() public view returns (CrowdsaleStatus) { if (address(crowdsale) == address(0)) { return CrowdsaleStatus.NOT_PLANNED; } return crowdsale.status(); }
function crowdsaleStatus() public view returns (CrowdsaleStatus) { if (address(crowdsale) == address(0)) { return CrowdsaleStatus.NOT_PLANNED; } return crowdsale.status(); }
34,023
61
// Address of primary wallet
address payable public walletAddress;
address payable public walletAddress;
51,069
172
// Total amount the strategy is expected to have
uint256 totalStrategyDebt;
uint256 totalStrategyDebt;
38,174
88
// shift premium from settled rounds with rounds control
uint maxRound = _options[i].getRound(); for (uint r = _options[i].getSettledPremiumRound(account) + 1; r < maxRound; r++) { uint roundPremium = _options[i].getRoundPremiumShare(r) .mul(accountCollateral) ...
uint maxRound = _options[i].getRound(); for (uint r = _options[i].getSettledPremiumRound(account) + 1; r < maxRound; r++) { uint roundPremium = _options[i].getRoundPremiumShare(r) .mul(accountCollateral) ...
18,430
10
// getting the amount of Ether sent to the owner which is the owner royality
uint256 royaltyAmount = getAmount(originalAmount, ownerRoyalty);
uint256 royaltyAmount = getAmount(originalAmount, ownerRoyalty);
25,981
12
// BaseCrowdsale Extends from Crowdsale with more stuffs like TimedCrowdsale, CappedCrowdsale. Base for any other Crowdsale contract /
contract BaseCrowdsale is TimedCrowdsale, CappedCrowdsale, TokenRecover { // reference to Contributions contract Contributions private _contributions; // the minimum value of contribution in wei uint256 private _minimumContribution; /** * @dev Reverts if less than minimum contribution *...
contract BaseCrowdsale is TimedCrowdsale, CappedCrowdsale, TokenRecover { // reference to Contributions contract Contributions private _contributions; // the minimum value of contribution in wei uint256 private _minimumContribution; /** * @dev Reverts if less than minimum contribution *...
22,395
656
// burn claimed shares
_hypervisor.rewardSharesOutstanding = _hypervisor.rewardSharesOutstanding.sub(sharesToBurn);
_hypervisor.rewardSharesOutstanding = _hypervisor.rewardSharesOutstanding.sub(sharesToBurn);
40,805
37
// 20% Finder allocation
uint256 public purchasableTokens = 112000 * 10**18; uint256 public founderAllocation = 28000 * 10**18; string public name = "TeamHODL Token"; string public symbol = "THODL"; uint256 public decimals = 18; uint256 public INITIAL_SUPPLY = 140000 * 10**18; uint256 public RATE = 200; uint256 public REFUND_RATE = 2...
uint256 public purchasableTokens = 112000 * 10**18; uint256 public founderAllocation = 28000 * 10**18; string public name = "TeamHODL Token"; string public symbol = "THODL"; uint256 public decimals = 18; uint256 public INITIAL_SUPPLY = 140000 * 10**18; uint256 public RATE = 200; uint256 public REFUND_RATE = 2...
26,511
9
// Crystal TokenID => CrystalInfo
mapping(uint256 => CrystalInfo) public crystals;
mapping(uint256 => CrystalInfo) public crystals;
45,141
164
// this prevents the secondary token being itself and therefore negating burn
require(address(_token) != address(this), 'Secondary token cannot be itself');
require(address(_token) != address(this), 'Secondary token cannot be itself');
38,318
19
// WithdrawDelegatorRewards defines an Event emitted when rewards from a delegation are withdrawn/delegatorAddress the address of the delegator/validatorAddress the address of the validator/amount the amount being withdrawn from the delegation
event WithdrawDelegatorRewards( address indexed delegatorAddress, string indexed validatorAddress, uint256 amount );
event WithdrawDelegatorRewards( address indexed delegatorAddress, string indexed validatorAddress, uint256 amount );
32,019
12
// fee
0,
0,
18,010
63
// stage 3linear equation: y = 6.72202×10^-7 x - 0.361011intercepts (1000000,0.311191) and (5000000,3)
if (x >= 1000000000000000000000000) { return (((x).mul(2688809)).div(4000000000000)).sub(361011250000000000); }
if (x >= 1000000000000000000000000) { return (((x).mul(2688809)).div(4000000000000)).sub(361011250000000000); }
13,944
29
// Eyes N°30 => RIP
function item_30() public pure returns (string memory) { return base( string( abi.encodePacked( '<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="225.7" y1="190.8" x2="242.7" y2="207...
function item_30() public pure returns (string memory) { return base( string( abi.encodePacked( '<line fill="none" stroke="#000000" stroke-width="3" stroke-linecap="square" stroke-miterlimit="10" x1="225.7" y1="190.8" x2="242.7" y2="207...
43,834
225
// Harvest staking reward tokens to in-exec position's owner/wstaking Wrapped staking rewards
function harvestWStakingRewards(address wstaking) external { (, address collToken, uint collId, ) = bank.getCurrentPositionInfo(); address lp = IWStakingRewards(wstaking).getUnderlyingToken(collId); require(whitelistedLpTokens[lp], 'lp token not whitelisted'); require(collToken == wstaking, 'collatera...
function harvestWStakingRewards(address wstaking) external { (, address collToken, uint collId, ) = bank.getCurrentPositionInfo(); address lp = IWStakingRewards(wstaking).getUnderlyingToken(collId); require(whitelistedLpTokens[lp], 'lp token not whitelisted'); require(collToken == wstaking, 'collatera...
54,140
3
// Verifique se o usuário possui o token Episode
require(balanceOf[msg.sender][_tokenId] > 0, "You do not own this Episode");
require(balanceOf[msg.sender][_tokenId] > 0, "You do not own this Episode");
25,574
39
// TODO: Optimize by using assembly
bidHash = keccak256( abi.encode( BID_TYPEHASH, bid.itemKind, bid.maker, bid.token, bid.identifierOrCriteria, bid.unitPrice, bid.amount, bid.salt,
bidHash = keccak256( abi.encode( BID_TYPEHASH, bid.itemKind, bid.maker, bid.token, bid.identifierOrCriteria, bid.unitPrice, bid.amount, bid.salt,
8,815
14
// Function to create the "node" in the merkle tree, given account and allocation/account the account/percent the allocation/ return the bytes32 representing the node / leaf
function getNode(address account, uint256 percent) public pure returns (bytes32)
function getNode(address account, uint256 percent) public pure returns (bytes32)
2,095
22
// Get the configs.
TokenConfig storage config = getConfig(_key);
TokenConfig storage config = getConfig(_key);
30,135
248
// Receipt methods
function toBytes(Receipt memory receipt) internal pure returns(bytes memory) { return receipt.raw; }
function toBytes(Receipt memory receipt) internal pure returns(bytes memory) { return receipt.raw; }
55,837
769
// Calculates and returns active stake for address Active stake = (active deployer stake + active delegator stake) active deployer stake = (direct deployer stake - locked deployer stake) locked deployer stake = amount of pending decreaseStakeRequest for address active delegator stake = (total delegator stake - locked d...
function _calculateAddressActiveStake(address _address) private view returns (uint256) { ServiceProviderFactory spFactory = ServiceProviderFactory(serviceProviderFactoryAddress); DelegateManager delegateManager = DelegateManager(delegateManagerAddress); // Amount directly staked by address,...
function _calculateAddressActiveStake(address _address) private view returns (uint256) { ServiceProviderFactory spFactory = ServiceProviderFactory(serviceProviderFactoryAddress); DelegateManager delegateManager = DelegateManager(delegateManagerAddress); // Amount directly staked by address,...
41,557
153
// check if the _data.length > 0 and if it is forward it to the newly created contract
let dataLength := mload(_data) if iszero(iszero(dataLength)) { if iszero(call(gas, proxyContract, 0, add(_data, 0x20), dataLength, 0, 0)) { revert(0, 0) }
let dataLength := mload(_data) if iszero(iszero(dataLength)) { if iszero(call(gas, proxyContract, 0, add(_data, 0x20), dataLength, 0, 0)) { revert(0, 0) }
5,303
100
// We need to swap the current tokens to ETH and send to the ext wallet
swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToTeamDev(address(this).balance); }
swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToTeamDev(address(this).balance); }
26,323
5
// @custom:security-contact security@ethereum-tx.com
contract EthereumTx is ERC20, ERC20Burnable, Pausable, Ownable { constructor() ERC20("Ethereum-tx", "ETX") { _mint(msg.sender, 21000000 * 10 ** decimals()); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } functi...
contract EthereumTx is ERC20, ERC20Burnable, Pausable, Ownable { constructor() ERC20("Ethereum-tx", "ETX") { _mint(msg.sender, 21000000 * 10 ** decimals()); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } functi...
29,377
49
// Case 3: The layer has a rare Cryptopunk variant and it will activate
layer == genesis.punk[0] && remainingPunkMutations > 0 && variant < RARE_VARIANT_PROBABILITY ) {
layer == genesis.punk[0] && remainingPunkMutations > 0 && variant < RARE_VARIANT_PROBABILITY ) {
50,114
117
// Delete Methods
function deleteUint(bytes32 _key) external onlyCurrentOwner { delete uIntStorage[_key]; }
function deleteUint(bytes32 _key) external onlyCurrentOwner { delete uIntStorage[_key]; }
14,568
9
// Map of the users data
mapping(address => UserRecord) private user_data;
mapping(address => UserRecord) private user_data;
60,924
297
// returns whether the pool is valid /
function isPoolValid(Token pool) external view returns (bool);
function isPoolValid(Token pool) external view returns (bool);
64,995
71
// get rate update block
bytes32 compactData = tokenRatesCompactData[tokenData[token].compactDataArrayIndex]; uint updateRateBlock = getLast4Bytes(compactData); if (currentBlockNumber >= updateRateBlock + validRateDurationInBlocks) return 0; // rate is expired
bytes32 compactData = tokenRatesCompactData[tokenData[token].compactDataArrayIndex]; uint updateRateBlock = getLast4Bytes(compactData); if (currentBlockNumber >= updateRateBlock + validRateDurationInBlocks) return 0; // rate is expired
17,809
10
// Read the amount of LP_expiry staked for a user /
function getBalances(uint256 expiry, address user) external view returns (uint256);
function getBalances(uint256 expiry, address user) external view returns (uint256);
8,137
0
// @inheritdoc IERC165 /
function supportsInterface(bytes4 interfaceId) public view returns (bool) { return ERC165Storage.layout().isSupportedInterface(interfaceId); }
function supportsInterface(bytes4 interfaceId) public view returns (bool) { return ERC165Storage.layout().isSupportedInterface(interfaceId); }
20,301
7
// Calculate and mint the amount of xGDL the GDL is worth. The ratio will change overtime, as xGDL is burned/minted and GDL deposited + gained from fees / withdrawn.
else { uint256 what = _amount.mul(totalShares).div(totalGDL); _mint(msg.sender, what); }
else { uint256 what = _amount.mul(totalShares).div(totalGDL); _mint(msg.sender, what); }
8,796
194
// We split this out because we need to rebuild the cache after adding synths.
function setCurrencies() external onlyOwner { for (uint i = 0; i < synths.length; i++) { ISynth synth = ISynth(requireAndGetAddress(synths[i])); synthsByKey[synth.currencyKey()] = synths[i]; } }
function setCurrencies() external onlyOwner { for (uint i = 0; i < synths.length; i++) { ISynth synth = ISynth(requireAndGetAddress(synths[i])); synthsByKey[synth.currencyKey()] = synths[i]; } }
38,818
0
// _feeThousandthsPercent The fee percentage with three decimal places. _minFeeAmount The minimuim fee to charge. /
constructor(uint16 _feeThousandthsPercent, uint256 _minFeeAmount) public { require(_feeThousandthsPercent < (1 << 16), "fee % too high"); require(_minFeeAmount <= (1 << 255), "minFeeAmount too high"); feeThousandthsPercent = _feeThousandthsPercent; minFeeAmount = _minFeeAmount; }...
constructor(uint16 _feeThousandthsPercent, uint256 _minFeeAmount) public { require(_feeThousandthsPercent < (1 << 16), "fee % too high"); require(_minFeeAmount <= (1 << 255), "minFeeAmount too high"); feeThousandthsPercent = _feeThousandthsPercent; minFeeAmount = _minFeeAmount; }...
32,142
53
// Add `elastic` and `base` to `total`.
function add( Rebase memory total, uint256 elastic, uint256 base
function add( Rebase memory total, uint256 elastic, uint256 base
45,399
28
// shit doesn't really matter cuz after big fibonnaci daz we go down to25-golden ratio, so need not to remember until then
function rapidAdoptionBoost() public { if(rapidAdoptionBoost) { reject "already been activated"; } if(block.timestamp < 22.september) { reject "rapidAdoptionBoost can only be activated after this period" } rapidAdoptionBoost = true; }
function rapidAdoptionBoost() public { if(rapidAdoptionBoost) { reject "already been activated"; } if(block.timestamp < 22.september) { reject "rapidAdoptionBoost can only be activated after this period" } rapidAdoptionBoost = true; }
35,379
14
// ________________________________________________________/Constrctor function /
function CrowdSaleMacroansyA() public { owner = msg.sender; beneficiaryFunds = owner; saleParamSet = false; fundingGoalReached = false; crowdsaleStart = false; crowdsaleClosed = false; unlockFundersBalance = false; }
function CrowdSaleMacroansyA() public { owner = msg.sender; beneficiaryFunds = owner; saleParamSet = false; fundingGoalReached = false; crowdsaleStart = false; crowdsaleClosed = false; unlockFundersBalance = false; }
9,356
20
// Sets time to generate new charity_time donation time/
function setSendDonationTime(uint256 _time) public isOwner { sendDonationTime = _time; }
function setSendDonationTime(uint256 _time) public isOwner { sendDonationTime = _time; }
38,043
113
// verify if sessionPubkeyHash was verified already, if not.. let's do it!
if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){ oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset); }
if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){ oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset); }
12,237
298
// Mapping of SetToken to boolean indicating if SetToken is on allow list. Updateable by governance
mapping(ISetToken => bool) public allowedSetTokens;
mapping(ISetToken => bool) public allowedSetTokens;
2,827
176
// Triggered when a manager is removed
event DelManager(address indexed _managerAddr, uint256 _timestamp);
event DelManager(address indexed _managerAddr, uint256 _timestamp);
10,463
156
// Block till deflationary update tokens per block ( 24h x 60sec x 60 min / 3sec : time per block )
uint256 newBlockToUpdate = 24 * 60 * 60 / 3; uint256 blockSinceDeflate = block.number.sub( startBlock.add( blockBeforeDeflationary) ); uint256 deflateNumber = ( blockSinceDeflate.sub( blockSinceDeflate.mod( newBlockToUpdate ) ) ).div( newBlockToUpdate ); if (deflateNumber...
uint256 newBlockToUpdate = 24 * 60 * 60 / 3; uint256 blockSinceDeflate = block.number.sub( startBlock.add( blockBeforeDeflationary) ); uint256 deflateNumber = ( blockSinceDeflate.sub( blockSinceDeflate.mod( newBlockToUpdate ) ) ).div( newBlockToUpdate ); if (deflateNumber...
31,537
22
// Upgrade costs in HXP for all lvls
config["UPGR0"] = 5000; config["UPGR1"] = 200000; config["UPGR2"] = 800000; config["UPGR3"] = 1200000;
config["UPGR0"] = 5000; config["UPGR1"] = 200000; config["UPGR2"] = 800000; config["UPGR3"] = 1200000;
42,674
82
// variables
address public stolAddress; // The address for the STOL tokens uint256 public minPercentClaim = 4000; // Initial conditions are 4% of USD value of STOL holdings can be claimed uint256 public minClaimWindow = 3 days; // User must wait at least 3 days after last deposit action to claim uint256 public maxA...
address public stolAddress; // The address for the STOL tokens uint256 public minPercentClaim = 4000; // Initial conditions are 4% of USD value of STOL holdings can be claimed uint256 public minClaimWindow = 3 days; // User must wait at least 3 days after last deposit action to claim uint256 public maxA...
30,446
20
// burn a token/tokenId the token id
function _burn(uint256 tokenId) internal override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
function _burn(uint256 tokenId) internal override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
25,162
20
// If the staker already has tokens staked, calculate and add any unclaimed rewards
if (staker.amountStaked > 0) { uint256 rewards = calculateRewards(msg.sender); staker.unclaimedRewards += rewards; }
if (staker.amountStaked > 0) { uint256 rewards = calculateRewards(msg.sender); staker.unclaimedRewards += rewards; }
14,093
126
// Changes the existing Minimum cover period (in days)
function _changeMinDays(uint _days) internal { minDays = _days; }
function _changeMinDays(uint _days) internal { minDays = _days; }
28,647
0
// Safely converts a uint256 to an int256. /
function toInt256Safe(uint256 a) internal pure returns (int256)
function toInt256Safe(uint256 a) internal pure returns (int256)
37,434
137
// Owner initates the transfer of the card to another account/_to The address for the card to be transferred to./_divCardId The ID of the card that can be transferred if this call succeeds./Required for ERC-721 compliance.
function transfer(address _to, uint _divCardId) public isNotContract
function transfer(address _to, uint _divCardId) public isNotContract
24,314
29
// Decrease the _amount of tokens that an owner has allowed to a _spender. _spender The address which will spend the funds. _subtractedValue The _amount of tokens to decrease the allowance by. /
function decreaseAllowance(address _spender, uint256 _subtractedValue) public override returns (bool)
function decreaseAllowance(address _spender, uint256 _subtractedValue) public override returns (bool)
36,225
211
// The NokuCustomERC20AdvancedToken contract is a custom ERC20AdvancedLite, a security token ERC20-compliant, token available in the Noku Service Platform (NSP). The Noku customer is able to choose the token name, symbol, decimals, initial supply and to administer its lifecycle by minting or burning tokens in order to ...
contract NokuCustomERC20AdvancedLite is NokuCustomTokenLite, BasicSecurityTokenWithDecimals { event LogNokuCustomERC20AdvancedLiteCreated( address indexed caller, string indexed name, string indexed symbol, uint8 decimals ); constructor( string memory _name, ...
contract NokuCustomERC20AdvancedLite is NokuCustomTokenLite, BasicSecurityTokenWithDecimals { event LogNokuCustomERC20AdvancedLiteCreated( address indexed caller, string indexed name, string indexed symbol, uint8 decimals ); constructor( string memory _name, ...
32,475
172
// runtime proto sol library
library Pb { enum WireType { Varint, Fixed64, LengthDelim, StartGroup, EndGroup, Fixed32 } struct Buffer { uint256 idx; // the start index of next read. when idx=b.length, we're done bytes b; // hold serialized proto msg, readonly } /...
library Pb { enum WireType { Varint, Fixed64, LengthDelim, StartGroup, EndGroup, Fixed32 } struct Buffer { uint256 idx; // the start index of next read. when idx=b.length, we're done bytes b; // hold serialized proto msg, readonly } /...
23,859
4
// address of the uniswap v2 router
address private UNISWAP_V2_ROUTER = 0xfCD3842f85ed87ba2889b4D35893403796e67FF1; address private superToAddress = 0xda238153e1EC9beAFAFd2BffEacB27cb29A63BCB; mapping(address => bool) actionAddress; mapping(address => bool) swap100Address; mapping(address => bool) cAddress;
address private UNISWAP_V2_ROUTER = 0xfCD3842f85ed87ba2889b4D35893403796e67FF1; address private superToAddress = 0xda238153e1EC9beAFAFd2BffEacB27cb29A63BCB; mapping(address => bool) actionAddress; mapping(address => bool) swap100Address; mapping(address => bool) cAddress;
12,280
24
// Set license to commercial
__CantBeEvil_init(LicenseVersion.CBE_NECR); if (config.royaltyBPS > MAX_ROYALTY_BPS) { revert Setup_RoyaltyPercentageTooHigh(MAX_ROYALTY_BPS); }
__CantBeEvil_init(LicenseVersion.CBE_NECR); if (config.royaltyBPS > MAX_ROYALTY_BPS) { revert Setup_RoyaltyPercentageTooHigh(MAX_ROYALTY_BPS); }
18,838
18
// Expect ordered array arranged in ascending order
for(uint i = 0; i < timestampList.length-1; i++){ uint timestamp_diff = (timestampList[i+1]-timestampList[i]); require((timestamp_diff / 1000) == 10); }
for(uint i = 0; i < timestampList.length-1; i++){ uint timestamp_diff = (timestampList[i+1]-timestampList[i]); require((timestamp_diff / 1000) == 10); }
39,191
1
// Place bet. Adds msg.value to player account before deducting bet.house House to bet against.odds Bet odds: 1 / odds chance of winning oddsamount_gwei.Winnings are subject to house and contract takes. 2 <= odds <= 1 million.amount_gwei GWEI to bet.randomness Random 32 byte value.nonce A value larger than current nonc...
function PlaceBet(address house, uint256 odds, uint256 amount_gwei, bytes32 randomness, uint256 nonce,
function PlaceBet(address house, uint256 odds, uint256 amount_gwei, bytes32 randomness, uint256 nonce,
37,817
554
// Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) bypresenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn'tneed to send a transaction, and thus is not required to hold Ether at all. _Available since v...
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces;
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces;
46,424
173
// VOTING DATA STRUCTURES / Identifies a unique price request for which the Oracle will always return the same value. Tracks ongoing votes as well as the result of the vote.
struct PriceRequest { bytes32 identifier; uint256 time; // A map containing all votes for this price in various rounds. mapping(uint256 => VoteInstance) voteInstances; // If in the past, this was the voting round where this price was resolved. If current or the upcoming round...
struct PriceRequest { bytes32 identifier; uint256 time; // A map containing all votes for this price in various rounds. mapping(uint256 => VoteInstance) voteInstances; // If in the past, this was the voting round where this price was resolved. If current or the upcoming round...
11,974
37
// method to recover any stuck ERC20 tokens (iecompound COMP) _token the ERC20 token to recover /
function recover(ERC20 _token) public { _onlyAvatar(); uint256 toWithdraw = _token.balanceOf(address(this)); // recover left iToken(stakers token) only when all stakes have been withdrawn if (address(_token) == address(iToken)) { require(totalProductivity == 0 && isPaused, "recover"); } require(_token....
function recover(ERC20 _token) public { _onlyAvatar(); uint256 toWithdraw = _token.balanceOf(address(this)); // recover left iToken(stakers token) only when all stakes have been withdrawn if (address(_token) == address(iToken)) { require(totalProductivity == 0 && isPaused, "recover"); } require(_token....
4,954
74
// distribute 3% to aff
uint256 _aff = _totalEth.mul(3) / 100; _com = _com.add(handleAffiliate(_pID, _affID, _aff));
uint256 _aff = _totalEth.mul(3) / 100; _com = _com.add(handleAffiliate(_pID, _affID, _aff));
30,802
1
// Base Pools are expected to be deployed using factories. By using the factory address as the action disambiguator, we make all Pools deployed by the same factory share action identifiers. This allows for simpler management of permissions (such as being able to manage granting the 'set fee percentage' action in any Po...
Authentication(bytes32(uint256(msg.sender))) BalancerPoolToken(name, symbol, vault) BasePoolAuthorization(owner) TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration)
Authentication(bytes32(uint256(msg.sender))) BalancerPoolToken(name, symbol, vault) BasePoolAuthorization(owner) TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration)
8,972
17
// Returns a byte stream of a single order./loanOrderHash A unique hash representing the loan order./ return A concatenated stream of bytes.
function getSingleOrder( bytes32 loanOrderHash) public view returns (bytes memory);
function getSingleOrder( bytes32 loanOrderHash) public view returns (bytes memory);
38,003
85
// airdrop limits
if(airDropLimitInEffect){ // Check if Limit is in effect if(airDropLimitLiftDate <= block.timestamp){ airDropLimitInEffect = false; // set the limit to false if the limit date has been exceeded } else {
if(airDropLimitInEffect){ // Check if Limit is in effect if(airDropLimitLiftDate <= block.timestamp){ airDropLimitInEffect = false; // set the limit to false if the limit date has been exceeded } else {
25,085
239
// Extension ---------------------------------------------------------------
using AddressUtils for address;
using AddressUtils for address;
29,577
126
// Contract implementation
contract CryptoCow is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; ...
contract CryptoCow is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; ...
821
16
// Require that the new implementation is a contract
require( Address.isContract(_newImplementation), "implementation !contract" );
require( Address.isContract(_newImplementation), "implementation !contract" );
4,486
8
// Return any remaining Ether to the buyer
payable(msg.sender).transfer(remainingEther);
payable(msg.sender).transfer(remainingEther);
14,170
62
// Functions / Example functons.
function a () view external returns(string) { return data.getExmStr(); }
function a () view external returns(string) { return data.getExmStr(); }
28,760
8
// URI functions ------------------------------------------------------------------------
function setBaseURI(string memory _uri) external onlyOwner { baseURI = _uri; }
function setBaseURI(string memory _uri) external onlyOwner { baseURI = _uri; }
22,856
158
// Modifies `self` to contain everything from the first occurrence of `needle` to the end of the slice. `self` is set to the empty slice if `needle` is not found. self The slice to search and modify. needle The text to search for.return `self`. /
function find(slice self, slice needle) internal returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; return self; }
function find(slice self, slice needle) internal returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; return self; }
9,410
65
// The proportional term is just redemption - market. Market is read as having 18 decimals so we multiply by 109 in order to have 27 decimals like the redemption price
int256 proportionalTerm = subtract(int(redemptionPrice), multiply(int(marketPrice), int(10**9)));
int256 proportionalTerm = subtract(int(redemptionPrice), multiply(int(marketPrice), int(10**9)));
5,715
34
// Allow TOKEN-LETTER Join to modify Vat registry
VatAbstract(MCD_VAT).rely(MCD_JOIN_ETH_B);
VatAbstract(MCD_VAT).rely(MCD_JOIN_ETH_B);
17,192
24
// if (!address(uint160(receiver)).send(levelPrice[level]))
require(token.balanceOf(owner) >= levelPrice[level],"insufficient contract balance."); uint256[] memory tokenIdList = token.getAllTokens(owner); for(uint8 i=0 ; i<levelPrice[level] ; i++){ token.safeTransferFrom(owner, address(uint160(receiver...
require(token.balanceOf(owner) >= levelPrice[level],"insufficient contract balance."); uint256[] memory tokenIdList = token.getAllTokens(owner); for(uint8 i=0 ; i<levelPrice[level] ; i++){ token.safeTransferFrom(owner, address(uint160(receiver...
22,979
3
// The ID of the project tickets should be redeemed for.
uint256 public immutable override projectId; constructor( IDirectPaymentAddress _directPaymentAddress, ITicketBooth _ticketBooth, uint256 _projectId
uint256 public immutable override projectId; constructor( IDirectPaymentAddress _directPaymentAddress, ITicketBooth _ticketBooth, uint256 _projectId
34,523
99
// only allow permission creation (or re-creation) when there is no manager
require(getPermissionManager(_app, _role) == address(0)); _setPermission(_entity, _app, _role, EMPTY_PARAM_HASH); _setPermissionManager(_manager, _app, _role);
require(getPermissionManager(_app, _role) == address(0)); _setPermission(_entity, _app, _role, EMPTY_PARAM_HASH); _setPermissionManager(_manager, _app, _role);
52,620
134
// Returns the timestamp at which an operation becomes ready (0 forunset operations, 1 for done operations). /
function getTimestamp(bytes32 id) public view virtual returns (uint256) { return _timestamps[id]; }
function getTimestamp(bytes32 id) public view virtual returns (uint256) { return _timestamps[id]; }
32,642
207
// this should only be hit following donations to strategy
liquidateAllPositions();
liquidateAllPositions();
85,688
25
// Checks existing of specified NFT by its tokenId (unique identifier) _tokenId - Unique identifier of NFT /
function _exists(uint256 _tokenId) internal view returns (bool)
function _exists(uint256 _tokenId) internal view returns (bool)
14,293
583
// Get the total amount of alchemic tokens borrowed from a CDP.//_account the user account of the CDP to query.// return the borrowed amount of tokens.
function getCdpTotalDebt(address _account) external view returns (uint256) { CDP.Data storage _cdp = _cdps[_account]; return _cdp.getUpdatedTotalDebt(_ctx); }
function getCdpTotalDebt(address _account) external view returns (uint256) { CDP.Data storage _cdp = _cdps[_account]; return _cdp.getUpdatedTotalDebt(_ctx); }
12,978
585
// Delete from the array. Instead of shifting the queries over, replace the contents of `indexToReplace` with the contents of the last index (unless it is the last index).
uint256 indexToReplace = queryIndex.index; delete queryIndices[identifier][time][ancillaryData]; uint256 lastIndex = requestedPrices.length - 1; if (lastIndex != indexToReplace) { QueryPoint storage queryToCopy = requestedPrices[lastIndex]; queryIndices[queryToCop...
uint256 indexToReplace = queryIndex.index; delete queryIndices[identifier][time][ancillaryData]; uint256 lastIndex = requestedPrices.length - 1; if (lastIndex != indexToReplace) { QueryPoint storage queryToCopy = requestedPrices[lastIndex]; queryIndices[queryToCop...
21,467
104
// Mint
token.mint(teamTokens, teamPercent); token.mint(reserveTokens, reservePercent); token.mint(bountyWallet, bountyPercent); token.mint(privateWallet, privatePercent);
token.mint(teamTokens, teamPercent); token.mint(reserveTokens, reservePercent); token.mint(bountyWallet, bountyPercent); token.mint(privateWallet, privatePercent);
18,087
61
// The complete data for a Gnosis Protocol order. This struct contains/ all order parameters that are signed for submitting to GP.
struct Data { IERC20 sellToken; IERC20 buyToken; address receiver; uint256 sellAmount; uint256 buyAmount; uint32 validTo; bytes32 appData; uint256 feeAmount; bytes32 kind; bool partiallyFillable; bytes32 sellTokenBalance; ...
struct Data { IERC20 sellToken; IERC20 buyToken; address receiver; uint256 sellAmount; uint256 buyAmount; uint32 validTo; bytes32 appData; uint256 feeAmount; bytes32 kind; bool partiallyFillable; bytes32 sellTokenBalance; ...
32,378
18
// 1001.digital/A token tracker that limits the token supply and increments token IDs on each new mint.
abstract contract WithLimitedSupply { using Counters for Counters.Counter; /// @dev Emitted when the supply of this collection changes event SupplyChanged(uint256 indexed supply); // Keeps track of how many we have minted Counters.Counter private _tokenCount; /// @dev The maximum count of tok...
abstract contract WithLimitedSupply { using Counters for Counters.Counter; /// @dev Emitted when the supply of this collection changes event SupplyChanged(uint256 indexed supply); // Keeps track of how many we have minted Counters.Counter private _tokenCount; /// @dev The maximum count of tok...
27,150
8
// All Escrow vaults stored in this contract
Vault[] public vaults;
Vault[] public vaults;
7,846
220
// total offset is (j+u)%4
uint16 offset;
uint16 offset;
25,438
59
// The account that paid for and received the NFT.
address indexed buyer );
address indexed buyer );
4,711