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 | // solhint-disable-next-line no-empty-blocks | receive() external virtual payable {}
} abstract contract CTokenInterface is ERC20 {
function mint(uint256 mintAmount) external virtual returns (uint256);
// function mint() external virtual payable;
function accrueInterest() public virtual returns (uint);
function redeem(uint256 redeemTokens) ex... | receive() external virtual payable {}
} abstract contract CTokenInterface is ERC20 {
function mint(uint256 mintAmount) external virtual returns (uint256);
// function mint() external virtual payable;
function accrueInterest() public virtual returns (uint);
function redeem(uint256 redeemTokens) ex... | 6,178 |
46 | // Exit rewards condition | maxIterations = 0;
| maxIterations = 0;
| 9,698 |
345 | // Returns the current total supply of votes. / | function _getTotalSupply() internal view virtual returns (uint256) {
return _totalCheckpoints.latest();
}
| function _getTotalSupply() internal view virtual returns (uint256) {
return _totalCheckpoints.latest();
}
| 62,786 |
48 | // Base pool hook called from `onJoinPool`. Forward to `onJoinExitPool` with `isJoin` set to true. / | function _onJoinPool(
bytes32,
address,
address,
uint256[] memory registeredBalances,
uint256,
uint256,
uint256[] memory scalingFactors,
bytes memory userData
| function _onJoinPool(
bytes32,
address,
address,
uint256[] memory registeredBalances,
uint256,
uint256,
uint256[] memory scalingFactors,
bytes memory userData
| 21,152 |
124 | // Distributes the provided amount of fees._feeManager address of the fee manager contract_fee total amount to be distributed to the list of reward accounts._messageId id of the message that generated fee distribution/ | function distributeFee(IMediatorFeeManager _feeManager, uint256 _fee, bytes32 _messageId) internal {
onFeeDistribution(_feeManager, _fee);
_feeManager.call(abi.encodeWithSelector(ON_TOKEN_TRANSFER, address(this), _fee, ""));
emit FeeDistributed(_fee, _messageId);
}
| function distributeFee(IMediatorFeeManager _feeManager, uint256 _fee, bytes32 _messageId) internal {
onFeeDistribution(_feeManager, _fee);
_feeManager.call(abi.encodeWithSelector(ON_TOKEN_TRANSFER, address(this), _fee, ""));
emit FeeDistributed(_fee, _messageId);
}
| 50,398 |
27 | // Gets the borrow cap of the reserve self The reserve configurationreturn The borrow cap / | {
return (self.data & ~BORROW_CAP_MASK) >> BORROW_CAP_START_BIT_POSITION;
}
| {
return (self.data & ~BORROW_CAP_MASK) >> BORROW_CAP_START_BIT_POSITION;
}
| 4,688 |
521 | // get the most recently reported answer[deprecated] Use latestRoundData instead. This does not error if noanswer has been reached, it will simply return 0. Either wait to point toan already answered Aggregator or use the recommended latestRoundDatainstead which includes better verification information. / | function latestAnswer() public view virtual override returns (int256) {
return rounds[latestRoundId].answer;
}
| function latestAnswer() public view virtual override returns (int256) {
return rounds[latestRoundId].answer;
}
| 12,929 |
29 | // modifier to check validation of lock status of smart contract / | modifier AllTransfersLockStatus()
| modifier AllTransfersLockStatus()
| 14,149 |
0 | // Functions that create transaction on block chain | function setName(string memory newName) public {
name = newName;
}
| function setName(string memory newName) public {
name = newName;
}
| 38,455 |
77 | // Create keeper listNOTE: Any function with onlyKeeper modifier will not work until this function is called.NOTE: Due to gas constraint this function cannot be called in constructor. _addressListFactory To support same code in eth side chain, user _addressListFactory as paramethereum- 0xded8217De022706A191eE7Ee0Dc9df1... | function init(address _addressListFactory) external onlyGovernor {
require(address(keepers) == address(0), "keeper-list-already-created");
// Prepare keeper list
IAddressListFactory _factory = IAddressListFactory(_addressListFactory);
keepers = IAddressList(_factory.createList());
... | function init(address _addressListFactory) external onlyGovernor {
require(address(keepers) == address(0), "keeper-list-already-created");
// Prepare keeper list
IAddressListFactory _factory = IAddressListFactory(_addressListFactory);
keepers = IAddressList(_factory.createList());
... | 25,695 |
46 | // Don't allow setting bad agent | if(!finalizeAgent.isFinalizeAgent()) {
throw;
}
| if(!finalizeAgent.isFinalizeAgent()) {
throw;
}
| 6,052 |
99 | // Handle the receipt of ERC1363 tokens Any ERC1363 smart contract calls this function on the recipientafter a `transfer` or a `transferFrom`. This function MAY throw to revert and reject thetransfer. Return of other than the magic value MUST result in thetransaction being reverted.Note: the token contract address is a... | function onTransferReceived(address operator, address sender, uint256 amount, bytes calldata data) external returns (bytes4);
| function onTransferReceived(address operator, address sender, uint256 amount, bytes calldata data) external returns (bytes4);
| 9,843 |
27 | // no vesting allowed | mVestingAllowed[target]=0;
| mVestingAllowed[target]=0;
| 28,132 |
91 | // `prevId` does not exist anymore or now has a smaller key than the given key | prevId = address(0);
| prevId = address(0);
| 5,934 |
0 | // Required interface of an ERC721 compliant contract. / | interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` to... | interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` to... | 2,813 |
83 | // This is used instead of msg.sender as transactions won't be sent by the original token owner, but by OpenSea. /function _msgSender()internaloverrideviewreturns (address sender) | // {
// return ContextMixin.msgSender();
// }
| // {
// return ContextMixin.msgSender();
// }
| 21,089 |
5 | // Address of the OptimistAllowlist contract. / | OptimistAllowlist public immutable OPTIMIST_ALLOWLIST;
| OptimistAllowlist public immutable OPTIMIST_ALLOWLIST;
| 10,667 |
166 | // removeLiquidity | _approveRouter(_pair,_lpAmount);
(uint256 removeAmount0,uint256 removeAmount1) = swapRouter.removeLiquidity(token0,token1,_lpAmount,0,0,
address(this), block.timestamp + 300);
| _approveRouter(_pair,_lpAmount);
(uint256 removeAmount0,uint256 removeAmount1) = swapRouter.removeLiquidity(token0,token1,_lpAmount,0,0,
address(this), block.timestamp + 300);
| 13,894 |
19 | // Populate U matrix | for (uint i=0; i<a[0].length; i++) {
| for (uint i=0; i<a[0].length; i++) {
| 31,034 |
10 | // Claim rewards owed | IRewardsHandler(rewardsHandlerAddress).claimRewards(fnftId, _msgSender());
| IRewardsHandler(rewardsHandlerAddress).claimRewards(fnftId, _msgSender());
| 5,660 |
32 | // 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... | 35,502 |
80 | // Outside-visible transact entry point. Executes transaction immediately if below daily spend limit. If not, goes into multisig process. We provide a hash on return to allow the sender to provide shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value and _data arguments). They still ... | function execute(address _to, uint _value, bytes _data) onlyowner external returns (bytes32 o_hash) {
// first, take the opportunity to check that we're under the daily limit.
if ((_data.length == 0 && underLimit(_value)) || m_required == 1) {
// yes - just execute the call.
address created;
if (_to == 0)... | function execute(address _to, uint _value, bytes _data) onlyowner external returns (bytes32 o_hash) {
// first, take the opportunity to check that we're under the daily limit.
if ((_data.length == 0 && underLimit(_value)) || m_required == 1) {
// yes - just execute the call.
address created;
if (_to == 0)... | 87,260 |
497 | // Checks all cash group settings for invalid values and sets them into storage | function setCashGroupStorage(uint256 currencyId, CashGroupSettings calldata cashGroup)
internal
| function setCashGroupStorage(uint256 currencyId, CashGroupSettings calldata cashGroup)
internal
| 65,000 |
108 | // Start a new period needs corresponding permissions for sender / | function startNewPeriod() external;
| function startNewPeriod() external;
| 23,651 |
206 | // Get channel confirm settle open time _channelId ID of the channel to be viewedreturn channel confirm settle open time / | function getSettleFinalizedTime(bytes32 _channelId) public view returns(uint) {
| function getSettleFinalizedTime(bytes32 _channelId) public view returns(uint) {
| 55,329 |
197 | // return stakingToken.balanceOf(address(this)); | return totalStakedAmount;
| return totalStakedAmount;
| 77,405 |
93 | // Fetches Compound prices for tokens/_cTokens Arr. of cTokens for which to get the prices/ return prices Array of prices | function getPrices(address[] memory _cTokens) public view returns (uint[] memory prices) {
prices = new uint[](_cTokens.length);
address oracleAddr = Comptroller.oracle();
for (uint i = 0; i < _cTokens.length; ++i) {
prices[i] = ICompoundOracle(oracleAddr).getUnderlyingPrice(_cT... | function getPrices(address[] memory _cTokens) public view returns (uint[] memory prices) {
prices = new uint[](_cTokens.length);
address oracleAddr = Comptroller.oracle();
for (uint i = 0; i < _cTokens.length; ++i) {
prices[i] = ICompoundOracle(oracleAddr).getUnderlyingPrice(_cT... | 46,978 |
157 | // Calculates the how is gonna be a new cooldown timestamp depending on the sender/receiver situation - If the timestamp of the sender is "better" or the timestamp of the recipient is 0, we take the one of the recipient - Weighted average of from/to cooldown timestamps if:The sender doesn't have the cooldown activated ... | ) public view returns (uint256) {
uint256 toCooldownTimestamp = stakersCooldowns[toAddress];
if (toCooldownTimestamp == 0) {
return 0;
}
uint256 minimalValidCooldownTimestamp =
block.timestamp.sub(COOLDOWN_SECONDS).sub(UNSTAKE_WINDOW);
if (minimalValidCooldownTimestamp > toCooldownTi... | ) public view returns (uint256) {
uint256 toCooldownTimestamp = stakersCooldowns[toAddress];
if (toCooldownTimestamp == 0) {
return 0;
}
uint256 minimalValidCooldownTimestamp =
block.timestamp.sub(COOLDOWN_SECONDS).sub(UNSTAKE_WINDOW);
if (minimalValidCooldownTimestamp > toCooldownTi... | 59,573 |
0 | // Block congestion level targeted by the gas price minimum calculation. | FixidityLib.Fraction public targetDensity;
| FixidityLib.Fraction public targetDensity;
| 27,397 |
10 | // Triggers stopped state. Requirements: - The buyer must not be paused. / | function _pauseBuyer() internal whenBuyerNotPaused {
_buyerPaused = true;
emit Paused(_msgSender());
}
| function _pauseBuyer() internal whenBuyerNotPaused {
_buyerPaused = true;
emit Paused(_msgSender());
}
| 41,722 |
994 | // Check the amount of token to send meets minDy | require(v.dy >= minDy, "Swap didn't result in min tokens");
| require(v.dy >= minDy, "Swap didn't result in min tokens");
| 88,363 |
6,338 | // 3171 | entry "nosewise" : ENG_ADVERB
| entry "nosewise" : ENG_ADVERB
| 24,007 |
38 | // Whether the `_tokenIds` can be transfered / | modifier canTransferInBatch(uint256[] _tokenIds) {
for(uint256 i = 0; i < _tokenIds.length; i++) {
address owner = dataSource.roomNightIndexToOwner(_tokenIds[i]);
bool isOwner = (msg.sender == owner);
bool isApproval = (msg.sender == dataSource.roomNightApprovals(_tokenId... | modifier canTransferInBatch(uint256[] _tokenIds) {
for(uint256 i = 0; i < _tokenIds.length; i++) {
address owner = dataSource.roomNightIndexToOwner(_tokenIds[i]);
bool isOwner = (msg.sender == owner);
bool isApproval = (msg.sender == dataSource.roomNightApprovals(_tokenId... | 14,419 |
4 | // no-op | return;
| return;
| 7,658 |
105 | // exchange | (uint256 tokenAmount,uint256 currencyAmount) = matchBuyOrderAmount(orderId,maker,taker,amount);
require(tokenAmount>0,"!tokenAmount");
require(currencyAmount>0,"!currencyAmount");
| (uint256 tokenAmount,uint256 currencyAmount) = matchBuyOrderAmount(orderId,maker,taker,amount);
require(tokenAmount>0,"!tokenAmount");
require(currencyAmount>0,"!currencyAmount");
| 24,800 |
4 | // Implements EIP-165 for standard interface detection/`0x01ffc9a7` is the IERC165 interface id/_interfaceId The identifier of a given interface/ return If the given interface is supported | function supportsInterface(bytes4 _interfaceId) external pure returns (bool) {
return _interfaceId == type(IAsksCoreEth).interfaceId || _interfaceId == 0x01ffc9a7;
}
| function supportsInterface(bytes4 _interfaceId) external pure returns (bool) {
return _interfaceId == type(IAsksCoreEth).interfaceId || _interfaceId == 0x01ffc9a7;
}
| 18,593 |
269 | // DGCLTESTToken Implementation of the DGCLTESTToken / | contract DGCLTESTToken is ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover {
// indicates if minting is finished
bool private _mintingFinished = false;
// indicates if transfer is enabled
bool private _transferEnabled = false;
/**
* @dev Emitted during finish minting
*/
event... | contract DGCLTESTToken is ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover {
// indicates if minting is finished
bool private _mintingFinished = false;
// indicates if transfer is enabled
bool private _transferEnabled = false;
/**
* @dev Emitted during finish minting
*/
event... | 4,364 |
9 | // make seperate contract | function createAppointment(Appointment calldata appointment)
external
payable
| function createAppointment(Appointment calldata appointment)
external
payable
| 17,477 |
253 | // owner set a new address for signature verification | function setVerifySigner(address _verifySigner) external virtual onlyOwner {
verifySigner = _verifySigner;
emit ContractUpdated("verifySigner");
}
| function setVerifySigner(address _verifySigner) external virtual onlyOwner {
verifySigner = _verifySigner;
emit ContractUpdated("verifySigner");
}
| 40,947 |
5 | // Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation./ See {IERC165-supportsInterface}. / | function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
| function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
| 17,072 |
11 | // getOwner | function go_() external view isOwnerOrManager returns (address) {
return owner;
}
| function go_() external view isOwnerOrManager returns (address) {
return owner;
}
| 35,261 |
14 | // Launch and retire the founder / | function launch() public {
require(msg.sender == founder);
launched = block.timestamp;
founder = 0x0;
}
| function launch() public {
require(msg.sender == founder);
launched = block.timestamp;
founder = 0x0;
}
| 8,045 |
33 | // Assigns a new address to act as the Admin. Only available to the current Admin./_newAdminAddress The address of the new Admin | function setAdmin(address _newAdminAddress) public onlyAdmin {
require(_newAdminAddress != address(0));
adminAddress = _newAdminAddress;
}
| function setAdmin(address _newAdminAddress) public onlyAdmin {
require(_newAdminAddress != address(0));
adminAddress = _newAdminAddress;
}
| 41,976 |
44 | // only IRN Nodes can call, otherwise throw | modifier onlyIRNNode() {
require(network[msg.sender].isIRNNode, "must be an irn node");
_;
}
| modifier onlyIRNNode() {
require(network[msg.sender].isIRNNode, "must be an irn node");
_;
}
| 16,175 |
124 | // Address of a gambler, used to pay out winning bets. | address payable gambler;
| address payable gambler;
| 18,040 |
58 | // | constructor () ERC20("CZ PEPE", "CZPEPE") {
totalsupply_ = 100000000000000 * 10**9;
_mint(_msgSender(), totalsupply_);
}
| constructor () ERC20("CZ PEPE", "CZPEPE") {
totalsupply_ = 100000000000000 * 10**9;
_mint(_msgSender(), totalsupply_);
}
| 26,012 |
16 | // make sure that the variable is of storage type because we need a reference | Poll storage poll = polls[pollId];
| Poll storage poll = polls[pollId];
| 22 |
140 | // User will always withdraw everything available | function withdraw()
external
| function withdraw()
external
| 33,558 |
1 | // The address of an oracle - you can find node addresses on https:market.link/search/nodes | address ORACLE_ADDRESS = 0xB36d3709e22F7c708348E225b20b13eA546E6D9c;
| address ORACLE_ADDRESS = 0xB36d3709e22F7c708348E225b20b13eA546E6D9c;
| 19,567 |
27 | // 3pool | uint256[3] calldata amounts,
uint256 min_mint_amount
) external payable;
function add_liquidity(
| uint256[3] calldata amounts,
uint256 min_mint_amount
) external payable;
function add_liquidity(
| 39,304 |
366 | // Deletes a sponsor's position and updates global counters. Does not make any external transfers. | function _deleteSponsorPosition(address sponsor) internal returns (FixedPoint.Unsigned memory) {
PositionData storage positionToLiquidate = _getPositionData(sponsor);
FixedPoint.Unsigned memory startingGlobalCollateral = _getFeeAdjustedCollateral(rawTotalPositionCollateral);
// Remove the ... | function _deleteSponsorPosition(address sponsor) internal returns (FixedPoint.Unsigned memory) {
PositionData storage positionToLiquidate = _getPositionData(sponsor);
FixedPoint.Unsigned memory startingGlobalCollateral = _getFeeAdjustedCollateral(rawTotalPositionCollateral);
// Remove the ... | 34,905 |
27 | // Do not allow staking over occupied planets, they are going to zero at some point though | require(planetUpdate.owner == player, "OCCUPIED");
| require(planetUpdate.owner == player, "OCCUPIED");
| 23,218 |
0 | // declaring 50% chance, (0.5(uint256+1)) | uint256 constant half = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
uint256 public randomResult;
mapping(uint256 => Game) public games;
event Withdraw(address admin, uint256 amount);
event Received(address indexed sender, uint256 amount);
event Result(uint... | uint256 constant half = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
uint256 public randomResult;
mapping(uint256 => Game) public games;
event Withdraw(address admin, uint256 amount);
event Received(address indexed sender, uint256 amount);
event Result(uint... | 37,845 |
4 | // The Ownable constructor sets the original `owner` of the contract to the sender account./ | constructor() public {
_owner = msg.sender;
_operator = msg.sender;
emit OwnershipTransferred(address(0), _owner);
emit OperatorTransferred(address(0), _operator);
}
| constructor() public {
_owner = msg.sender;
_operator = msg.sender;
emit OwnershipTransferred(address(0), _owner);
emit OperatorTransferred(address(0), _operator);
}
| 25,213 |
16 | // Hardcaps & Softcaps | uint Hardcap = 100000;
uint Softcap = 10000;
| uint Hardcap = 100000;
uint Softcap = 10000;
| 12,636 |
12 | // tier pop | function populateTierTokens() public {
require((msg.sender == owner) && (initialTiers == false));
scheduleTokens[1] = 5.33696E18;
scheduleTokens[2] = 7.69493333E18;
scheduleTokens[3] = 4.75684324E18;
scheduleTokens[4] = 6.30846753E18;
scheduleTokens[5] = 6.21620513E18... | function populateTierTokens() public {
require((msg.sender == owner) && (initialTiers == false));
scheduleTokens[1] = 5.33696E18;
scheduleTokens[2] = 7.69493333E18;
scheduleTokens[3] = 4.75684324E18;
scheduleTokens[4] = 6.30846753E18;
scheduleTokens[5] = 6.21620513E18... | 67,138 |
187 | // Emit TokensUnlocked | emit TokensUnlocked(msg.sender, tokenLocked);
| emit TokensUnlocked(msg.sender, tokenLocked);
| 51,538 |
83 | // Two different getReward functions are needed because of delegateCall and msg.sender issues (important for migration) | function getReward() external nonReentrant returns (uint256) {
require(rewardsCollectionPaused == false,"Rewards collection paused");
return _getReward(msg.sender, msg.sender);
}
| function getReward() external nonReentrant returns (uint256) {
require(rewardsCollectionPaused == false,"Rewards collection paused");
return _getReward(msg.sender, msg.sender);
}
| 82,564 |
37 | // Called when `_owner` sends ether to the MiniMe Token contract/_owner The address that sent the ether to create tokens/ return True if the ether is accepted, false if it throws | function proxyPayment(address _owner) external payable returns(bool);
| function proxyPayment(address _owner) external payable returns(bool);
| 25,379 |
114 | // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and then delete the last slot (swap and pop). |
uint256 lastTokenIndex = _ownedTokens[from].length.sub(1);
uint256 tokenIndex = _ownedTokensIndex[tokenId];
|
uint256 lastTokenIndex = _ownedTokens[from].length.sub(1);
uint256 tokenIndex = _ownedTokensIndex[tokenId];
| 4,144 |
284 | // the stablecoin pool contract / | interface IStableSwap3Pool {
function exchange(
int128 i,
int128 j,
uint256 dx,
uint256 min_dy // solhint-disable-line func-param-name-mixedcase
) external;
function coins(uint256 coin) external view returns (address);
// solhint-disable-next-line func-name-mixedcase
... | interface IStableSwap3Pool {
function exchange(
int128 i,
int128 j,
uint256 dx,
uint256 min_dy // solhint-disable-line func-param-name-mixedcase
) external;
function coins(uint256 coin) external view returns (address);
// solhint-disable-next-line func-name-mixedcase
... | 44,021 |
433 | // Get an item from withdrawal request-chain./index The 0-based index of the request/ return accumulatedHash See @Request/ return accumulatedFeeSee @Request/ return timestamp See @Request | function getWithdrawRequest(
uint index
)
external
view
returns (
bytes32 accumulatedHash,
uint accumulatedFee,
uint32 timestamp
);
| function getWithdrawRequest(
uint index
)
external
view
returns (
bytes32 accumulatedHash,
uint accumulatedFee,
uint32 timestamp
);
| 28,734 |
29 | // Returns the square root of a number. It the number is not a perfect square, the value is rounded down. Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). / | function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
// We know that the "msb" (most significant bit) of our target number `a` is a ... | function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
// We know that the "msb" (most significant bit) of our target number `a` is a ... | 18,592 |
121 | // Someone claims rewards for a PoolMember in a given group of epochs in all feeHandlers. It will transfer rewards where epoch->feeHandler has been claimed by the pool and not yet by the member. This contract will keep locked remainings from rounding at a wei level. _epochGroup An array of epochs for which rewards are ... | function claimRewardsMember(
address _poolMember,
uint256[] memory _epochGroup
| function claimRewardsMember(
address _poolMember,
uint256[] memory _epochGroup
| 87,348 |
51 | // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have `msb(a) <= a < 2msb(a)`. This value can be written `msb(a)=2k` with `k=log2(a)`. This can be rewritten `2log... | uint256 result = 1 << (log2(a) >> 1);
| uint256 result = 1 << (log2(a) >> 1);
| 437 |
2 | // stake token for miner | function deposit(uint256 _amount) external;
| function deposit(uint256 _amount) external;
| 20,913 |
16 | // Set access control roles | _setupRole(DEFAULT_ADMIN_ROLE, _admin);
| _setupRole(DEFAULT_ADMIN_ROLE, _admin);
| 29,013 |
2 | // Encode it | ret = new bytes(count + 4);
assembly {
mstore(add(ret, 32), selector)
}
| ret = new bytes(count + 4);
assembly {
mstore(add(ret, 32), selector)
}
| 21,916 |
114 | // if no one voted for an epoch (like epoch 0), no one gets rewards - should burn it./ Will move the epoch reward amount to burn amount. So can later be burned./ calls kyberDao contract to check if there were any votes for this epoch./epoch epoch number to check. | function makeEpochRewardBurnable(uint256 epoch) external {
require(kyberDao != IKyberDao(0), "kyberDao not set");
require(kyberDao.shouldBurnRewardForEpoch(epoch), "should not burn reward");
uint256 rewardAmount = rewardsPerEpoch[epoch];
require(rewardAmount > 0, "reward is 0");
... | function makeEpochRewardBurnable(uint256 epoch) external {
require(kyberDao != IKyberDao(0), "kyberDao not set");
require(kyberDao.shouldBurnRewardForEpoch(epoch), "should not burn reward");
uint256 rewardAmount = rewardsPerEpoch[epoch];
require(rewardAmount > 0, "reward is 0");
... | 11,909 |
5 | // Enable or disable the ability of `metaTransactionProcessor` to perform meta-tx (metaTransactionProcessor rights)./metaTransactionProcessor address that will be given/removed metaTransactionProcessor rights./enabled set whether the metaTransactionProcessor is enabled or disabled. | function setMetaTransactionProcessor(address metaTransactionProcessor, bool enabled) external {
require(
msg.sender == _admin,
"only admin can setup metaTransactionProcessors"
);
_metaTransactionContracts[metaTransactionProcessor] = enabled;
emit MetaTransacti... | function setMetaTransactionProcessor(address metaTransactionProcessor, bool enabled) external {
require(
msg.sender == _admin,
"only admin can setup metaTransactionProcessors"
);
_metaTransactionContracts[metaTransactionProcessor] = enabled;
emit MetaTransacti... | 43,624 |
32 | // Update the total borrows based on the proportional rate of interest applied to the entire system | totalBorrowed = totalBorrowed.mul(borrowIndex).div(BASE);
| totalBorrowed = totalBorrowed.mul(borrowIndex).div(BASE);
| 49,868 |
1 | // lottoTimestamp => participants | mapping(uint256 => address[]) public lottoParticipants;
| mapping(uint256 => address[]) public lottoParticipants;
| 5,120 |
79 | // Allows the owner to complete the two-step ownership handover to `pendingOwner`./ Reverts if there is no existing ownership handover requested by `pendingOwner`. | function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {
/// @solidity memory-safe-assembly
assembly {
// Compute and set the handover slot to 0.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, pendingOwner)
let handov... | function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {
/// @solidity memory-safe-assembly
assembly {
// Compute and set the handover slot to 0.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, pendingOwner)
let handov... | 20,903 |
12 | // AcceptGame struct type encoding per EIP 712keccak256("AcceptGame(uint256 bet,bool isHost,address opponentAddress,bytes32 hashOfMySecret,bytes32 hashOfOpponentSecret)") / | bytes32 private constant ACCEPTGAME_TYPEHASH = 0x5ceee84403c984fbd9fb4ebf11b09c4f28f87290116c8b7f24a3e2a89d26588f;
| bytes32 private constant ACCEPTGAME_TYPEHASH = 0x5ceee84403c984fbd9fb4ebf11b09c4f28f87290116c8b7f24a3e2a89d26588f;
| 31,996 |
115 | // Returns the stake of the specified stake owner (excluding unstaked tokens)./_stakeOwner address The address to check./ return uint256 The total stake. | function getStakeBalanceOf(address _stakeOwner) external view returns (uint256);
| function getStakeBalanceOf(address _stakeOwner) external view returns (uint256);
| 43,032 |
52 | // disperse dividends among holders | profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
| profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
| 19,761 |
12 | // And Send 0.5 USDT to Target | currency.transfer(ERC721BaseInternal._ownerOf(targetId), 500000);
Settings storage x = getSettings();
x.contractERCBalance = x.contractERCBalance + 1000000;
emit Admired(invokerId, targetId);
| currency.transfer(ERC721BaseInternal._ownerOf(targetId), 500000);
Settings storage x = getSettings();
x.contractERCBalance = x.contractERCBalance + 1000000;
emit Admired(invokerId, targetId);
| 27,636 |
29 | // Fail if the sender code does not match | require(calculatedPaymentCode == paymentCode);
| require(calculatedPaymentCode == paymentCode);
| 24,776 |
18 | // Not whitelisted | error NotWhitelisted();
| error NotWhitelisted();
| 24,447 |
35 | // Get locked item's attributes for return | address payable sender = items[_id].sender;
address token = items[_id].token;
uint256 amount = items[_id].amount;
uint256 uniqueNonce = items[_id].nonce;
| address payable sender = items[_id].sender;
address token = items[_id].token;
uint256 amount = items[_id].amount;
uint256 uniqueNonce = items[_id].nonce;
| 44,180 |
85 | // allows the configurator to update the loan to value of a reserve_reserve the address of the reserve_ltv the new loan to value/ | {
CoreLibrary.ReserveData storage reserve = reserves[_reserve];
reserve.baseLTVasCollateral = _ltv;
}
| {
CoreLibrary.ReserveData storage reserve = reserves[_reserve];
reserve.baseLTVasCollateral = _ltv;
}
| 39,912 |
324 | // Works out the amount of interest and principal after a repayment is made. | function _processPayment(Loan memory loanBefore, uint payment) internal returns (Loan memory loanAfter) {
loanAfter = loanBefore;
if (payment > 0 && loanBefore.accruedInterest > 0) {
uint interestPaid = payment > loanBefore.accruedInterest ? loanBefore.accruedInterest : payment;
... | function _processPayment(Loan memory loanBefore, uint payment) internal returns (Loan memory loanAfter) {
loanAfter = loanBefore;
if (payment > 0 && loanBefore.accruedInterest > 0) {
uint interestPaid = payment > loanBefore.accruedInterest ? loanBefore.accruedInterest : payment;
... | 29,030 |
39 | // Tool to verify that a low level call to smart-contract was successful, and reverts if the target | * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!... | * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!... | 32,184 |
19 | // called by the owner on emergency, triggers stopped state | function emergencyStop() external onlyOwner {
stopped = true;
}
| function emergencyStop() external onlyOwner {
stopped = true;
}
| 33,111 |
78 | // See {ERC20-approve}. Requirements: - `spender` cannot be the zero address. / | function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| 15,457 |
161 | // Selector of `log(string,uint256,address)`. | mstore(0x00, 0x1c7ec448)
mstore(0x20, 0x60)
mstore(0x40, p1)
mstore(0x60, p2)
writeString(0x80, p0)
| mstore(0x00, 0x1c7ec448)
mstore(0x20, 0x60)
mstore(0x40, p1)
mstore(0x60, p2)
writeString(0x80, p0)
| 30,513 |
19 | // remove pool | pools[_poolId] = pools[pools.length - 1];
pools.pop();
poolAdded[poolAddress] = false;
emit PoolRemoved(_poolId, poolAddress);
| pools[_poolId] = pools[pools.length - 1];
pools.pop();
poolAdded[poolAddress] = false;
emit PoolRemoved(_poolId, poolAddress);
| 29,767 |
45 | // Calculates the amount that has already vested. account address of the user / | function _vestedAmount(address account) internal view returns (uint256) {
VestedToken storage vested = vestedUser[account];
uint256 totalToken = vested.totalToken;
if(block.timestamp < vested.start + (vested.cliff)){
return 0;
}else if(block.timestamp >= vested.start+(ve... | function _vestedAmount(address account) internal view returns (uint256) {
VestedToken storage vested = vestedUser[account];
uint256 totalToken = vested.totalToken;
if(block.timestamp < vested.start + (vested.cliff)){
return 0;
}else if(block.timestamp >= vested.start+(ve... | 14,403 |
6 | // To get the followed hashtag names for this msg.sender/ return bytes32[] The hashtags followed by this user | function getFollowedHashtags() public view returns(bytes32[] memory) {
return subscribedHashtags[msg.sender];
}
| function getFollowedHashtags() public view returns(bytes32[] memory) {
return subscribedHashtags[msg.sender];
}
| 25,983 |
25 | // Decode the passed variables from the data object | (
| (
| 40,004 |
168 | // if _amountNeeded != withdrawnBal, then we have an error | if (_amountNeeded != withdrawnBal) {
uint256 assets = estimatedTotalAssets();
uint256 debt = vault.strategies(address(this)).totalDebt;
_loss = debt.sub(assets);
}
| if (_amountNeeded != withdrawnBal) {
uint256 assets = estimatedTotalAssets();
uint256 debt = vault.strategies(address(this)).totalDebt;
_loss = debt.sub(assets);
}
| 16,839 |
3 | // 50 slots were consumed by adding ReentrancyGuardUpgradeable | uint256[950] private ______gap;
| uint256[950] private ______gap;
| 43,527 |
139 | // check the address is registered for token sale | mapping (address => bool) public registeredAddress;
| mapping (address => bool) public registeredAddress;
| 81,342 |
269 | // distribute funds between owner, creator and adminThis function will transfer the funds from the contract, which must have previously sent to the contract, to the beneficiaries of the saleThe "false" parameter at the end means: do a simple transfer / | distributeFunds(qty * openOffers[tokenId][index].price, openOffers[tokenId][index].user, _msgSender(), tokenId, false);
| distributeFunds(qty * openOffers[tokenId][index].price, openOffers[tokenId][index].user, _msgSender(), tokenId, false);
| 31,179 |
137 | // Function to check how many tokens of this product are currently available for purchase,by taking the difference between max cap count and current token in circulation or burned. return availablethe number of tokens available/ | function getAvailability()
public view virtual returns (uint32 available)
{
return maxTokenCount - uint32(totalSupply()) - tradeinCount; // add safemath for uint32 later
}
| function getAvailability()
public view virtual returns (uint32 available)
{
return maxTokenCount - uint32(totalSupply()) - tradeinCount; // add safemath for uint32 later
}
| 57,713 |
111 | // uint256 supply = totalSupply(); | require( SaleActive, "Sale isn't active" );
require( _amount > 0 && _amount < 11, "Can only mint between 1 and 10 tokens at once" );
require( TokensMinted + _amount <= Max_Supply, "Can't mint more than max supply" );
require( msg.value == SalePrice * _amount, "Wr... | require( SaleActive, "Sale isn't active" );
require( _amount > 0 && _amount < 11, "Can only mint between 1 and 10 tokens at once" );
require( TokensMinted + _amount <= Max_Supply, "Can't mint more than max supply" );
require( msg.value == SalePrice * _amount, "Wr... | 44,570 |
74 | // Mapping owner address to token count | mapping(address => uint256) private _balances;
| mapping(address => uint256) private _balances;
| 40,928 |
8 | // required for the claimed ether to be transfered here | function() public payable { }
function claim(address race) external
_validRace(race) {
BettingInterface raceContract = BettingInterface(race);
if(!ClaimedRaces[race]) {
toDistributeRace[race] = raceContract.checkReward();
raceContract.claim_reward();
... | function() public payable { }
function claim(address race) external
_validRace(race) {
BettingInterface raceContract = BettingInterface(race);
if(!ClaimedRaces[race]) {
toDistributeRace[race] = raceContract.checkReward();
raceContract.claim_reward();
... | 38,327 |
270 | // A structure for planet info | struct PlanetInfo {
string name;
uint256 radius;
}
| struct PlanetInfo {
string name;
uint256 radius;
}
| 44,284 |
10 | // immutable function example | function example() public pure returns (string memory) {
return "THIS IS AN EXAMPLE OF AN IMMUTABLE FUNCTION";
}
| function example() public pure returns (string memory) {
return "THIS IS AN EXAMPLE OF AN IMMUTABLE FUNCTION";
}
| 35,240 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.