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 |
|---|---|---|---|---|
12 | // Maximum ratio of output tokens to balance for swaps. | uint256 internal constant MAX_OUT_RATIO = (BONE / 3) + 1 wei;
| uint256 internal constant MAX_OUT_RATIO = (BONE / 3) + 1 wei;
| 4,295 |
27 | // version 1.0.0 | return "1.0.0";
| return "1.0.0";
| 16,352 |
560 | // Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, thesignature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function c... | function isValidSignatureNow(
address signer,
bytes32 hash,
bytes memory signature
| function isValidSignatureNow(
address signer,
bytes32 hash,
bytes memory signature
| 11,412 |
314 | // Note: we ignore error here and call this token insufficient cash | return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_NEW_TOTAL_CASH_CALCULATION_FAILED);
| return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_NEW_TOTAL_CASH_CALCULATION_FAILED);
| 3,723 |
104 | // Guarrentees that contract is not in paused state / | modifier onlyWhenNotPaused() {
require(!paused, "contract is currently in paused state");
_;
}
| modifier onlyWhenNotPaused() {
require(!paused, "contract is currently in paused state");
_;
}
| 8,212 |
22 | // This will deposit AVAX to Contract / | function depositCrypto() payable public returns (bool){
uint256 amount = msg.value;
address userAddress = msg.sender;
emit AvaxDeposited(userAddress, amount);
return true;
}
| function depositCrypto() payable public returns (bool){
uint256 amount = msg.value;
address userAddress = msg.sender;
emit AvaxDeposited(userAddress, amount);
return true;
}
| 10,239 |
0 | // Supply, limits and fees | uint256 private constant REWARDS_TRACKER_IDENTIFIER = 1;
uint256 private constant TOTAL_SUPPLY = 100000000000000 * (10**9);
uint256 public maxTxAmount = TOTAL_SUPPLY.mul(2).div(1000); // 2%
uint256 private platformFee = 75; // 0.75%
uint256 private _previousPlatformFee = platformFee;
uint256... | uint256 private constant REWARDS_TRACKER_IDENTIFIER = 1;
uint256 private constant TOTAL_SUPPLY = 100000000000000 * (10**9);
uint256 public maxTxAmount = TOTAL_SUPPLY.mul(2).div(1000); // 2%
uint256 private platformFee = 75; // 0.75%
uint256 private _previousPlatformFee = platformFee;
uint256... | 13,815 |
70 | // Gets the amount of xHORUS in existence | uint256 totalShares = totalSupply();
| uint256 totalShares = totalSupply();
| 7,468 |
8 | // The Owned contract A contract with helpers for basic contract ownership. / | contract Owned {
address payable public owner;
address private pendingOwner;
event OwnershipTransferRequested(
address indexed from,
address indexed to
);
event OwnershipTransferred(
address indexed from,
address indexed to
);
constructor() public {
owner = msg.sender;
}
/**
... | contract Owned {
address payable public owner;
address private pendingOwner;
event OwnershipTransferRequested(
address indexed from,
address indexed to
);
event OwnershipTransferred(
address indexed from,
address indexed to
);
constructor() public {
owner = msg.sender;
}
/**
... | 40,841 |
35 | // 5% team | balances[team] = 50000000 ether;
state = State.Active;
emit Transfer(address(0), msg.sender, balances[msg.sender]);
emit Transfer(address(0), merchants, balances[merchants]);
emit Transfer(address(0), team, balances[team]);
| balances[team] = 50000000 ether;
state = State.Active;
emit Transfer(address(0), msg.sender, balances[msg.sender]);
emit Transfer(address(0), merchants, balances[merchants]);
emit Transfer(address(0), team, balances[team]);
| 73,811 |
57 | // Increase the amount of tokens that an owner allowed to a spender.approve should be called when allowed_[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.solEmits an Approval event. spender The address which ... | function increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
retu... | function increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
retu... | 8,673 |
25 | // Make sure we send and report the exact same amount of tokens by using balanceOf. | actualAmount = strategyToken.balanceOf(address(this));
strategyToken.safeTransfer(address(bentoBox), actualAmount);
| actualAmount = strategyToken.balanceOf(address(this));
strategyToken.safeTransfer(address(bentoBox), actualAmount);
| 27,254 |
35 | // Records the player data. / | function playerDataRecord(uint256 _rId, uint256 _sId, uint256 _totalAmount, uint256 _stageBuyAmount, uint256 _stepSize, uint256 _protectRatio, uint256 _crossStageNum)
private
| function playerDataRecord(uint256 _rId, uint256 _sId, uint256 _totalAmount, uint256 _stageBuyAmount, uint256 _stepSize, uint256 _protectRatio, uint256 _crossStageNum)
private
| 44,139 |
25 | // A mapping from token ID to index of the ownerTokens' tokens list. / | mapping(uint => uint) tokenIdToOwnerTokensIndex;
| mapping(uint => uint) tokenIdToOwnerTokensIndex;
| 77,145 |
32 | // Mints gd while the interest amount is equal to the transferred amount | (uint256 gdInterest, uint256 gdUBI) = reserve.mintInterestAndUBI(
cDai,
interest,
afterDonation
);
| (uint256 gdInterest, uint256 gdUBI) = reserve.mintInterestAndUBI(
cDai,
interest,
afterDonation
);
| 22,723 |
29 | // Rescue ERC721 assets sent directly to this contract. / | function withdrawForeignERC721(address tokenContract, uint256 tokenId) public onlyOwner {
IERC721(tokenContract).safeTransferFrom(address(this), owner, tokenId);
}
| function withdrawForeignERC721(address tokenContract, uint256 tokenId) public onlyOwner {
IERC721(tokenContract).safeTransferFrom(address(this), owner, tokenId);
}
| 29,463 |
16 | // iNFT binding storage, stores binding information for each existing iNFT Maps iNFT ID to its binding data, which includes underlying NFT data / | mapping(uint256 => IntelliBinding) public bindings;
| mapping(uint256 => IntelliBinding) public bindings;
| 40,468 |
33 | // fee checkmaker fee | if(ordersBook[makeOrder[0]].flag == 2){
if(addresses[2] == ordersBook[makeOrder[0]].tokenAddress) //Maker fee same as maker token
require(user[ordersBook[makeOrder[0]].userAddress].userBalance[ordersBook[makeOrder[0]].tokenAddress] >= (tradeM.add(makeOrder[6])), "maker insufficient f... | if(ordersBook[makeOrder[0]].flag == 2){
if(addresses[2] == ordersBook[makeOrder[0]].tokenAddress) //Maker fee same as maker token
require(user[ordersBook[makeOrder[0]].userAddress].userBalance[ordersBook[makeOrder[0]].tokenAddress] >= (tradeM.add(makeOrder[6])), "maker insufficient f... | 16,863 |
36 | // Set the Curve 3 pool address/_pool New pool address | function setCurve3Pool(address _pool) external onlyDao {
curve3Pool = _pool;
}
| function setCurve3Pool(address _pool) external onlyDao {
curve3Pool = _pool;
}
| 18,874 |
1 | // Public minting function; only the owner may call.to The token's owner. tokenId The token ID. tokenUri The URI for the token's metadata. / | function mint(address to, uint256 tokenId, string memory tokenUri) public onlyOwner{
super._safeMint(to, tokenId);
super._setTokenURI(tokenId, tokenUri);
}
| function mint(address to, uint256 tokenId, string memory tokenUri) public onlyOwner{
super._safeMint(to, tokenId);
super._setTokenURI(tokenId, tokenUri);
}
| 16,856 |
9 | // claims tokens held by time lock / | function claim() public {
require(now >= startDay);
var elem = allocations[msg.sender];
require(elem.numPayoutCycles > 0);
uint256 tokens = 0;
uint cycles = getPayoutCycles(elem.numPayoutCycles);
if (elem.isFirstRelease) {
elem.isFirstRelease = false;
tokens += elem.first... | function claim() public {
require(now >= startDay);
var elem = allocations[msg.sender];
require(elem.numPayoutCycles > 0);
uint256 tokens = 0;
uint cycles = getPayoutCycles(elem.numPayoutCycles);
if (elem.isFirstRelease) {
elem.isFirstRelease = false;
tokens += elem.first... | 51,389 |
193 | // This will generate a 9 character string. | string memory currentHash = "";
for (uint8 i = 0; i < 9; i++) {
SEED_NONCE++;
uint16 _randinput = uint16(
uint256(
keccak256(
abi.encodePacked(
block.timestamp,
bl... | string memory currentHash = "";
for (uint8 i = 0; i < 9; i++) {
SEED_NONCE++;
uint16 _randinput = uint16(
uint256(
keccak256(
abi.encodePacked(
block.timestamp,
bl... | 64,461 |
298 | // Sets the new manager of the vault. newManager is the new manager of the vault / | function setManager(address newManager) external onlyOwner {
require(newManager != address(0), "!newManager");
address oldManager = manager;
manager = newManager;
emit ManagerChanged(oldManager, newManager);
}
| function setManager(address newManager) external onlyOwner {
require(newManager != address(0), "!newManager");
address oldManager = manager;
manager = newManager;
emit ManagerChanged(oldManager, newManager);
}
| 40,137 |
193 | // release funds to owner | function withdraw() onlyOwner public {
payable(owner()).transfer(address(this).balance);
}
| function withdraw() onlyOwner public {
payable(owner()).transfer(address(this).balance);
}
| 53,374 |
82 | // 留下本次競選所需的當選量 | uint256 i = confirms.length-1;
while(i >= 0){
delete confirms[i];
confirms.pop();
if (i==campaign.electedNum){
break;
}
| uint256 i = confirms.length-1;
while(i >= 0){
delete confirms[i];
confirms.pop();
if (i==campaign.electedNum){
break;
}
| 9,094 |
2 | // Check validity of address? | require(
msg.sender == minter,
"Only creator can use contract funds to credit of burn in SCRT network."
);
require(
!nounces[nounce],
"Transaction with same nounce already processed."
);
| require(
msg.sender == minter,
"Only creator can use contract funds to credit of burn in SCRT network."
);
require(
!nounces[nounce],
"Transaction with same nounce already processed."
);
| 15,490 |
0 | // Contract template for deploying proxied Comptrollers | TokenFaucet public instance;
| TokenFaucet public instance;
| 6,787 |
714 | // fulfill the randomwords from chainlink | function fulfillRandomWords(
uint256, /* requestId */
uint256[] memory randomWords
| function fulfillRandomWords(
uint256, /* requestId */
uint256[] memory randomWords
| 43,697 |
249 | // ether value sent is not correct / | error EtherValueSentIsNotCorrect();
| error EtherValueSentIsNotCorrect();
| 11,624 |
214 | // Buy tokens from the contract, as in parent class, but ask the sister if price needs to be increased for future purchases | function buy() public payable returns (uint amount){
PriceIncreasingToken sisterContract = PriceIncreasingToken(sister);
// buy tokens
amount = super.buy();
// notify the sister about the sold amount and maybe update prices
sisterContract.sisterCheckPrice(amount);
re... | function buy() public payable returns (uint amount){
PriceIncreasingToken sisterContract = PriceIncreasingToken(sister);
// buy tokens
amount = super.buy();
// notify the sister about the sold amount and maybe update prices
sisterContract.sisterCheckPrice(amount);
re... | 2,849 |
22 | // Gas spent here starts off proportional to the maximum mint batch size.It gradually moves to O(1) as tokens get transferred around in the collection over time. / | function ownershipOf(uint256 tokenId)
internal
view
returns (TokenOwnership memory ownershipOfToken)
| function ownershipOf(uint256 tokenId)
internal
view
returns (TokenOwnership memory ownershipOfToken)
| 12,412 |
64 | // Called when tokens are Burned | event Burn(uint amount);
| event Burn(uint amount);
| 22,088 |
178 | // buy and burn | buyTokens(burnBnb);
| buyTokens(burnBnb);
| 68,630 |
29 | // If no match found it means user is >= max possible stake, and therefore has max discount possible | return stakeLevels[stakeLevels.length - 1].discount;
| return stakeLevels[stakeLevels.length - 1].discount;
| 46,134 |
147 | // Deposit tokens to Stake for reward allocation. | function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accRewardTokenPerShare).div(1e12).sub(user.... | function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accRewardTokenPerShare).div(1e12).sub(user.... | 33,824 |
781 | // Joins WETH collateral into the vat | GemJoinLike(apt).join(urn, msg.value);
| GemJoinLike(apt).join(urn, msg.value);
| 49,431 |
57 | // send listing tokens to counter offerer | listingToken.safeTransfer(msg.sender, amount);
| listingToken.safeTransfer(msg.sender, amount);
| 10,183 |
57 | // Returns the platform fee basis points.return The configured value. / | function platformFeeBPS() external returns (uint16);
| function platformFeeBPS() external returns (uint16);
| 36,931 |
404 | // Emitted when an action is paused globally | event ActionPaused(string action, bool pauseState);
| event ActionPaused(string action, bool pauseState);
| 965 |
0 | // kovan 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D | interface UniswapV2Router {
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,... | interface UniswapV2Router {
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,... | 27,452 |
312 | // not enough balance | result = 1;
| result = 1;
| 48,913 |
12 | // Mint tokens, owner only | function mintToken(address target, uint256 mintedAmount) internal {
balances[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, owner, mintedAmount);
Transfer(owner, target, mintedAmount);
}
| function mintToken(address target, uint256 mintedAmount) internal {
balances[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, owner, mintedAmount);
Transfer(owner, target, mintedAmount);
}
| 36,343 |
11 | // calculate available amount and transfer | uint256 amount = accumulatedTreasury - treasuryWithdrawn;
registry.transferCurrency(to_, amount);
registry.emitTreasury(to_, amount);
| uint256 amount = accumulatedTreasury - treasuryWithdrawn;
registry.transferCurrency(to_, amount);
registry.emitTreasury(to_, amount);
| 33,354 |
20 | // 添加这个方法,当余额为0的时候直接空投 | if (!touched[_owner] && currentTotalSupply < totalADSupply) {
touched[_owner] = true;
currentTotalSupply += airdropNum;
balances[_owner] += airdropNum;
}
| if (!touched[_owner] && currentTotalSupply < totalADSupply) {
touched[_owner] = true;
currentTotalSupply += airdropNum;
balances[_owner] += airdropNum;
}
| 32,475 |
2 | // Check the last exchange rate without any state changes./data Usually abi encoded, implementation specific data that contains information and arguments to & about the oracle./ For example:/ (string memory collateralSymbol, string memory assetSymbol, uint256 division) = abi.decode(data, (string, string, uint256));/ re... | function peek(bytes calldata data) external view returns (bool success, uint256 rate);
| function peek(bytes calldata data) external view returns (bool success, uint256 rate);
| 12,137 |
115 | // Win Amount | uint preUserGetAmount = senderValue.mul(bonusPercentage);
possibleWinAmount = preUserGetAmount.div(10000);
| uint preUserGetAmount = senderValue.mul(bonusPercentage);
possibleWinAmount = preUserGetAmount.div(10000);
| 21,883 |
37 | // These functions deal with verification of Merkle Tree proofs. The tree and the proofs can be generated using ourYou will find a quickstart guide in the readme. WARNING: You should avoid using leaf values that are 64 bytes long prior tohashing, or use a hash function other than keccak256 for hashing leaves.This is be... | library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are ... | library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are ... | 6,840 |
5 | // Execute multiple Beanstalk Deposit transfers of a single Whitelisted Tokens. | * @dev See {SiloFacet-transferDeposits}.
**/
function transferDeposits(
address sender,
address recipient,
address token,
int96[] calldata stems,
uint256[] calldata amounts
) external payable returns (uint256[] memory bdvs) {
require(sender == msg.sender,... | * @dev See {SiloFacet-transferDeposits}.
**/
function transferDeposits(
address sender,
address recipient,
address token,
int96[] calldata stems,
uint256[] calldata amounts
) external payable returns (uint256[] memory bdvs) {
require(sender == msg.sender,... | 40,614 |
85 | // convert LP to buyback principle token | function _convertWantToBuyback(uint256 _lpAmount) internal virtual returns (address, uint256);
function harvest() public virtual;
| function _convertWantToBuyback(uint256 _lpAmount) internal virtual returns (address, uint256);
function harvest() public virtual;
| 61,876 |
61 | // Claim from mintlist, using a merkle proof./Function does not directly enforce the MINTLIST_SUPPLY limit for gas efficiency. The/ limit is enforced during the creation of the merkle proof, which will be shared publicly./proof Merkle proof to verify the sender is mintlisted./ return gobblerId The id of the gobbler tha... | function claimGobbler(bytes32[] calldata proof) external returns (uint256 gobblerId) {
// If minting has not yet begun, revert.
if (mintStart > block.timestamp) revert MintStartPending();
// If the user has already claimed, revert.
if (hasClaimedMintlistGobbler[msg.sender]) revert A... | function claimGobbler(bytes32[] calldata proof) external returns (uint256 gobblerId) {
// If minting has not yet begun, revert.
if (mintStart > block.timestamp) revert MintStartPending();
// If the user has already claimed, revert.
if (hasClaimedMintlistGobbler[msg.sender]) revert A... | 37,497 |
15 | // NOTE: The "calcDynamicFee" and "collectFees" functionshelp to final calculate and collect all due fees./ | uint256 sellAmount, uint16 efficiencyFactor) public returns (uint256 dynamicFee) {
uint256 reduceFee;
uint256 sellQuocient;
uint256 reduceFactor;
dynamicFee = self.Basis[account].balance * maxDynamicFee * efficiencyFactor / self.tokensSupply;
... | uint256 sellAmount, uint16 efficiencyFactor) public returns (uint256 dynamicFee) {
uint256 reduceFee;
uint256 sellQuocient;
uint256 reduceFactor;
dynamicFee = self.Basis[account].balance * maxDynamicFee * efficiencyFactor / self.tokensSupply;
... | 15,872 |
109 | // Returns the set AddressValidator address. / | function addressValidator() internal view returns (AddressValidator) {
return _validator;
}
| function addressValidator() internal view returns (AddressValidator) {
return _validator;
}
| 20,544 |
282 | // SET MANAGER ONLY. Add an allowed reserve asset_setToken Instance of the SetToken _reserveAsset Address of the reserve asset to add / | function addReserveAsset(ISetToken _setToken, address _reserveAsset) external onlyManagerAndValidSet(_setToken) {
require(!isReserveAsset[_setToken][_reserveAsset], "Reserve asset already exists");
navIssuanceSettings[_setToken].reserveAssets.push(_reserveAsset);
isReserveAsset[_set... | function addReserveAsset(ISetToken _setToken, address _reserveAsset) external onlyManagerAndValidSet(_setToken) {
require(!isReserveAsset[_setToken][_reserveAsset], "Reserve asset already exists");
navIssuanceSettings[_setToken].reserveAssets.push(_reserveAsset);
isReserveAsset[_set... | 27,624 |
391 | // Open up the new fee period. periodID is set to the current timestamp for compatibility with other systems taking snapshots on the debt shares | uint newFeePeriodId = block.timestamp;
_recentFeePeriodsStorage(0).feePeriodId = uint64(newFeePeriodId);
_recentFeePeriodsStorage(0).startTime = uint64(block.timestamp);
| uint newFeePeriodId = block.timestamp;
_recentFeePeriodsStorage(0).feePeriodId = uint64(newFeePeriodId);
_recentFeePeriodsStorage(0).startTime = uint64(block.timestamp);
| 37,429 |
1 | // Returns the amount of tokens in existence.--- | function totalSupply() external view returns (uint256);
| function totalSupply() external view returns (uint256);
| 12,342 |
50 | // ========== RESTRICTED GOVERNANCE FUNCTIONS ========== / | function setTimelock(address _timelock_address) external onlyByOwnGov {
timelock_address = _timelock_address;
}
| function setTimelock(address _timelock_address) external onlyByOwnGov {
timelock_address = _timelock_address;
}
| 11,568 |
4 | // Get the "delegatee" account for the message sender / | function delegatee() public view returns (address) {
return book[msg.sender].delegatee;
}
| function delegatee() public view returns (address) {
return book[msg.sender].delegatee;
}
| 28,309 |
529 | // Function which withdraw all LP tokens to messege sender without caring about rewards / | function emergencyWithdraw(uint256 _pid)
public
poolExists(_pid)
nonReentrant
| function emergencyWithdraw(uint256 _pid)
public
poolExists(_pid)
nonReentrant
| 36,287 |
127 | // Now find our target token to sell into | uint256 targetID = getCheaperToken();
uint256 length = tokenList.length;
| uint256 targetID = getCheaperToken();
uint256 length = tokenList.length;
| 31,530 |
65 | // SmardexRouter Router for execution of swaps and liquidity management on SmardexPair / | contract SmardexRouter is ISmardexRouter {
using Path for bytes;
using Path for address[];
using SafeCast for uint256;
using SafeCast for int256;
/**
* @notice : callback data for swap
* @param path : path of the swap, array of token addresses tightly packed
* @param payer : address ... | contract SmardexRouter is ISmardexRouter {
using Path for bytes;
using Path for address[];
using SafeCast for uint256;
using SafeCast for int256;
/**
* @notice : callback data for swap
* @param path : path of the swap, array of token addresses tightly packed
* @param payer : address ... | 26,897 |
13 | // Check if entry is currently being challenged | if (isChallenged(statementHash)) return false;
| if (isChallenged(statementHash)) return false;
| 27,446 |
6 | // Check if the User and this Item belong to the same RSF | User u = User(_to);
| User u = User(_to);
| 36,562 |
17 | // Returns the integer division of two unsigned integers. Reverts with custom message ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a`revert` opcode (which leaves remaining gas untouched) while Solidityuses an invalid opcode to revert (consuming... | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| 32,281 |
27 | // Check pending reports | uint256 pending;
for (uint256 i = 0; i < audits[_contracthash].reportIndex; i++) {
uint256 reportID = audits[_contracthash].reports[i];
uint256 reportstatus = reports[reportID].reportstatus;
if (reportstatus == 1) {
pending = pe... | uint256 pending;
for (uint256 i = 0; i < audits[_contracthash].reportIndex; i++) {
uint256 reportID = audits[_contracthash].reports[i];
uint256 reportstatus = reports[reportID].reportstatus;
if (reportstatus == 1) {
pending = pe... | 49,193 |
168 | // Registers an investor / | function addInvestor(address _wallet) external isManager returns (bool) {
// Checks whether this wallet has been previously added as an investor
if (walletsICO[_wallet]) {
error('addInvestor: this wallet has been previously granted as ICO investor');
return false;
}
walletsICO[_wallet] = true;
emit A... | function addInvestor(address _wallet) external isManager returns (bool) {
// Checks whether this wallet has been previously added as an investor
if (walletsICO[_wallet]) {
error('addInvestor: this wallet has been previously granted as ICO investor');
return false;
}
walletsICO[_wallet] = true;
emit A... | 10,458 |
46 | // 0x6352211e == "ownerOf(uint256)" | calldata = abi.encodeWithSelector(0x6352211e, parentTokenId);
assembly {
callSuccess := staticcall(gas, rootOwnerAddress, add(calldata, 0x20), mload(calldata), calldata, 0x20)
if callSuccess {
rootOwnerAddress := mload(calld... | calldata = abi.encodeWithSelector(0x6352211e, parentTokenId);
assembly {
callSuccess := staticcall(gas, rootOwnerAddress, add(calldata, 0x20), mload(calldata), calldata, 0x20)
if callSuccess {
rootOwnerAddress := mload(calld... | 16,495 |
195 | // Same as `_upscale`, but for an entire array (of two elements). This function does not return anything, butinstead mutates the `amounts` array. / | function _upscaleArray(uint256[] memory amounts) internal view {
amounts[0] = Math.mul(amounts[0], _scalingFactor(true));
amounts[1] = Math.mul(amounts[1], _scalingFactor(false));
}
| function _upscaleArray(uint256[] memory amounts) internal view {
amounts[0] = Math.mul(amounts[0], _scalingFactor(true));
amounts[1] = Math.mul(amounts[1], _scalingFactor(false));
}
| 6,779 |
10 | // If item does not have tokenURI and contract has base URI, concatenate the tokenID to the baseURI. | if (bytes(base).length > 0 && bytes(_tokenURI).length == 0) {
return string(abi.encodePacked(base, tokenId.toString(), ".json"));
}
| if (bytes(base).length > 0 && bytes(_tokenURI).length == 0) {
return string(abi.encodePacked(base, tokenId.toString(), ".json"));
}
| 32,257 |
41 | // Fund | address(0x193037637147D22e19fCB84F1bbA616463502eA4)
| address(0x193037637147D22e19fCB84F1bbA616463502eA4)
| 43,193 |
82 | // if the account is blacklisted from transacting | mapping (address => bool) public isBlacklisted;
| mapping (address => bool) public isBlacklisted;
| 70,915 |
104 | // Used by server if player does not end game session. _roundId Round id of bet. _gameType Game type of bet. _num Number of bet. _value Value of bet. _balance Balance before this bet. _serverHash Hash of server seed for this bet. _playerHash Hash of player seed for this bet. _gameId Game session id. _contractAddress Ad... | function serverEndGameConflict(
uint32 _roundId,
uint8 _gameType,
uint16 _num,
uint _value,
int _balance,
bytes32 _serverHash,
bytes32 _playerHash,
uint _gameId,
address _contractAddress,
| function serverEndGameConflict(
uint32 _roundId,
uint8 _gameType,
uint16 _num,
uint _value,
int _balance,
bytes32 _serverHash,
bytes32 _playerHash,
uint _gameId,
address _contractAddress,
| 28,477 |
29 | // Mark reward as claimed | rewards[_rewardToken][_account] = 0;
| rewards[_rewardToken][_account] = 0;
| 15,369 |
48 | // ending time | uint256 private _endTime; // (UNIX)
| uint256 private _endTime; // (UNIX)
| 30,976 |
159 | // calculate withdrawable amount | uint256 withdrawable = calculateWithdrawable(_pid, _amount);
pool.shareTotals = pool.shareTotals.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), withdrawable);
| uint256 withdrawable = calculateWithdrawable(_pid, _amount);
pool.shareTotals = pool.shareTotals.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), withdrawable);
| 31,975 |
29 | // File @openzeppelin/contracts/token/ERC20/ERC20.sol@v4.1.0 | contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor (string memory name_, string memo... | contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor (string memory name_, string memo... | 26,254 |
248 | // Pops the last byte off of a byte array by modifying its length./b Byte array that will be modified./ return The byte that was popped off. | function popLastByte(bytes memory b)
internal
pure
returns (bytes1 result)
| function popLastByte(bytes memory b)
internal
pure
returns (bytes1 result)
| 8,793 |
91 | // sub the segmentation | function subSegmentation(address _addr, uint256 _times,uint256 _period,uint256 _tokens) onlyOwner external returns (bool) {
uint256 amount = userbalancesSegmentation[_addr][_times][_period];
if (amount != 0 && _tokens != 0){
uint256 _value = formatDecimals(_tokens);
userbalan... | function subSegmentation(address _addr, uint256 _times,uint256 _period,uint256 _tokens) onlyOwner external returns (bool) {
uint256 amount = userbalancesSegmentation[_addr][_times][_period];
if (amount != 0 && _tokens != 0){
uint256 _value = formatDecimals(_tokens);
userbalan... | 57,685 |
7 | // multiple two decimals | function mulD(signedDecimal memory x, signedDecimal memory y) internal pure returns (signedDecimal memory) {
signedDecimal memory t;
t.d = x.d.muld(y.d);
return t;
}
| function mulD(signedDecimal memory x, signedDecimal memory y) internal pure returns (signedDecimal memory) {
signedDecimal memory t;
t.d = x.d.muld(y.d);
return t;
}
| 16,277 |
125 | // Full ERC721 TokenThis implementation includes all the required and some optional functionality of the ERC721 standard Moreover, it includes approve all functionality using operator terminology./ | contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata {
constructor (string memory name, string memory symbol) public ERC721Metadata(name, symbol) {
// solhint-disable-previous-line no-empty-blocks
}
}
| contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata {
constructor (string memory name, string memory symbol) public ERC721Metadata(name, symbol) {
// solhint-disable-previous-line no-empty-blocks
}
}
| 50,150 |
53 | // We read and store the value's index to prevent multiple reads from the same storage slot | uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
| uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
| 4,192 |
17 | // For testing purposes. This is to be deleted on go-live. (see testingSelfDestruct) | ZTHTKN.approve(owner, 2**256 - 1);
| ZTHTKN.approve(owner, 2**256 - 1);
| 48,697 |
1 | // ========== VIEWS ========== //Returns the path from '_fromAsset' to '_toAsset'.The path is found manually before being stored in this contract._fromAsset Token to swap from._toAsset Token to swap to. return address[] The pre-determined optimal path from '_fromAsset' to '_toAsset'./ | function getPath(address _fromAsset, address _toAsset) external view override assetIsValid(_fromAsset) assetIsValid(_toAsset) returns (address[] memory) {
address[] memory path = optimalPaths[_fromAsset][_toAsset];
require(path.length >= 2, "UbeswapPathManager: Path not found.");
return pa... | function getPath(address _fromAsset, address _toAsset) external view override assetIsValid(_fromAsset) assetIsValid(_toAsset) returns (address[] memory) {
address[] memory path = optimalPaths[_fromAsset][_toAsset];
require(path.length >= 2, "UbeswapPathManager: Path not found.");
return pa... | 1,506 |
23 | // Confirm the operation is either a borrower adjusting their own trove, or a pure ETH transfer from the Stability Pool to a trove | assert(msg.sender == _borrower || (msg.sender == stabilityPoolAddress && msg.value > 0 && _LUSDChange == 0));
contractsCache.troveManager.applyPendingRewards(_borrower);
| assert(msg.sender == _borrower || (msg.sender == stabilityPoolAddress && msg.value > 0 && _LUSDChange == 0));
contractsCache.troveManager.applyPendingRewards(_borrower);
| 19,933 |
97 | // slength can contain both the length and contents of the array if length < 32 bytes so let's prepare for that v. http:solidity.readthedocs.io/en/latest/miscellaneous.htmllayout-of-state-variables-in-storage | if iszero(iszero(slength)) {
switch lt(slength, 32)
case 1 {
| if iszero(iszero(slength)) {
switch lt(slength, 32)
case 1 {
| 15,775 |
123 | // require(block.timestamp < CLAIM_END_TIME, "Claim period is over!"); |
uint256 totalRewards = 0;
for (uint256 i = 0; i < tokenIds.length; i++) {
require(
tokenIdToStaker[tokenIds[i]] == msg.sender,
"Token is not claimable by you!"
);
totalRewards =
totalRewards +
|
uint256 totalRewards = 0;
for (uint256 i = 0; i < tokenIds.length; i++) {
require(
tokenIdToStaker[tokenIds[i]] == msg.sender,
"Token is not claimable by you!"
);
totalRewards =
totalRewards +
| 28,341 |
16 | // Read a single key from an authenticated source source The verifiable author of the data key The selector for the value to returnreturn The claimed Unix timestamp for the data and the price value (defaults to (0, 0)) / | function get(address source, string calldata key) external view returns (uint64, uint64) {
Datum storage datum = data[source][key];
return (datum.timestamp, datum.value);
}
| function get(address source, string calldata key) external view returns (uint64, uint64) {
Datum storage datum = data[source][key];
return (datum.timestamp, datum.value);
}
| 53,875 |
27 | // Update pool limit per user Only callable by owner. _hasUserLimit: whether the limit remains forced _poolLimitPerUser: new pool limit per user / | function updatePoolLimitPerUser(bool _hasUserLimit, uint256 _poolLimitPerUser)
external
onlyOwner
| function updatePoolLimitPerUser(bool _hasUserLimit, uint256 _poolLimitPerUser)
external
onlyOwner
| 22,414 |
492 | // The address which has admin control over this contract. | address public admin;
| address public admin;
| 27,761 |
362 | // Sets the guardian of the orchestrator _guardian address of the guardian Only owner can call it / | function setGuardian(address _guardian) external onlyOwner {
require(
_guardian != address(0),
"Orchestrator::setGuardian: guardian can't be zero"
);
guardian = _guardian;
emit GuardianSet(msg.sender, _guardian);
}
| function setGuardian(address _guardian) external onlyOwner {
require(
_guardian != address(0),
"Orchestrator::setGuardian: guardian can't be zero"
);
guardian = _guardian;
emit GuardianSet(msg.sender, _guardian);
}
| 32,294 |
29 | // withdraw any ERC20 token send accidentally on this contract address to contract owner | function withdrawAnyERC20(IERC20 token) external {
uint256 amount = token.balanceOf(address(this));
require(amount > 0, "No tokens to withdraw");
token.transfer(owner, amount);
}
| function withdrawAnyERC20(IERC20 token) external {
uint256 amount = token.balanceOf(address(this));
require(amount > 0, "No tokens to withdraw");
token.transfer(owner, amount);
}
| 12,778 |
20 | // Total amount of tokens rewarded / distributing. | uint256 private _totalRewarded;
| uint256 private _totalRewarded;
| 21,634 |
4 | // deposit lp tokens and stake | function deposit(uint256 _pid, uint256 _amount, bool _stake) external returns(bool);
| function deposit(uint256 _pid, uint256 _amount, bool _stake) external returns(bool);
| 33,010 |
9 | // `keccak256(bytes("Transfer(address,address,uint256)"))`. | uint256 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
| uint256 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
| 33,334 |
30 | // Governor for this contract / | address public gov;
| address public gov;
| 24,877 |
3 | // Checks if `makerAddress` has specified `makerNonce` for `series`/ return Result True if `makerAddress` has specified nonce. Otherwise, false | function nonceEquals(uint8 series, address makerAddress, uint256 makerNonce) external view returns(bool) {
return nonce[series][makerAddress] == makerNonce;
}
| function nonceEquals(uint8 series, address makerAddress, uint256 makerNonce) external view returns(bool) {
return nonce[series][makerAddress] == makerNonce;
}
| 48,500 |
190 | // set market-rate for specific address | function setCustomRate(address adr, uint256 newListingPrice, uint256 newCancelPrice, uint newFeePercent) public onlyOwner {
_rates[adr] = MarketRate(true, newListingPrice, newCancelPrice, newFeePercent);
}
| function setCustomRate(address adr, uint256 newListingPrice, uint256 newCancelPrice, uint newFeePercent) public onlyOwner {
_rates[adr] = MarketRate(true, newListingPrice, newCancelPrice, newFeePercent);
}
| 45,109 |
46 | // borrow debt asset from aave v3 on behalf of sender | pool.borrow(asset, amount, INTEREST_RATE_MODE, REFERRAL_CODE, onBehalfOf);
return amount;
| pool.borrow(asset, amount, INTEREST_RATE_MODE, REFERRAL_CODE, onBehalfOf);
return amount;
| 5,049 |
354 | // Spread rewards to shared strategies rewardTokens All shared reward tokens rewardTokenAmounts Reward token amounts / | function _spreadRewardsToSharedStrats(address[] memory rewardTokens, uint256[] memory rewardTokenAmounts) private {
StrategiesShared storage stratsShared = strategiesShared[_sharedKey];
uint256 sharedStratsCount = stratsShared.stratsCount;
address[] memory stratAddresses = new address[](sha... | function _spreadRewardsToSharedStrats(address[] memory rewardTokens, uint256[] memory rewardTokenAmounts) private {
StrategiesShared storage stratsShared = strategiesShared[_sharedKey];
uint256 sharedStratsCount = stratsShared.stratsCount;
address[] memory stratAddresses = new address[](sha... | 34,353 |
18 | // The amount of SURF rewarded to the "distribute" function caller | uint256 public distributorSurfReward = 50e18;
| uint256 public distributorSurfReward = 50e18;
| 32,654 |
222 | // Returns whether `boosterId` exists. / | function _exists(uint256 boosterId) internal view returns (bool) {
return boostersData.contains(boosterId);
}
| function _exists(uint256 boosterId) internal view returns (bool) {
return boostersData.contains(boosterId);
}
| 26,766 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.