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 |
|---|---|---|---|---|
8 | // Extracts number of outputs and ending indexrawTx Raw transaction return Number of outputs return Scanner end position/ | function extractOutputLength(bytes memory rawTx) internal pure returns (uint, uint) {
uint length = rawTx.length;
uint pos = 0;
uint varIntLen = rawTx.slice(pos, length - pos).determineVarIntDataLength();
if (varIntLen == 0) {
varIntLen = 1;
}
uint numOu... | function extractOutputLength(bytes memory rawTx) internal pure returns (uint, uint) {
uint length = rawTx.length;
uint pos = 0;
uint varIntLen = rawTx.slice(pos, length - pos).determineVarIntDataLength();
if (varIntLen == 0) {
varIntLen = 1;
}
uint numOu... | 38,694 |
13 | // Asserts that a particular block had a particular hash. Callable only from provers. verifier The block history verifier to use for the query hash The block hash in question num The block number to query proof Any witness information needed by the verifier Reverts if the given block was not proven to have the given ha... | function assertValidBlockHashFromProver(
| function assertValidBlockHashFromProver(
| 24,838 |
3 | // external contracts | Asteroid public asteroid;
address public spacestationAddress;
address public dogeTypeOracleAddress;
| Asteroid public asteroid;
address public spacestationAddress;
address public dogeTypeOracleAddress;
| 22,618 |
626 | // the total amount of rewards distributed by the contract over entire period/ return the total, including currently held and previously claimed rewards | function totalReward() external view returns (uint);
| function totalReward() external view returns (uint);
| 39,682 |
0 | // Emitted when the pause is triggered by `account` | event Paused(
address account
| event Paused(
address account
| 23,501 |
36 | // ПЛОХОЙ etc. | paradigm Плохой, Прил_5026 : ПРИЛАГАТЕЛЬНОЕ for "(.+)\\@аХОЙ"
| paradigm Плохой, Прил_5026 : ПРИЛАГАТЕЛЬНОЕ for "(.+)\\@аХОЙ"
| 21,361 |
228 | // pay our winner | plyr_[_winPID].win = _win.add(plyr_[_winPID].win);
| plyr_[_winPID].win = _win.add(plyr_[_winPID].win);
| 31,689 |
63 | // Function to be called by top level contract after initialization to enable the contractat a future block number rather than immediately./ | function initializedAt(uint256 _blockNumber) internal onlyInit {
INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber);
}
| function initializedAt(uint256 _blockNumber) internal onlyInit {
INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber);
}
| 31,626 |
8 | // GET ALL CREATED CHANNELS / | {
result = new Channel[](channelId.current());
for (uint i = 1; i <= channelId.current(); i++) {
uint index = i - 1;
result[index] = channels[i];
}
}
| {
result = new Channel[](channelId.current());
for (uint i = 1; i <= channelId.current(); i++) {
uint index = i - 1;
result[index] = channels[i];
}
}
| 35,970 |
292 | // lib/dss-test/lib/dss-interfaces/src/dss/mip21/RwaJarAbstract.sol SPDX-FileCopyrightText: © 2022 Dai Foundation <www.daifoundation.org>/ pragma solidity >=0.5.12; / https:github.com/makerdao/mip21-toolkit/blob/master/src/jars/RwaJar.sol | interface RwaJarAbstract {
function daiJoin() external view returns(address);
function dai() external view returns(address);
function chainlog() external view returns(address);
function void() external;
function toss(uint256) external;
}
| interface RwaJarAbstract {
function daiJoin() external view returns(address);
function dai() external view returns(address);
function chainlog() external view returns(address);
function void() external;
function toss(uint256) external;
}
| 27,741 |
28 | // checks if the current vault can be settled / | function _canSettleVault() internal view returns (bool) {
if (lockedAsset != 0 && otoken != address(0)) {
return controller.isSettlementAllowed(otoken);
}
return false;
}
| function _canSettleVault() internal view returns (bool) {
if (lockedAsset != 0 && otoken != address(0)) {
return controller.isSettlementAllowed(otoken);
}
return false;
}
| 38,995 |
1 | // sealed closed portal | svg = LibSvg.getSvg("portal-closed", hauntId);
| svg = LibSvg.getSvg("portal-closed", hauntId);
| 2,955 |
38 | // If a pre-issue hook has been configured, call the external-protocol contract. Pre-issue hook logiccan contain arbitrary logic including validations, external function calls, etc. / | function _callManagerPreIssueHooks(
ISetToken _setToken,
uint256 _quantity,
address _caller,
address _to
)
internal
returns(address)
| function _callManagerPreIssueHooks(
ISetToken _setToken,
uint256 _quantity,
address _caller,
address _to
)
internal
returns(address)
| 18,075 |
24 | // calculate how much input tokens our total supply is worth | uint256 nTotalInputTokens = nTotalSupply.mul(TOKEN_BASE_RATE);
| uint256 nTotalInputTokens = nTotalSupply.mul(TOKEN_BASE_RATE);
| 21,623 |
212 | // ========== RESTRICTED FUNCTIONS, CUSTODIAN CAN CALL TOO ========== / | function toggleMRBR(uint256 col_idx, uint8 tog_idx) external onlyByOwnGovCust {
if (tog_idx == 0) mintPaused[col_idx] = !mintPaused[col_idx];
else if (tog_idx == 1) redeemPaused[col_idx] = !redeemPaused[col_idx];
else if (tog_idx == 2) buyBackPaused[col_idx] = !buyBackPaused[col_idx];
... | function toggleMRBR(uint256 col_idx, uint8 tog_idx) external onlyByOwnGovCust {
if (tog_idx == 0) mintPaused[col_idx] = !mintPaused[col_idx];
else if (tog_idx == 1) redeemPaused[col_idx] = !redeemPaused[col_idx];
else if (tog_idx == 2) buyBackPaused[col_idx] = !buyBackPaused[col_idx];
... | 62,224 |
95 | // This function should only be used in the scenario where the Strategy isbeing retired but no migration of the positions are possible, or in theextreme scenario that the Strategy needs to be put into "Emergency Exit"mode in order for it to exit as quickly as possible. The latter scenariocould be for any reason that is... | function revokeStrategy() external;
| function revokeStrategy() external;
| 4,469 |
4 | // bytes32 array of all ERC20 tokens traded on DEXALOT | EnumerableSetUpgradeable.Bytes32Set private tokenList;
| EnumerableSetUpgradeable.Bytes32Set private tokenList;
| 43,262 |
26 | // postion with {_nftId}. Can beextrapolated linear with {_intervall}. / | function _overallUSDBorrow(
uint256 _nftId,
uint256 _interval
)
internal
view
returns (uint256 buffer)
{
uint256 i;
address tokenAddress;
| function _overallUSDBorrow(
uint256 _nftId,
uint256 _interval
)
internal
view
returns (uint256 buffer)
{
uint256 i;
address tokenAddress;
| 1,233 |
67 | // Unstakes a certain amount of previously deposited tokens. User also receives theiralotted number of distribution tokens. amount Number of deposit tokens to unstake / withdraw. / | function unstake(uint256 amount) external {
_unstake(amount);
}
| function unstake(uint256 amount) external {
_unstake(amount);
}
| 9,838 |
7 | // 其他人不能作为老师登陆 | else require(msg.sender == teacher.addresses, "\nError!You are a student!");
/*//学生第一次登陆时必须输入idea
if (isStudent == true) require(bytes(idea).length != 0 || bytes(students[msg.sender].idea).length != 0, "\nError!Idea is necessary.");
| else require(msg.sender == teacher.addresses, "\nError!You are a student!");
/*//学生第一次登陆时必须输入idea
if (isStudent == true) require(bytes(idea).length != 0 || bytes(students[msg.sender].idea).length != 0, "\nError!Idea is necessary.");
| 10,604 |
202 | // The 8 bonus cards that you get for your first 8 referrals, in order. | uint8[] public bonusCards = [
115, // Kanté
127, // Navas
122, // Hummels
130, // Alves
116, // Cavani
123, // Özil
121, // Thiago
131 // Zlatan
];
| uint8[] public bonusCards = [
115, // Kanté
127, // Navas
122, // Hummels
130, // Alves
116, // Cavani
123, // Özil
121, // Thiago
131 // Zlatan
];
| 29,402 |
67 | // keccak256("ERC777TokensSender") | bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH =
0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895;
| bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH =
0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895;
| 5,399 |
42 | // A mask for isolating an item's group ID. | uint256 constant GROUP_MASK = uint256(uint128(~0)) << 128;
| uint256 constant GROUP_MASK = uint256(uint128(~0)) << 128;
| 41,343 |
40 | // ========== GAS QUEUE ========== / Address of Chainlink Fast Gas Price Oracle | address internal constant _FAST_GAS_ORACLE =
0x169E633A2D1E6c10dD91238Ba11c4A708dfEF37C;
| address internal constant _FAST_GAS_ORACLE =
0x169E633A2D1E6c10dD91238Ba11c4A708dfEF37C;
| 18,439 |
206 | // Increment Counter | PC[piece]+=1;
| PC[piece]+=1;
| 31,879 |
37 | // _state {State}_exchangeRate {uint256} return {bool}/ | function inState(State _state, uint256 _exchangeRate) public view returns (bool)
{
if (buffer(_exchangeRate) > 0)
{
return (_state == State.PEGGED);
}
| function inState(State _state, uint256 _exchangeRate) public view returns (bool)
{
if (buffer(_exchangeRate) > 0)
{
return (_state == State.PEGGED);
}
| 24,115 |
55 | // Atomically increases the allowance granted to `spender` by the caller. | * This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address s... | * This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address s... | 8,104 |
195 | // Reverts if it is not possible for the sender to claim the payout. / | modifier whenCanClaimPayout() {
require(canClaimPayout(msg.sender));
_;
}
| modifier whenCanClaimPayout() {
require(canClaimPayout(msg.sender));
_;
}
| 66,046 |
21 | // A vault can call to "return" all assets to an asgard, including ETH. | function returnVaultAssets(address router, address payable asgard, Coin[] memory coins, string memory memo) external payable nonReentrant {
if (router == address(this)){
for(uint i = 0; i < coins.length; i++){
_adjustAllowances(asgard, coins[i].asset, coins[i].amount);
... | function returnVaultAssets(address router, address payable asgard, Coin[] memory coins, string memory memo) external payable nonReentrant {
if (router == address(this)){
for(uint i = 0; i < coins.length; i++){
_adjustAllowances(asgard, coins[i].asset, coins[i].amount);
... | 82,483 |
65 | // openzeppelin 3.3 | library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uin... | library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uin... | 8,915 |
3 | // bool | bool public started;
| bool public started;
| 38,053 |
13 | // Returns true if a `leaf` can be proved to be a part of a Merkle treedefined by `root`. For this, a `proof` must be provided, containingsibling hashes on the branch from the leaf to the root of the tree. Eachpair of leaves and each pair of pre-images are assumed to be sorted. / | function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current ... | function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current ... | 5,348 |
3 | // Owned | function setTokenInstance(address tokenAddress) external returns (bool);
function setWithdrawalTreshold(uint withdrawalTreshold) external returns (bool);
function setMaxHotBalance(uint maxHotBalance) external returns (bool);
function setColdAddress(address coldAddress) external returns (bool);
funct... | function setTokenInstance(address tokenAddress) external returns (bool);
function setWithdrawalTreshold(uint withdrawalTreshold) external returns (bool);
function setMaxHotBalance(uint maxHotBalance) external returns (bool);
function setColdAddress(address coldAddress) external returns (bool);
funct... | 70,468 |
13 | // Returns all proposals made. | function getAllProposals() external view returns (Proposal[] memory allProposals) {
uint256 nextProposalIndex = proposalIndex;
allProposals = new Proposal[](nextProposalIndex);
for (uint256 i = 0; i < nextProposalIndex; i += 1) {
allProposals[i] = proposals[i];
}
}
| function getAllProposals() external view returns (Proposal[] memory allProposals) {
uint256 nextProposalIndex = proposalIndex;
allProposals = new Proposal[](nextProposalIndex);
for (uint256 i = 0; i < nextProposalIndex; i += 1) {
allProposals[i] = proposals[i];
}
}
| 25,955 |
76 | // .. since beginning of the year | uint16[12] days_since = [
11,
42,
70,
101,
131,
162,
192,
223,
254,
| uint16[12] days_since = [
11,
42,
70,
101,
131,
162,
192,
223,
254,
| 30,329 |
1 | // CONSTANT PUBLIC FUNCTIONS //Calculates how many shares a user holds./_who Address of the target account./ return Number of shares. | function balanceOf(address _who)
external
view
returns (uint256);
| function balanceOf(address _who)
external
view
returns (uint256);
| 40,076 |
331 | // Verify not already minted: | require(
_state.creatures[_eggIndex].tokenId == 0,
"WitmonERC721: already minted"
);
| require(
_state.creatures[_eggIndex].tokenId == 0,
"WitmonERC721: already minted"
);
| 61,277 |
60 | // Record invocation as separate call so we don't rollback in case we are called with STATICCALL | (, bytes memory r) = address(this).call{ gas: 100000 }(
| (, bytes memory r) = address(this).call{ gas: 100000 }(
| 30,393 |
1 | // Whether initialized. // Address which owns this proxy. // Associated registry with contract authentication information. // Whether access has been revoked. // Delegate call could be used to atomically transfer multiple assets owned by the proxy contract with one order. / | enum HowToCall { Call, DelegateCall }
/* Event fired when the proxy access is revoked or unrevoked. */
event Revoked(bool revoked);
/**
* Initialize an AuthenticatedProxy
*
* @param addrUser Address of user on whose behalf this proxy will act
* @param addrRegistry Address of ProxyR... | enum HowToCall { Call, DelegateCall }
/* Event fired when the proxy access is revoked or unrevoked. */
event Revoked(bool revoked);
/**
* Initialize an AuthenticatedProxy
*
* @param addrUser Address of user on whose behalf this proxy will act
* @param addrRegistry Address of ProxyR... | 16,014 |
0 | // ========== SETTERS ========== // Set ERC20 allowance. Only the associated contract may call this. tokenOwner The authorising party. spender The authorised party. value The total value the authorised party may spend on theauthorising party's behalf. / | function setAllowance(
address tokenOwner,
address spender,
uint value
) external onlyAssociatedContract {
allowance[tokenOwner][spender] = value;
}
| function setAllowance(
address tokenOwner,
address spender,
uint value
) external onlyAssociatedContract {
allowance[tokenOwner][spender] = value;
}
| 36,967 |
10 | // Contract whitelist status changed | event WhiteListStatusChanged(address target, bool status);
| event WhiteListStatusChanged(address target, bool status);
| 35,341 |
24 | // Store the `operator`. | mstore(0x3a, operator)
| mstore(0x3a, operator)
| 7,897 |
217 | // Helper: computes the end of the reserved portion of the execution window. / | function reservedWindowEnd(ExecutionWindow storage self)
internal view returns (uint)
| function reservedWindowEnd(ExecutionWindow storage self)
internal view returns (uint)
| 16,047 |
157 | // Opens Safe, locks Eth, generates debt and sends COIN amount (deltaWad) and provides it as liquidity to Uniswap/manager address/taxCollector address/ethJoin address/coinJoin address/uniswapRouter address - Uniswap V2 Router/collateralType bytes32 - The ETH type used to generate debt/deltaWad uint - Amount of debt to ... | function openLockETHGenerateDebtProvideLiquidityUniswap(
address manager,
address taxCollector,
address ethJoin,
address coinJoin,
address uniswapRouter,
bytes32 collateralType,
uint deltaWad,
uint liquidityWad,
uint[2] calldata minTokenAmounts... | function openLockETHGenerateDebtProvideLiquidityUniswap(
address manager,
address taxCollector,
address ethJoin,
address coinJoin,
address uniswapRouter,
bytes32 collateralType,
uint deltaWad,
uint liquidityWad,
uint[2] calldata minTokenAmounts... | 12,998 |
34 | // Gets the owner of the specified Fas ID_FasId uint256 ID of the Fas to query the owner of return owner address currently marked as the owner of the given Fas ID/ | function ownerOf(uint256 _FasId) public view returns (address) {
address _owner = FasOwner[_FasId];
require(_owner != address(0));
return _owner;
}
| function ownerOf(uint256 _FasId) public view returns (address) {
address _owner = FasOwner[_FasId];
require(_owner != address(0));
return _owner;
}
| 21,876 |
14 | // The entry is stored at length-1, but we add 1 to all indexes and use 0 as a sentinel value | map._indexes[key] = map._entries.length;
return true;
| map._indexes[key] = map._entries.length;
return true;
| 1,974 |
10 | // total number of tokens in existence / | function totalSupply() public view returns (uint256) {
return totalSupply_;
}
| function totalSupply() public view returns (uint256) {
return totalSupply_;
}
| 3,361 |
51 | // Gets the token address from the Join contract/_joinAddr Address of the Join contract | function getCollateralAddr(address _joinAddr) internal view returns (address) {
return address(Join(_joinAddr).gem());
}
| function getCollateralAddr(address _joinAddr) internal view returns (address) {
return address(Join(_joinAddr).gem());
}
| 27,462 |
2 | // Function to create loan token by borrower | function createTokenLoan(address _addborrower, uint256 _amount)
public payable
onlyManager
returns (uint256)
| function createTokenLoan(address _addborrower, uint256 _amount)
public payable
onlyManager
returns (uint256)
| 11,800 |
10 | // UTILITY FUNCTIONS// Get operating status of contract return A bool that is the current operating status / | function isOperational() public view returns (bool) {
return operational;
}
| function isOperational() public view returns (bool) {
return operational;
}
| 15,184 |
71 | // Add an address that can administer the token even when paused. _administrator Address of the given administrator.return True if the administrator has been added, false if the address was already an administrator. / | function addAdministrator(address _administrator) onlyOwner public returns (bool) {
if (isAdministrator(_administrator)) {
return false;
} else {
addRole(_administrator, ROLE_ADMINISTRATOR);
return true;
}
}
| function addAdministrator(address _administrator) onlyOwner public returns (bool) {
if (isAdministrator(_administrator)) {
return false;
} else {
addRole(_administrator, ROLE_ADMINISTRATOR);
return true;
}
}
| 12,679 |
180 | // - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.- `quantity` must be greater than 0. Emits a {Transfer} event. / | function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
| function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
| 35,940 |
2 | // Emitted when a policy is burned. | event PolicyBurned(uint256 policyID);
| event PolicyBurned(uint256 policyID);
| 38,668 |
4 | // So we compare to four times the y | bytes memory almost_y = almost_mulmod(y, hex"01", MODULUS);
almost_y = trim(almost_y);
require(big_eq(proposed_y, almost_y), "VDF proof verification failed");
| bytes memory almost_y = almost_mulmod(y, hex"01", MODULUS);
almost_y = trim(almost_y);
require(big_eq(proposed_y, almost_y), "VDF proof verification failed");
| 21,186 |
17 | // Emitted when a claim request was performed. Specification: Is not clear / | event ClaimRequested(uint256 indexed claimRequestId, uint256 indexed topic, uint256 scheme, address indexed issuer, bytes signature, bytes data, string uri);
| event ClaimRequested(uint256 indexed claimRequestId, uint256 indexed topic, uint256 scheme, address indexed issuer, bytes signature, bytes data, string uri);
| 13,537 |
53 | // Mark the proposal as cancelled. Do so prior to refunding as a measure against reentrancy. | proposal.state = ExchangeProposalState.Cancelled;
| proposal.state = ExchangeProposalState.Cancelled;
| 24,621 |
25 | // Transfers a given amount tokens to the address specified.from The address of the sender.to The address to transfer to.value The amount to be transferred. return Returns true in case of success./ | function executeErc20Transfer (address from, address to, uint256 value) private returns (bool) {
// Checks
require(to != address(0), "non-zero address required");
require(from != address(0), "non-zero sender required");
require(value > 0, "Amount cannot be zero");
require(_ba... | function executeErc20Transfer (address from, address to, uint256 value) private returns (bool) {
// Checks
require(to != address(0), "non-zero address required");
require(from != address(0), "non-zero sender required");
require(value > 0, "Amount cannot be zero");
require(_ba... | 43,832 |
59 | // MintedCrowdsale Extension of Crowdsale contract whose tokens are minted in each purchase.Token ownership should be transferred to MintedCrowdsale for minting./ | contract MintedCrowdsale is Crowdsale {
/**
* @dev Overrides delivery by minting tokens upon purchase.
* @param _beneficiary Token purchaser
* @param _tokenAmount Number of tokens to be minted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
require(MintableToken(to... | contract MintedCrowdsale is Crowdsale {
/**
* @dev Overrides delivery by minting tokens upon purchase.
* @param _beneficiary Token purchaser
* @param _tokenAmount Number of tokens to be minted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
require(MintableToken(to... | 10,357 |
50 | // Cancel pending removal of whitelisted addresses. | function cancelWhitelistRemoval(bytes32 _hash) external onlyController {
// Check if operation has been submitted.
require(submittedWhitelistRemoval, "whitelist removal has not been submitted");
// Require that confirmation hash and the hash of the pending whitelist removal match
req... | function cancelWhitelistRemoval(bytes32 _hash) external onlyController {
// Check if operation has been submitted.
require(submittedWhitelistRemoval, "whitelist removal has not been submitted");
// Require that confirmation hash and the hash of the pending whitelist removal match
req... | 20,918 |
276 | // Make sure sire isn't pregnant, or in the middle of a siring cooldown | require(
_isReadyToHatch(sire),
"CryptoAlpaca: Sire is not yet ready to hatch"
);
| require(
_isReadyToHatch(sire),
"CryptoAlpaca: Sire is not yet ready to hatch"
);
| 22,861 |
3 | // data from old contract | ticketsPlayed = 10;
ticketsSold = 13;
| ticketsPlayed = 10;
ticketsSold = 13;
| 41,528 |
7 | // すでに応募している人は無効 | for(uint i = 0; i < applicantsCount; i++) {
require(applicants[i] != msg.sender);
}
| for(uint i = 0; i < applicantsCount; i++) {
require(applicants[i] != msg.sender);
}
| 21,968 |
262 | // Returns the downcasted uint224 from uint256, reverting onoverflow (when the input is greater than largest uint224). Counterpart to Solidity's `uint224` operator. Requirements: - input must fit into 224 bits / | function toUint224(uint256 _value) internal pure returns (uint224) {
require(_value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(_value);
}
| function toUint224(uint256 _value) internal pure returns (uint224) {
require(_value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(_value);
}
| 80,112 |
576 | // compute the round end time as a function of the round Id. data input data object. roundId uniquely identifies the current round.return timestamp unix time of when the current round will end. / | function computeRoundEndTime(Data storage data, uint256 roundId) internal view returns (uint256) {
uint256 roundLength = data.phaseLength.mul(uint256(VotingAncillaryInterface.Phase.NUM_PHASES_PLACEHOLDER));
return roundLength.mul(roundId.add(1));
}
| function computeRoundEndTime(Data storage data, uint256 roundId) internal view returns (uint256) {
uint256 roundLength = data.phaseLength.mul(uint256(VotingAncillaryInterface.Phase.NUM_PHASES_PLACEHOLDER));
return roundLength.mul(roundId.add(1));
}
| 30,370 |
170 | // ensure account doesn't have escrow migration pending / being imported more than once | require(totalBalancePendingMigration[account] == 0, "Account migration is pending already");
| require(totalBalancePendingMigration[account] == 0, "Account migration is pending already");
| 24,207 |
127 | // COPIED FROM https:github.com/compound-finance/compound-protocol/blob/master/contracts/ErrorReporter.solCopyright 2020 Compound Labs, Inc.Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:1. Redistributions of source code must... | contract ComptrollerErrorReporter {
enum Error {
NO_ERROR,
UNAUTHORIZED,
COMPTROLLER_MISMATCH,
INSUFFICIENT_SHORTFALL,
INSUFFICIENT_LIQUIDITY,
INVALID_CLOSE_FACTOR,
INVALID_COLLATERAL_FACTOR,
INVALID_LIQUIDATION_INCENTIVE,
MARKET_NOT_ENTERED, /... | contract ComptrollerErrorReporter {
enum Error {
NO_ERROR,
UNAUTHORIZED,
COMPTROLLER_MISMATCH,
INSUFFICIENT_SHORTFALL,
INSUFFICIENT_LIQUIDITY,
INVALID_CLOSE_FACTOR,
INVALID_COLLATERAL_FACTOR,
INVALID_LIQUIDATION_INCENTIVE,
MARKET_NOT_ENTERED, /... | 11,061 |
104 | // Internal view to convert values to 8 decimals precision input Value to convert to TRU precisionreturn output TRU amount / | function toTrustToken(uint256 input) internal pure returns (uint256 output) {
output = input.div(TOKEN_PRECISION_DIFFERENCE);
}
| function toTrustToken(uint256 input) internal pure returns (uint256 output) {
output = input.div(TOKEN_PRECISION_DIFFERENCE);
}
| 31,754 |
8 | // Wrappers over Solidity's uintXX casting operators with added overflowchecks. Downcasting from uint256 in Solidity does not revert on overflow. This caneasily result in undesired exploitation or bugs, since developers usuallyassume that overflows raise errors. `SafeCast` restores this intuition byreverting the transa... | * Can be combined with {SafeMath} to extend it to smaller types, by performing
* all math on `uint256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart... | * Can be combined with {SafeMath} to extend it to smaller types, by performing
* all math on `uint256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart... | 14,759 |
9 | // Project $ERIS by nCyoteeHave fun playing! SPDX-License-Identifier: AGPL-3.0-or-later/ | library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtracti... | library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtracti... | 29,130 |
23 | // ------------------------------------------------------------------------ Minting and management ------------------------------------------------------------------------ | function setMinter(Data storage self, address minter) public {
require(msg.sender == self.owner);
require(self.mintable);
MinterUpdated(self.minter, minter);
self.minter = minter;
}
| function setMinter(Data storage self, address minter) public {
require(msg.sender == self.owner);
require(self.mintable);
MinterUpdated(self.minter, minter);
self.minter = minter;
}
| 22,831 |
32 | // If the total amount is 0. | if (supply == 0) {
return (
poolInfo.accSTRFPerShare,
currentTime,
poolInfo.lastEid,
poolInfo.lastStageDistributionAmount
); // No tokens -> no changes.
}
| if (supply == 0) {
return (
poolInfo.accSTRFPerShare,
currentTime,
poolInfo.lastEid,
poolInfo.lastStageDistributionAmount
); // No tokens -> no changes.
}
| 32,798 |
37 | // 报名需要同时满足的条件:@仲裁编号在前"peg"内 或 持有特殊的NFT @保证金没被锁定@保证金余额大于商家缴纳的保证金 | require((arber[usr] <= peg || setNFT(usr)) && lock[usr] == 0 && balanceMar[usr] >= user[i].mma ,"arb1/Insufficient-conditions");
lock[usr] = 1;
appl[usr] += 1;
register[usr][appl[usr]] = i;
return true;
| require((arber[usr] <= peg || setNFT(usr)) && lock[usr] == 0 && balanceMar[usr] >= user[i].mma ,"arb1/Insufficient-conditions");
lock[usr] = 1;
appl[usr] += 1;
register[usr][appl[usr]] = i;
return true;
| 8,697 |
14 | // message unnecessarily. For custom revert reasons use {tryMod}. Counterpart to Solidity's `%` operator. This function uses a `revert`opcode (which leaves remaining gas untouched) while Solidity uses aninvalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero. / | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
| function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
| 631 |
62 | // This is denominated in Fragments, because the gons-fragments conversion might change before it's fully paid. | mapping(address => mapping(address => uint256)) private _allowedFragments;
| mapping(address => mapping(address => uint256)) private _allowedFragments;
| 4,944 |
304 | // Change Admin Address _poolId The ID of the Pool _adminAddress The new admin address to set / | function changeAdminAddress(uint256 _poolId, address _adminAddress) public {
// Check pool existence by requiring price > 0
require (pools[_poolId].price > 0 && (pools[_poolId].adminAddress == msg.sender || AOLibrary.isTheAO(msg.sender, theAO, nameTAOPositionAddress)));
require (_adminAddress != address(0));
p... | function changeAdminAddress(uint256 _poolId, address _adminAddress) public {
// Check pool existence by requiring price > 0
require (pools[_poolId].price > 0 && (pools[_poolId].adminAddress == msg.sender || AOLibrary.isTheAO(msg.sender, theAO, nameTAOPositionAddress)));
require (_adminAddress != address(0));
p... | 53,099 |
0 | // Basic interface for a feature contract. | interface IFeature {
// solhint-disable func-name-mixedcase
/// @dev The name of this feature set.
function FEATURE_NAME() external view returns (string memory name);
/// @dev The version of this feature set.
function FEATURE_VERSION() external view returns (uint256 version);
}
| interface IFeature {
// solhint-disable func-name-mixedcase
/// @dev The name of this feature set.
function FEATURE_NAME() external view returns (string memory name);
/// @dev The version of this feature set.
function FEATURE_VERSION() external view returns (uint256 version);
}
| 37,285 |
31 | // No balance, nothing to do here | if (assetBalance == 0) continue;
| if (assetBalance == 0) continue;
| 33,523 |
2 | // Update prntAddresses | prntAddresses = _prntAddresses;
| prntAddresses = _prntAddresses;
| 10,445 |
119 | // view function for getting the current proceeds for the given order | function orderPoolGetProceeds(OrderPool storage orderPool, uint256 orderId, uint256 blockTimestamp) internal view returns (bool orderExpired, uint256 totalReward) {
uint256 stakedAmount = orderPool.salesRate[orderId];
require(stakedAmount > 0);
uint256 orderExpiry = orderPool.orderExpiry[ord... | function orderPoolGetProceeds(OrderPool storage orderPool, uint256 orderId, uint256 blockTimestamp) internal view returns (bool orderExpired, uint256 totalReward) {
uint256 stakedAmount = orderPool.salesRate[orderId];
require(stakedAmount > 0);
uint256 orderExpiry = orderPool.orderExpiry[ord... | 44,742 |
17 | // Interface for SushiSwap. | interface ISushiSwap {
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
}
| interface ISushiSwap {
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
}
| 2,916 |
14 | // 变更指定地址_minter的铸币权限为false | minters[_minter] = false;
| minters[_minter] = false;
| 45,258 |
4 | // Sets a new owner address / | function setOwner(address newOwner) internal {
_owner = newOwner;
}
| function setOwner(address newOwner) internal {
_owner = newOwner;
}
| 16,965 |
9 | // re-join automatically |
increasePoolCurrentUserID(1);
uint poolCurrentUserID = getPoolCurrentUserID(1);
uint poolActiveID = getPoolActiveUserID(1);
userStruct = PoolUserStruct({
isExist:true,
... |
increasePoolCurrentUserID(1);
uint poolCurrentUserID = getPoolCurrentUserID(1);
uint poolActiveID = getPoolActiveUserID(1);
userStruct = PoolUserStruct({
isExist:true,
... | 9,358 |
25 | // validate if closed manually or reached the threshold | require(!IcoClosedManually);
require(!isReachedThreshold());
processPayment(msg.sender, msg.value, false);
| require(!IcoClosedManually);
require(!isReachedThreshold());
processPayment(msg.sender, msg.value, false);
| 4,028 |
87 | // Sets the incentivizer contract / | event NewIncentivizer(address oldIncentivizer, address newIncentivizer);
| event NewIncentivizer(address oldIncentivizer, address newIncentivizer);
| 25,414 |
57 | // update processed balance | _processedBalance[protectedWallet] += protectedAmount;
IPolicy.Claim memory claim = _getClaim(processId, CLAIM_ID);
uint256 payoutAmount = claim.claimAmount;
uint256 depegPayoutAmount = calculateClaimAmount(protectedAmount);
| _processedBalance[protectedWallet] += protectedAmount;
IPolicy.Claim memory claim = _getClaim(processId, CLAIM_ID);
uint256 payoutAmount = claim.claimAmount;
uint256 depegPayoutAmount = calculateClaimAmount(protectedAmount);
| 40,737 |
21 | // \Withdraw function (ETH)amount Quantity of ETH (in wei) withdrawn Admin can only withdraw after contract expires | function adminWithdraw(uint amount) public autobidExpired onlyAdmin {
// Send ETH
msg.sender.transfer(amount);
// Fire Redemption event
Redemption(msg.sender, 0, amount);
}
| function adminWithdraw(uint amount) public autobidExpired onlyAdmin {
// Send ETH
msg.sender.transfer(amount);
// Fire Redemption event
Redemption(msg.sender, 0, amount);
}
| 9,563 |
109 | // Adminable dYdXEIP-1967 Proxy Admin contract. / | contract Adminable {
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
bytes32 internal constant ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Modifier to c... | contract Adminable {
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
bytes32 internal constant ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Modifier to c... | 50,310 |
277 | // How much can we redeem | uint256 _redeemAndRepay = getRedeemable();
do {
| uint256 _redeemAndRepay = getRedeemable();
do {
| 2,706 |
74 | // Finalized Pre ICO crowdsele. | finalized = true;
uint256 tokensAmount = token.balanceOf(this);
token.transfer(owner, tokensAmount);
| finalized = true;
uint256 tokensAmount = token.balanceOf(this);
token.transfer(owner, tokensAmount);
| 28,709 |
3 | // Sets the current time. Will revert if not running in test mode. time timestamp to set current Testable time to. / | function setCurrentTime(uint256 time) external onlyIfTest {
Timer(timerAddress).setCurrentTime(time);
}
| function setCurrentTime(uint256 time) external onlyIfTest {
Timer(timerAddress).setCurrentTime(time);
}
| 23,436 |
66 | // Check withdrawls in verified block and generate pending withdraw if necessary/_blockNumberFrom Block number from/_blockNumberTo Block number to/_withdrawalsData - withdraw data of next verified block | function checkWithdrawals(uint32 _blockNumberFrom, uint32 _blockNumberTo, bytes[] calldata _withdrawalsData) external nonReentrant {
require(_blockNumberFrom <= _blockNumberTo, "cw1");
require(_blockNumberFrom == totalBlocksChecked + 1, "cw2");
require(_blockNumberTo <= totalBlocksVerified, ... | function checkWithdrawals(uint32 _blockNumberFrom, uint32 _blockNumberTo, bytes[] calldata _withdrawalsData) external nonReentrant {
require(_blockNumberFrom <= _blockNumberTo, "cw1");
require(_blockNumberFrom == totalBlocksChecked + 1, "cw2");
require(_blockNumberTo <= totalBlocksVerified, ... | 29,869 |
78 | // Transfer tokens to a specified address. to The address to transfer to. value The amount to be transferred.return True on success, false otherwise. / | function transfer(address to, uint256 value)
public
updateAccount(msg.sender)
updateAccount(to)
validRecipient(to)
returns (bool)
| function transfer(address to, uint256 value)
public
updateAccount(msg.sender)
updateAccount(to)
validRecipient(to)
returns (bool)
| 8,359 |
17 | // keeping redundant batchnum in event (batchnum and old outboxindex field) for outbox version interface compatibility | emit OutboxEntryCreated(batchNum, batchNum, outputRoot, numInBatch);
| emit OutboxEntryCreated(batchNum, batchNum, outputRoot, numInBatch);
| 22,055 |
257 | // Admin Functions //Sets a new comptroller for the marketAdmin function to set a new comptroller return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)/ | function _setComptroller(IComptroller newComptroller) public onlyOwner override returns (uint) {
IComptroller oldComptroller = comptroller;
// Ensure invoke comptroller.isComptroller() returns true
// require(newComptroller.isComptroller(), "marker method returned false");
// Set ma... | function _setComptroller(IComptroller newComptroller) public onlyOwner override returns (uint) {
IComptroller oldComptroller = comptroller;
// Ensure invoke comptroller.isComptroller() returns true
// require(newComptroller.isComptroller(), "marker method returned false");
// Set ma... | 15,532 |
57 | // The Open Oracle Price Data contract | OpenOraclePriceData public immutable priceData;
| OpenOraclePriceData public immutable priceData;
| 53,890 |
13 | // Adjust the mint price/modifies the state of the `mintPrice` variable/sets the price for minting a token/newPrice_ The new price for minting | function adjustMintPrice(uint256 newPrice_) external onlyOwner {
mintPrice = newPrice_;
}
| function adjustMintPrice(uint256 newPrice_) external onlyOwner {
mintPrice = newPrice_;
}
| 62,167 |
3 | // Is virtualPool connected to pool or not | function isIncentiveActiveInPool(IAlgebraPool pool, address virtualPool) external view returns (bool);
function l2Nfts(uint256) external view returns (uint96 nonce, address operator, uint256 tokenId);
| function isIncentiveActiveInPool(IAlgebraPool pool, address virtualPool) external view returns (bool);
function l2Nfts(uint256) external view returns (uint96 nonce, address operator, uint256 tokenId);
| 13,957 |
77 | // require(now >= lgeEndTime, "Liquidity generation ongoing"); require(LPGenerationCompleted == false, "Liquidity generation already finished"); | if (_msgSender() != owner()) {
require(now > (lgeEndTime + 2 hours), "Please wait for dev grace period");
}
| if (_msgSender() != owner()) {
require(now > (lgeEndTime + 2 hours), "Please wait for dev grace period");
}
| 12,662 |
17 | // First 32 bytes are the padded length of data, so exclude that | let dataAddress := add(data, 32)
result := call(
| let dataAddress := add(data, 32)
result := call(
| 29,707 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.