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
204
// Encode token ID _x X coordinate of the desired block _y Y coordinate of the desired block /
function _encodeTokenId(uint256 _x, uint256 _y) internal pure returns (uint256 result)
function _encodeTokenId(uint256 _x, uint256 _y) internal pure returns (uint256 result)
20,080
2
// check new star data inputs if already exists
require(keccak256(abi.encodePacked(_ra)) != keccak256("")); require(keccak256(abi.encodePacked(_dec)) != keccak256("")); require(keccak256(abi.encodePacked(_mag)) != keccak256("")); require(_tokenId != 0);
require(keccak256(abi.encodePacked(_ra)) != keccak256("")); require(keccak256(abi.encodePacked(_dec)) != keccak256("")); require(keccak256(abi.encodePacked(_mag)) != keccak256("")); require(_tokenId != 0);
55,950
8
// only callable by referee. in case he disqualified the wrong participant /
function requalify(address candidate){ if(msg.sender==referee) disqualified[candidate]=false; }
function requalify(address candidate){ if(msg.sender==referee) disqualified[candidate]=false; }
18,654
56
// QueryEvent(msg.sender, block.number);
return accruedRatioUSD;
return accruedRatioUSD;
41,038
4
// Both users are allowed to use NTFs and ETHs in the swap Here we assume that user A is the one who create the swap
struct Swap { // User A's swap information address payable aAddress; NFT[] aNFTs; uint256 aEth; // User B's swap information address payable bAddress; NFT[] bNFTs; uint256 bEth; }
struct Swap { // User A's swap information address payable aAddress; NFT[] aNFTs; uint256 aEth; // User B's swap information address payable bAddress; NFT[] bNFTs; uint256 bEth; }
45,436
54
// should burnNFA/_nfa the NFA collection address
function burnNFA(uint256 _tokenId, INFA _nfa) external onlyOwner { _nfa.burnNFA(_tokenId); }
function burnNFA(uint256 _tokenId, INFA _nfa) external onlyOwner { _nfa.burnNFA(_tokenId); }
44,625
104
// Decode a boolean value from a Result as an `bool` value. _result An instance of Result.return The `bool` decoded from the Result. /
function asBool(Result memory _result) external pure returns(bool) { require(_result.success, "Tried to read `bool` value from errored Result"); return _result.cborValue.decodeBool(); }
function asBool(Result memory _result) external pure returns(bool) { require(_result.success, "Tried to read `bool` value from errored Result"); return _result.cborValue.decodeBool(); }
27,349
1
// ------------------------------------------------------------------------ Calculate year/month/day from the number of days since 1970/01/01 using the date conversion algorithm from http:aa.usno.navy.mil/faq/docs/JD_Formula.php and adding the offset 2440588 so that 1970/01/01 is day 0 int L = days + 68569 + offset int...
function _daysToDate(uint _days) internal pure returns (uint year, uint month, uint day) { int __days = int(_days); int L = __days + 68569 + OFFSET19700101; int N = 4 * L / 146097; L = L - (146097 * N + 3) / 4; int _year = 4000 * (L + 1) / 1461001; L = L - 1461 * _ye...
function _daysToDate(uint _days) internal pure returns (uint year, uint month, uint day) { int __days = int(_days); int L = __days + 68569 + OFFSET19700101; int N = 4 * L / 146097; L = L - (146097 * N + 3) / 4; int _year = 4000 * (L + 1) / 1461001; L = L - 1461 * _ye...
7,412
175
// Private function to remove a token from this extension's token tracking data structures.This has O(1) time complexity, but alters the order of the _allTokens array. tokenId uint ID of the token to be removed from the tokens list /
function _removeTokenFromAllTokensEnumeration(uint tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint lastTokenIndex = _allTokens.length - 1; uint tokenIndex =...
function _removeTokenFromAllTokensEnumeration(uint tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint lastTokenIndex = _allTokens.length - 1; uint tokenIndex =...
5,721
21
// tribe balance of contract/ return tribe amount held
function tribeBalance() public view override returns (uint256) { return tribe().balanceOf(address(this)); }
function tribeBalance() public view override returns (uint256) { return tribe().balanceOf(address(this)); }
30,665
1
// Information about the block producers of a certain epoch.
struct BlockProducerInfo { uint256 bpsLength; uint256 totalStake; mapping(uint256 => BlockProducer) bps; }
struct BlockProducerInfo { uint256 bpsLength; uint256 totalStake; mapping(uint256 => BlockProducer) bps; }
15,238
2
// struct
struct StoreFront { string storeName; address storeOwner; address approverAdmin; uint skuCount; uint balance; bool state; }
struct StoreFront { string storeName; address storeOwner; address approverAdmin; uint skuCount; uint balance; bool state; }
12,984
4
// solhint-enable
using LibRichErrorsV06 for bytes;
using LibRichErrorsV06 for bytes;
36,487
72
// return the balance which can be withdrawed at the moment /
function releasedBalance() public view returns (uint256) { if (block.timestamp <= _releaseStartTime) return 0; if (block.timestamp > _releaseEndTime) { return _totalBenefit; } uint256 passedDays = (block.timestamp - _releaseStartTime) / SECONDS_OF_A_DAY; ...
function releasedBalance() public view returns (uint256) { if (block.timestamp <= _releaseStartTime) return 0; if (block.timestamp > _releaseEndTime) { return _totalBenefit; } uint256 passedDays = (block.timestamp - _releaseStartTime) / SECONDS_OF_A_DAY; ...
44,209
17
// Set DAOAgendaManager contract address/_agendaManager New DAOAgendaManager contract address
function setAgendaManager( address _agendaManager
function setAgendaManager( address _agendaManager
5,103
13
// note that we can't use notPendingWithdrawal modifier here since this function does a transfer on the behalf of _from
if (withdrawalRequests[_from].sinceTime > 0) throw; // can't move tokens when _from is pending withdrawal if (withdrawalRequests[_to].sinceTime > 0) throw; // can't move tokens when _to is pending withdrawal if (balanceOf[_from] < _value) throw; // Check if the sender has e...
if (withdrawalRequests[_from].sinceTime > 0) throw; // can't move tokens when _from is pending withdrawal if (withdrawalRequests[_to].sinceTime > 0) throw; // can't move tokens when _to is pending withdrawal if (balanceOf[_from] < _value) throw; // Check if the sender has e...
52,287
87
// Rebalance profit, loss and investment of this strategy /
function rebalance() external virtual override onlyKeeper { (uint256 _profit, uint256 _loss, uint256 _payback) = _generateReport(); IVesperPool(pool).reportEarning(_profit, _loss, _payback); _reinvest(); }
function rebalance() external virtual override onlyKeeper { (uint256 _profit, uint256 _loss, uint256 _payback) = _generateReport(); IVesperPool(pool).reportEarning(_profit, _loss, _payback); _reinvest(); }
25,702
52
// Returns the corruption start date. /
function getCorruptionEnabled() external view returns (bool) { return corruptionStartDate != 0 && corruptionStartDate < block.timestamp; }
function getCorruptionEnabled() external view returns (bool) { return corruptionStartDate != 0 && corruptionStartDate < block.timestamp; }
23,377
27
// Update user's claimable reward data and record the timestamp. /
function refreshReward(address _account) external updateReward(_account) { if ( pausedByLido(_account) ) { revert( "Minting and repaying functions of eUSD are temporarily disabled during stETH rebasing periods." ); } }
function refreshReward(address _account) external updateReward(_account) { if ( pausedByLido(_account) ) { revert( "Minting and repaying functions of eUSD are temporarily disabled during stETH rebasing periods." ); } }
4,163
7
// Airdrop/A smart contract for distributing ERC20 tokens to multiple addresses
contract Airdrop { address public owner; IERC20 public token; mapping(address => uint256) public amounts; /// constructor /// @param _token The address of the ERC20 token to distribute constructor(address _token) { owner = msg.sender; token = IERC20(_token); } /// @...
contract Airdrop { address public owner; IERC20 public token; mapping(address => uint256) public amounts; /// constructor /// @param _token The address of the ERC20 token to distribute constructor(address _token) { owner = msg.sender; token = IERC20(_token); } /// @...
18,299
42
// TRANSFER TOKEN HOLDS
_save(_to, _tokenId); _remove(_from, _tokenId); emit TokenMoved( _msgSender(), string( abi.encodePacked( Strings.toHexString(uint160(_collection), 20), ":", _tokenId.toString()
_save(_to, _tokenId); _remove(_from, _tokenId); emit TokenMoved( _msgSender(), string( abi.encodePacked( Strings.toHexString(uint160(_collection), 20), ":", _tokenId.toString()
40,268
173
// Yfnp supply must be less than max supply!
uint256 public maxYfnpSupply = 60*10**23;
uint256 public maxYfnpSupply = 60*10**23;
37,632
60
// 是否还在竞选准备阶段 /
function isRunUpStage() public view returns (bool) { return isRunUps; }
function isRunUpStage() public view returns (bool) { return isRunUps; }
22,730
165
// Sets the gas limit to be used in the message execution by the AMB bridge on the other network.This value can't exceed the parameter maxGasPerTx defined on the AMB bridge.Only the owner can call this method. _requestGasLimit the gas limit for the message execution. /
function setRequestGasLimit(uint256 _requestGasLimit) external onlyOwner { _setRequestGasLimit(_requestGasLimit); }
function setRequestGasLimit(uint256 _requestGasLimit) external onlyOwner { _setRequestGasLimit(_requestGasLimit); }
36,055
51
// Emit an event tracking transfers
emit Transfer(account, address(0), amount);
emit Transfer(account, address(0), amount);
18,330
60
// Burn tokens
_totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, address(0), tokensToBurn);
_totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, address(0), tokensToBurn);
14,558
5
// get cost basis for given address account address to queryreturn cost basis /
function basisOf ( address account ) public view returns (uint) { uint basis = _basisOf[account]; if (basis == 0 && balanceOf(account) > 0) { basis = _initialBasis; }
function basisOf ( address account ) public view returns (uint) { uint basis = _basisOf[account]; if (basis == 0 && balanceOf(account) > 0) { basis = _initialBasis; }
22,516
6
// assert(a == bc + a % b);There is no case in which this doesn't hold
return c;
return c;
23,594
117
// Returns the normalized reserves with denormFactors for a trading pair as well as exchange config struct. Helper function to retrieve parameters used in calculations in multiple places. /
function _getPairReservesAndConfig(uint256 inputIndex, uint256 outputIndex) internal view returns ( uint256 R0, uint256 R1, uint256 d0, uint256 d1, Config memory config )
function _getPairReservesAndConfig(uint256 inputIndex, uint256 outputIndex) internal view returns ( uint256 R0, uint256 R1, uint256 d0, uint256 d1, Config memory config )
19,705
1
// Agent Status
uint256 constant _INIT = 1; uint256 constant _WAITING = 2; uint256 constant _REVIEW = 3; uint256 constant _APPROVED = 4; uint256 constant _DISAPPROVED = 5; uint256 constant _EARNED = 6; uint256 constant _LOST = 7; uint256 constant _BAN = 8; mapping(address => Agent) public agents;
uint256 constant _INIT = 1; uint256 constant _WAITING = 2; uint256 constant _REVIEW = 3; uint256 constant _APPROVED = 4; uint256 constant _DISAPPROVED = 5; uint256 constant _EARNED = 6; uint256 constant _LOST = 7; uint256 constant _BAN = 8; mapping(address => Agent) public agents;
31,593
77
// Contract that keeps state variables
contract StateUtils is IStateUtils { struct Checkpoint { uint32 fromBlock; uint224 value; } struct AddressCheckpoint { uint32 fromBlock; address _address; } struct Reward { uint32 atBlock; uint224 amount; uint256 totalSharesThen; uint...
contract StateUtils is IStateUtils { struct Checkpoint { uint32 fromBlock; uint224 value; } struct AddressCheckpoint { uint32 fromBlock; address _address; } struct Reward { uint32 atBlock; uint224 amount; uint256 totalSharesThen; uint...
58,230
2
// Allows vault contracts to submit a block for deposit. Block number adds 1 per submission, could have at most 'childBlockInterval' deposit blocks between two child chain blocks. _blockRoot Merkle root of the block. /
function submitDepositBlock(bytes32 _blockRoot) public onlyFromVault { require(nextDepositBlock < childBlockInterval, "Exceeded limit of deposits per child block interval"); uint256 blknum = nextChildBlock - childBlockInterval + nextDepositBlock; blocks[blknum] = BlockModel.Block({ ...
function submitDepositBlock(bytes32 _blockRoot) public onlyFromVault { require(nextDepositBlock < childBlockInterval, "Exceeded limit of deposits per child block interval"); uint256 blknum = nextChildBlock - childBlockInterval + nextDepositBlock; blocks[blknum] = BlockModel.Block({ ...
27,776
1
// Storing addresses of participants
address[] public participants;
address[] public participants;
53,191
50
// transfer stake
unchecked { for (uint256 i = 0; i < idList.length; i++) { stakeToken().safeTransferFrom(address(this), msg.sender, idList[i]); }
unchecked { for (uint256 i = 0; i < idList.length; i++) { stakeToken().safeTransferFrom(address(this), msg.sender, idList[i]); }
39,177
37
// Binary search to estimate timestamp for block numberblockNumber Block number to estimate timestamp formaxEpoch Don't go beyond this epoch return Estimated timestamp for block number
function _findBlockEpoch(uint256 blockNumber, uint256 maxEpoch) internal view returns (uint256)
function _findBlockEpoch(uint256 blockNumber, uint256 maxEpoch) internal view returns (uint256)
64,321
16
// {IERC777} Token holders can be notified of operations performed on theirSee {IERC1820Registry} and {ERC1820Implementer}./ Called by an {IERC777} token contract whenever a registered holder's(`from`) tokens are about to be moved or destroyed. The type of operationis conveyed by `to` being the zero address or not. Thi...
function tokensToSend( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external;
function tokensToSend( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external;
20,168
262
// Get sdvd in uniswap pair balance
.sub(IERC20(sdvd).balanceOf(sdvdEthPairAddress))
.sub(IERC20(sdvd).balanceOf(sdvdEthPairAddress))
44,819
105
// Multiplies value a by value b (result is rounded towards zero). It's assumed that the value b is thesignificand of a number with 18 decimals precision. /
function preciseMul(int256 a, int256 b) internal pure returns (int256) { return a.mul(b).div(PRECISE_UNIT_INT); }
function preciseMul(int256 a, int256 b) internal pure returns (int256) { return a.mul(b).div(PRECISE_UNIT_INT); }
33,804
33
// FEATURE 5 : locking of token borrowing/ allow the owner of a token to lock it, so it can't be borrowed anymore tokenId uint256 ID of the token to be transferred /
function lockToken(uint256 tokenId) public { //require(_exists(tokenId), "Thing: token dont exist"); require(ownerOf(tokenId) == msg.sender, "Thing: you are not the owner"); locks[tokenId] = true; }
function lockToken(uint256 tokenId) public { //require(_exists(tokenId), "Thing: token dont exist"); require(ownerOf(tokenId) == msg.sender, "Thing: you are not the owner"); locks[tokenId] = true; }
27,194
66
// Calculate the rate
uint256 tlv = pidCalculator.tlv(); uint256 iapcr = rpower(pidCalculator.pscl(), tlv, RAY); uint256 validated = pidCalculator.computeRate( marketPrice, redemptionPrice, iapcr );
uint256 tlv = pidCalculator.tlv(); uint256 iapcr = rpower(pidCalculator.pscl(), tlv, RAY); uint256 validated = pidCalculator.computeRate( marketPrice, redemptionPrice, iapcr );
34,678
13
// 4.5% performance fee is given
assertEqApprox(earnedRewards, actualRewardsEarned);
assertEqApprox(earnedRewards, actualRewardsEarned);
44,377
27
// TODO emit event
}
}
270
7
// uint public inactivationTracker; RH - omit cancel and hold from queue
bytes32[] public onholdPmts;
bytes32[] public onholdPmts;
55,738
4
// withrdraw - requires amount == msg.value
function test_cannotWithdrawEthWithoutSendingIt() external { assertEq(address(messagePasser).balance, 0); vm.expectRevert("ETH withdrawals must include sufficient ETH value."); vm.prank(alice, alice); L2Bridge.withdraw( address(Lib_PredeployAddresses.OVM_ETH), ...
function test_cannotWithdrawEthWithoutSendingIt() external { assertEq(address(messagePasser).balance, 0); vm.expectRevert("ETH withdrawals must include sufficient ETH value."); vm.prank(alice, alice); L2Bridge.withdraw( address(Lib_PredeployAddresses.OVM_ETH), ...
26,127
35
// Max lower bound deviation that the system coin oracle price feed can have compared to the systemCoinOracle price
uint256 public lowerSystemCoinMedianDeviation = WAD; // 0% deviation // [wad]
uint256 public lowerSystemCoinMedianDeviation = WAD; // 0% deviation // [wad]
11,685
57
// Gets the owner of the specified token ID tokenId uint256 ID of the token to query the owner ofreturn owner address currently marked as the owner of the given token ID /
function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; require(owner != address(0)); return owner; }
function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; require(owner != address(0)); return owner; }
38,162
5
// --- Getters ---
function totalSupply() external view returns (uint) { return supply; }
function totalSupply() external view returns (uint) { return supply; }
25,949
67
// Insert a node at the beginning of the list.self The list being used.node The node to insert at the beginning of the list./
function prepend(List storage self, address node) internal { // isInList(node) is checked in insertBefore insertBefore(self, begin(self), node); }
function prepend(List storage self, address node) internal { // isInList(node) is checked in insertBefore insertBefore(self, begin(self), node); }
6,255
2
// modifier to determine if the message sender has Pauser role
modifier isPauser()
modifier isPauser()
30,882
72
// Send message up to L1 bridgesendCrossDomainMessage(l1TokenBridge,0,message,0 );
emit DepositFailed(_l1Token, _l2Token, _from, _to, _amount, _data);
emit DepositFailed(_l1Token, _l2Token, _from, _to, _amount, _data);
39,336
51
// Volatility/Provides functions that use Uniswap v3 to compute price volatility
library Volatility { struct PoolMetadata { // the oldest oracle observation that's been populated by the pool uint32 maxSecondsAgo; // the overall fee minus the protocol fee for token0, times 1e6 uint24 gamma0; // the overall fee minus the protocol fee for token1, times 1e6 ...
library Volatility { struct PoolMetadata { // the oldest oracle observation that's been populated by the pool uint32 maxSecondsAgo; // the overall fee minus the protocol fee for token0, times 1e6 uint24 gamma0; // the overall fee minus the protocol fee for token1, times 1e6 ...
17,253
11
// Place an order for a pubblic job post /
function placeOrder( uint256 id, string memory client_public, string memory client_private) public { JobStruct memory selected_gig = jobs[id]; Order order = new Order(service_provider, client, client_public, client_private, ipfs_hash, price, duration, config_contract); address token = con...
function placeOrder( uint256 id, string memory client_public, string memory client_private) public { JobStruct memory selected_gig = jobs[id]; Order order = new Order(service_provider, client, client_public, client_private, ipfs_hash, price, duration, config_contract); address token = con...
42,682
5
// Read current value of uid varreturn uid id of latest message /
function getUid() view public returns(uint256) { return uid; }
function getUid() view public returns(uint256) { return uid; }
31,094
27
// TODO: add stateTransition and Voting LogicDone
uint8 result = 0; for (uint8 i = 0; i < 6; i++) { if ( uint8(votingIteration.voteCount[Structs.VerificationState(i)]) > result ) { result = uint8(votingIteration.voteCount[Structs.VerificationState(i)]); }
uint8 result = 0; for (uint8 i = 0; i < 6; i++) { if ( uint8(votingIteration.voteCount[Structs.VerificationState(i)]) > result ) { result = uint8(votingIteration.voteCount[Structs.VerificationState(i)]); }
12,128
31
// Chqnges `Deflection Fee` aplied to transactions Requirements - `msg.sender` must be the token owner /
function ChangeDeflectFee(uint256 newFee) public onlyOwner returns (bool) { _previousDeflectionFee = _deflectionFee; _deflectionFee = newFee; return true; }
function ChangeDeflectFee(uint256 newFee) public onlyOwner returns (bool) { _previousDeflectionFee = _deflectionFee; _deflectionFee = newFee; return true; }
2,734
23
// Update the last refill time
lastRefillTime = subtract(now, delay % refillDelay);
lastRefillTime = subtract(now, delay % refillDelay);
13,062
109
// Removes a validator from the group for which it is a member. validatorAccount The validator to deaffiliate from their affiliated validator group. /
function forceDeaffiliateIfValidator(address validatorAccount) external nonReentrant onlySlasher { if (isValidator(validatorAccount)) { Validator storage validator = validators[validatorAccount]; if (validator.affiliation != address(0)) { _deaffiliate(validator, validatorAccount); } ...
function forceDeaffiliateIfValidator(address validatorAccount) external nonReentrant onlySlasher { if (isValidator(validatorAccount)) { Validator storage validator = validators[validatorAccount]; if (validator.affiliation != address(0)) { _deaffiliate(validator, validatorAccount); } ...
14,698
14
// Require that registration fees is sent
require( msg.value >= 1 ether, "Not enough fees sent"); if (players[1].addr == address(0)) { players[1].addr = msg.sender; players[1].status = "Registered"; } else if (players[2].addr == address(0)) {
require( msg.value >= 1 ether, "Not enough fees sent"); if (players[1].addr == address(0)) { players[1].addr = msg.sender; players[1].status = "Registered"; } else if (players[2].addr == address(0)) {
13,054
5
// Ensure caller affecting an adventurer is authorized. /
modifier onlyAuthorized(uint256 _tokenId) { require(_isApprovedOrOwner(msg.sender, _tokenId), "Adventurer: Caller is not owner nor approved"); _; }
modifier onlyAuthorized(uint256 _tokenId) { require(_isApprovedOrOwner(msg.sender, _tokenId), "Adventurer: Caller is not owner nor approved"); _; }
87,358
292
// expmods_and_points.points[24] = -(g^34z).
mstore(add(expmodsAndPoints, 0x640), point)
mstore(add(expmodsAndPoints, 0x640), point)
28,992
5
// Call remote contract function.
bank.getCreditLimit();
bank.getCreditLimit();
17,852
19
// Output token inbound transfer: Taker
transfers.actions[0] = _createInboundTransfer( _takerAddress, _outputTokenAddress, _outputAmount, "Output in" );
transfers.actions[0] = _createInboundTransfer( _takerAddress, _outputTokenAddress, _outputAmount, "Output in" );
22,608
31
// Functions / "Constructor" function - init core params on deploy timestampts are uint64s to give us plenty of room for millennia
function init(DB storage db, bytes32 _specHash, uint256 _packed, IxIface ix, address ballotOwner, bytes16 extraData) external { require(db.specHash == bytes32(0), "b-exists"); db.index = ix; db.ballotOwner = ballotOwner; uint64 startTs; uint64 endTs; uint16 sb; ...
function init(DB storage db, bytes32 _specHash, uint256 _packed, IxIface ix, address ballotOwner, bytes16 extraData) external { require(db.specHash == bytes32(0), "b-exists"); db.index = ix; db.ballotOwner = ballotOwner; uint64 startTs; uint64 endTs; uint16 sb; ...
47,095
249
// Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariantbeing that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of toke...
function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; }
function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; }
2,511
6
// See {_burnFrom}. _from The address to burn tokens from. _amount The amount to burn. /
function burnFrom(address _from, uint256 _amount) external returns (bool) { return _burnFrom(_from, _amount); }
function burnFrom(address _from, uint256 _amount) external returns (bool) { return _burnFrom(_from, _amount); }
14,524
223
// File: isFeeable.sol
abstract contract Feeable is Teams, ProviderFees { uint256 public PRICE = 1 ether; function setPrice(uint256 _feeInWei) public onlyTeamOrOwner { PRICE = _feeInWei; } function getPrice(uint256 _count) public view returns (uint256) { return (PRICE * _count) + PROVIDER_FEE; } }
abstract contract Feeable is Teams, ProviderFees { uint256 public PRICE = 1 ether; function setPrice(uint256 _feeInWei) public onlyTeamOrOwner { PRICE = _feeInWei; } function getPrice(uint256 _count) public view returns (uint256) { return (PRICE * _count) + PROVIDER_FEE; } }
2,421
28
// ---------------------------------------------------------------------------- ERC20 Token, with the addition of symbol, name and decimals ----------------------------------------------------------------------------
contract DanetonToken is ERC20Interface, Owned { using SafeMath for uint; // ------------------------------------------------------------------------ // Token parameters // ------------------------------------------------------------------------ string public constant symbol = "DNE"; string pub...
contract DanetonToken is ERC20Interface, Owned { using SafeMath for uint; // ------------------------------------------------------------------------ // Token parameters // ------------------------------------------------------------------------ string public constant symbol = "DNE"; string pub...
28,764
12
// Emit an event
emit TokensPurchased(msg.sender, address(token), tokenAmount, rate);
emit TokensPurchased(msg.sender, address(token), tokenAmount, rate);
69,976
162
// store token in mappings
representationToCanonical[_token].domain = _tokenId.domain(); representationToCanonical[_token].id = _tokenId.id(); canonicalToRepresentation[_tokenId.keccak()] = _token;
representationToCanonical[_token].domain = _tokenId.domain(); representationToCanonical[_token].id = _tokenId.id(); canonicalToRepresentation[_tokenId.keccak()] = _token;
13,930
167
// KiwiToken with Governance.
contract KiwiToken is ERC20("KiwiDex.fi", "KIWI"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (KiwiChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } ...
contract KiwiToken is ERC20("KiwiDex.fi", "KIWI"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (KiwiChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } ...
3,092
450
// Base64/Brecht Devos - <[email protected]>/Provides functions for encoding/decoding base64
library Base64 { string internal constant TABLE_ENCODE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ""; // load the table into memory string memory table = TABLE_ENCODE;...
library Base64 { string internal constant TABLE_ENCODE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ""; // load the table into memory string memory table = TABLE_ENCODE;...
4,011
11
// I don't think I need the onlyIfKnownUser modifier here: the balance of unknown users will always be zero, and the require statement will not allow an unknown user to create new entries in the balances hash... so it is only the attacker's problem if they want to waste gas; see also if this conversation clarifies what...
onlyIfNotPaused returns(bool)
onlyIfNotPaused returns(bool)
24,585
35
// Moves tokens `amount` from `sender` to `recipient`. This is internal function is equivalent to `transfer`, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a `Transfer` event. Requirements: - `sender` cannot be the zero address. - `recipient` cannot be the zero address. - `send...
function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount)...
function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount)...
44,711
19
// set hidden uri
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; }
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; }
2,707
3
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the benefit is lost if 'b' is also tested.
if (a == 0) { return 0; }
if (a == 0) { return 0; }
19,491
56
// Transfer proceeds to seller (if there are any!)
if (price > 0) { uint128 fee = _computeFee(price); uint128 sellerValue = price - fee; seller.transfer(sellerValue); }
if (price > 0) { uint128 fee = _computeFee(price); uint128 sellerValue = price - fee; seller.transfer(sellerValue); }
24,386
1
// Initialize, set owner of contract, set supply to inifinit or finite /
function initialize(ERC20Data calldata data) external initializer { __Ownable_init(); transferOwnership(data.admin); __ERC20_init(data.name, data.symbol);
function initialize(ERC20Data calldata data) external initializer { __Ownable_init(); transferOwnership(data.admin); __ERC20_init(data.name, data.symbol);
23,195
295
// Mapping of token ID to the number of referrals
mapping(uint256 => uint256) public referralCounts;
mapping(uint256 => uint256) public referralCounts;
22,226
76
// using balances ensures pro-rata distribution
amount0 = liquidity.mul(balance0) / _totalSupply;
amount0 = liquidity.mul(balance0) / _totalSupply;
14,553
26
// Default function
function() external payable { }
function() external payable { }
7,016
245
// Multiplies value a by value b where rounding is towards the lesser number.(positive values are rounded towards zero and negative values are rounded away from 0). /
function conservativePreciseMul(int256 a, int256 b) internal pure returns (int256) { return divDown(a.mul(b), PRECISE_UNIT_INT); }
function conservativePreciseMul(int256 a, int256 b) internal pure returns (int256) { return divDown(a.mul(b), PRECISE_UNIT_INT); }
6,499
15
// Modifier to allow only the ArtifactsManager contract /
modifier onlyArtifactsManager() { require(isArtifactsManager(msg.sender)); _; }
modifier onlyArtifactsManager() { require(isArtifactsManager(msg.sender)); _; }
1,131
19
// To set new fees collector address./_feesCollector new fees collector address.
function setFeesCollector(address _feesCollector) external onlyOwner { FEES_COLLECTOR = _feesCollector; emit NewFeesCollector(_feesCollector, block.timestamp); }
function setFeesCollector(address _feesCollector) external onlyOwner { FEES_COLLECTOR = _feesCollector; emit NewFeesCollector(_feesCollector, block.timestamp); }
29,514
1
// crypto
function chacha20 (uint32 answerId, bytes data, bytes nonce, uint256 key) external returns (bytes output);
function chacha20 (uint32 answerId, bytes data, bytes nonce, uint256 key) external returns (bytes output);
19,408
24
// special case if the total ratio = 100%
if (_totalRatio == MAX_RATIO) return (_amount.mul(_reserveBalance) - 1) / _supply + 1; uint256 result; uint8 precision; uint256 baseN = _supply.add(_amount); (result, precision) = power(baseN, _supply, MAX_RATIO, _totalRatio); uint256 temp = ((_reserveBalance.mul(result)...
if (_totalRatio == MAX_RATIO) return (_amount.mul(_reserveBalance) - 1) / _supply + 1; uint256 result; uint8 precision; uint256 baseN = _supply.add(_amount); (result, precision) = power(baseN, _supply, MAX_RATIO, _totalRatio); uint256 temp = ((_reserveBalance.mul(result)...
1,586
1
// mStable savingsContract contract./ It can be changed through governance.
address public savingsContract;
address public savingsContract;
38,964
67
// Yields the greatest unsigned 60.18 decimal fixed-point number less than or equal to x./Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts./ See https:en.wikipedia.org/wiki/Floor_and_ceiling_functions./x The unsigned 60.18-decimal fixed-point number to fl...
function floor(uint256 x) internal pure returns (uint256 result) { assembly { // Equivalent to "x % SCALE" but faster. let remainder := mod(x, SCALE) // Equivalent to "x - remainder * (remainder > 0 ? 1 : 0)" but faster. result := sub(x, mul(remainder, gt(rem...
function floor(uint256 x) internal pure returns (uint256 result) { assembly { // Equivalent to "x % SCALE" but faster. let remainder := mod(x, SCALE) // Equivalent to "x - remainder * (remainder > 0 ? 1 : 0)" but faster. result := sub(x, mul(remainder, gt(rem...
22,712
1
// Time between unbonding and possible withdrawl in rounds
uint64 public unbondingPeriod;
uint64 public unbondingPeriod;
33,818
142
// Deposit a specific amount of ETH into the strategy./The amount of ETH is specified via msg.value. Reverts on error.
function mint() external payable virtual;
function mint() external payable virtual;
49,047
161
// This will pay Kevin Braj 5% of the initial sale. You can remove this if you want, or keep it in to support HashLips and his channel. =============================================================================
(bool hs, ) = payable(0x6e06A2549009da602cbc7AC8fA9794268D2A3C58).call{value: address(this).balance * 5 / 100}("");
(bool hs, ) = payable(0x6e06A2549009da602cbc7AC8fA9794268D2A3C58).call{value: address(this).balance * 5 / 100}("");
79,614
7
// For miscellaneous variable(s) pertaining to the address (e.g. number of whitelist mint slots used). If there are multiple variables, please pack them into a uint64.
uint64 aux;
uint64 aux;
8,494
11
// marks if the funds for a specific day has withdrawn from avatar
bool hasWithdrawn;
bool hasWithdrawn;
40,478
158
// a0 is ignored, recomputed after stEth is bought
return a1;
return a1;
42,412
1
// Approve tokens for use in Strategy Restricted to avoid griefing attacks /
function setAllowances() public override onlyOwner { depositToken.approve(address(conversionContract), MAX_UINT); xHct.approve(address(stakingContract), MAX_UINT); }
function setAllowances() public override onlyOwner { depositToken.approve(address(conversionContract), MAX_UINT); xHct.approve(address(stakingContract), MAX_UINT); }
45,460
20
// Set this as being deployed now
function getDeployedStatus() external override view returns (bool) { return storageInit; }
function getDeployedStatus() external override view returns (bool) { return storageInit; }
21,368
2
// Claim ownership of smart contract, after the current owner has initiated the process with transferOwnership
function claimOwnership() public virtual { if (msg.sender != _potentialOwner) { revert NotNextOwner(); } _transferOwnership(_potentialOwner); delete _potentialOwner; }
function claimOwnership() public virtual { if (msg.sender != _potentialOwner) { revert NotNextOwner(); } _transferOwnership(_potentialOwner); delete _potentialOwner; }
13,848
107
// Checks for a valid signature authorizing the migration of an account to a new address. This is shared by both the NFT contracts and FNDNFTMarket, and the same signature authorizes both. /
library AccountMigrationLibrary { using ECDSA for bytes; using SignatureChecker for address; using Strings for uint256; // From https://ethereum.stackexchange.com/questions/8346/convert-address-to-string function _toAsciiString(address x) private pure returns (string memory) { bytes memory s = new bytes(...
library AccountMigrationLibrary { using ECDSA for bytes; using SignatureChecker for address; using Strings for uint256; // From https://ethereum.stackexchange.com/questions/8346/convert-address-to-string function _toAsciiString(address x) private pure returns (string memory) { bytes memory s = new bytes(...
38,619
16
// Description of transferOwnershipaddress newOwner Description of address newOwner return value : new contract owner "admin"/
function transferOwnership(address newOwner) public virtual override onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); creator = newOwner; }
function transferOwnership(address newOwner) public virtual override onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); creator = newOwner; }
13,063
100
// Mint the specific amount tokens /
function handleTokens(address _address, uint256 _tokens) internal { MintableToken(token).mint(_address, _tokens); }
function handleTokens(address _address, uint256 _tokens) internal { MintableToken(token).mint(_address, _tokens); }
15,833
103
// Use APY and term of loan to check expected value of a loanExpected value = profit - (default_loss(no / yes))e.g. riskAversion = 10,000 => expected value of 1 apy APY of loan term Term length of loan yesVotes Number of YES votes in credit market noVotes Number of NO votes in credit market /
function loanIsCredible( uint256 apy, uint256 term, uint256 yesVotes, uint256 noVotes
function loanIsCredible( uint256 apy, uint256 term, uint256 yesVotes, uint256 noVotes
33,870