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
106
// Allows the current owner to change the ETH to token generation rate. _rate indicating the new token generation rate. /
function setRate(uint256 _rate) external onlyOwner { // make sure the crowdsale has not started require(weiRaised == 0 && now <= startTime); // make sure new rate is greater than 0 require(_rate > 0); rate = _rate; }
function setRate(uint256 _rate) external onlyOwner { // make sure the crowdsale has not started require(weiRaised == 0 && now <= startTime); // make sure new rate is greater than 0 require(_rate > 0); rate = _rate; }
33,106
93
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); }
if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); }
1,505
6
// Emitted when reward distributor is changed
event NewRewardDistributor( address oldRewardDistributor, address newRewardDistributor );
event NewRewardDistributor( address oldRewardDistributor, address newRewardDistributor );
14,004
16
// issue the refund
incentive.totalRewardUnclaimed = 0; TransferHelperExtended.safeTransfer(address(key.rewardToken), key.refundee, refund);
incentive.totalRewardUnclaimed = 0; TransferHelperExtended.safeTransfer(address(key.rewardToken), key.refundee, refund);
40,914
22
// function donateUPC
44,766
113
// Check reserveFactorMantissa + newAdminFeeMantissa + newFuseFeeMantissa ≤ reserveFactorPlusFeesMaxMantissa
if (add_(add_(reserveFactorMantissa, newAdminFeeMantissa), newFuseFeeMantissa) > reserveFactorPlusFeesMaxMantissa) { return fail(Error.BAD_INPUT, FailureInfo.SET_ADMIN_FEE_BOUNDS_CHECK); }
if (add_(add_(reserveFactorMantissa, newAdminFeeMantissa), newFuseFeeMantissa) > reserveFactorPlusFeesMaxMantissa) { return fail(Error.BAD_INPUT, FailureInfo.SET_ADMIN_FEE_BOUNDS_CHECK); }
63,314
40
// Downgrade ERC20 to SuperToken by host contract.account The account to be changed.amount Number of tokens to be downgraded (in 18 decimals) @custom:modifiers- onlyHost/
function operationDowngrade(address account, uint256 amount) external;
function operationDowngrade(address account, uint256 amount) external;
11,070
35
// Total = 107.15 ether
PrizeRefLevels[1][2][0] = 28.55 ether; PrizeRefLevels[1][2][1] = 10.7 ether; PrizeRefLevels[1][2][2] = 7.2 ether; PrizeRefLevels[1][2][3] = 3.55 ether; PrizeRefLevels[1][2][4] = 3.55 ether;
PrizeRefLevels[1][2][0] = 28.55 ether; PrizeRefLevels[1][2][1] = 10.7 ether; PrizeRefLevels[1][2][2] = 7.2 ether; PrizeRefLevels[1][2][3] = 3.55 ether; PrizeRefLevels[1][2][4] = 3.55 ether;
3,998
225
// issue 1471 last block when it turn restriction mode on. In restriction mode, no one can do multi open/close/liquidate position in the same block. If any underwater position being closed (having a bad debt and make insuranceFund loss), or any liquidation happened, restriction mode is ON in that block and OFF(default)...
uint256 lastRestrictionBlock; SignedDecimal.signedDecimal[] cumulativePremiumFractions; mapping(address => Position) positionMap;
uint256 lastRestrictionBlock; SignedDecimal.signedDecimal[] cumulativePremiumFractions; mapping(address => Position) positionMap;
8,034
4
// @inheritdoc IBeaconTimelockTrigger
function push(IDrawBeacon.Draw memory _draw, uint256 _totalNetworkTicketSupply) external override onlyManagerOrOwner
function push(IDrawBeacon.Draw memory _draw, uint256 _totalNetworkTicketSupply) external override onlyManagerOrOwner
15,264
11
// level 2
deliverAccessCard(2);
deliverAccessCard(2);
13,415
119
// See {IERC777-burn}. Also emits a {IERC20-Transfer} event for ERC20 compatibility. /
function burn(uint256 amount, bytes memory data) public virtual override { _burn(_msgSender(), amount, data, ""); }
function burn(uint256 amount, bytes memory data) public virtual override { _burn(_msgSender(), amount, data, ""); }
31,475
15
// Random number between 0 10
function random() private view returns (uint256) { uint256 randomHash = uint256(keccak256(abi.encodePacked( blockhash(block.number - 1), block.timestamp))); randomHash = randomHash % 10; if(randomHash == 0) randomHash = 1; return randomHash; }
function random() private view returns (uint256) { uint256 randomHash = uint256(keccak256(abi.encodePacked( blockhash(block.number - 1), block.timestamp))); randomHash = randomHash % 10; if(randomHash == 0) randomHash = 1; return randomHash; }
6,759
68
// Update storage information
_tokenIdsOfSellerForCollection[askOrder.seller][_collection].remove(_tokenId); delete _askDetails[_collection][_tokenId]; _askTokenIds[_collection].remove(_tokenId);
_tokenIdsOfSellerForCollection[askOrder.seller][_collection].remove(_tokenId); delete _askDetails[_collection][_tokenId]; _askTokenIds[_collection].remove(_tokenId);
15,804
22
// Subtract amount from Temporary Refundable Collateral
temporaryCollaterals[loan].refundableCollateral = sub(temporaryCollaterals[loan].refundableCollateral, amount);
temporaryCollaterals[loan].refundableCollateral = sub(temporaryCollaterals[loan].refundableCollateral, amount);
35,276
11
// To update the price _id Presale id to update _newPrice New sale price of the token /
function changePrice(uint256 _id, uint256 _newPrice) external checkPresaleId(_id) onlyOwner
function changePrice(uint256 _id, uint256 _newPrice) external checkPresaleId(_id) onlyOwner
27,550
10
// referral
event Referral( address indexed buyer, address indexed referral, uint256 amount, uint256 flag // 1.direct, 2.indirect );
event Referral( address indexed buyer, address indexed referral, uint256 amount, uint256 flag // 1.direct, 2.indirect );
28,925
27
// validator configurationreturn validator validator contractreturn gasLimit gas limit for validate calls /
function validatorConfig() external view
function validatorConfig() external view
22,748
13
// Insert after `nextId` as the tail
data.nodes[_id].prevId = data.tail; data.nodes[data.tail].nextId = _id; data.tail = _id;
data.nodes[_id].prevId = data.tail; data.nodes[data.tail].nextId = _id; data.tail = _id;
9,415
27
// Revert with an error when attempting to perform invalid logic in an Hybrid cycle. /
error HybridCycle();
error HybridCycle();
21,130
4
// issueBounty(): instantiates a new bounty _data the requirement of the bounty _deadline the Unix timestamp after which fulfilments will no longer be accepted /
function issueBounty( string memory _data, uint64 _deadline ) public payable hasValue() validateDeadline(_deadline) returns (uint) { bounties.push(Bounty(msg.sender, _deadline, _data, BountyStatus.CREATED, msg.value)); emit BountyIssued(bounties.length - 1, msg.sender, m...
function issueBounty( string memory _data, uint64 _deadline ) public payable hasValue() validateDeadline(_deadline) returns (uint) { bounties.push(Bounty(msg.sender, _deadline, _data, BountyStatus.CREATED, msg.value)); emit BountyIssued(bounties.length - 1, msg.sender, m...
13,026
3
// Calls `sellTokenForEth` on the given `provider` contract to/trigger a trade./provider The address of the on-chain liquidity provider./inputToken The token being sold./recipient The recipient of the bought tokens./minBuyAmount The minimum acceptable amount of ETH to buy./auxiliaryData Auxiliary data supplied to the `...
function executeSellTokenForEth( ILiquidityProvider provider, IERC20TokenV06 inputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData ) external;
function executeSellTokenForEth( ILiquidityProvider provider, IERC20TokenV06 inputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData ) external;
11,604
9
// The market's last updated idleSupplyIndex
uint256 index;
uint256 index;
8,561
2
// due solidity limitation we cannot return dynamic array from methods/ so it creates incompability between functions across different contracts
uint8 public constant STATS_SIZE = 10; uint8 public constant SHIP_SLOTS = 5;
uint8 public constant STATS_SIZE = 10; uint8 public constant SHIP_SLOTS = 5;
10,863
11
// Adds/Removes permissions for the given address THROWS when the permissions can't be granted/revokedkind The kind of the permissions to grantaddr The address to add/remove permissions forgrant If permissions are being granted or revoked /
function setPermission(uint8 kind, address addr, bool grant)
function setPermission(uint8 kind, address addr, bool grant)
43,859
16
// Sell attached ETH directly against uniswap v3./encodedPath Uniswap-encoded path, where the first token is WETH./recipient The recipient of the bought tokens. Can be zero for sender./minBuyAmount Minimum amount of the last token in the path to buy./ return buyAmount Amount of the last token in the path bought.
function sellEthForTokenToUniswapV3( bytes memory encodedPath, uint256 minBuyAmount, address recipient ) public payable override returns (uint256 buyAmount)
function sellEthForTokenToUniswapV3( bytes memory encodedPath, uint256 minBuyAmount, address recipient ) public payable override returns (uint256 buyAmount)
1,518
20
// Ends the sale, once ended can't be reopened again /
function endSale() public onlyOwner { require(state == State.Active || state == State.Dormant); state = State.Successful; emit SuccessfulState(); }
function endSale() public onlyOwner { require(state == State.Active || state == State.Dormant); state = State.Successful; emit SuccessfulState(); }
44,694
458
// Rounding division for signed numerator
return (ln > 0 ? ln + _HALF_LOG_COMPRESSION_FACTOR : ln - _HALF_LOG_COMPRESSION_FACTOR) / _LOG_COMPRESSION_FACTOR;
return (ln > 0 ? ln + _HALF_LOG_COMPRESSION_FACTOR : ln - _HALF_LOG_COMPRESSION_FACTOR) / _LOG_COMPRESSION_FACTOR;
52,215
331
// Approvals: CRV -> cvxCRV converter
crvToken.approve(address(crvDepositor), MAX_UINT_256);
crvToken.approve(address(crvDepositor), MAX_UINT_256);
13,482
15
// Propose Governance call(s) targets Ordered list of targeted addresses signatures Orderd list of function signatures to be called calldatas Orderded list of calldata to be passed with each call description Description of the governancereturn uint256 id of the proposal /
function propose( address[] memory targets, string[] memory signatures, bytes[] memory calldatas, string memory description ) public returns (uint256) {
function propose( address[] memory targets, string[] memory signatures, bytes[] memory calldatas, string memory description ) public returns (uint256) {
29,306
16
// CALLDATA OFFSETS IN BYTES -- adding 7 and dividing by 8 here is for rounding up the bit amounts to bytes amounts uint256 internal constant CALLDATA_OFFSET_headerHash = 0; uint256 internal constant CALLDATA_OFFSET_durationDataStoreId = ((BIT_LENGTH_headerHash + 7) / 8); uint256 internal constant CALLDATA_OFFSET_globa...
uint256 internal constant CALLDATA_OFFSET_headerHash = 0; uint256 internal constant CALLDATA_OFFSET_durationDataStoreId = 32; uint256 internal constant CALLDATA_OFFSET_globalDataStoreId = 36; uint256 internal constant CALLDATA_OFFSET_referenceBlockNumber = 40; uint256 internal constant CALLDATA_OFFS...
uint256 internal constant CALLDATA_OFFSET_headerHash = 0; uint256 internal constant CALLDATA_OFFSET_durationDataStoreId = 32; uint256 internal constant CALLDATA_OFFSET_globalDataStoreId = 36; uint256 internal constant CALLDATA_OFFSET_referenceBlockNumber = 40; uint256 internal constant CALLDATA_OFFS...
29,607
328
// realize $SQUID earnings for a single Guard and optionally unstake itWolves earn $SQUID proportional to their Alpha rank tokenId the ID of the Guard to claim earnings from unstake whether or not to unstake the Guardreturn owed - the amount of $SQUID earned /
function _claimGuardFromPack(uint256 tokenId, bool unstake) internal returns (uint256 owed) { require(squuid.ownerOf(tokenId) == address(this), "AINT A PART OF THE PACK"); uint256 alpha = _alphaForGuard(tokenId); Stake memory stake = pack[alpha][packIndices[tokenId]]; require(stake.owner == _msgSender...
function _claimGuardFromPack(uint256 tokenId, bool unstake) internal returns (uint256 owed) { require(squuid.ownerOf(tokenId) == address(this), "AINT A PART OF THE PACK"); uint256 alpha = _alphaForGuard(tokenId); Stake memory stake = pack[alpha][packIndices[tokenId]]; require(stake.owner == _msgSender...
21,130
1
// Unit of time specified in number of seconds. Can be set as 1 seconds, 1 days, 1 hours, etc.
uint256 public timeUnit;
uint256 public timeUnit;
8,882
389
// mint
_updateAccountSnapshot(to); _updateTotalSupplySnapshot();
_updateAccountSnapshot(to); _updateTotalSupplySnapshot();
6,714
31
// DistrFinished Event gets emmited when the contract owner ends the presale /
event DistrFinished();
event DistrFinished();
8,794
58
// Sub `base` from `total` and update `total.elastic`./ return (Rebase) The new total./ return elastic in relationship to `base`.
function sub( Rebase memory total, uint256 base, bool roundUp
function sub( Rebase memory total, uint256 base, bool roundUp
24,033
13
// set the destination address
resolver.setAddr(subdomainNamehash, _target);
resolver.setAddr(subdomainNamehash, _target);
22,308
107
// If the address' personal cap is below the pointer, refund them all their ETH./if it is above the pointer, calculate tokens purchased and refund leftoever ETH/self Stored crowdsale from crowdsale contract/ return bool success if the contract runs successfully/ What should not happen here? /
function retrieveFinalResult(InteractiveCrowdsaleStorage storage self) public returns (bool) { require(now > self.endTime); /* This ensure that the endTime is past */ require(self.personalCaps[msg.sender] > 0); /* This requires that */ uint256 numTokens; /* setup some pointers */ uint256 remainder; ...
function retrieveFinalResult(InteractiveCrowdsaleStorage storage self) public returns (bool) { require(now > self.endTime); /* This ensure that the endTime is past */ require(self.personalCaps[msg.sender] > 0); /* This requires that */ uint256 numTokens; /* setup some pointers */ uint256 remainder; ...
50,378
27
// Returns the number of minted tokens per presale address /
function presaleMintedByAddress(address _address) public view returns (uint256)
function presaleMintedByAddress(address _address) public view returns (uint256)
8,277
13
// PIGGY-MODIFY: Checks if the seizing of assets should be allowed to occur pTokenCollateral Asset which was used as collateral and will be seized pTokenBorrowed Asset which was borrowed by the borrower liquidator The address repaying the borrow and seizing the collateral borrower The address of the borrower seizeToken...
function seizeAllowed(
function seizeAllowed(
28,859
14
// Delete the state batch.
ovmStateCommitmentChain.deleteStateBatch( _postStateRootBatchHeader );
ovmStateCommitmentChain.deleteStateBatch( _postStateRootBatchHeader );
12,805
234
// Trigger a withdrawal of account funds held in the exchange contract. This can be called after a (slow) withdrawal has already been processed by the L2 exchange. starkKey The STARK key of the account. Must be authorized by OWNER_ROLE.assetTypeThe exchange asset ID for the asset to withdraw. return The ERC20 token amo...
function withdrawFromExchange( uint256 starkKey, uint256 assetType ) external nonReentrant onlyRole(EXCHANGE_OPERATOR_ROLE) onlyAllowedKey(starkKey) returns (uint256)
function withdrawFromExchange( uint256 starkKey, uint256 assetType ) external nonReentrant onlyRole(EXCHANGE_OPERATOR_ROLE) onlyAllowedKey(starkKey) returns (uint256)
4,669
15
// A boolean for whether the bridge is closed
bool public isClosed;
bool public isClosed;
28,632
2
// Maximum deviation allowed between two consecutive oracle prices
uint128 maxPriceDeviation;
uint128 maxPriceDeviation;
28,073
214
// An RFQ limit order.
struct RfqOrder { IERC20TokenV06 makerToken; IERC20TokenV06 takerToken; uint128 makerAmount; uint128 takerAmount; address maker; address taker; address txOrigin; bytes32 pool; uint64 expiry; uint256 salt; }
struct RfqOrder { IERC20TokenV06 makerToken; IERC20TokenV06 takerToken; uint128 makerAmount; uint128 takerAmount; address maker; address taker; address txOrigin; bytes32 pool; uint64 expiry; uint256 salt; }
19,473
93
// @note: first need to bootstrap the uniswap exchange to get the address.
IERC20 oToken = IERC20(oTokenAddress); IERC20 payoutToken = IERC20(payoutTokenAddress); oToken.transferFrom(msg.sender, address(this), oTokensToSell); uint256 payoutTokensReceived = uniswapSellOToken( oToken, payoutToken, oTokensToSell, rec...
IERC20 oToken = IERC20(oTokenAddress); IERC20 payoutToken = IERC20(payoutTokenAddress); oToken.transferFrom(msg.sender, address(this), oTokensToSell); uint256 payoutTokensReceived = uniswapSellOToken( oToken, payoutToken, oTokensToSell, rec...
43,408
7
// The SYRUP TOKEN!
BoostBar public boost;
BoostBar public boost;
25,778
16
// Allocate a string in memory (divide the length by 8 since it is in bits and we need bytes)
result = new string(length >> 3);
result = new string(length >> 3);
2,456
169
// Restirct the bond maker. /
function _assertBondMakerDecimals(BondMakerInterface bondMaker) internal view
function _assertBondMakerDecimals(BondMakerInterface bondMaker) internal view
37,359
9
// The unspent fee is refunded if applicable. _feeInWei The fee paid for delivery in Wei. _to The recipient of the message and gas refund. _calldata The calldata of the message. /pre-execution
uint256 startingGas = gasleft(); _;
uint256 startingGas = gasleft(); _;
15,597
34
// Emits a {Transfer} event with `to` set to the zero address. Requirements: - `account` cannot be the zero address.- `account` must have at least `amount` tokens. /
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "EToken: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 scaledAmount = _scaleAmount(amount); uint256 accountBalance = _balances[account]; require(accountBala...
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "EToken: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 scaledAmount = _scaleAmount(amount); uint256 accountBalance = _balances[account]; require(accountBala...
26,545
139
// VestedAkro token represents AKRO token vested for a vestingPeriod set by owner of this VestedAkro token.Generic holders of this token CAN NOT transfer it. They only can redeem AKRO from unlocked vAKRO.Minters can mint unlocked vAKRO from AKRO to special VestedAkroSenders.VestedAkroSender can send his unlocked vAKRO ...
contract VestedAkro is OwnableUpgradeable, IERC20Upgradeable, MinterRole, VestedAkroSenderRole { using SafeMathUpgradeable for uint256; using SafeERC20Upgradeable for IERC20Upgradeable; event Locked(address indexed holder, uint256 amount); event Unlocked(address indexed holder, uint256 amount); eve...
contract VestedAkro is OwnableUpgradeable, IERC20Upgradeable, MinterRole, VestedAkroSenderRole { using SafeMathUpgradeable for uint256; using SafeERC20Upgradeable for IERC20Upgradeable; event Locked(address indexed holder, uint256 amount); event Unlocked(address indexed holder, uint256 amount); eve...
60,151
25
// Safe Token // Gets internal balance of this contract in terms of the underlying. It excludes balance from direct transfer. This excludes the value of the current message, if anyreturn The quantity of underlying tokens owned by this contract /
function getCashPrior() internal view returns (uint) { return internalCash; }
function getCashPrior() internal view returns (uint) { return internalCash; }
7,233
43
// Effects
emit OwnershipTransferred(owner, _pendingOwner); owner = _pendingOwner; pendingOwner = address(0);
emit OwnershipTransferred(owner, _pendingOwner); owner = _pendingOwner; pendingOwner = address(0);
5,790
9
// get the inboundNonce of a receiver from a source chain which could be EVM or non-EVM chain_srcChainId - the source chain identifier_srcAddress - the source chain contract address
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
20,866
16
// Ensure the provided reward amount is not more than the balance in the contract. This keeps the reward rate in the right range, preventing overflows due to very high values of rewardRate in the earned and rewardsPerToken functions; Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
uint256 balance = rewardsToken.balanceOf(address(this)); require( rewardRate <= balance.div(rewardsDuration), "Provided reward too high" ); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward);
uint256 balance = rewardsToken.balanceOf(address(this)); require( rewardRate <= balance.div(rewardsDuration), "Provided reward too high" ); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward);
7,470
41
// force reserves to match balances
function sync() external override lock execVirtualOrders { _update( IERC20V5(token0).balanceOf(address(this)) - twammReserve0, IERC20V5(token1).balanceOf(address(this)) - twammReserve1, reserve0, reserve1 ); }
function sync() external override lock execVirtualOrders { _update( IERC20V5(token0).balanceOf(address(this)) - twammReserve0, IERC20V5(token1).balanceOf(address(this)) - twammReserve1, reserve0, reserve1 ); }
15,175
111
// 将 partner 地址从白名单移除 _addr Partner 地址 /
function removeAddressFromPartnerWhiteList(address _addr) public onlyOwner
function removeAddressFromPartnerWhiteList(address _addr) public onlyOwner
39,330
18
// assert(b > 0);Solidity automatically throws when dividing by 0
uint256 c = a / b;
uint256 c = a / b;
22,853
82
// Amount of wei that was reimbursed via sendTokens calls
uint256 public totalReimbursedWei = 0;
uint256 public totalReimbursedWei = 0;
49,036
21
// Removes addresses from the airdrop /
function removeFromAirdrop(address[] calldata _addresses) external onlyOwner { for (uint i = 0; i < _addresses.length; i++) { _airdropList[_addresses[i]] = false; } }
function removeFromAirdrop(address[] calldata _addresses) external onlyOwner { for (uint i = 0; i < _addresses.length; i++) { _airdropList[_addresses[i]] = false; } }
79,661
17
// Sets the reward hook address/_hook The address of the reward hook
function setRewardHook(address _hook) external onlyAddress(IController(operator).owner()) { rewardHook = _hook; emit RewardHookSet(_hook); }
function setRewardHook(address _hook) external onlyAddress(IController(operator).owner()) { rewardHook = _hook; emit RewardHookSet(_hook); }
10,155
173
// allows to create stake with another tokenif you don't have SWAPP tokens method will convertand use amount returned from UNISWAP to open a stake the token must have WETH pair on UNISWAP _tokenAddress any ERC20 token address _tokenAmount amount to be converted to SWAPP _lockDays amount of days it is locked for. _refer...
function createStakeWithToken( address _tokenAddress, uint256 _tokenAmount, uint64 _lockDays, address _referrer
function createStakeWithToken( address _tokenAddress, uint256 _tokenAmount, uint64 _lockDays, address _referrer
39,163
117
// Remove the Booster ID
listOfBoosters[_BoosterType].boosterIdsList[0] = listOfBoosters[_BoosterType].boosterIdsList[listLength.sub(1)]; listOfBoosters[_BoosterType].boosterIdsList.pop(); listLength = listLength.sub(1);
listOfBoosters[_BoosterType].boosterIdsList[0] = listOfBoosters[_BoosterType].boosterIdsList[listLength.sub(1)]; listOfBoosters[_BoosterType].boosterIdsList.pop(); listLength = listLength.sub(1);
40,428
7
// only owner
function setSaleId(uint256 _saleId) public onlyOwner { saleId = _saleId; }
function setSaleId(uint256 _saleId) public onlyOwner { saleId = _saleId; }
27,489
157
// Returns a fraction from two uint256's. Fits them into uint128 if necessary. numThe numeratordenThe denominatorreturnThe Fraction128 that matches num/den most closely // solium-disable-next-line security/no-assign-params /
{ uint256 max = num > den ? num : den; uint256 first128Bits = (max >> 128); if (first128Bits != 0) { first128Bits += 1; num /= first128Bits; den /= first128Bits; } assert(den != 0); // coverage-enable-line assert(den < 2**128); ...
{ uint256 max = num > den ? num : den; uint256 first128Bits = (max >> 128); if (first128Bits != 0) { first128Bits += 1; num /= first128Bits; den /= first128Bits; } assert(den != 0); // coverage-enable-line assert(den < 2**128); ...
67,193
6
// Check the swap was successful
require(swapAmounts[0] == amountIn, "Wrong number of source tokens deducted"); require(swapAmounts[swapAmounts.length - 1] >= amountOutMin, "Insufficient destination tokens received"); require(sourceToken.balanceOf(address(this)) == balanceBefore, "Tokens left in contract");
require(swapAmounts[0] == amountIn, "Wrong number of source tokens deducted"); require(swapAmounts[swapAmounts.length - 1] >= amountOutMin, "Insufficient destination tokens received"); require(sourceToken.balanceOf(address(this)) == balanceBefore, "Tokens left in contract");
39,570
135
// Generate edition metadata from storage information as base64-json blob/ Combines the media data and metadata/name Name of NFT in metadata/description Description of NFT in metadata/imageUrl URL of image to render for edition/animationUrl URL of animation to render for edition/tokenOfEdition Token ID for specific tok...
function createMetadataEdition( string memory name, string memory description, string memory imageUrl, string memory animationUrl, uint256 tokenOfEdition, uint256 editionSize
function createMetadataEdition( string memory name, string memory description, string memory imageUrl, string memory animationUrl, uint256 tokenOfEdition, uint256 editionSize
42,402
20
// Update the mapping of tokenId's to Token details, useful for retrieval functions
idToListedToken[tokenId] = ListedToken( tokenId, payable(address(this)), payable(msg.sender), price, true ); _transfer(msg.sender, address(this), tokenId);
idToListedToken[tokenId] = ListedToken( tokenId, payable(address(this)), payable(msg.sender), price, true ); _transfer(msg.sender, address(this), tokenId);
19,314
24
// Assigns ownership of a specific Painting to an address.
function _transfer(address _from, address _to, uint256 _tokenId)
function _transfer(address _from, address _to, uint256 _tokenId)
31,661
19
// Access modifier for contract owner only functionality
modifier onlyCLevel() { require( msg.sender == ceoAddress || msg.sender == cooAddress ); _; }
modifier onlyCLevel() { require( msg.sender == ceoAddress || msg.sender == cooAddress ); _; }
24,502
511
// Starts a new calculation epoch Because averge since start will not be accurate
function startNewEpoch() public { require(epochCalculationStartBlock + 50000 < block.number, "New epoch not ready yet"); // About a week epochRewards[epoch] = rewardsInThisEpoch; cumulativeRewardsSinceStart = cumulativeRewardsSinceStart.add(rewardsInThisEpoch); rewardsInThisEpoch = 0...
function startNewEpoch() public { require(epochCalculationStartBlock + 50000 < block.number, "New epoch not ready yet"); // About a week epochRewards[epoch] = rewardsInThisEpoch; cumulativeRewardsSinceStart = cumulativeRewardsSinceStart.add(rewardsInThisEpoch); rewardsInThisEpoch = 0...
33,314
25
// Validate round parameters
GrantRound[] calldata _rounds = _donations[i].rounds; for (uint256 j = 0; j < _rounds.length; j++) { require(_rounds[j].isActive(),"GrantRoundManager: GrantRound is not active"); require(_rounds[j].registry() == registry,"GrantRoundManager: Round-Registry mismatch...
GrantRound[] calldata _rounds = _donations[i].rounds; for (uint256 j = 0; j < _rounds.length; j++) { require(_rounds[j].isActive(),"GrantRoundManager: GrantRound is not active"); require(_rounds[j].registry() == registry,"GrantRoundManager: Round-Registry mismatch...
16,838
94
// Compares two serial numbers using RFC1982 serial number math. /
function serialNumberGte(uint32 i1, uint32 i2) internal pure returns(bool) { return int32(i1) - int32(i2) >= 0; }
function serialNumberGte(uint32 i1, uint32 i2) internal pure returns(bool) { return int32(i1) - int32(i2) >= 0; }
40,013
55
// The rules were changed what kind of investments we accept
event InvestmentPolicyChanged(bool requireCustomerId, bool requiredSignedAddress, address signerAddress); event Pause(); event Unpause();
event InvestmentPolicyChanged(bool requireCustomerId, bool requiredSignedAddress, address signerAddress); event Pause(); event Unpause();
4,468
84
// cutFor returns the affiliate cut for a sale cutFor returns the cut (amount in wei) to give in comission to the affiliate_affiliate - the address of the affiliate to check for _productId - the productId in the sale _purchaseId - the purchaseId in the sale _purchaseAmount - the purchaseAmount /
function cutFor( address _affiliate, uint256 _productId, uint256 _purchaseId, uint256 _purchaseAmount) public view returns (uint256)
function cutFor( address _affiliate, uint256 _productId, uint256 _purchaseId, uint256 _purchaseAmount) public view returns (uint256)
42,744
12
// check to ensure approvedSynths includes sUSD
bool sUSDFound = false; for(uint i = 0; i < _approvedSynths.length; i++) { if (_approvedSynths[i] == sUSD) { sUSDFound = true; }
bool sUSDFound = false; for(uint i = 0; i < _approvedSynths.length; i++) { if (_approvedSynths[i] == sUSD) { sUSDFound = true; }
13,686
0
// Calls subscription contract and creates a DSGuard if non existent/_minRatio Minimum ratio below which repay is triggered/_maxRatio Maximum ratio after which boost is triggered/_optimalRatioBoost Ratio amount which boost should target/_optimalRatioRepay Ratio amount which repay should target/_boostEnabled Boolean det...
function subscribe( uint128 _minRatio, uint128 _maxRatio, uint128 _optimalRatioBoost, uint128 _optimalRatioRepay, bool _boostEnabled
function subscribe( uint128 _minRatio, uint128 _maxRatio, uint128 _optimalRatioBoost, uint128 _optimalRatioRepay, bool _boostEnabled
3,432
11
// Callable by sender to recover funds after the timeout period has passed lockValue Lock value is used to identify the original deposit /
function recoverFunds(bytes32 lockValue) public { // check that caller is valid, contract has funds, and enough time has passed require(msg.sender == _contracts[lockValue].sender, "only sender can recover funds"); require(_contracts[lockValue].amount > 0, "no funds to recover"); requ...
function recoverFunds(bytes32 lockValue) public { // check that caller is valid, contract has funds, and enough time has passed require(msg.sender == _contracts[lockValue].sender, "only sender can recover funds"); require(_contracts[lockValue].amount > 0, "no funds to recover"); requ...
44,370
50
// store ticket in selectedTickets
selectedTickets[selectedTicket] = true;
selectedTickets[selectedTicket] = true;
15,905
3
// CONTRACT INSTANCES:
Verifier_Interface private verifier; // the verification smart contract ERC20Interface private fToken; // the ERC-20 token contract
Verifier_Interface private verifier; // the verification smart contract ERC20Interface private fToken; // the ERC-20 token contract
6,119
150
// Sets the value for an address to be in the restricted approval address pool.Setting an address to true will disable token owners from being able to mark the addressfor approval for trading. This would be used in theory to prevent token owners from listingon specific marketplaces or protcols. Only modifible by the co...
function setApprovalRestriction(address _address, bool _isRestricted) public onlyTeamOrOwner { restrictedApprovalAddresses[_address] = _isRestricted; }
function setApprovalRestriction(address _address, bool _isRestricted) public onlyTeamOrOwner { restrictedApprovalAddresses[_address] = _isRestricted; }
38,250
46
// This function checks the transfer amount against the current balance and vested amount Returns true if transfer amount is smaller than the difference between the balance and vested amount
function validateTransferAmount(address _user, uint256 _amount) internal view returns (bool) { if(vestingEnded(_user)){ return true; }else{ uint256 _vestedAmount = getVestedAmount(_user); uint256 _currentBalance = balanceOf(_user); uint256 _availableBa...
function validateTransferAmount(address _user, uint256 _amount) internal view returns (bool) { if(vestingEnded(_user)){ return true; }else{ uint256 _vestedAmount = getVestedAmount(_user); uint256 _currentBalance = balanceOf(_user); uint256 _availableBa...
57,617
39
// Refund any excess to the guest
guest.transfer(msg.value - stake); emit BookingComplete(msg.sender, bid);
guest.transfer(msg.value - stake); emit BookingComplete(msg.sender, bid);
29,337
0
// Represents a mutable buffer. Buffers have a current value (buf) anda capacity. The capacity may be longer than the current value, inwhich case it can be extended without the need to allocate more memory./
struct buffer { bytes buf; uint capacity; }
struct buffer { bytes buf; uint capacity; }
2,722
19
// Iterate over each transfer.
for (uint256 i = 0; i < totalStandardTransfers; ) {
for (uint256 i = 0; i < totalStandardTransfers; ) {
14,305
14
// add a role to an address addr address roleName the name of the role /
function addRole(address addr, string memory roleName) internal
function addRole(address addr, string memory roleName) internal
17,417
8
// Called to mint tokens on `buy`.function _mint(address _to,uint _quantity) internalauthorizeTransfer(address(0), _to, _quantity, false)
// { // uint96 quantity = safe96(_quantity, "DAT::_mint: amount exceeds 96 bits"); // super._mint(_to, quantity); // // // Math: If this value got too large, the DAT may overflow on sell // require(totalSupply.add(burnedSupply) <= MAX_SUPPLY, "EXCESSIVE_SUPPLY"); // }
// { // uint96 quantity = safe96(_quantity, "DAT::_mint: amount exceeds 96 bits"); // super._mint(_to, quantity); // // // Math: If this value got too large, the DAT may overflow on sell // require(totalSupply.add(burnedSupply) <= MAX_SUPPLY, "EXCESSIVE_SUPPLY"); // }
39,021
7
// An event that is emitted when a transaction is created. /by The address of the user creating the transaction./to The address of the user who will receive the ETH if the transaction is completed./amount The amount of ETH that will be transfered from the safe to the recepient if the transaction is completed./transacti...
event TransactionCreated(address by, address to, uint256 amount, uint256 transactionId);
event TransactionCreated(address by, address to, uint256 amount, uint256 transactionId);
11,562
175
// LBCBar with Governance.
contract LBCBar is BEP20('LBC Bar', 'LBCBAR') { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } functi...
contract LBCBar is BEP20('LBC Bar', 'LBCBAR') { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } functi...
16,621
2
// The address of the proxy's current target.
address public target;
address public target;
21,058
20
// get zero-indexed total of drawings
function getDrawingCount() external view returns (uint256) { return drawingCount; }
function getDrawingCount() external view returns (uint256) { return drawingCount; }
40,988
85
// fallback function can be used to sale tokens
function () external payable { _saleTokens(); }
function () external payable { _saleTokens(); }
10,018
100
// Map of financial contract contracts to the associated FinancialContract struct.
mapping(address => FinancialContract) public contractMap;
mapping(address => FinancialContract) public contractMap;
17,108
0
// Network: xDaiAggregator: ETH/USDAddress: 0xa767f745331D267c7751297D982b050c93985627 /
constructor() public { priceFeed = AggregatorV3Interface(0xa767f745331D267c7751297D982b050c93985627); }
constructor() public { priceFeed = AggregatorV3Interface(0xa767f745331D267c7751297D982b050c93985627); }
21,197
15
// returns: oracle fee
function getOracleFee(uint256 req) external returns(uint256); //req: 1 - cancel, 2 - claim, returns: value
function getOracleFee(uint256 req) external returns(uint256); //req: 1 - cancel, 2 - claim, returns: value
81,614
163
// Takes token amount from user's wallet and joins into the vat
gemJoin_join(gemJoin, address(this), wad, transferFrom);
gemJoin_join(gemJoin, address(this), wad, transferFrom);
19,705
114
// Transfer NokuCustomReservation ownership to the client
customReservation.transferOwnership(msg.sender); require(pricingPlan.payFee(SERVICE_NAME, CREATE_AMOUNT, msg.sender), "fee payment failed");
customReservation.transferOwnership(msg.sender); require(pricingPlan.payFee(SERVICE_NAME, CREATE_AMOUNT, msg.sender), "fee payment failed");
47,883
1
// ======== MAX MINTS ========
uint256 public maxPremintGenesisMob = 4; uint256 public maxPremintMutant = 3; uint256 public maxPremintOG = 2; uint256 public maxPremintTraplist = 1; uint256 public maxPublicSaleMint = 10;
uint256 public maxPremintGenesisMob = 4; uint256 public maxPremintMutant = 3; uint256 public maxPremintOG = 2; uint256 public maxPremintTraplist = 1; uint256 public maxPublicSaleMint = 10;
66,135
28
// setIsPublicSaleActive toggles the functionality of the public minting function.
function setIsPublicSaleActive(bool _isPublicSaleActive) external onlyOwner
function setIsPublicSaleActive(bool _isPublicSaleActive) external onlyOwner
70,584