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
266
// sOHM
interface IsOlympus { function DOMAIN_SEPARATOR() external view returns (bytes32); function INDEX() external view returns (uint256); function PERMIT_TYPEHASH() external view returns (bytes32); function allowance(address owner_, address spender) external view returns (uint256); function approve(addre...
interface IsOlympus { function DOMAIN_SEPARATOR() external view returns (bytes32); function INDEX() external view returns (uint256); function PERMIT_TYPEHASH() external view returns (bytes32); function allowance(address owner_, address spender) external view returns (uint256); function approve(addre...
22,917
4
// User should not spend more than the gas price max
weiGasPrice = weiGasPriceMax;
weiGasPrice = weiGasPriceMax;
70,030
201
// Send the registration fee
if (total > 0) { domain.owner.transfer(total); }
if (total > 0) { domain.owner.transfer(total); }
46,124
25
// return The address of the implementation. /
function implementation() external ifAdmin returns (address) { return _implementation(); }
function implementation() external ifAdmin returns (address) { return _implementation(); }
10,794
0
// Is the contract paused?
bool public isPaused;
bool public isPaused;
34,547
76
// Transfer back deposit.
if (Loans[_loanID].Loan_Info.Payments_Missed < Payments_Missed_Max[Loans[_loanID].Payment_Interval]) { uint _amountTransferredIn = Loans[_loanID].Collateral_Supplied; uint _percentageToReturn = Loans[_loanID].Notional_Supplied.mul(100).div(Loans[_loanID].Notional_Requested); ...
if (Loans[_loanID].Loan_Info.Payments_Missed < Payments_Missed_Max[Loans[_loanID].Payment_Interval]) { uint _amountTransferredIn = Loans[_loanID].Collateral_Supplied; uint _percentageToReturn = Loans[_loanID].Notional_Supplied.mul(100).div(Loans[_loanID].Notional_Requested); ...
18,944
72
// calc fee from remaining principal
_fee = stakeValue.div(fee); _devFee = _fee.div(devFee); _refFee = _fee.div(refFee); _profit = 0; _principal = stakeValue.sub(_fee);//sub fee from remaining principal
_fee = stakeValue.div(fee); _devFee = _fee.div(devFee); _refFee = _fee.div(refFee); _profit = 0; _principal = stakeValue.sub(_fee);//sub fee from remaining principal
13,216
271
// Set some Clowns aside /
function reserveClowns() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 20; i++) { _safeMint(msg.sender, supply + i); } }
function reserveClowns() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 20; i++) { _safeMint(msg.sender, supply + i); } }
27,622
100
// toggle swap back (fees)
bool inSwapAndLiquify; uint256 public tokensForLiquidity; uint256 public tokensForOperations;
bool inSwapAndLiquify; uint256 public tokensForLiquidity; uint256 public tokensForOperations;
14,275
61
// Ensure the amount is less than the max price
require(price < MAX_SALE_PRICE, 'Maximum sale price exceeded');
require(price < MAX_SALE_PRICE, 'Maximum sale price exceeded');
14,832
12
// Require that the sender is the nounders DAO. /
modifier onlyNoundersDAO() { require(msg.sender == noundersDAO, 'Sender is not the nounders DAO'); _; }
modifier onlyNoundersDAO() { require(msg.sender == noundersDAO, 'Sender is not the nounders DAO'); _; }
15,636
23
// Run over all conditional transactions
uint minTxIndex = 0; bytes memory txData = new bytes(ExchangeData.TX_DATA_AVAILABILITY_SIZE); for (uint i = 0; i < block_auxiliaryData.length; i++) { uint txIndex; ExchangeData.TransactionType txType; if (i < header.depositSize) { ...
uint minTxIndex = 0; bytes memory txData = new bytes(ExchangeData.TX_DATA_AVAILABILITY_SIZE); for (uint i = 0; i < block_auxiliaryData.length; i++) { uint txIndex; ExchangeData.TransactionType txType; if (i < header.depositSize) { ...
27,525
228
// Copies a piece of memory to another location. _dest Destination location. _src Source location. _len Length of memory to copy. /
function memcpy(uint _dest, uint _src, uint _len) private pure { uint dest = _dest; uint src = _src; uint len = _len; for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } ...
function memcpy(uint _dest, uint _src, uint _len) private pure { uint dest = _dest; uint src = _src; uint len = _len; for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } ...
7,829
167
// Hook that is called after a set of serially-ordered token ids have been transferred. This includesminting. startTokenId - the first token id to be transferredquantity - the amount to be transferred Calling conditions: - when `from` and `to` are both non-zero.- `from` and `to` are never both zero. /
function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity
function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity
11,082
225
// event
emit MintBonuses(mintedTokenID, requiredValue, thisRefBonus, thisUserPoolBonus, thisVipPoolBonus, thisCommissionPoolBonus);
emit MintBonuses(mintedTokenID, requiredValue, thisRefBonus, thisUserPoolBonus, thisVipPoolBonus, thisCommissionPoolBonus);
18,886
2
// the total amount that has been claimed
uint256 claimedAmount; uint256 startTime; uint256 cliffTime; uint256 endTime; uint256 cliffWeeks;
uint256 claimedAmount; uint256 startTime; uint256 cliffTime; uint256 endTime; uint256 cliffWeeks;
13,913
54
// Library for managingtypes. Sets have the following properties: - Elements are added, removed, and checked for existence in constant time(O(1)).- Elements are enumerated in O(n). No guarantees are made on the ordering. ```
* contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * }
* contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * }
174
72
// Position id/Position ID/addr any address/tickLower Tick lower price bound/tickUpper Tick upper price bound/ return ABI encode
function positionKey( address addr, int24 tickLower, int24 tickUpper
function positionKey( address addr, int24 tickLower, int24 tickUpper
27,283
169
// Transfer XVS to the user Note: If there is not enough XVS, we do not perform the transfer all. user The address of the user to transfer XVS to amount The amount of XVS to (possibly) transferreturn The amount of XVS which was NOT transferred to the user /
function grantXVSInternal(address user, uint amount) internal returns (uint) { XVS xvs = XVS(getXVSAddress()); uint venusRemaining = xvs.balanceOf(address(this)); if (amount > 0 && amount <= venusRemaining) { xvs.transfer(user, amount); return 0; } ret...
function grantXVSInternal(address user, uint amount) internal returns (uint) { XVS xvs = XVS(getXVSAddress()); uint venusRemaining = xvs.balanceOf(address(this)); if (amount > 0 && amount <= venusRemaining) { xvs.transfer(user, amount); return 0; } ret...
43,654
16
// extra fees from users type 1
uint120 extraFees1AllocationTillNow = _applyPercentage(extraFees1Allocation, unlockPercentages[currentUnlock]); uint120 extraFee1 = extraFees1AllocationTillNow - extraFees1AllocationUncollectable; extraFees1AllocationUncollectable = extraFees1AllocationTillNow; extraFee = extraFee1 + ex...
uint120 extraFees1AllocationTillNow = _applyPercentage(extraFees1Allocation, unlockPercentages[currentUnlock]); uint120 extraFee1 = extraFees1AllocationTillNow - extraFees1AllocationUncollectable; extraFees1AllocationUncollectable = extraFees1AllocationTillNow; extraFee = extraFee1 + ex...
13,561
67
// MaxTxn [END] //LockTrade [START] /
function isTradeLocked() public view returns (bool) { return tradeLocked; }
function isTradeLocked() public view returns (bool) { return tradeLocked; }
21,240
98
// Returns the total credits and debits for a given address
function creditsAndDebits(address _addr) public view returns (uint256 _credits, uint256 _debits) { User memory _user = users[_addr]; Airdrop memory _airdrop = airdrops[_addr]; _credits = _airdrop.airdrops + _user.rolls + _user.deposits; _debits = _user.payouts; }
function creditsAndDebits(address _addr) public view returns (uint256 _credits, uint256 _debits) { User memory _user = users[_addr]; Airdrop memory _airdrop = airdrops[_addr]; _credits = _airdrop.airdrops + _user.rolls + _user.deposits; _debits = _user.payouts; }
13,947
42
// Allows the owner to enable the trading. This can not be undone /
function startTrading() public onlyOwner { tradingStarted = true; }
function startTrading() public onlyOwner { tradingStarted = true; }
64,159
23
// ```==== /
abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** ...
abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** ...
4,808
43
// instantiates contract and rarity tables /
constructor() ERC721("ShatteredEon", "Colonists") { auth = msg.sender; admins[msg.sender] = true; // Saves users gas by making lookup O(1) // A.J. Walker's Alias Algorithm // Credit to WolfGame devs // colonist // background rarities[0] = [255, 255, 2...
constructor() ERC721("ShatteredEon", "Colonists") { auth = msg.sender; admins[msg.sender] = true; // Saves users gas by making lookup O(1) // A.J. Walker's Alias Algorithm // Credit to WolfGame devs // colonist // background rarities[0] = [255, 255, 2...
69,523
1
// The fixed amount of tokens stored in an unsigned integer type variable.
uint256 public totalSupply = 1000000;
uint256 public totalSupply = 1000000;
9,228
174
// Pay the miners
for (i = 0; i < 5; i++) { TellorTransfer.doTransfer(self, address(this), a[i].miner, 5e18 + self.uintVars[keccak256("currentTotalTips")] / 5); }
for (i = 0; i < 5; i++) { TellorTransfer.doTransfer(self, address(this), a[i].miner, 5e18 + self.uintVars[keccak256("currentTotalTips")] / 5); }
15,407
7
// a successful voted proposal will be waited to execute within this timeframeafter this /
uint public waitingForRatifyNoOfBlock;
uint public waitingForRatifyNoOfBlock;
9,946
353
// Getter for premium in underlying tokens that can be redeemed at the end of the period of the deposit _amount the amount of underlying depositedreturn the number of underlying of the ibt deposited that will be redeemable /
function getPremiumPerUnderlyingDeposited(uint256 _amount) external view returns (uint256);
function getPremiumPerUnderlyingDeposited(uint256 _amount) external view returns (uint256);
25,428
266
// Compute proportional transfer amounts
fillResults.takerAssetFilledAmount = takerAssetFilledAmount; fillResults.makerAssetFilledAmount = LibMath.safeGetPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.makerAssetAmount ); fillResults.makerFeePaid = LibMath.safeGetPar...
fillResults.takerAssetFilledAmount = takerAssetFilledAmount; fillResults.makerAssetFilledAmount = LibMath.safeGetPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.makerAssetAmount ); fillResults.makerFeePaid = LibMath.safeGetPar...
39,523
11
// onlyFoundation or ThirdParty can refuse
function refuse (uint256 id) public returns (bool) { require(msg.sender == Foundation || msg.sender == ThirdParty); Proposal storage p = Proposals[id]; require(p.close == false); require(p.approvalByFoundation == 0 || p.approvalByThirdParty == 0); if (msg.sender == F...
function refuse (uint256 id) public returns (bool) { require(msg.sender == Foundation || msg.sender == ThirdParty); Proposal storage p = Proposals[id]; require(p.close == false); require(p.approvalByFoundation == 0 || p.approvalByThirdParty == 0); if (msg.sender == F...
84,518
2
// =================== Modifiers =================
modifier notHold(address _account) { require(balanceOf(_account) == 0, 'account holds > 0 valid token'); _; }
modifier notHold(address _account) { require(balanceOf(_account) == 0, 'account holds > 0 valid token'); _; }
4,675
44
// Verifies the signature
require(_recoverSigner(digest, sig) == inscriber, "Recovered address does not match inscriber"); require(_isApprovedOrOwner(msg.sender, nftAddress, tokenId), "NFT does not belong to msg sender"); uint256 inscriptionId = latestInscriptionId;
require(_recoverSigner(digest, sig) == inscriber, "Recovered address does not match inscriber"); require(_isApprovedOrOwner(msg.sender, nftAddress, tokenId), "NFT does not belong to msg sender"); uint256 inscriptionId = latestInscriptionId;
253
174
// Save the hero class.
heroClasses[numberOfHeroClasses] = _heroType;
heroClasses[numberOfHeroClasses] = _heroType;
18,094
10
// Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previoussubscription if present.Note that accounts with subscriptions may go on to subscribe to other accounts - in this case,subscriptions will not be forwarded. Instead the former subscription's existing entries will still ...
function subscribe(address registrant, address registrantToSubscribe) external;
function subscribe(address registrant, address registrantToSubscribe) external;
23,179
1
// Mapping of call hashes to block timestamps
mapping(bytes32 => uint256) public callTimestamps;
mapping(bytes32 => uint256) public callTimestamps;
37,209
79
// Typed equality. Shortcuts if the pointers are identical, otherwise/ compares type and digest
function equal(bytes29 left, bytes29 right) internal pure returns (bool) { return left == right || (typeOf(left) == typeOf(right) && keccak(left) == keccak(right)); }
function equal(bytes29 left, bytes29 right) internal pure returns (bool) { return left == right || (typeOf(left) == typeOf(right) && keccak(left) == keccak(right)); }
42,468
4
// Initializes the contract with a given `minDelay`. /
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors) public { _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors) public { _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);
3,409
448
// transfer all users balance to this contract
require(cDaiContract.transferFrom(_user, address(this), ERC20(NEW_CDAI_ADDRESS).balanceOf(_user)));
require(cDaiContract.transferFrom(_user, address(this), ERC20(NEW_CDAI_ADDRESS).balanceOf(_user)));
31,285
1
// require stake amount to be greate than 0
require(_amount > 0, "amount cannot be 0");
require(_amount > 0, "amount cannot be 0");
47,728
55
// toGroup needs to have less stCELO than it should
revert RebalanceEnoughStCelo(toGroup, actualToStCelo, expectedToStCelo);
revert RebalanceEnoughStCelo(toGroup, actualToStCelo, expectedToStCelo);
19,179
16
// Check if it is safe to subtract two numbers
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { uint c = a - b; assert(b <= a && c <= a); return c; }
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { uint c = a - b; assert(b <= a && c <= a); return c; }
31,088
40
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
if (returndata.length > 0) {
16,179
144
// wrapper contract
function setPublicWrappingRatio(uint256 _ratioBase100) public governanceLevel(1) { INectar(wUNIv2).setPublicWrappingRatio(_ratioBase100); }
function setPublicWrappingRatio(uint256 _ratioBase100) public governanceLevel(1) { INectar(wUNIv2).setPublicWrappingRatio(_ratioBase100); }
21,938
284
// update the maximum time an option can be created for newMinTime_ the time (in seconds) of maximum possible bet /
function uMNOT(uint256 newMinTime_) external tierOneDelegation { BinaryOptions protocol = BinaryOptions(pA); protocol.setMinT(newMinTime_); }
function uMNOT(uint256 newMinTime_) external tierOneDelegation { BinaryOptions protocol = BinaryOptions(pA); protocol.setMinT(newMinTime_); }
27,215
85
// help debug mining software
function getMintDigest(uint256 nonce, bytes32 challenge_number) public view returns(bytes32 digesttest) { bytes32 digest = keccak256(abi.encodePacked(challenge_number, msg.sender, nonce)); return digest; }
function getMintDigest(uint256 nonce, bytes32 challenge_number) public view returns(bytes32 digesttest) { bytes32 digest = keccak256(abi.encodePacked(challenge_number, msg.sender, nonce)); return digest; }
33,179
36
// give token to sender
yeedToken.transferFrom(tokenOwner, msg.sender, token); FundTransfer(msg.sender, token);
yeedToken.transferFrom(tokenOwner, msg.sender, token); FundTransfer(msg.sender, token);
21,995
43
// by a token by passing in the token's id
function buyToken(uint256 _tokenId) public payable { // check if the function caller is not an zero account address require(msg.sender != address(0)); // check if the token id of the token being bought exists or not require(_exists(_tokenId)); // get the token's owner address tokenOwner = owne...
function buyToken(uint256 _tokenId) public payable { // check if the function caller is not an zero account address require(msg.sender != address(0)); // check if the token id of the token being bought exists or not require(_exists(_tokenId)); // get the token's owner address tokenOwner = owne...
10,026
49
// Read lidoAPR variable /
function getLidoAPR() external view returns (uint16);
function getLidoAPR() external view returns (uint16);
5,137
16
// 14: no partial fills, only offerer or zone can execute
ERC20_TO_ERC1155_FULL_RESTRICTED,
ERC20_TO_ERC1155_FULL_RESTRICTED,
1,491
142
// Allows the contract owner to update the minimum epoch interval./_nextMinimumEpochInterval The minimum number of blocks between epochs.
function updateMinimumEpochInterval(uint256 _nextMinimumEpochInterval) external onlyOwner { // Will be updated next epoch nextMinimumEpochInterval = _nextMinimumEpochInterval; }
function updateMinimumEpochInterval(uint256 _nextMinimumEpochInterval) external onlyOwner { // Will be updated next epoch nextMinimumEpochInterval = _nextMinimumEpochInterval; }
12,408
17
// 通过商品ID获取商品信息
Product storage product = stores[productIdInStore[_productId]][_productId];
Product storage product = stores[productIdInStore[_productId]][_productId];
18,290
207
// SakeMaster is the master of Sake. He can make Sake 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 SAKE is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it'...
contract SakeMaster is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy...
contract SakeMaster is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy...
10,393
21
// BOX INTERVAL
function govUpdatePoolInterval( uint256 _poolIndex, string calldata _oldTitle, uint256 _newInterval
function govUpdatePoolInterval( uint256 _poolIndex, string calldata _oldTitle, uint256 _newInterval
12,801
49
// signatures ECDSA signatures in raw bytes (rsv).
function getSignatureParts( bytes memory signatures) public pure returns ( uint8[] memory vs, bytes32[] memory rs, bytes32[] memory ss)
function getSignatureParts( bytes memory signatures) public pure returns ( uint8[] memory vs, bytes32[] memory rs, bytes32[] memory ss)
52,643
67
// Get number of tokens bought by given investor during reserve stage that arenot yet delivered to him._investor address of investor to get number of outstanding tokensforreturn number of non-delivered tokens given investor bought during reservestage /
function outstandingTokens (address _investor) public view returns (uint256) { return investors [_investor].tokensBought; }
function outstandingTokens (address _investor) public view returns (uint256) { return investors [_investor].tokensBought; }
14,108
14
// the Reward distribution speed supply side of each iToken
mapping(address => uint256) public distributionSupplySpeed;
mapping(address => uint256) public distributionSupplySpeed;
40,449
60
// Change amount from fee to _newFee.
fee = _newFee;
fee = _newFee;
27,085
117
// Max tokens, setup in constructor
uint256 public _totalSupplyCrowdsale = 0; uint256 public _totalSupplyCars = 0;
uint256 public _totalSupplyCrowdsale = 0; uint256 public _totalSupplyCars = 0;
38,654
20
// Deposit is a key data structure used in staking, it represents a unit of stake with its amount, weight and term (time interval) /
struct Deposit { // @dev token amount staked uint256 tokenAmount; // @dev stake weight uint256 weight; // @dev locking period - from uint64 lockedFrom; // @dev locking period - until uint64 lockedUntil; // @dev indicates if the stake was create...
struct Deposit { // @dev token amount staked uint256 tokenAmount; // @dev stake weight uint256 weight; // @dev locking period - from uint64 lockedFrom; // @dev locking period - until uint64 lockedUntil; // @dev indicates if the stake was create...
6,803
6
// scheduleTime and EventType are tightly packed and encoded as bytes32
struct Schedule { // schedule times of cyclic events (used if no schedule is set) mapping(EventType => uint256) lastScheduleTimeOfCyclicEvent; // index of event => bytes32 encoded event mapping(uint256 => bytes32) events; // the length of the schedule, used to determine the end of the schedule u...
struct Schedule { // schedule times of cyclic events (used if no schedule is set) mapping(EventType => uint256) lastScheduleTimeOfCyclicEvent; // index of event => bytes32 encoded event mapping(uint256 => bytes32) events; // the length of the schedule, used to determine the end of the schedule u...
35,276
20
// fetch offset of `packedMetadata` input in calldata
pointer := packedMetadata.offset mstore(
pointer := packedMetadata.offset mstore(
29,611
18
// Set default royalties /
function setRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints) external;
function setRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints) external;
7,656
34
// realize $TOKE earnings for a single Stoned Ape and optionally unstake itif not unstaking, pay a 20% tax to the staked Fed Apesif unstaking, there is a 50% chance all $TOKE is stolen tokenId the ID of the Stoned Ape to claim earnings from unstake whether or not to unstake the Stoned Apereturn owed - the amount of $TO...
function _claimStonedApeFromGrowOperation(uint256 tokenId, bool unstake) internal returns (uint256 owed) { Stake memory _stake = GrowOperation[tokenId]; require(_stake.owner == msg.sender, "msg.sender not stake.owner"); require( !(unstake && block.timestamp - _stake.value < MINIMUM_TO_EXIT), "block.timesta...
function _claimStonedApeFromGrowOperation(uint256 tokenId, bool unstake) internal returns (uint256 owed) { Stake memory _stake = GrowOperation[tokenId]; require(_stake.owner == msg.sender, "msg.sender not stake.owner"); require( !(unstake && block.timestamp - _stake.value < MINIMUM_TO_EXIT), "block.timesta...
40,097
99
// Mint the tokens
_mint(PartnershipsTokenAddress, PartnershipsTokenAmount); _mint(address(this), contractAmount);
_mint(PartnershipsTokenAddress, PartnershipsTokenAmount); _mint(address(this), contractAmount);
5,364
7
// Function returns current (with accrual) total borrows valuereturn Current borrows /
function borrows() external view returns (uint256) { return _accrueInterestVirtual().borrows; }
function borrows() external view returns (uint256) { return _accrueInterestVirtual().borrows; }
8,301
141
// Rescue BBI from the treasuryTax amount/Should only be used in an emergency/_amount The amount of BBI to rescue/_recipient The recipient of the rescued BBI
function rescueTreasuryTaxTokens(uint256 _amount, address _recipient) external onlyOwner
function rescueTreasuryTaxTokens(uint256 _amount, address _recipient) external onlyOwner
1,889
47
// Set Refunder.
function setRefunder(address _refunder) external onlyOwner { refunder = _refunder; }
function setRefunder(address _refunder) external onlyOwner { refunder = _refunder; }
21,837
21
// function to set up a new admin / requires new admin name and address are not blank / requester needs to be an existing admin / newAdminName newAdminAddress / return userName of the newly added admin
function addAdmin(bytes32 newAdminName, address newAdminAddress) public payable onlyValidName(newAdminName) onlyValidAddress(newAdminAddress)
function addAdmin(bytes32 newAdminName, address newAdminAddress) public payable onlyValidName(newAdminName) onlyValidAddress(newAdminAddress)
42,737
12
// add a callback function for a state/ _stateId The ID of the state to add a callback function for/ _callback The callback function to add
function addCallback(bytes32 _stateId, function() internal _callback) internal { states[_stateId].transitionCallbacks.push(_callback); }
function addCallback(bytes32 _stateId, function() internal _callback) internal { states[_stateId].transitionCallbacks.push(_callback); }
36,521
50
// `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/
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}("");
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}("");
36,614
195
// Lib Allow List/LI.FI (https:li.fi)/Library for managing and accessing the conract address allow list
library LibAllowList { /// Storage /// bytes32 internal constant NAMESPACE = keccak256("com.lifi.library.allow.list"); struct AllowListStorage { mapping(address => bool) allowlist; mapping(bytes4 => bool) selectorAllowList; address[] contracts; } /// @dev Adds a con...
library LibAllowList { /// Storage /// bytes32 internal constant NAMESPACE = keccak256("com.lifi.library.allow.list"); struct AllowListStorage { mapping(address => bool) allowlist; mapping(bytes4 => bool) selectorAllowList; address[] contracts; } /// @dev Adds a con...
8,904
31
// user(as owner) needs to give approval to this contract (spender) in USDZ contract.
tokenA.transferFrom(msg.sender, address(this), tokenADeopsit); if(!firstTx[_msgSender()]) { address upline = viewMyUplinesAddress(); tokenA.transfer(_msgSender(), tokenADeopsit*introducerReward100x/10000); if(upline != address(0)) tokenA.transfer(upli...
tokenA.transferFrom(msg.sender, address(this), tokenADeopsit); if(!firstTx[_msgSender()]) { address upline = viewMyUplinesAddress(); tokenA.transfer(_msgSender(), tokenADeopsit*introducerReward100x/10000); if(upline != address(0)) tokenA.transfer(upli...
23,739
7
// 20160 minutes (two weeks)
uint public deadline;
uint public deadline;
34,939
67
// buy core
buyCore(_pID, 2, _eventData_);
buyCore(_pID, 2, _eventData_);
35,629
1
// check number of bytes returned from last function call
switch returndatasize
switch returndatasize
13,440
495
// check that the reserve is enabled for borrowing
require(core.isReserveBorrowingEnabled(_reserve), "Reserve is not enabled for borrowing");
require(core.isReserveBorrowingEnabled(_reserve), "Reserve is not enabled for borrowing");
51,628
146
// Validates the sender is Lockup contract. /
addressValidator().validateAddress(msg.sender, config().lockup());
addressValidator().validateAddress(msg.sender, config().lockup());
64,109
24
// the claim success event, used for whent he claim has successfully be used
event ClaimSuccess(address _sender);
event ClaimSuccess(address _sender);
22,995
28
// Only 1 value absolut reward
require(_rewardPathTo[0].length == 1, "TokenSwapModule: Error 105");
require(_rewardPathTo[0].length == 1, "TokenSwapModule: Error 105");
5,480
19
// Get the state of the player's NFT.
uint256 nftTokenIdOfPlayer = nftHolders[msg.sender]; CharacterAttributes storage player = nftHolderAttributes[ nftTokenIdOfPlayer ]; console.log( "\nPlayer w/ character %s about to offer Milk Prodiction. Has %s milk and %s milkProduced", player.name, ...
uint256 nftTokenIdOfPlayer = nftHolders[msg.sender]; CharacterAttributes storage player = nftHolderAttributes[ nftTokenIdOfPlayer ]; console.log( "\nPlayer w/ character %s about to offer Milk Prodiction. Has %s milk and %s milkProduced", player.name, ...
7,240
104
// Returns a Fraction128 that is equal to a - (1/2)^d aThe Fraction128dThe power of (1/2)returnThe result /
function sub1Over( Fraction.Fraction128 memory a, uint128 d ) internal pure returns (Fraction.Fraction128 memory)
function sub1Over( Fraction.Fraction128 memory a, uint128 d ) internal pure returns (Fraction.Fraction128 memory)
35,087
130
// https:docs.peri.finance/contracts/source/interfaces/iperiFinance
interface IPeriFinance { // Views function getRequiredAddress(bytes32 contractName) external view returns (address); function anyPynthOrPERIRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availablePyn...
interface IPeriFinance { // Views function getRequiredAddress(bytes32 contractName) external view returns (address); function anyPynthOrPERIRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availablePyn...
12,618
28
// Appends a byte array to the end of the buffer. Resizes if doing so would exceed the capacity of the buffer. buf The buffer to append to. data The data to append.return The original buffer. /
function append(buffer memory buf, bytes data) internal pure returns(buffer memory) { if(data.length + buf.buf.length > buf.capacity) { resize(buf, max(buf.capacity, data.length) * 2); } uint dest; uint src; uint len = data.length; assembly { ...
function append(buffer memory buf, bytes data) internal pure returns(buffer memory) { if(data.length + buf.buf.length > buf.capacity) { resize(buf, max(buf.capacity, data.length) * 2); } uint dest; uint src; uint len = data.length; assembly { ...
52,396
43
// can later be changed with {transferOwnership}./ Initializes the contract setting the deployer as the initial owner. /
constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); }
constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); }
7,414
128
// VisualToken with Governance.
contract VisualToken is BEP20('Visual Token', 'VSAL') { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } ...
contract VisualToken is BEP20('Visual Token', 'VSAL') { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } ...
23,211
105
// - Bitcoin-way of hashing_dataBytes - raw data to be hashed return - result of applying SHA-256 twice to raw data and then flipping the bytes
function dblShaFlip(bytes _dataBytes) internal pure returns (uint) { return flip32Bytes(uint(sha256(abi.encodePacked(sha256(abi.encodePacked(_dataBytes)))))); }
function dblShaFlip(bytes _dataBytes) internal pure returns (uint) { return flip32Bytes(uint(sha256(abi.encodePacked(sha256(abi.encodePacked(_dataBytes)))))); }
3,026
26
// Recall that the buffer is not actually sorted: we need to apply the offset to access it in a sorted way.
mid = midWithoutOffset.add(offset); sample = samples[mid]; sampleTimestamp = sample.timestamp(); if (sampleTimestamp < lookUpDate) {
mid = midWithoutOffset.add(offset); sample = samples[mid]; sampleTimestamp = sample.timestamp(); if (sampleTimestamp < lookUpDate) {
24,323
50
// The deployer can mint in bulk without paying
function devMint(uint quantity, address recipient) external onlyDeployer { for (uint i = 0; i < quantity; i++) { _mint(recipient, 0); } }
function devMint(uint quantity, address recipient) external onlyDeployer { for (uint i = 0; i < quantity; i++) { _mint(recipient, 0); } }
30,700
226
// calculate amount that won't decrease invested baseAsset amount if calculation underflows, this is bad (vault shows negative return)
uint256 accruedYieldUSDC = lpTokensBalance.mul(lpPriceUSDC).div(1e18).sub(amountInvested); require(accruedYieldUSDC >= minExpectedAmount, "yield to harvest less than min");
uint256 accruedYieldUSDC = lpTokensBalance.mul(lpPriceUSDC).div(1e18).sub(amountInvested); require(accruedYieldUSDC >= minExpectedAmount, "yield to harvest less than min");
58,887
27
// Finishes initialization of the Linear Pool: it is unusable before calling this function as no BPT will havebeen minted. Since Linear Pools have preminted BPT stored in the Vault, they require an initial join to deposit said BPT astheir balance. Unfortunately, this cannot be performed during construction, as a join i...
function initialize() external { bytes32 poolId = getPoolId(); (IERC20[] memory tokens, , ) = getVault().getPoolTokens(poolId); // Joins typically involve the Pool receiving tokens in exchange for newly-minted BPT. In this case however, the // Pool will mint the entire BPT supply to...
function initialize() external { bytes32 poolId = getPoolId(); (IERC20[] memory tokens, , ) = getVault().getPoolTokens(poolId); // Joins typically involve the Pool receiving tokens in exchange for newly-minted BPT. In this case however, the // Pool will mint the entire BPT supply to...
67,754
75
// lock of depot ERC20/_tokenContractAddress address : ERC20 smart contract/_amount uint256 : amount to lock/_lockedFor uin256 : id to lock for/ return _success bool
function lockDepositERC20_V1( address _tokenContractAddress, uint256 _amount, uint256 _lockedFor
function lockDepositERC20_V1( address _tokenContractAddress, uint256 _amount, uint256 _lockedFor
8,029
7
// Mapping of Owner Address to list of owned Items /
mapping (address => uint256[]) public ownedItems;
mapping (address => uint256[]) public ownedItems;
7,662
5
// If set to 0, this listing will be considered non-existent.
uint256 listingStart;
uint256 listingStart;
22,531
144
// =================== Modifier =================== /
modifier checkMigration { require(!migrated, 'Treasury: migrated'); _; }
modifier checkMigration { require(!migrated, 'Treasury: migrated'); _; }
31,662
28
// terms contracts
ETOTerms private ETO_TERMS;
ETOTerms private ETO_TERMS;
40,394
101
// Handling weth
if(balWETH > 0){ totalETHContributed = totalETHContributed.add(balWETH); totalCredit = handleWETHLiquidityAddition(balWETH,tokenBeingWrappedPer1ETH,coreTokenPer1ETH);
if(balWETH > 0){ totalETHContributed = totalETHContributed.add(balWETH); totalCredit = handleWETHLiquidityAddition(balWETH,tokenBeingWrappedPer1ETH,coreTokenPer1ETH);
80,416
144
// search up _hatId's local address space for an admin hat that the _user wears
while (adminLocalHatLevel > 0) { if ( isWearerOfHat( _user, getAdminAtLocalLevel(_hatId, adminLocalHatLevel) ) ) { return isAdmin = true; }
while (adminLocalHatLevel > 0) { if ( isWearerOfHat( _user, getAdminAtLocalLevel(_hatId, adminLocalHatLevel) ) ) { return isAdmin = true; }
10,446
11
// Make sure the amount of ETH sent matches the update cost
require(msg.value >= updateCost, "You didn't send enough wei, check getCost()");
require(msg.value >= updateCost, "You didn't send enough wei, check getCost()");
34,913
0
// the greeting variable, by default, it is set as "Hello World from Learn Ethereum"
string public greeting;
string public greeting;
13,209