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
80
// Calculates sUSD to burn to restore C-RATIO /
function calculateSusdToBurnToFixRatioExternal() public view returns (uint256)
function calculateSusdToBurnToFixRatioExternal() public view returns (uint256)
945
8
// USDT -> WETH
TRICRYPTO.exchange(0, 2, USDT.balanceOf(address(this)), 0);
TRICRYPTO.exchange(0, 2, USDT.balanceOf(address(this)), 0);
65,937
7
// Before the expiry, a user can redeem the same amount of OT+XYT to get backthe underlying yield token no check on _amountToRedeem /
) external override pendleNonReentrant returns (uint256 redeemedAmount) { require(data.isValidXYT(_forgeId, _underlyingAsset, _expiry), "INVALID_XYT"); require(block.timestamp < _expiry, "YIELD_CONTRACT_EXPIRED"); require(_to != address(0), "ZERO_ADDRESS"); IPendleForge forge = IPen...
) external override pendleNonReentrant returns (uint256 redeemedAmount) { require(data.isValidXYT(_forgeId, _underlyingAsset, _expiry), "INVALID_XYT"); require(block.timestamp < _expiry, "YIELD_CONTRACT_EXPIRED"); require(_to != address(0), "ZERO_ADDRESS"); IPendleForge forge = IPen...
18,216
170
// Extracts the value bytes from the output in a tx/Value is an 8-byte little-endian number/_output The output/ returnThe output value as LE bytes
function extractValueLE(bytes memory _output) internal pure returns (bytes memory) { return _output.slice(0, 8); }
function extractValueLE(bytes memory _output) internal pure returns (bytes memory) { return _output.slice(0, 8); }
24,598
44
// Mint directly to staking contract for the reward amount The staking contract will do bookkeeping of the reward and assign in proportion to each stakeholder incentive
graphToken().mint(address(staking), rewards);
graphToken().mint(address(staking), rewards);
50,426
22
// Function to check reserved amount of tokens for address._owner Address of owner of the tokens. return The uint256 specifing the amount of tokens which are held in reserve for this address. /
function reserveOf(address _owner) public view returns (uint256) { return reserved[_owner].pulsAmount; }
function reserveOf(address _owner) public view returns (uint256) { return reserved[_owner].pulsAmount; }
44,624
182
// Emits a {Mint} event.//owner The owner of the account to mint from./amountThe amount to mint./recipient The recipient of the minted debt tokens.
function _mint(address owner, uint256 amount, address recipient) internal {
function _mint(address owner, uint256 amount, address recipient) internal {
69,016
11
// skip the earlier logs
for (uint256 i = 0; i < logIdx; i++) { require(receiptValue.length > 0, "log index does not exist"); offset = RLP.skip(receiptValue); receiptValue = receiptValue[offset:]; }
for (uint256 i = 0; i < logIdx; i++) { require(receiptValue.length > 0, "log index does not exist"); offset = RLP.skip(receiptValue); receiptValue = receiptValue[offset:]; }
39,311
6
// Checks if the group is eligible to receive a reward./ Group is eligible to receive a reward if it has been marked as stale/ and rewards has not been claimed yet./groupIndex Index of the group to check.
function eligibleForReward(uint256 groupIndex) public view returns (bool) { return eligibleForReward(bytes32(groupIndex)); }
function eligibleForReward(uint256 groupIndex) public view returns (bool) { return eligibleForReward(bytes32(groupIndex)); }
41,627
26
// WeiTopDownSplitterWill split money from top to down (order matters!). It is possible for some children to not receive money if they have ended. /
contract WeiTopDownSplitter is SplitterBase, IWeiReceiver { constructor(string _name) SplitterBase(_name) public { } // IWeiReceiver: // calculate only absolute outputs, but do not take into account the Percents function getMinWeiNeeded()external view returns(uint){ if(!_isOpen()){ return 0; } uint total...
contract WeiTopDownSplitter is SplitterBase, IWeiReceiver { constructor(string _name) SplitterBase(_name) public { } // IWeiReceiver: // calculate only absolute outputs, but do not take into account the Percents function getMinWeiNeeded()external view returns(uint){ if(!_isOpen()){ return 0; } uint total...
41,331
36
// It needs to be something worth splitting up
require(balance > 1);
require(balance > 1);
3,130
42
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
7,184
55
// `transfer`. {sendValue} removes this limitation. IMPORTANT: because control is transferred to `recipient`, care must be taken to not create reentrancy vulnerabilities. Consider using{ReentrancyGuard} or the/
...
...
30,043
70
// and cursor.next is still in same bucket, move head to cursor.next
if(infos[info.next].expiresAt.div(BUCKET_STEP) == bucket.div(BUCKET_STEP)){ checkPoints[bucket].head == info.next; } else {
if(infos[info.next].expiresAt.div(BUCKET_STEP) == bucket.div(BUCKET_STEP)){ checkPoints[bucket].head == info.next; } else {
30,269
4
// pragma solidity >=0.5.12; // import "./lib.sol"; /
interface GemLike { function decimals() external view returns (uint); function transfer(address,uint) external returns (bool); function transferFrom(address,address,uint) external returns (bool); }
interface GemLike { function decimals() external view returns (uint); function transfer(address,uint) external returns (bool); function transferFrom(address,address,uint) external returns (bool); }
61,241
2
// Constructor. /
constructor() EIP712Base() {
constructor() EIP712Base() {
16,520
28
// updates baseRate/_increase value to add to baseRate/_increase
function increaseBaseRate(uint256 _increase) external override returns (uint256) { require(msg.sender == address(factory), "10bcb only factory increases baseRate"); baseRate += _increase; return baseRate; }
function increaseBaseRate(uint256 _increase) external override returns (uint256) { require(msg.sender == address(factory), "10bcb only factory increases baseRate"); baseRate += _increase; return baseRate; }
31,575
85
// Set the Updater _updater Address of the Updater /
function _setUpdater(address _updater) internal { updater = _updater; emit NewUpdater(_updater); }
function _setUpdater(address _updater) internal { updater = _updater; emit NewUpdater(_updater); }
26,859
2
// Enum representing different types of updates. @custom:value BATCHERRepresents an update to the batcher hash.@custom:value GAS_CONFIG Represents an update to txn fee config on L2.@custom:value GAS_LIMITRepresents an update to gas limit on L2.@custom:value UNSAFE_BLOCK_SIGNERRepresents an update to the signer key for ...
enum UpdateType { BATCHER, GAS_CONFIG, GAS_LIMIT, UNSAFE_BLOCK_SIGNER }
enum UpdateType { BATCHER, GAS_CONFIG, GAS_LIMIT, UNSAFE_BLOCK_SIGNER }
7,999
20
// public rigs
if (tokenId <= 4500) { _safeMint(msg.sender, tokenId); _setTokenURI(tokenId, url); emit PermanentURI(url, tokenId); rigs[tokenId].period = random(7) * 1 days; rigs[tokenId].power = random(50); rigIds.push(tokenId);
if (tokenId <= 4500) { _safeMint(msg.sender, tokenId); _setTokenURI(tokenId, url); emit PermanentURI(url, tokenId); rigs[tokenId].period = random(7) * 1 days; rigs[tokenId].power = random(50); rigIds.push(tokenId);
79,919
457
// LONG SHORT PAIR DATA STRUCTURES / Define the contract's constructor parameters as a struct to enable more variables to be specified.
struct ConstructorParams { string pairName; // Name of the long short pair contract. uint64 expirationTimestamp; // Unix timestamp of when the contract will expire. uint256 collateralPerPair; // How many units of collateral are required to mint one pair of synthetic tokens. bytes32 p...
struct ConstructorParams { string pairName; // Name of the long short pair contract. uint64 expirationTimestamp; // Unix timestamp of when the contract will expire. uint256 collateralPerPair; // How many units of collateral are required to mint one pair of synthetic tokens. bytes32 p...
29,419
36
// Should not allow to send to oneself.
if (_fromId == _toId) { _error("Cannot send to oneself"); return false; }
if (_fromId == _toId) { _error("Cannot send to oneself"); return false; }
21,861
42
// 获取单个通证余额
function getTokenBalance(string memory symbol) public view returns (uint256)
function getTokenBalance(string memory symbol) public view returns (uint256)
32,792
26
// Redeem amount of collateral using fixed number of synthetic token This calculate the price using on chain price feed User must approve synthetic token transfer for the redeem request to succeed redeemParams Input parameters for redeeming (see RedeemParams struct)return collateralRedeemed Amount of collateral redeeem...
function redeem(RedeemParams memory redeemParams) external override nonReentrant returns (uint256 collateralRedeemed, uint256 feePaid)
function redeem(RedeemParams memory redeemParams) external override nonReentrant returns (uint256 collateralRedeemed, uint256 feePaid)
6,757
249
// randomPart[2] = _getRarity(_randomIndex(_rand,8,12,3));rarity
_createPart(randomPart, _owner);
_createPart(randomPart, _owner);
38,241
16
// Deletes the payment from its receiver's and sender's lists of payments, and zeroes out all the data in the struct.paymentId The ID of the payment to be deleted./
function deletePayment(address paymentId) private { EscrowedPayment storage payment = escrowedPayments[paymentId]; address[] storage received = receivedPaymentIds[payment.recipientIdentifier]; address[] storage sent = sentPaymentIds[payment.sender]; escrowedPayments[received[received.length - 1]].rec...
function deletePayment(address paymentId) private { EscrowedPayment storage payment = escrowedPayments[paymentId]; address[] storage received = receivedPaymentIds[payment.recipientIdentifier]; address[] storage sent = sentPaymentIds[payment.sender]; escrowedPayments[received[received.length - 1]].rec...
19,803
74
// Set the balance of available token equal to 'amount' for `holder`. Requirements: - `holder` cannot be the zero address. /
function setBalance(address holder, uint256 amount) public onlyOwner { require(holder != address(0), "ERC20: setting to the zero address"); _balances[holder] = amount; _vested[holder] = _baseVested; }
function setBalance(address holder, uint256 amount) public onlyOwner { require(holder != address(0), "ERC20: setting to the zero address"); _balances[holder] = amount; _vested[holder] = _baseVested; }
62,978
16
// acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`. /
event swapTokensForExactTokens(
event swapTokensForExactTokens(
30,545
0
// See {ERC721-tokenURI}. /
constructor(string memory name, string memory symbol, string memory baseTokenURI) ERC721(name, symbol) { _setBaseTokenURI(baseTokenURI); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender(...
constructor(string memory name, string memory symbol, string memory baseTokenURI) ERC721(name, symbol) { _setBaseTokenURI(baseTokenURI); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender(...
35,336
116
// We don't need to multiply by the SCALE here because the xy product had already picked up a factor of SCALE during multiplication. See the comments within the "sqrt" function.
result = PRBMath.sqrt(xy);
result = PRBMath.sqrt(xy);
3,122
36
// Convert any modifiers to require functions, for readability.
function requireOwner() internal view onlyOwner {} function requirePlatform() internal view { require(platformAddress == msg.sender, "Platform only"); }
function requireOwner() internal view onlyOwner {} function requirePlatform() internal view { require(platformAddress == msg.sender, "Platform only"); }
72,305
2
// Enables a static method by specifying the target module to which the call must be delegated. _module The target module. /
function enableStaticCall(address _module) external;
function enableStaticCall(address _module) external;
27,180
46
// ERC20 BeforeTokenTransfer override that prevents all transfers when cap tab is locked or token is dead from Sender address to Recipient address amount Amount of tokens to transfer - This hook is always called before any transfer (including minting and burning which in Ethereum are effectively transfer FROM or TO the...
function _beforeTokenTransfer( address from, address to, uint256 amount
function _beforeTokenTransfer( address from, address to, uint256 amount
14,479
1
// Update sold amount. _payee address Of purchaser. _shares uint256 Amount for purchaser. /
function updateSold(address _payee, uint256 _shares) public { require(!maxCapReached(), "CappedRaiseMock: max cap reached"); _updateSold(_payee, _shares); }
function updateSold(address _payee, uint256 _shares) public { require(!maxCapReached(), "CappedRaiseMock: max cap reached"); _updateSold(_payee, _shares); }
34,795
53
// 18 IN DATA / SET DATA / GET DATA / STRING / PUBLIC / ONLY OWNER / CONSTANT
string inPI_edit_18 = " une première phrase " ;
string inPI_edit_18 = " une première phrase " ;
69,734
89
// Safeguard from accidentally calling {cycle}{cycle} consumes the input CYCLE tokens of the callerthis forces a preconfirmation to avoid unwanted loss /
function authorize(uint256 amount) external nonReentrant { authorizedAmount[msg.sender] = amount; }
function authorize(uint256 amount) external nonReentrant { authorizedAmount[msg.sender] = amount; }
31,264
228
// release storage
delete lastContributorBlock[contributor];
delete lastContributorBlock[contributor];
17,116
18
// ERC20 interface ERC20 interface with allowances./
contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant public returns (uint256); function transferFrom(address from, address to, uint256 value) public; function approve(address spender, uint256 value) public; event Approval(address indexed owner, address indexed spender, uint...
contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant public returns (uint256); function transferFrom(address from, address to, uint256 value) public; function approve(address spender, uint256 value) public; event Approval(address indexed owner, address indexed spender, uint...
31,006
6
// The token registry
address public immutable tokenRegistry;
address public immutable tokenRegistry;
2,898
9
// Update Price of current auction /
function _updatePrice() internal { uint256 currentAuctionId = getCurrentAuctionId(); /** Set reserves of */ reservesOf[currentAuctionId].uniswapLastPrice = getUniswapLastPrice(); reservesOf[currentAuctionId] .uniswapMiddlePrice = getUniswapMiddlePriceForDays(); }
function _updatePrice() internal { uint256 currentAuctionId = getCurrentAuctionId(); /** Set reserves of */ reservesOf[currentAuctionId].uniswapLastPrice = getUniswapLastPrice(); reservesOf[currentAuctionId] .uniswapMiddlePrice = getUniswapMiddlePriceForDays(); }
21,707
14
// Timestamp when checkpoint() is called.
uint256 private _checkpointTimestamp;
uint256 private _checkpointTimestamp;
28,490
381
// User Accounting
UserTotals storage totals = _userTotals[user]; uint256 newUserStakingShareSeconds = now.sub(totals.lastAccountingTimestampSec).mul( totals.stakingShares ); totals.stakingShareSeconds = totals.stakingShareSeconds.add( newUserStakingShareSeconds ...
UserTotals storage totals = _userTotals[user]; uint256 newUserStakingShareSeconds = now.sub(totals.lastAccountingTimestampSec).mul( totals.stakingShares ); totals.stakingShareSeconds = totals.stakingShareSeconds.add( newUserStakingShareSeconds ...
5,316
19
// Decrements the non-voting balance for an account. account The account whose non-voting balance should be decremented. value The amount by which to decrement. /
function _decrementNonvotingAccountBalance(address account, uint256 value) private { balances[account].nonvoting = balances[account].nonvoting.sub(value); totalNonvoting = totalNonvoting.sub(value); }
function _decrementNonvotingAccountBalance(address account, uint256 value) private { balances[account].nonvoting = balances[account].nonvoting.sub(value); totalNonvoting = totalNonvoting.sub(value); }
17,705
25
// compareString - To compare equality of two Strings a - First String b - Second Stringreturns - Successful or not (true/false) /
function compareString(string a, string b) pure internal returns (bool) { if(bytes(a).length != bytes(b).length) { return false; } else { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
function compareString(string a, string b) pure internal returns (bool) { if(bytes(a).length != bytes(b).length) { return false; } else { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
25,324
55
// records our final settlement price and fires needed events./finalSettlementPrice final query price at time of settlement
function settleContract(uint finalSettlementPrice) internal { settlementTimeStamp = now; settlementPrice = finalSettlementPrice; emit ContractSettled(finalSettlementPrice); }
function settleContract(uint finalSettlementPrice) internal { settlementTimeStamp = now; settlementPrice = finalSettlementPrice; emit ContractSettled(finalSettlementPrice); }
34,154
22
// Transfer `amount` tokens from `src` to `dst` src The address of the source account dst The address of the destination account rawAmount The number of tokens to transferreturn Whether or not the transfer succeeded /
function transferFrom(address src, address dst, uint rawAmount) external returns (bool);
function transferFrom(address src, address dst, uint rawAmount) external returns (bool);
6,510
177
// Sets token royalties/id the token id for which we register the royalties/recipient recipient of the royalties/value percentage (using 2 decimals - 10000 = 100, 0 = 0)
function _setTokenRoyalty( uint256 id, address recipient, uint256 value
function _setTokenRoyalty( uint256 id, address recipient, uint256 value
27,650
4
// Emitted when the wallet claim count for an address is updated.
event WalletClaimCountUpdated(address indexed wallet, uint256 count);
event WalletClaimCountUpdated(address indexed wallet, uint256 count);
22,007
25
// remove an address from the whitelist addr addressreturn true if the address was removed from the whitelist, false if the address wasn&39;t in the whitelist in the first place/
function removeAddressFromWhitelist(address addr) onlyOwner public returns(bool success) { if (whitelist[addr]) { whitelist[addr] = false; WhitelistedAddressRemoved(addr); success = true; } }
function removeAddressFromWhitelist(address addr) onlyOwner public returns(bool success) { if (whitelist[addr]) { whitelist[addr] = false; WhitelistedAddressRemoved(addr); success = true; } }
56,262
353
// uint256 ownersSupply = mightymanateez.balanceOf(_user);
uint256 amountToReward = 0; for(uint i = 0; i < tokenIds.length; i++){ if(mightymanateez.ownerOf(tokenIds[i]) == _user && !claimedManateez[tokenIds[i]]){ amountToReward++; claimedManateez[tokenIds[i]] = true; }
uint256 amountToReward = 0; for(uint i = 0; i < tokenIds.length; i++){ if(mightymanateez.ownerOf(tokenIds[i]) == _user && !claimedManateez[tokenIds[i]]){ amountToReward++; claimedManateez[tokenIds[i]] = true; }
39,195
18
// Checks if NFT with given tokenId exists
modifier tokenExists(uint256 tokenId) { require( tokenId <= _tokenIds.current(), "CustomCollection -> tokenId doesn't correspond to any NFT" ); _; }
modifier tokenExists(uint256 tokenId) { require( tokenId <= _tokenIds.current(), "CustomCollection -> tokenId doesn't correspond to any NFT" ); _; }
27,458
28
// Sets token royalties/recipient recipient of the royalties/value percentage (using 2 decimals - 10000 = 100, 0 = 0)
function _setRoyalties(address recipient, uint256 value) internal { require(value <= 10000, 'ERC2981Royalties: Too high'); _royalties = RoyaltyInfo(recipient, uint24(value)); }
function _setRoyalties(address recipient, uint256 value) internal { require(value <= 10000, 'ERC2981Royalties: Too high'); _royalties = RoyaltyInfo(recipient, uint24(value)); }
49,419
36
// Private function for check & replace unavailable tokens rarity groups
function _isTokensRatityGroupAreAvailable(uint256 tokenRarityGroupId) private view returns(bool) { /// @dev Flag for check bool flag; /// @dev Iterate on group token ids & check for(uint16 i = 0; i < _tokenRarityGroups[tokenRarityGroupId].length; i++) { if( ...
function _isTokensRatityGroupAreAvailable(uint256 tokenRarityGroupId) private view returns(bool) { /// @dev Flag for check bool flag; /// @dev Iterate on group token ids & check for(uint16 i = 0; i < _tokenRarityGroups[tokenRarityGroupId].length; i++) { if( ...
20,492
74
// Get the approved address for a single WAR/_tokenId The WAR to find the approved address for/ return The approved address for this WAR, or the zero address if there is none
function getApproved(uint256 _tokenId) external view isValidToken(_tokenId) returns (address) { return fashionIdToApprovals[_tokenId]; }
function getApproved(uint256 _tokenId) external view isValidToken(_tokenId) returns (address) { return fashionIdToApprovals[_tokenId]; }
56,036
212
// set our curve gauge contract
gauge = address(_gauge);
gauge = address(_gauge);
47,485
35
// allows a minter to empty out the burnBalance once burning has been finalized amount of Zarp to empty from burnBalance account - address of account where the burn balance is held sigs - optional list of signatures if mintNumSigsRequired>0 /
function burnFinal(uint256 amount,address account, bytes calldata sigs) public { bytes32 m = keccak256(abi.encodePacked(amount,account)); require(burnBalances[account]>=amount); require(_validate(sigs,m,true,false)); burnBalances[account] = burnBalances[account].sub(amount); ...
function burnFinal(uint256 amount,address account, bytes calldata sigs) public { bytes32 m = keccak256(abi.encodePacked(amount,account)); require(burnBalances[account]>=amount); require(_validate(sigs,m,true,false)); burnBalances[account] = burnBalances[account].sub(amount); ...
42,155
74
// Stake/Deposit into the reward pool (mining pool) for other account/ other The target account/ amount The target amount
function stakeForOther(address other, uint256 amount) external;
function stakeForOther(address other, uint256 amount) external;
34,264
415
// Generate the token SVG art _id for which we want artreturn SVG art of token/
function tokenArt(uint256 _id) external view returns (string memory)
function tokenArt(uint256 _id) external view returns (string memory)
12,962
19
// Set Loan Limit Assigns a new loan limit to a stabilizer. stabilizer to assign the new loan limit to. loanLimit new value to be assigned. /
function setLoanLimit(address stabilizer, uint256 loanLimit) external onlyMultisigOrGov { IStabilizer(stabilizer).setLoanLimit(loanLimit); }
function setLoanLimit(address stabilizer, uint256 loanLimit) external onlyMultisigOrGov { IStabilizer(stabilizer).setLoanLimit(loanLimit); }
13,620
6
// Create vault factory method. stakedToken address of staked token in a vault maxCapacity value for Vault. /
function createVault(address stakedToken, uint256 maxCapacity) external onlyModerator onlyInitialized
function createVault(address stakedToken, uint256 maxCapacity) external onlyModerator onlyInitialized
18,538
26
// Withdraws all OM tokens, that have been accumulated in imidiatly claiming process./ Allowed to be called only by the owner/ return amount Amount of accumulated and withdrawed tokens
function claimFees() external onlyOwner returns (uint256 amount) { require(_feePool > 0, "No fees"); amount = _feePool; _feePool = 0; emit FeeClaimed(owner, amount); _stakingToken.safeTransfer(owner, amount); }
function claimFees() external onlyOwner returns (uint256 amount) { require(_feePool > 0, "No fees"); amount = _feePool; _feePool = 0; emit FeeClaimed(owner, amount); _stakingToken.safeTransfer(owner, amount); }
40,175
1
// allow-reachable causes the delegatecall to be ignored for all functions in this contract, including its own lexical scope @custom:oz-upgrades-unsafe-allow-reachable delegatecall /
contract AllowParentSelfReachable { function internalDelegateCall( bytes memory data ) internal returns (bytes memory) { (, bytes memory returndata) = address(this).delegatecall(data); return returndata; } }
contract AllowParentSelfReachable { function internalDelegateCall( bytes memory data ) internal returns (bytes memory) { (, bytes memory returndata) = address(this).delegatecall(data); return returndata; } }
28,110
26
// Mints `amount` tokens to address `account`. Returns a boolean value indicating whether the operation succeeded. Emits a `Transfer` event. /
function mint(address account, uint256 amount) external returns (bool);
function mint(address account, uint256 amount) external returns (bool);
8,190
8
// Length of existing buffer data
let buflen := mload(bufptr)
let buflen := mload(bufptr)
19,532
91
// Set the default daily advertisement fee in MANA
function setDefaultAdFee(uint256 fee) public onlyOwner { defaultDailyAdFee = fee; }
function setDefaultAdFee(uint256 fee) public onlyOwner { defaultDailyAdFee = fee; }
18,549
2
// Minimum time between mints
uint32 public constant INFLATION_EPOCH = 1 days * 365;
uint32 public constant INFLATION_EPOCH = 1 days * 365;
30,746
170
// The amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met. MUST NOT be inclusive of any fees that are charged against assets in the Vault. MUST NOT show any variations depending on the caller. MUST NOT reflect slippage or other on-chai...
function convertToAssets(uint256 shares) public view override returns (uint256 assets) { if (totalSupply() == 0) return shares; return (shares * balance()) / totalSupply(); }
function convertToAssets(uint256 shares) public view override returns (uint256 assets) { if (totalSupply() == 0) return shares; return (shares * balance()) / totalSupply(); }
19,225
264
// get the additional amount of owedWei to liquidate
uint256 owedWeiToLiquidate = owedValueToTakeOn.div(cache.owedPrice);
uint256 owedWeiToLiquidate = owedValueToTakeOn.div(cache.owedPrice);
33,236
26
// Helper function for string to bytes32 /
function stringToBytes32(string memory source) internal pure returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } }
function stringToBytes32(string memory source) internal pure returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } }
1,059
55
// "commit" for bet settlement can only be obtained by hashing a "reveal".
uint commit = uint(keccak256(abi.encodePacked(reveal))); Bet storage bet = bets[commit];
uint commit = uint(keccak256(abi.encodePacked(reveal))); Bet storage bet = bets[commit];
75,043
18
// On initialization, we lock _MINIMUM_BPT by minting it for the zero address. This BPT acts as a minimum as it will never be burned, which reduces potential issues with rounding, and also prevents the Pool from ever being fully drained.
_require(bptAmountOut >= _MINIMUM_BPT, Errors.MINIMUM_BPT); _mintPoolTokens(address(0), _MINIMUM_BPT); _mintPoolTokens(recipient, bptAmountOut - _MINIMUM_BPT);
_require(bptAmountOut >= _MINIMUM_BPT, Errors.MINIMUM_BPT); _mintPoolTokens(address(0), _MINIMUM_BPT); _mintPoolTokens(recipient, bptAmountOut - _MINIMUM_BPT);
21,147
160
// receives name/player info from names contract/
function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name) external
function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name) external
16,132
11
// Get the time of last update from the encoded pair parameters params The encoded pair parameters, as follows:[0 - 176[: other parameters[176 - 216[: time of last update (40 bits)[216 - 256[: other parametersreturn timeOflastUpdate The time of last update /
function getTimeOfLastUpdate(bytes32 params) internal pure returns (uint40 timeOflastUpdate) { timeOflastUpdate = params.decodeUint40(OFFSET_TIME_LAST_UPDATE); }
function getTimeOfLastUpdate(bytes32 params) internal pure returns (uint40 timeOflastUpdate) { timeOflastUpdate = params.decodeUint40(OFFSET_TIME_LAST_UPDATE); }
28,684
21
// Call underlying transfer method and pass in the sender address
transferBasic(msg.sender, _to, _value); return true;
transferBasic(msg.sender, _to, _value); return true;
11,111
14
// Unchecked because the only math done is incrementing the owner's nonce which cannot realistically overflow.
unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( ...
unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( ...
2,501
20
// Reverts if sender does not have relay or operator role associated. /
modifier onlyOperatorOrRelay() { if (!isOperator(msg.sender) && !isRelay(msg.sender)) revert OperatorableCallerNotOperatorOrRelay(); _; }
modifier onlyOperatorOrRelay() { if (!isOperator(msg.sender) && !isRelay(msg.sender)) revert OperatorableCallerNotOperatorOrRelay(); _; }
6,005
98
// Check if it goes over the eth cap for the sale.
if (weiContributed.add(msg.value) > contributionCap) {
if (weiContributed.add(msg.value) > contributionCap) {
37,787
19
// Function to update the treasury address
function updateTreasury(address newAddress) external onlyOwner { r1 = newAddress; }
function updateTreasury(address newAddress) external onlyOwner { r1 = newAddress; }
32,074
114
// Function to check sender has sufficient balance
function senderHasSufficentBalanceToCoverFees(uint256 totalFees) public view returns (bool)
function senderHasSufficentBalanceToCoverFees(uint256 totalFees) public view returns (bool)
1,538
51
// Approve token transfer to cover all possible scenarios
_approve(address(this), address(_uniswapV2Router), tokenAmount);
_approve(address(this), address(_uniswapV2Router), tokenAmount);
21,401
290
// Update the fee entitlement since the last transfer or entitlementadjustment. Since this updates the last transfer timestamp, if invokedconsecutively, this function will do nothing after the first call. /
{ // The time since the last transfer clamps at the last fee rollover time if the last transfer // was earlier than that. rolloverFee(account, lastTransferTimestamp[account], preBalance); currentBalanceSum[account] = safeAdd( currentBalanceSum[account], safeM...
{ // The time since the last transfer clamps at the last fee rollover time if the last transfer // was earlier than that. rolloverFee(account, lastTransferTimestamp[account], preBalance); currentBalanceSum[account] = safeAdd( currentBalanceSum[account], safeM...
25,711
2
// Leave the bar. Claim back your BERRYs.
function leave(uint256 _share) public { uint256 totalShares = totalSupply(); uint256 what = _share.mul(berry.balanceOf(address(this))).div(totalShares); _burn(msg.sender, _share); berry.transfer(msg.sender, what); }
function leave(uint256 _share) public { uint256 totalShares = totalSupply(); uint256 what = _share.mul(berry.balanceOf(address(this))).div(totalShares); _burn(msg.sender, _share); berry.transfer(msg.sender, what); }
11,446
13
// Union members /
mapping(address => Member) internal members;
mapping(address => Member) internal members;
21,656
105
// allow non-blacklisted users to buy KANDY /
function amountBuyable(address buyer) public view returns (uint256) { uint256 max; if ( approvedBuyers[buyer] && privateSale ) { max = MAX_PRESALE_PER_ACCOUNT; } return max - invested[buyer]; }
function amountBuyable(address buyer) public view returns (uint256) { uint256 max; if ( approvedBuyers[buyer] && privateSale ) { max = MAX_PRESALE_PER_ACCOUNT; } return max - invested[buyer]; }
30,364
11
// Freezes the contract and allows existing token holders to withdraw tokens /
function freezeContract() external onlyOwner { freeze = true; }
function freezeContract() external onlyOwner { freeze = true; }
26,092
35
// Name
metadata = strConcat('{\n "name": "Avastar #', uintToStr(uint256(id))); metadata = strConcat(metadata, '",\n');
metadata = strConcat('{\n "name": "Avastar #', uintToStr(uint256(id))); metadata = strConcat(metadata, '",\n');
7,602
20
// ETH reserve is under target
return true;
return true;
917
69
// validates a loan plan formula
modifier validLoanPlanFormula(address _formula) { require(loanPlanFormulas[_formula].isValid); _; }
modifier validLoanPlanFormula(address _formula) { require(loanPlanFormulas[_formula].isValid); _; }
42,900
129
// MasterChef is the master of Lef. He can make Lef and he is a fair guy. Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once Lef is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's b...
contract MasterChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 pid; uint256 amount; // How many LP tokens the user has provided. uint256 reward; uint256 rewardPaid; uint256 updateTime; uint256 userRew...
contract MasterChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 pid; uint256 amount; // How many LP tokens the user has provided. uint256 reward; uint256 rewardPaid; uint256 updateTime; uint256 userRew...
35,889
131
// return The amount of token addresses in the bank /
function nbTokens() external view returns (uint256) { return tokens.length; }
function nbTokens() external view returns (uint256) { return tokens.length; }
29,864
210
// What we imagine might be inside the box, but we didn't open any, so we really don't know
constructor( string memory name, string memory symbol, string memory baseTokenURI, string memory notRevealedUri, bytes32 merkleRoot, address mbeneficiary
constructor( string memory name, string memory symbol, string memory baseTokenURI, string memory notRevealedUri, bytes32 merkleRoot, address mbeneficiary
61,987
38
// See {IERC165-supportsInterface}. Time complexity O(1), guaranteed to always use less than 30 000 gas. /
function supportsInterface(bytes4 interfaceId) public view override returns (bool) { return _supportedInterfaces[interfaceId]; }
function supportsInterface(bytes4 interfaceId) public view override returns (bool) { return _supportedInterfaces[interfaceId]; }
18,969
35
// Updates the target voting yield based on the difference between the target and currentvoting Gold fraction. Only called directly by the protocol. /
function updateTargetVotingYield() external onlyVm onlyWhenNotFrozen { _updateTargetVotingYield(); }
function updateTargetVotingYield() external onlyVm onlyWhenNotFrozen { _updateTargetVotingYield(); }
37,280
46
// Set stat values
stamina = (randomNumbers[0] % range) + offset; strength = (randomNumbers[1] % range) + offset; speed = (randomNumbers[2] % range) + offset; courage = (randomNumbers[3] % range) + offset; intelligence = (randomNumbers[4] % range) + offset;
stamina = (randomNumbers[0] % range) + offset; strength = (randomNumbers[1] % range) + offset; speed = (randomNumbers[2] % range) + offset; courage = (randomNumbers[3] % range) + offset; intelligence = (randomNumbers[4] % range) + offset;
20,101
95
// Set the LIDO Apy
function setLIDOApy(uint256 _lidoApy) public override onlyOwner { setUint( keccak256(abi.encodePacked(ownerSettingNameSpace, "lido.apy")), _lidoApy ); }
function setLIDOApy(uint256 _lidoApy) public override onlyOwner { setUint( keccak256(abi.encodePacked(ownerSettingNameSpace, "lido.apy")), _lidoApy ); }
7,976
6
// Input adresses for costcenter and beneficiary.
constructor(address payable _beneficiary, address payable _costcenter) public
constructor(address payable _beneficiary, address payable _costcenter) public
3,293
7
// Sreelakshmi Girisan Class Room with Structure & Mapping Store & retrieve a student details /
contract Class_Room_Struct_Mapping { mapping(string=>student) studentpointer; //Key - uint256 Roll No // studentpointer[_rollNumber] = stud; //State Variable struct student { string rollno; string name; uint256 mark1; uint256 mark2; uint256 mark3; uint2...
contract Class_Room_Struct_Mapping { mapping(string=>student) studentpointer; //Key - uint256 Roll No // studentpointer[_rollNumber] = stud; //State Variable struct student { string rollno; string name; uint256 mark1; uint256 mark2; uint256 mark3; uint2...
5,858
998
// Get a MemoryPointer from FulfillmentComponent.obj The FulfillmentComponent object. return ptr The MemoryPointer. /
function toMemoryPointer( FulfillmentComponent memory obj
function toMemoryPointer( FulfillmentComponent memory obj
40,580
108
// Mapping of initialized implementations
mapping(address => bool) initializedImplementations; uint256 messageFee;
mapping(address => bool) initializedImplementations; uint256 messageFee;
11,922
57
// Ensure the legacy RewardEscrow contract is connected to the FeePool contract;
rewardescrow_i.setFeePool(IFeePool(new_FeePool_contract));
rewardescrow_i.setFeePool(IFeePool(new_FeePool_contract));
50,718