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 |
|---|---|---|---|---|
84 | // remove address of ERC20 token to top token regitry & sell it for DAI | function removeTopTopen(uint _index) public isOwner {
require(_index >= 0 && _index < topTokensLength());
_sellERCToken(topTokens[_index], topTokens[_index].balanceOf(address(this)), address(this)); // sell token for dai
topTokens[_index] = topTokens[topTokensLeng... | function removeTopTopen(uint _index) public isOwner {
require(_index >= 0 && _index < topTokensLength());
_sellERCToken(topTokens[_index], topTokens[_index].balanceOf(address(this)), address(this)); // sell token for dai
topTokens[_index] = topTokens[topTokensLeng... | 9,910 |
8 | // Set the URI of a token. | function setTokenUri(uint256 tokenId, string memory tokenUri) external onlyOwner nonReentrant {
tokenInfo[tokenId].uri = tokenUri;
}
| function setTokenUri(uint256 tokenId, string memory tokenUri) external onlyOwner nonReentrant {
tokenInfo[tokenId].uri = tokenUri;
}
| 5,478 |
10 | // Notifies the controller about an approval allowing the/controller to react if desired/_owner The address that calls `approve()`/_spender The spender in the `approve()` call/_amount_old The current allowed amount in the `approve()` call/_amount_new The amount in the `approve()` call/ return False if the controller do... | function onApprove(address _owner, address _spender, uint _amount_old, uint _amount_new) public returns(bool);
| function onApprove(address _owner, address _spender, uint _amount_old, uint _amount_new) public returns(bool);
| 35,675 |
12 | // once we reach the end of the total period, we stop increasing the daily price (and therefore the profit from withdrawing) | stake_price_by_day.push(prev_price);
| stake_price_by_day.push(prev_price);
| 2,342 |
6 | // user structure | struct UserStruct {
bool isExist;
//unique id
uint256 id;
//person who referred unique id
uint256 referrerID;
//user current level
uint256 currentLevel;
//total eraning for user
uint256 totalEarningEth;
//persons referred
addres... | struct UserStruct {
bool isExist;
//unique id
uint256 id;
//person who referred unique id
uint256 referrerID;
//user current level
uint256 currentLevel;
//total eraning for user
uint256 totalEarningEth;
//persons referred
addres... | 24,659 |
7 | // total alpha scores staked | uint256 public totalAlphaStaked = 0;
| uint256 public totalAlphaStaked = 0;
| 33,104 |
172 | // marketId => Market | mapping(uint256 => Market) markets;
| mapping(uint256 => Market) markets;
| 25,571 |
71 | // Decode a CBOR value into a Result instance. _cborValue An instance of `CBOR.Value`.return A `Result` instance. / | function resultFromCborValue(CBOR.Value memory _cborValue) public pure returns(Result memory) {
// Witnet uses CBOR tag 39 to represent RADON error code identifiers.
// [CBOR tag 39] Identifiers for CBOR: https://github.com/lucas-clemente/cbor-specs/blob/master/id.md
bool success = _cborValue.tag != 39;
... | function resultFromCborValue(CBOR.Value memory _cborValue) public pure returns(Result memory) {
// Witnet uses CBOR tag 39 to represent RADON error code identifiers.
// [CBOR tag 39] Identifiers for CBOR: https://github.com/lucas-clemente/cbor-specs/blob/master/id.md
bool success = _cborValue.tag != 39;
... | 6,704 |
0 | // Check if the forwarder is trusted / | function isTrustedForwarder(address forwarder) public view virtual override returns(bool);
| function isTrustedForwarder(address forwarder) public view virtual override returns(bool);
| 17,830 |
32 | // Internal function to get a valid option price on a quote.The minimum option price restriction is applied. price Calculated option price. underlyingPrice The current underlying price. quoteData The quote data.return The valid option price considering the minimum price allowed. / | function _getValidPriceForQuote(uint256 price, uint256 underlyingPrice, OptionQuote memory quoteData) internal view returns(uint256) {
uint256 basePrice = quoteData.isCallOption ? underlyingPrice : quoteData.strikePrice;
uint256 minPrice = basePrice.mul(minOptionPricePercentage).div(PERCENTAGE_PRECISION);
if ... | function _getValidPriceForQuote(uint256 price, uint256 underlyingPrice, OptionQuote memory quoteData) internal view returns(uint256) {
uint256 basePrice = quoteData.isCallOption ? underlyingPrice : quoteData.strikePrice;
uint256 minPrice = basePrice.mul(minOptionPricePercentage).div(PERCENTAGE_PRECISION);
if ... | 35,206 |
23 | // update variables | totalCollected = safeAdd(totalCollected, msg.value);
tokensIssued = safeAdd(tokensIssued, numTokens);
| totalCollected = safeAdd(totalCollected, msg.value);
tokensIssued = safeAdd(tokensIssued, numTokens);
| 50,022 |
95 | // Amount to unstake each time. | uint256[] private amounts;
| uint256[] private amounts;
| 2,568 |
48 | // if the transfer delay is enabled at launch | if (transferDelayEnabled) {
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)) {
require(_holderLastTransferTimestamp[tx.origin] < block.number, "Only one purchase per block allowed.");
_holderLastTransferTimestamp[tx.... | if (transferDelayEnabled) {
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)) {
require(_holderLastTransferTimestamp[tx.origin] < block.number, "Only one purchase per block allowed.");
_holderLastTransferTimestamp[tx.... | 42,634 |
9 | // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ C O N S T R U C T O R @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ | {
contractOwner = msg.sender;
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ASSET VALUE TRACKING: TOKEN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
name = "Token";
symbol = "TKN";
decimals = 18;
// // Multiplier to convert to smallest unit
UNIT_MULTIPL... | {
contractOwner = msg.sender;
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ASSET VALUE TRACKING: TOKEN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
name = "Token";
symbol = "TKN";
decimals = 18;
// // Multiplier to convert to smallest unit
UNIT_MULTIPL... | 19,888 |
72 | // Register the investor on the list of investors to keep them in order. | _whitelistInvestors.push(investor);
| _whitelistInvestors.push(investor);
| 19,654 |
103 | // calculate fee numerator | uint256 numerator = FEE_DIVISOR.sub(marketingFee).sub(stakingFee);
| uint256 numerator = FEE_DIVISOR.sub(marketingFee).sub(stakingFee);
| 33,943 |
84 | // Moves `amount` tokens from the caller's account to `recipient`./ return True if the operation succeeded, reverts otherwise./Requirements:/ - `recipient` cannot be the zero address,/ - the caller must have a balance of at least `amount`. | function transfer(address recipient, uint256 amount)
external
override
returns (bool)
| function transfer(address recipient, uint256 amount)
external
override
returns (bool)
| 61,508 |
329 | // returns the default flash-loan fee (in units of PPM) / | function defaultFlashLoanFeePPM() external view returns (uint32);
| function defaultFlashLoanFeePPM() external view returns (uint32);
| 17,374 |
12 | // send `_value` token to `_to` from `msg.sender` _to The address of the recipient _value The amount of token to be transferredreturn Whether the transfer was successful or not / | function transfer(address _to, uint256 _value) returns (bool);
| function transfer(address _to, uint256 _value) returns (bool);
| 32,975 |
26 | // Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)return block number as int / | function arbBlockNumber() external view returns (uint256);
| function arbBlockNumber() external view returns (uint256);
| 59,440 |
91 | // Calculate the exchange fee for a given source and destination currency key/sourceCurrencyKey The source currency key/destinationCurrencyKey The destination currency key/ return The exchange fee rate/ return The exchange dynamic fee rate and if rates are too volatile | function _feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey)
internal
view
returns (uint feeRate, bool tooVolatile)
| function _feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey)
internal
view
returns (uint feeRate, bool tooVolatile)
| 23,446 |
6 | // Autogenerated - DO NOT EDIT | return "https://ipfs.io/ipfs/QmehvpF3vWWMQTt4wc5D9i9UD1QLYJBFuyHMLsfYLJbXUh";
| return "https://ipfs.io/ipfs/QmehvpF3vWWMQTt4wc5D9i9UD1QLYJBFuyHMLsfYLJbXUh";
| 17,195 |
11 | // ------------------------------------------------------------------------ Transfer tokens from sender account to receiver accountThe calling account must already have sufficient tokens approve(...)-d for spending from sender account and - From account must have sufficient balance to transfer - Spender must have suffi... | function transferFrom(address sender, address receiver, uint tokens) public override returns (bool success) {
balances[sender] = safeSub(balances[sender], tokens);
allowed[sender][msg.sender] = safeSub(allowed[sender][msg.sender], tokens);
balances[receiver] = safeAdd(balances[receiver], tok... | function transferFrom(address sender, address receiver, uint tokens) public override returns (bool success) {
balances[sender] = safeSub(balances[sender], tokens);
allowed[sender][msg.sender] = safeSub(allowed[sender][msg.sender], tokens);
balances[receiver] = safeAdd(balances[receiver], tok... | 23,043 |
38 | // bytes4(keccak256(bytes('transfer(address,uint256)'))); | (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED');
| (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED');
| 7,954 |
19 | // Mint an allocated token, every token must be allocated before minting / | function mintAllocated(uint256 allocatedTokenId, string calldata tokenURI) external {
require(allocatedTokenId < _tokenId, ""); // Restrict to currently allocated tokens
address to = _tokenAllocation[allocatedTokenId];
require(to != address(0), ""); // Prevent minting to 0x0 address
... | function mintAllocated(uint256 allocatedTokenId, string calldata tokenURI) external {
require(allocatedTokenId < _tokenId, ""); // Restrict to currently allocated tokens
address to = _tokenAllocation[allocatedTokenId];
require(to != address(0), ""); // Prevent minting to 0x0 address
... | 10,263 |
3 | // Instantiate a new Fundraiser contract and add its address to the _fundraisers collection. | function createFundraiser(
string memory name,
string memory url,
string memory imageUrl,
string memory description,
address payable beneficiary
)
public
| function createFundraiser(
string memory name,
string memory url,
string memory imageUrl,
string memory description,
address payable beneficiary
)
public
| 40,091 |
15 | // guobin卖出通证/ | function sell(uint256 amount,uint256 eth_amount) public payable {
_sell(amount,eth_amount);
}
| function sell(uint256 amount,uint256 eth_amount) public payable {
_sell(amount,eth_amount);
}
| 9,458 |
13 | // return balances[addr]; | }*/
| }*/
| 8,327 |
287 | // calculate amount of FEI and TRIBE received if the Genesis Group ended now./amountIn amount of FGEN held or equivalently amount of ETH purchasing with/inclusive if true, assumes the `amountIn` is part of the existing FGEN supply. Set to false to simulate a new purchase./ return feiAmount the amount of FEI received by... | function getAmountOut(uint256 amountIn, bool inclusive)
public
view
override
returns (uint256 feiAmount, uint256 tribeAmount)
| function getAmountOut(uint256 amountIn, bool inclusive)
public
view
override
returns (uint256 feiAmount, uint256 tribeAmount)
| 15,194 |
0 | // {ERC721} token that contains an id token tracker for/ Creates a new token for `to`. Its token ID will be automaticallyassigned (and available on the emitted {IERC721-Transfer} event). See {ERC721Minter-mint}. / | function mint(address to) public virtual returns (uint256 id){
id = _tokenIdTracker.current();
_mint(to, id);
_tokenIdTracker.increment();
return id;
}
| function mint(address to) public virtual returns (uint256 id){
id = _tokenIdTracker.current();
_mint(to, id);
_tokenIdTracker.increment();
return id;
}
| 25,738 |
34 | // New Balance = Total Borrow Bal. - repayAmount | uint accountBorrowsNew = amountToRepay - repayAmount;
accountBorrows[borrower].principal = accountBorrowsNew;
totalBorrows = totalBorrows - repayAmount;
emit RepayBorrow(borrower, repayAmount, accountBorrowsNew, totalBorrows);
return true;
| uint accountBorrowsNew = amountToRepay - repayAmount;
accountBorrows[borrower].principal = accountBorrowsNew;
totalBorrows = totalBorrows - repayAmount;
emit RepayBorrow(borrower, repayAmount, accountBorrowsNew, totalBorrows);
return true;
| 52,748 |
87 | // check if flow exists | (bool exist, FlowData memory oldFlowData) = _getAgreementData(token, _generateFlowId(sender, receiver));
{
| (bool exist, FlowData memory oldFlowData) = _getAgreementData(token, _generateFlowId(sender, receiver));
{
| 34,584 |
62 | // Grants `role` to `account`. | * If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(... | * If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(... | 28,135 |
34 | // The allocated (underlying) tokens of the Allocator | IERC20[] internal _tokens;
| IERC20[] internal _tokens;
| 8,953 |
58 | // Upgrade a wallet to a new version. _wallet the wallet to upgrade _toVersion the new version / | function upgradeWallet(address _wallet, uint256 _toVersion) external;
| function upgradeWallet(address _wallet, uint256 _toVersion) external;
| 26,209 |
1 | // Emitted when an associated system is set. kind The type of associated system (managed ERC20, managed ERC721, unmanaged, etc - See the AssociatedSystem util). id The bytes32 identifier of the associated system. proxy The main external contract address of the associated system. impl The address of the implementation o... | event AssociatedSystemSet(
bytes32 indexed kind,
bytes32 indexed id,
address proxy,
address impl
);
| event AssociatedSystemSet(
bytes32 indexed kind,
bytes32 indexed id,
address proxy,
address impl
);
| 26,288 |
45 | // Constructor. / | constructor () public {
contractOwner = msg.sender;
stopped = false;
}
| constructor () public {
contractOwner = msg.sender;
stopped = false;
}
| 25,084 |
175 | // Fallback function to execute swaps directly on 0x for users that don't pay a fee/params as of API documentation from 0x API (https:0x.org/docs/apiresponse-1) | fallback() external payable {
bytes4 selector = msg.data.readBytes4(0);
address impl = IZerox(zeroEx).getFunctionImplementation(selector);
require(impl != address(0), "FloozRouter: NO_IMPLEMENTATION");
(bool success, ) = impl.delegatecall(msg.data);
require(success, "FloozRo... | fallback() external payable {
bytes4 selector = msg.data.readBytes4(0);
address impl = IZerox(zeroEx).getFunctionImplementation(selector);
require(impl != address(0), "FloozRouter: NO_IMPLEMENTATION");
(bool success, ) = impl.delegatecall(msg.data);
require(success, "FloozRo... | 58,737 |
10 | // UpgradeabilityProxy This contract represents a proxy where the implementation address to which it will delegate can be upgraded / | contract UpgradeabilityProxy is Proxy {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(address indexed implementation, uint256 version);
// Storage position of the address... | contract UpgradeabilityProxy is Proxy {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(address indexed implementation, uint256 version);
// Storage position of the address... | 12,298 |
12 | // SpacesAvailables Parking Spaces. Key: space name, Value: the parking space | mapping(string => uint256) private parkingSpaces;
ParkingSpace[] private spaces;
using Counters for Counters.Counter;
Counters.Counter private spaceCount;
| mapping(string => uint256) private parkingSpaces;
ParkingSpace[] private spaces;
using Counters for Counters.Counter;
Counters.Counter private spaceCount;
| 9,270 |
237 | // Check for sanity and depositability | require((nDays < 2000) && ClipperExchangeInterface(theExchange.exchangeInterfaceContract()).approvalContract().approveDeposit(msg.sender, nDays), "Clipper: Deposit rejected");
uint256 beforeDepositInvariant = theExchange.exchangeInterfaceContract().invariant();
uint256 initialFullyDilutedSupply ... | require((nDays < 2000) && ClipperExchangeInterface(theExchange.exchangeInterfaceContract()).approvalContract().approveDeposit(msg.sender, nDays), "Clipper: Deposit rejected");
uint256 beforeDepositInvariant = theExchange.exchangeInterfaceContract().invariant();
uint256 initialFullyDilutedSupply ... | 14,377 |
57 | // 如果拍卖已结束,撤销函数的调用。 | require(block.timestamp <= record.endTime && record.AuctionStatus == 0,"Auction already ended.");
| require(block.timestamp <= record.endTime && record.AuctionStatus == 0,"Auction already ended.");
| 33,326 |
79 | // vanishing_denominator = (z - w^{n-1})(z - w^{n-2})(z - w^{n-3})(z - w^{n-4}) we need to cut 4 roots of unity out of the vanishing poly, the last 4 constraints are not satisfied due to randomness added to ensure the proving system is zero-knowledge | vanishing_denominator := addmod(z, sub(p, work_root), p)
work_root := mulmod(work_root, accumulating_root, p)
vanishing_denominator := mulmod(vanishing_denominator, addmod(z, sub(p, work_root), p), p)
work_root := mulmod(work_root, accumulating_root, p)
vanish... | vanishing_denominator := addmod(z, sub(p, work_root), p)
work_root := mulmod(work_root, accumulating_root, p)
vanishing_denominator := mulmod(vanishing_denominator, addmod(z, sub(p, work_root), p), p)
work_root := mulmod(work_root, accumulating_root, p)
vanish... | 59,037 |
135 | // delete an order from storage | function _deleteOrder(bool isBuy, uint32 id) internal {
if(isBuy) {
delete _buyOrders[id];
} else {
delete _sellOrders[id];
}
}
| function _deleteOrder(bool isBuy, uint32 id) internal {
if(isBuy) {
delete _buyOrders[id];
} else {
delete _sellOrders[id];
}
}
| 33,034 |
289 | // Gets current transaction price. | function _getGasPrice() internal view virtual returns (uint256);
| function _getGasPrice() internal view virtual returns (uint256);
| 22,480 |
16 | // Compute the keccak256 hash of an interface given its name./_interfaceName Name of the interface./ return The keccak256 hash of an interface name. | function interfaceHash(string calldata _interfaceName) external pure returns(bytes32) {
return keccak256(abi.encodePacked(_interfaceName));
}
| function interfaceHash(string calldata _interfaceName) external pure returns(bytes32) {
return keccak256(abi.encodePacked(_interfaceName));
}
| 37,502 |
26 | // ---------------------------------------------------------------------------- ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers ---------------------------------------------------------------------------- | contract ADZbuzzCommunityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
... | contract ADZbuzzCommunityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
... | 45,728 |
780 | // Unpause drawdowns / | function unpauseDrawdowns() public onlyAdmin {
drawdownsPaused = false;
emit DrawdownsUnpaused(address(this));
}
| function unpauseDrawdowns() public onlyAdmin {
drawdownsPaused = false;
emit DrawdownsUnpaused(address(this));
}
| 72,912 |
17 | // The list of rewards token. | RewardInfo[] public rewards;
| RewardInfo[] public rewards;
| 15,038 |
22 | // Deregisters `tokens` for the `poolId` Pool. Must be called by the Pool's contract. Only registered tokens (via `registerTokens`) can be deregistered. Additionally, they must have zero totalbalance. For Pools with the Two Token specialization, `tokens` must have a length of two, that is, both tokensmust be deregister... | function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external;
| function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external;
| 25,830 |
603 | // Optional mapping for device IDs and and device roots. | mapping(uint256 => Device) private _devices;
event UpdateRegistry(address registryAddress);
event DeviceSet(
uint256 tokenId,
bytes32 publicKeyHash,
bytes32 merkleRoot
);
| mapping(uint256 => Device) private _devices;
event UpdateRegistry(address registryAddress);
event DeviceSet(
uint256 tokenId,
bytes32 publicKeyHash,
bytes32 merkleRoot
);
| 63,763 |
6 | // mapping(uint256 => mapping(uint256 => TokenPair)) public auctionNfts; delete |
mapping(IERC721 => bool) public nftBlacklist;
mapping(address => bool) public nftForAccrualRB; //add tokens on which RobiBoost is accrual
mapping(IERC20 => bool) public dealTokensWhitelist;
mapping(IERC721 => mapping(uint256 => uint256)) public auctionNftIndex; // nft -> tokenId -> id
mapping(addre... |
mapping(IERC721 => bool) public nftBlacklist;
mapping(address => bool) public nftForAccrualRB; //add tokens on which RobiBoost is accrual
mapping(IERC20 => bool) public dealTokensWhitelist;
mapping(IERC721 => mapping(uint256 => uint256)) public auctionNftIndex; // nft -> tokenId -> id
mapping(addre... | 13,815 |
732 | // Checks limit for minimum ratio and if minRatio is bigger than max | function checkParams(bytes32 _ilk, uint128 _minRatio, uint128 _maxRatio) internal view returns (bool) {
if (_minRatio < minLimits[_ilk]) {
return false;
}
if (_minRatio > _maxRatio) {
return false;
}
return true;
}
| function checkParams(bytes32 _ilk, uint128 _minRatio, uint128 _maxRatio) internal view returns (bool) {
if (_minRatio < minLimits[_ilk]) {
return false;
}
if (_minRatio > _maxRatio) {
return false;
}
return true;
}
| 55,090 |
94 | // 5 | _lock(holder,totalLocked.sub(value),releaseTime);
return true;
| _lock(holder,totalLocked.sub(value),releaseTime);
return true;
| 257 |
18 | // Funding View Functions | function fundsOf(address owner) external view returns (uint256);
function lastSettlementTime() external view returns (uint256);
function keeperSolvent() external view returns (bool);
function keeperTaxNumerator() external view returns (uint256);
function feeDenominator() external view returns (uint2... | function fundsOf(address owner) external view returns (uint256);
function lastSettlementTime() external view returns (uint256);
function keeperSolvent() external view returns (bool);
function keeperTaxNumerator() external view returns (uint256);
function feeDenominator() external view returns (uint2... | 37,353 |
36 | // return Returns index and ok of the first occurrence starting from index 0 | function index(address[] addresses, address a) internal pure returns (uint, bool) {
for (uint i = 0; i < addresses.length; i++) {
if (addresses[i] == a) {
return (i, true);
}
}
return (0, false);
}
| function index(address[] addresses, address a) internal pure returns (uint, bool) {
for (uint i = 0; i < addresses.length; i++) {
if (addresses[i] == a) {
return (i, true);
}
}
return (0, false);
}
| 57,136 |
59 | // Allows the owner to transfer out external ERC20 tokens/Used to transfer out tokens held by the Prize Pool.Could be liquidated, or anything./to The address that receives the tokens/externalToken The address of the external asset token being transferred/amount The amount of external assets to be transferred | function transferExternalERC20(
address to,
address externalToken,
uint256 amount
)
external
onlyOwner
requireAwardNotInProgress
| function transferExternalERC20(
address to,
address externalToken,
uint256 amount
)
external
onlyOwner
requireAwardNotInProgress
| 41,765 |
327 | // mint for each protocol and update currentTokensUsed | uint256[] memory protocolAmounts = _amountsFromAllocations(allocations, total);
uint256 currAmount;
address protWrapper;
address[] memory _tokens = allAvailableTokens;
for (uint256 i = 0; i < protocolAmounts.length; i++) {
currAmount = protocolAmounts[i];
if (currAmount != 0) {
... | uint256[] memory protocolAmounts = _amountsFromAllocations(allocations, total);
uint256 currAmount;
address protWrapper;
address[] memory _tokens = allAvailableTokens;
for (uint256 i = 0; i < protocolAmounts.length; i++) {
currAmount = protocolAmounts[i];
if (currAmount != 0) {
... | 72,657 |
153 | // Withdraw a token amount in excess of the borrowed balance, or an amount approved by the GUARDIAN_ROLE.The contract may hold an excess balance if, for example, additional funds were added by the contract owner for use with the same exchange account, or if profits were earned from activity on the exchange. recipientTh... | function externalWithdrawToken(
address recipient,
uint256 amount
)
external
nonReentrant
onlyRole(WITHDRAWAL_OPERATOR_ROLE)
onlyAllowedRecipient(recipient)
| function externalWithdrawToken(
address recipient,
uint256 amount
)
external
nonReentrant
onlyRole(WITHDRAWAL_OPERATOR_ROLE)
onlyAllowedRecipient(recipient)
| 4,637 |
151 | // Enters the Compound market so it can be deposited/borrowed/Markets can be entered multiple times, without the code reverting/_cTokenAddr CToken address of the token | function enterMarket(address _cTokenAddr) public {
address[] memory markets = new address[](1);
markets[0] = _cTokenAddr;
uint256[] memory errCodes = IComptroller(COMPTROLLER_ADDR).enterMarkets(markets);
if (errCodes[0] != NO_ERROR){
revert CompEnterMarketError();
... | function enterMarket(address _cTokenAddr) public {
address[] memory markets = new address[](1);
markets[0] = _cTokenAddr;
uint256[] memory errCodes = IComptroller(COMPTROLLER_ADDR).enterMarkets(markets);
if (errCodes[0] != NO_ERROR){
revert CompEnterMarketError();
... | 6,017 |
7 | // Check if we have enough remaining funds | if (oraclize_getPrice("URL") > address(this).balance) {
emit LogInfo("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
} else {
| if (oraclize_getPrice("URL") > address(this).balance) {
emit LogInfo("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
} else {
| 11,917 |
73 | // swap contract's tokens for ETH | uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance > 0) {
swapTokens(contractTokenBalance);
}
| uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance > 0) {
swapTokens(contractTokenBalance);
}
| 5,693 |
545 | // Emitted when `to` accound executes redeem ipTokens | event Redeem(
| event Redeem(
| 31,418 |
73 | // token constants | string public constant name = "Discoperi Token"; // solium-disable-line uppercase
string public constant symbol = "DISC"; // solium-disable-line uppercase
uint8 public constant decimals = 18; // solium-disable-line uppercase
| string public constant name = "Discoperi Token"; // solium-disable-line uppercase
string public constant symbol = "DISC"; // solium-disable-line uppercase
uint8 public constant decimals = 18; // solium-disable-line uppercase
| 69,837 |
38 | // Fetches a PoolUI struct (poolId, stakedAmount, currentTimeRange) for each reward poolreturn PoolUI for FoldToken. / | function getPoolsUI() public view returns (PoolUI memory) {
Pool memory foldTokenPool = pools[0];
uint256 current = getCurrentTimeRangeIndex(foldTokenPool);
return (PoolUI(0,foldTokenPool.stakedAmount, foldTokenPool.timeRanges[current]));
}
| function getPoolsUI() public view returns (PoolUI memory) {
Pool memory foldTokenPool = pools[0];
uint256 current = getCurrentTimeRangeIndex(foldTokenPool);
return (PoolUI(0,foldTokenPool.stakedAmount, foldTokenPool.timeRanges[current]));
}
| 29,116 |
866 | // The Exchange domain hash.. | LibEIP712ExchangeDomain internal _exchange;
| LibEIP712ExchangeDomain internal _exchange;
| 12,591 |
266 | // Provenance number | string public PROVENANCE = "";
| string public PROVENANCE = "";
| 32,277 |
1 | // TODO: verify proof |
accuracies[msg.sender] = accuracy;
uint256 bestAccuracy = accuracies[bestModelAddress];
if (accuracy > bestAccuracy) {
bestModelAddress = payable(msg.sender);
}
|
accuracies[msg.sender] = accuracy;
uint256 bestAccuracy = accuracies[bestModelAddress];
if (accuracy > bestAccuracy) {
bestModelAddress = payable(msg.sender);
}
| 34,394 |
139 | // STRUCTS | struct Weaver {
uint256 amount;
uint256 accrued;
}
| struct Weaver {
uint256 amount;
uint256 accrued;
}
| 47,926 |
86 | // update the treshhold | tokenLiquidityThreshold = new_amount;
| tokenLiquidityThreshold = new_amount;
| 35,742 |
44 | // 获取前一个每token奖励 | function getPriorRewardPerToken(address token, uint256 timestamp)
public
view
returns (uint256, uint256)
| function getPriorRewardPerToken(address token, uint256 timestamp)
public
view
returns (uint256, uint256)
| 28,210 |
17 | // there are no validators, reward & validator chunk must be sent back | task.markTaskClaimable(false);
reward = task.weiReward().mul(21).div(20);
tr.revertWei(reward);
project.returnWei(_hyphaTokenAddress, reward);
emit LogTaskValidated(address(task), _projectAddress, false);
| task.markTaskClaimable(false);
reward = task.weiReward().mul(21).div(20);
tr.revertWei(reward);
project.returnWei(_hyphaTokenAddress, reward);
emit LogTaskValidated(address(task), _projectAddress, false);
| 47,281 |
10 | // ensures that the first tokens in the contract will be equally distributed meaning, no divine dump will be ever possible result: healthy longevity. | modifier antiEarlyWhale(uint256 _amountOfEthereum){
address _customerAddress = msg.sender;
// are we still in the vulnerable phase?
// if so, enact anti early whale protocol
if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){
... | modifier antiEarlyWhale(uint256 _amountOfEthereum){
address _customerAddress = msg.sender;
// are we still in the vulnerable phase?
// if so, enact anti early whale protocol
if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){
... | 16,521 |
98 | // Add wallet to whitelist.Accept request from the owner only._wallet The address of wallet to add./ | function addWallet(address _wallet) onlyOwner public {
require(_wallet != address(0));
require(!isWhitelisted(_wallet));
whitelist[_wallet] = true;
whitelistLength++;
}
| function addWallet(address _wallet) onlyOwner public {
require(_wallet != address(0));
require(!isWhitelisted(_wallet));
whitelist[_wallet] = true;
whitelistLength++;
}
| 38,279 |
72 | // can only ragequit if the latest proposal you voted YES on has been processed | function canRagequit(uint256 highestIndexYesVote) public view returns (bool) {
if(proposalQueue.length == 0){
return true;
} else {
require(highestIndexYesVote < proposalQueue.length, "no such proposal");
return proposals[proposalQueue[highestIndexYesVote]].flags[... | function canRagequit(uint256 highestIndexYesVote) public view returns (bool) {
if(proposalQueue.length == 0){
return true;
} else {
require(highestIndexYesVote < proposalQueue.length, "no such proposal");
return proposals[proposalQueue[highestIndexYesVote]].flags[... | 32,111 |
6 | // Move the last value to the index where the deleted value is | set.values[toDeleteIndex] = lastValue;
| set.values[toDeleteIndex] = lastValue;
| 14,807 |
15 | // For Zora Protocol, ensure that the bid is valid for the current bidShare configuration | if(auctions[auctionId].tokenContract == zora) {
require(
IMarket(IMediaExtended(zora).marketContract()).isValidBid(
auctions[auctionId].tokenId,
amount
),
"Bid invalid for share splitting"
);
... | if(auctions[auctionId].tokenContract == zora) {
require(
IMarket(IMediaExtended(zora).marketContract()).isValidBid(
auctions[auctionId].tokenId,
amount
),
"Bid invalid for share splitting"
);
... | 25,782 |
54 | // Denominator for constraints: 'rc16/perm/last', 'rc16/maximum'. denominators[9] = point - trace_generator^(4(trace_length / 4 - 1)). | mstore(0x4b80,
addmod(
point,
sub(PRIME, /*trace_generator^(4 * (trace_length / 4 - 1))*/ mload(0x4420)),
PRIME))
| mstore(0x4b80,
addmod(
point,
sub(PRIME, /*trace_generator^(4 * (trace_length / 4 - 1))*/ mload(0x4420)),
PRIME))
| 51,606 |
200 | // Handles the liquidation of users' balances, once the users' amount of collateral is too low./users An array of user addresses./maxBorrowParts A one-to-one mapping to `users`, contains maximum (partial) borrow amounts (to liquidate) of the respective user./to Address of the receiver in open liquidations if `swapper` ... | function liquidate(
address[] calldata users,
uint256[] calldata maxBorrowParts,
address to,
address swapper
| function liquidate(
address[] calldata users,
uint256[] calldata maxBorrowParts,
address to,
address swapper
| 32,904 |
10 | // if we're here, this is the last pool in the path, meaning tokenOut represents the destination token. so, if tokenIn < tokenOut, then tokenIn is token0 of the last pool, meaning the current running ticks are going to represent tokenOut/tokenIn prices. so, the lower these prices get, the worse of a price the swap will... | lowerTicksAreWorse = tokenIn < tokenOut;
| lowerTicksAreWorse = tokenIn < tokenOut;
| 7,066 |
1 | // Mapping of approved & linked tophats to admin hats in other trees, used for grafting one hats tree onto another/Trees can only be linked to another tree via their tophat | mapping(uint32 => uint256) public linkedTreeAdmins; // topHatDomain => hatId
| mapping(uint32 => uint256) public linkedTreeAdmins; // topHatDomain => hatId
| 10,491 |
103 | // vote for or against | if (decision == true) {// apply numTokens to appropriate poll choice
proposals[_proposalID].votesFor += _numTokens;
} else {
| if (decision == true) {// apply numTokens to appropriate poll choice
proposals[_proposalID].votesFor += _numTokens;
} else {
| 20,388 |
128 | // Add the market to the markets mapping and set it as listedAdmin function to set isListed and add support for the marketcToken The address of the market (token) to list return uint 0=success, otherwise a failure. (See enum Error for details)/ | function _supportMarket(CToken cToken) external returns (uint) {
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);
}
if (markets[address(cToken)].isListed) {
return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPOR... | function _supportMarket(CToken cToken) external returns (uint) {
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);
}
if (markets[address(cToken)].isListed) {
return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPOR... | 11,860 |
183 | // reference to the KongIsland for choosing random Kong thieves | IKongIsland public kongIsland;
| IKongIsland public kongIsland;
| 38,990 |
52 | // ---------------------------------------------------------------------------- BokkyPooBah's Red-Black Tree Library v1.0-pre-release-a A Solidity Red-Black Tree binary search library to store and access a sorted list of unsigned integer data. The Red-Black algorithm rebalances the binary search tree, resulting in O(lo... | library BokkyPooBahsRedBlackTreeLibrary {
struct Node {
uint parent;
uint left;
uint right;
bool red;
}
struct Tree {
uint root;
mapping(uint => Node) nodes;
}
uint private constant EMPTY = 0;
function first(Tree storage self) internal view ret... | library BokkyPooBahsRedBlackTreeLibrary {
struct Node {
uint parent;
uint left;
uint right;
bool red;
}
struct Tree {
uint root;
mapping(uint => Node) nodes;
}
uint private constant EMPTY = 0;
function first(Tree storage self) internal view ret... | 23,236 |
96 | // Set hard cap. _hardCap - Hard cap value / | function setHardCap(uint256 _hardCap) public onlyOwner {
require(hardCap == 0);
hardCap = _hardCap;
}
| function setHardCap(uint256 _hardCap) public onlyOwner {
require(hardCap == 0);
hardCap = _hardCap;
}
| 80,336 |
121 | // Transfers 'amount' of tokens to address 'to', and MUST fire the Transfer event. The function SHOULD throw if the _from account balance does not have enough tokens to spend.to The address of the recipientamount The amount of token to be transferred / | function transfer(address to, uint amount) external returns (bool) {
return transferFrom(msg.sender, to, amount);
}
| function transfer(address to, uint amount) external returns (bool) {
return transferFrom(msg.sender, to, amount);
}
| 60,838 |
25 | // Returns the contract's settings/ return annualStakingRewardsCap is the annual rate in percent-mille/ return annualStakingRewardsRatePercentMille is the annual rate in percent-mille/ return defaultDelegatorsStakingRewardsPercentMille is the default delegators portion in percent-mille/ return maxDelegatorsStakingRewar... | function getSettings() external view returns (
uint annualStakingRewardsCap,
uint32 annualStakingRewardsRatePercentMille,
uint32 defaultDelegatorsStakingRewardsPercentMille,
uint32 maxDelegatorsStakingRewardsPercentMille,
bool rewardAllocationActive
);
| function getSettings() external view returns (
uint annualStakingRewardsCap,
uint32 annualStakingRewardsRatePercentMille,
uint32 defaultDelegatorsStakingRewardsPercentMille,
uint32 maxDelegatorsStakingRewardsPercentMille,
bool rewardAllocationActive
);
| 51,545 |
3 | // create TokenKey of types supplyKey and pauseKey with value a contract address passed as function arg | uint supplyPauseKeyType;
IHederaTokenService.KeyValue memory supplyPauseKeyValue;
| uint supplyPauseKeyType;
IHederaTokenService.KeyValue memory supplyPauseKeyValue;
| 52,158 |
78 | // Declare a stack variable where all additional recipients will be combined to guard against providing dirty upper bits. | let combinedAdditionalRecipients
| let combinedAdditionalRecipients
| 21,169 |
238 | // Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. It's a good idea to use the same `name` that is defined as the ERC20 token name. / | constructor(string memory name) EIP712(name, "1") {}
| constructor(string memory name) EIP712(name, "1") {}
| 4,436 |
198 | // Executes the same as `openFlashLongWithPermit`, but for DAI. / | function openFlashLongWithDAIPermit(
IOption optionToken,
uint256 amountOptions,
uint256 maxPremium,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
| function openFlashLongWithDAIPermit(
IOption optionToken,
uint256 amountOptions,
uint256 maxPremium,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
| 64,416 |
8 | // sales limits | mapping(address => uint256) internal soldInPeriod;
mapping(address => uint256) internal periodStartTimestamp;
| mapping(address => uint256) internal soldInPeriod;
mapping(address => uint256) internal periodStartTimestamp;
| 27,963 |
11 | // ensure that we don't overflow | if gt(lengthSize, 31) {
revert(0, 0)
}
| if gt(lengthSize, 31) {
revert(0, 0)
}
| 27,590 |
111 | // step 1. Check is it enough unspent native tokens | {
require(nativeSpent >= vars.localNative, "NativeSpent balance higher then remote");
uint256 nativeAvailable = nativeSpent - vars.localNative;
| {
require(nativeSpent >= vars.localNative, "NativeSpent balance higher then remote");
uint256 nativeAvailable = nativeSpent - vars.localNative;
| 30,114 |
119 | // Returns the next available cast time | function nextCastTime(uint256 eta) external returns (uint256 castTime) {
require(eta <= uint40(-1));
castTime = DssExecLib.nextCastTime(uint40(eta), uint40(block.timestamp), officeHours());
}
| function nextCastTime(uint256 eta) external returns (uint256 castTime) {
require(eta <= uint40(-1));
castTime = DssExecLib.nextCastTime(uint40(eta), uint40(block.timestamp), officeHours());
}
| 34,399 |
290 | // query the allowance granted from given holder to given spender holder approver of allowance spender recipient of allowancereturn token allowance / | function allowance(address holder, address spender)
external
view
returns (uint256);
| function allowance(address holder, address spender)
external
view
returns (uint256);
| 38,845 |
99 | // Possible Uniswap routes, UST / USDT, USDT / ETH | UniswapRouter router = UniswapRouter(UNISWAP_ROUTER_ADDRESS);
address[] memory path;
if(_inputToken == address(tokenList[0].token) && _outputToken == WETH_ADDRESS){
| UniswapRouter router = UniswapRouter(UNISWAP_ROUTER_ADDRESS);
address[] memory path;
if(_inputToken == address(tokenList[0].token) && _outputToken == WETH_ADDRESS){
| 52,416 |
17 | // clear selector position in slot and add selector | _selectorSlot =
(_selectorSlot &
~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |
(bytes32(selector) >> selectorInSlotPosition);
| _selectorSlot =
(_selectorSlot &
~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |
(bytes32(selector) >> selectorInSlotPosition);
| 35,733 |
206 | // uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);uint256 cynReward = multiplier.mul(cynPerBlock).mul(pool.allocPoint).div(totalAllocPoint); | IUniswapV2Pair pair = IUniswapV2Pair(address(pool.lpToken));
if (address(pair) == address(0)) {
return;
}
| IUniswapV2Pair pair = IUniswapV2Pair(address(pool.lpToken));
if (address(pair) == address(0)) {
return;
}
| 53,442 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.