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
23
// First try to get contract verifier
address verifier = ADDRESS_RESOLVER.contractVerifiers(to);
address verifier = ADDRESS_RESOLVER.contractVerifiers(to);
10,012
26
// constructor /
function BadPractices() { creator = tx.origin; owner = msg.sender; }
function BadPractices() { creator = tx.origin; owner = msg.sender; }
41,655
15
// Contract module defining the ERC721 NFT Token.There is a total supply of N tokens to be minted, each unit costs ETH.some are reserved for presale and promo purposes. /
contract AndreyWeb3MintGas is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string _baseTokenURI; uint256 public _cardPrice = 5000000000000000; // .005 ETH bool public _saleIsActive = true; // Reserve units for team - G...
contract AndreyWeb3MintGas is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string _baseTokenURI; uint256 public _cardPrice = 5000000000000000; // .005 ETH bool public _saleIsActive = true; // Reserve units for team - G...
30,276
66
// // FUNCTIONS ///OpenZeppelin's ECDSA library is used to call all ECDSA functions directly on the bytes32 variables themselves.
using ECDSA for bytes32;
using ECDSA for bytes32;
10,182
6
// Give permissions to new derivative contract and then hand over ownership.
tokenCurrency.addMinter(derivative); tokenCurrency.addBurner(derivative); tokenCurrency.resetOwner(derivative); _registerContract(new address[](0), address(derivative)); emit CreatedExpiringMultiParty(address(derivative), msg.sender); return address(derivative);
tokenCurrency.addMinter(derivative); tokenCurrency.addBurner(derivative); tokenCurrency.resetOwner(derivative); _registerContract(new address[](0), address(derivative)); emit CreatedExpiringMultiParty(address(derivative), msg.sender); return address(derivative);
43,049
98
// Freze account /
function _freeze(address target, bool freeze) internal { _beforeAccountFreeze(target); require(target != address(0), "FreezableToken: target the zero address"); _frozenAccounts[target] = freeze; emit FrozenFunds(target, freeze); }
function _freeze(address target, bool freeze) internal { _beforeAccountFreeze(target); require(target != address(0), "FreezableToken: target the zero address"); _frozenAccounts[target] = freeze; emit FrozenFunds(target, freeze); }
76,233
0
// Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's `+` operator. Requirements: - Addition cannot overflow./
function add( uint256 a, uint256 b ) internal pure returns ( uint256 )
function add( uint256 a, uint256 b ) internal pure returns ( uint256 )
14,955
44
// Allows address to be approved for transferFrom().
function _approve(uint256 _tokenId, address _approved) internal { gunIndexToApproved[_tokenId] = _approved; }
function _approve(uint256 _tokenId, address _approved) internal { gunIndexToApproved[_tokenId] = _approved; }
13,007
118
// Sets the address of the application's Mailbox. _mailbox The address of the Mailbox contract. /
function setMailbox(address _mailbox) external virtual onlyOwner { _setMailbox(_mailbox); }
function setMailbox(address _mailbox) external virtual onlyOwner { _setMailbox(_mailbox); }
19,109
114
// ...or the crowdfunding period is over, but the minimum has been reached
(block.timestamp >= endTimestamp && totalCollected >= minimalGoal) );
(block.timestamp >= endTimestamp && totalCollected >= minimalGoal) );
32,918
11
// Burn redeemTokens to withdraw underlyingTokens and strikeTokens from expired options. optionToken The address of the option contract. unwindQuantity Quantity of option tokens used to calculate the amount of redeem tokens to burn. receiver The underlyingTokens are sent to the receiver address and the redeemTokens are...
function safeUnwind( IOption optionToken, uint256 unwindQuantity, address receiver ) internal returns ( uint256, uint256, uint256
function safeUnwind( IOption optionToken, uint256 unwindQuantity, address receiver ) internal returns ( uint256, uint256, uint256
13,250
103
// LifestoryPlanets contract
IERC721 private immutable planetContract;
IERC721 private immutable planetContract;
22,884
45
// Allows a liquidity provider to give anend user fast liquidity by pre-filling anincoming transfer message.Transfers tokens from the liquidity provider to the end recipient, minus the LP fee;Records the liquidity provider, who receivesthe full token amount when the transfer message is handled. fast liquidity can only ...
function preFill(bytes calldata _message) external { // parse tokenId and action from message bytes29 _msg = _message.ref(0).mustBeMessage(); bytes29 _tokenId = _msg.tokenId().mustBeTokenId(); bytes29 _action = _msg.action().mustBeTransfer(); // calculate prefill ID b...
function preFill(bytes calldata _message) external { // parse tokenId and action from message bytes29 _msg = _message.ref(0).mustBeMessage(); bytes29 _tokenId = _msg.tokenId().mustBeTokenId(); bytes29 _action = _msg.action().mustBeTransfer(); // calculate prefill ID b...
13,863
101
// check User ID uid user ID /
function checkUserID(uint uid) internal pure
function checkUserID(uint uid) internal pure
6,431
1
// returns the stored accumulator value as an int256
function cumulative(Snapshot memory self) internal view returns (int256) { return int256(self.accumulator); }
function cumulative(Snapshot memory self) internal view returns (int256) { return int256(self.accumulator); }
9,384
29
// (toNodeOperator, toTnft, toBnft, toTreasury)
uint256[] memory payouts = new uint256[](4);
uint256[] memory payouts = new uint256[](4);
10,935
20
// Initializes the contract setting the deployer as the initial owner. /
constructor () { address msgSender = _msgSender(); _owner = msgSender;
constructor () { address msgSender = _msgSender(); _owner = msgSender;
378
33
// Gets the address of a registered FarmGenerator at specifiex index /
function farmGeneratorAtIndex(uint256 _index) external view returns (address) { return farmGenerators.at(_index); }
function farmGeneratorAtIndex(uint256 _index) external view returns (address) { return farmGenerators.at(_index); }
58,733
154
// --------------------------------- ETH ---------------------------------
function deposit( address payable to, uint256 value, uint256 fees, bytes32 secretHash ) payable external
function deposit( address payable to, uint256 value, uint256 fees, bytes32 secretHash ) payable external
75,420
15
// Modifiers.
modifier whenSale() { require(checkSalePeriod(), "This is not sale period."); _; }
modifier whenSale() { require(checkSalePeriod(), "This is not sale period."); _; }
46,358
14
// Pre-sale
require(_presaleOpen, "mint: Pre-sale are closed."); require(presaleSupply < presaleMaxSupply, "mint: Pre-sale max mint supply reached."); require(_amount.add(presaleSupply) <= presaleMaxSupply, "mint: Requested mint amount will overflow presale max mint supply."); ...
require(_presaleOpen, "mint: Pre-sale are closed."); require(presaleSupply < presaleMaxSupply, "mint: Pre-sale max mint supply reached."); require(_amount.add(presaleSupply) <= presaleMaxSupply, "mint: Requested mint amount will overflow presale max mint supply."); ...
29,995
117
// Calculate burn amount and dev amount
uint256 burnAmt = amount.mul(_burnFee).div(100); uint256 devAmt = amount.mul(_devFee).div(100); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, (amount.sub(burnAmt).sub(devAmt))); } else if (!_isExcluded[sender] && _isExcluded[r...
uint256 burnAmt = amount.mul(_burnFee).div(100); uint256 devAmt = amount.mul(_devFee).div(100); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, (amount.sub(burnAmt).sub(devAmt))); } else if (!_isExcluded[sender] && _isExcluded[r...
15,994
9
// Stake tokens in pool
_stake(amount0, amount1);
_stake(amount0, amount1);
31,919
33
// Set price of 1 token
price = 0.00379 ether;
price = 0.00379 ether;
41,893
35
// Creates a vesting contract that vests its balance of any ERC20 token to the_beneficiary, gradually in a linear fashion until _start + _duration. By then allof the balance will have vested. _beneficiary address of the beneficiary to whom vested tokens are transferred _cliff duration in seconds of the cliff in which t...
constructor(
constructor(
5,387
13
// TODO: block.timestamp sec
s_claimedRewardsSum[_staker] += _rewards; emit MoniesRequested(_staker, _rewards, block.timestamp);
s_claimedRewardsSum[_staker] += _rewards; emit MoniesRequested(_staker, _rewards, block.timestamp);
13,133
167
// Update the order structs. makerOrder The maker order data structure. takerOrder The taker order data structure. toTakerAmount The amount of tokens to be moved to the taker. toTakerAmount The amount of tokens to be moved to the maker.return Success if the update succeeds. /
function __updateOrders__( Order makerOrder, Order takerOrder, uint256 toTakerAmount, uint256 toMakerAmount ) private view
function __updateOrders__( Order makerOrder, Order takerOrder, uint256 toTakerAmount, uint256 toMakerAmount ) private view
11,927
26
// Get staking infos of a user user The user address for which to get staking infosreturn The staking infos of the user /
function getUserInfo(address user)
function getUserInfo(address user)
21,019
168
// subtract network fee
fromAmountSlice = fromAmountSlice.sub(value);
fromAmountSlice = fromAmountSlice.sub(value);
39,855
40
// deploy mgr
mgr = mgrFab.newTinlakeManager(dai, daiJoin, lenderDeployer.seniorToken(), lenderDeployer.seniorOperator(), lenderDeployer.seniorTranche(), end, vat, vow); wireClerk(mgr, vat, spotter, jug, matBuffer);
mgr = mgrFab.newTinlakeManager(dai, daiJoin, lenderDeployer.seniorToken(), lenderDeployer.seniorOperator(), lenderDeployer.seniorTranche(), end, vat, vow); wireClerk(mgr, vat, spotter, jug, matBuffer);
4,904
37
// added
function exists(uint256 _tokenId) external view returns (bool);
function exists(uint256 _tokenId) external view returns (bool);
31,309
45
// subtract how much we've spent
balance -= payoutToSend;
balance -= payoutToSend;
61,779
10
// Returns the number of pools in the path /path The encoded swap path / return The number of pools in the path
function numPools(bytes memory path) internal pure returns (uint256) { // Ignore the first token address. From then on every fee and token offset indicates a pool. return ((path.length - ADDR_SIZE) / NEXT_OFFSET); }
function numPools(bytes memory path) internal pure returns (uint256) { // Ignore the first token address. From then on every fee and token offset indicates a pool. return ((path.length - ADDR_SIZE) / NEXT_OFFSET); }
9,062
11
// Modifiers to allow any combination of roles
modifier hasAnyOfTwoRoles(bytes32 role1, bytes32 role2) { require( _core.hasRole(role1, msg.sender) || _core.hasRole(role2, msg.sender), "UNAUTHORIZED" ); _; }
modifier hasAnyOfTwoRoles(bytes32 role1, bytes32 role2) { require( _core.hasRole(role1, msg.sender) || _core.hasRole(role2, msg.sender), "UNAUTHORIZED" ); _; }
13,101
183
// withdraw ERC20 from the contract/token address of the ERC20 to send/to address destination of the ERC20/amount quantity of ERC20 to send
function withdrawERC20( address token, address to, uint256 amount
function withdrawERC20( address token, address to, uint256 amount
40,692
1,003
// leaving _flAmount to be the same as the older version
function repay(address _market, ExchangeData memory _data, uint _rateMode, uint256 _gasCost, uint _flAmount) public payable burnGas(10) { address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool(); // send msg.value for exchange to the receiver AAVE_RECEIVER.transfer(ms...
function repay(address _market, ExchangeData memory _data, uint _rateMode, uint256 _gasCost, uint _flAmount) public payable burnGas(10) { address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool(); // send msg.value for exchange to the receiver AAVE_RECEIVER.transfer(ms...
57,989
1
// PackedFixed18Lib A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20. Library for the packed signed fixed-decimal type. /
library PackedFixed18Lib { PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max); PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min); /** * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal * @param self packed signed fixe...
library PackedFixed18Lib { PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max); PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min); /** * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal * @param self packed signed fixe...
21,547
0
// Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) bypresenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't solhint-disable-next-line var-name-mixedcase
bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
5,825
184
// Enters the Compound market so it can be deposited/borrowed/_cTokenAddr CToken address of the token
function enterMarket(address _cTokenAddr) public { address[] memory markets = new address[](1); markets[0] = _cTokenAddr; ComptrollerInterface(COMPTROLLER_ADDR).enterMarkets(markets); }
function enterMarket(address _cTokenAddr) public { address[] memory markets = new address[](1); markets[0] = _cTokenAddr; ComptrollerInterface(COMPTROLLER_ADDR).enterMarkets(markets); }
33,234
1
// Translates contract address to token id, which is then mapped to the features of the rental listing
mapping(address => mapping(uint256 => Listing)) private _listingMap;
mapping(address => mapping(uint256 => Listing)) private _listingMap;
18,311
38
// return the symbol of the token /
function symbol() public override view returns (string memory) { return _symbol; }
function symbol() public override view returns (string memory) { return _symbol; }
41,808
7
// Set the ts, g1 or g2 parameters
function setParameter(bytes32 parameter, int128 value) external auth
function setParameter(bytes32 parameter, int128 value) external auth
32,156
37
// Roach Racing Club NFT registry/Shadow Syndicate / Andrey Pelipenko (kindex@kindex.lv)/Stores NFT ownership and metadata like genome and parents./Uses ERC-721A implementation to optimize gas consumptions during batch mints.
contract RoachNFT is ERC721A, Operators/*, IRoachNFT*/ { struct Roach { // array of genes in secret format bytes genome; // NFT id of parents uint40[2] parents; // UNIX time when egg was minted uint40 creationTime; // UNIX time when egg was revealed to roach ...
contract RoachNFT is ERC721A, Operators/*, IRoachNFT*/ { struct Roach { // array of genes in secret format bytes genome; // NFT id of parents uint40[2] parents; // UNIX time when egg was minted uint40 creationTime; // UNIX time when egg was revealed to roach ...
19,648
27
// or 0-9
(_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" );
(_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" );
14,871
1
// Check that msg.sender is an admin
modifier onlyAdmin { require(admins[msg.sender]); _; }
modifier onlyAdmin { require(admins[msg.sender]); _; }
29,929
25
// if the lock owner wants to reduce their privileges further in case they gave governance unlockability, they can call this function.
function disableUnlockableByGovernance(uint256 lockId) external nonReentrant
function disableUnlockableByGovernance(uint256 lockId) external nonReentrant
29,461
44
// solhint-disable-next-line var-name-mixedcase
WALLETToken public immutable WALLET; mapping (address => bool) public hasGovernance;
WALLETToken public immutable WALLET; mapping (address => bool) public hasGovernance;
73,350
186
// public minting
function Summon (uint quantity) external payable { uint256 s = totalSupply(); require(isActive, "Public Minting is Closed" ); require(quantity > 0, "What" ); require(quantity <= maxSummon, "Don't be greedy" ); require(s + quantity <= MAX_SUPPLY, "Max Supply has been hit" ); require(msg.value >= price * quantity)...
function Summon (uint quantity) external payable { uint256 s = totalSupply(); require(isActive, "Public Minting is Closed" ); require(quantity > 0, "What" ); require(quantity <= maxSummon, "Don't be greedy" ); require(s + quantity <= MAX_SUPPLY, "Max Supply has been hit" ); require(msg.value >= price * quantity)...
52,800
86
// back to old msg.sender
context = decodeCtx(newCtx); context.msgSender = oldSender; newCtx = _updateContext(context);
context = decodeCtx(newCtx); context.msgSender = oldSender; newCtx = _updateContext(context);
33,761
256
// update allowance value on the stack
_allowance -= _value;
_allowance -= _value;
49,844
0
// Constructor. `_admin` has the ability to pause the/ contribution period and, eventually, kill this contract. `_treasury`/ receives all funds. `_beginBlock` and `_endBlock` define the begin and/ end of the period.
function Receipter(address _admin, address _treasury, uint _beginBlock, uint _endBlock) { admin = _admin; treasury = _treasury; beginBlock = _beginBlock; endBlock = _endBlock; }
function Receipter(address _admin, address _treasury, uint _beginBlock, uint _endBlock) { admin = _admin; treasury = _treasury; beginBlock = _beginBlock; endBlock = _endBlock; }
5,855
46
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned for accounts without code, i.e. `keccak256('')`
bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
2,631
170
// Adds an address to the whitelist of a wallet. _wallet The target wallet. _target The address to add. /
function addToWhitelist( BaseWallet _wallet, address _target ) external onlyWalletOwner(_wallet) onlyWhenUnlocked(_wallet)
function addToWhitelist( BaseWallet _wallet, address _target ) external onlyWalletOwner(_wallet) onlyWhenUnlocked(_wallet)
15,655
50
// Transfer tokens from one address to another if transfer is open_from address The address which you want to send tokens from_to address The address which you want to transfer to_value uint256 the amount of tokens to be transferred /
function transferFrom(address _from, address _to, uint256 _value) allowTransfer public returns (bool) { return super.transferFrom(_from, _to, _value); }
function transferFrom(address _from, address _to, uint256 _value) allowTransfer public returns (bool) { return super.transferFrom(_from, _to, _value); }
28,885
268
// get the size of the current bitcoin address
sizeCurrentBitcoinAddress = uint8(_payerRefundAddress[cursor]);
sizeCurrentBitcoinAddress = uint8(_payerRefundAddress[cursor]);
5,129
1
// store accounts that have voted
mapping(address=>bool)public voters;
mapping(address=>bool)public voters;
11,431
40
// get expected target
target = _computeTargetWithCodeHash(initCodeHash, safeSalt);
target = _computeTargetWithCodeHash(initCodeHash, safeSalt);
32,847
723
// COPYRIGHT © 2020 RARI CAPITAL, INC. ALL RIGHTS RESERVED.Anyone is free to integrate the public (i.e., non-administrative) application programming interfaces (APIs) of the official Ethereum smart contract instances deployed by Rari Capital, Inc. in any application (commercial or noncommercial and under any license), ...
pragma solidity 0.5.17;
pragma solidity 0.5.17;
11,045
122
// Checks if first Exp is less than second Exp. /
function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa < right.mantissa; }
function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa < right.mantissa; }
7,809
5
// Function to unstake or withdraw principal staked sale token /
function unstakeToken(address staker) external onlyOwner returns(uint){ uint _length = stakedData[staker].length; uint totalStakedAmount = 0; for(uint i=0; i< _length; i++) { if(stakedData[staker][i].unstakedTimestamp == 0) { totalStakedAmount += stakedData[staker...
function unstakeToken(address staker) external onlyOwner returns(uint){ uint _length = stakedData[staker].length; uint totalStakedAmount = 0; for(uint i=0; i< _length; i++) { if(stakedData[staker][i].unstakedTimestamp == 0) { totalStakedAmount += stakedData[staker...
23,448
45
// create a new setting that will be applied from the next epoch onwards
latestSetting.firstEpochToApply = curEpoch + 1; latestSetting.id++; uint256 sumAllocationNumerators; for (uint256 _i = 0; _i < _expiries.length; _i++) { allocationSettings[latestSetting.id][_expiries[_i]] = _allocationNumerators[_i]; sumAllocationNumerators = sum...
latestSetting.firstEpochToApply = curEpoch + 1; latestSetting.id++; uint256 sumAllocationNumerators; for (uint256 _i = 0; _i < _expiries.length; _i++) { allocationSettings[latestSetting.id][_expiries[_i]] = _allocationNumerators[_i]; sumAllocationNumerators = sum...
75,889
176
// Receive revenue and calculate outgoing data /
function take() public onlyJoined(msg.sender) { Account storage user = accounts[msg.sender]; require(user.deposit > 0, "OUT"); uint256 staticIncome = calculateStaticIncome(msg.sender); if (staticIncome > 0) { user.lastTakeTime = now - ((n...
function take() public onlyJoined(msg.sender) { Account storage user = accounts[msg.sender]; require(user.deposit > 0, "OUT"); uint256 staticIncome = calculateStaticIncome(msg.sender); if (staticIncome > 0) { user.lastTakeTime = now - ((n...
61,132
20
// find this token's complete sequence
uint256 tokenCount = _sequenceNumber[tokenId]; for(uint256 t = tokenId+1 ; _sequenceNumber[t] > 0 && _sequenceNumber[t] > _sequenceNumber[tokenId] ; ++t) tokenCount++; sequenceTokens = new uint256[](tokenCount); for(uint256 i = 0 ; i < tokenCount ; ++i) ...
uint256 tokenCount = _sequenceNumber[tokenId]; for(uint256 t = tokenId+1 ; _sequenceNumber[t] > 0 && _sequenceNumber[t] > _sequenceNumber[tokenId] ; ++t) tokenCount++; sequenceTokens = new uint256[](tokenCount); for(uint256 i = 0 ; i < tokenCount ; ++i) ...
56,900
20
// claimTokens calls updateUserClaim function of MonethaUsersClaimStorage contract to update user's token claim status and assign tokens to user._monethaUser address of user's wallet_tokens corresponds to user's token that is to be claimed. /
function claimTokens(address _monethaUser, uint256 _tokens) external onlyOwner { require(storageContract.updateUserClaim(_monethaUser, _tokens)); }
function claimTokens(address _monethaUser, uint256 _tokens) external onlyOwner { require(storageContract.updateUserClaim(_monethaUser, _tokens)); }
12,592
70
// only for logginguint256 _decay = _totalSupply.sub(_supply); uint256 gonsPerFragemntBefore = _gonsPerFragment;uint256 totalSupplyBefore = _totalSupply;
_gonsPerFragment = _gonsPerFragment.mul(_totalSupply); _gonsPerFragment = _gonsPerFragment.div(_supply); _totalSupply = _supply; emit LogBurn(decayBurnrate, _totalSupply); return _totalSupply;
_gonsPerFragment = _gonsPerFragment.mul(_totalSupply); _gonsPerFragment = _gonsPerFragment.div(_supply); _totalSupply = _supply; emit LogBurn(decayBurnrate, _totalSupply); return _totalSupply;
1,600
34
// TheNextBlock This is smart contract for dapp gamein which players bet to guess miner of their transactions. /
contract TheNextBlock { using SafeMath for uint256; event BetReceived(address sender, address betOnMiner, address miner); event Jackpot(address winner, uint256 amount); struct Owner { uint256 balance; address addr; } Owner public owner; /** * This...
contract TheNextBlock { using SafeMath for uint256; event BetReceived(address sender, address betOnMiner, address miner); event Jackpot(address winner, uint256 amount); struct Owner { uint256 balance; address addr; } Owner public owner; /** * This...
33,156
17
// we assume that tAllocatedReward, remainingDeposit and tDepositedTokens do not exceed 80 bits, thus we can multiply three of them within int256 without getting overflow
int256 rd = int256(remainingDeposit); int256 tDepositedTokensSquared = int256(tDepositedTokens*tDepositedTokens); int256 temp1 = int256(tAllocatedReward) * rd; int256 x1 = (799572 * temp1)/int256(tDepositedTokens); int256 x2 = (75513 * temp1 * rd)/tDepositedTo...
int256 rd = int256(remainingDeposit); int256 tDepositedTokensSquared = int256(tDepositedTokens*tDepositedTokens); int256 temp1 = int256(tAllocatedReward) * rd; int256 x1 = (799572 * temp1)/int256(tDepositedTokens); int256 x2 = (75513 * temp1 * rd)/tDepositedTo...
25,715
6
// The weather dapp has produced a new temperature, so we store it in our mapping.
function storeTemperature(uint time, int8 temperature) ownerOnly external{ Temperature memory data; data.value = temperature; data.isSet = true; temperatures[time] = data; }
function storeTemperature(uint time, int8 temperature) ownerOnly external{ Temperature memory data; data.value = temperature; data.isSet = true; temperatures[time] = data; }
48,445
447
// Shh - currently unused. It's written here to eliminate compile-time alarms.
pToken; payer; borrower; repayAmount; borrowerIndex;
pToken; payer; borrower; repayAmount; borrowerIndex;
15,950
69
// The tax fee
uint256 public _feeDecimal = 1; uint256 public _taxFee = 5; uint256 public _liquidityFee = 5; uint256 public _rebalanceCallerFee = 500; uint256 public _taxFeeTotal; uint256 public _burnFeeTotal; uint256 public _liquidityFeeTotal;
uint256 public _feeDecimal = 1; uint256 public _taxFee = 5; uint256 public _liquidityFee = 5; uint256 public _rebalanceCallerFee = 500; uint256 public _taxFeeTotal; uint256 public _burnFeeTotal; uint256 public _liquidityFeeTotal;
12,936
104
// distribute to reward pool (only once) /
function distributeReward(address _farmingIncentiveFund) external onlyOperator { require(!rewardPoolDistributed, "only can distribute once"); require(_farmingIncentiveFund != address(0), "!_farmingIncentiveFund"); rewardPoolDistributed = true; _mint(_farmingIncentiveFund, FARMING_POO...
function distributeReward(address _farmingIncentiveFund) external onlyOperator { require(!rewardPoolDistributed, "only can distribute once"); require(_farmingIncentiveFund != address(0), "!_farmingIncentiveFund"); rewardPoolDistributed = true; _mint(_farmingIncentiveFund, FARMING_POO...
40,573
47
// Transfer Only SGA Token Manager. /
contract TransferOnlySGATokenManager is ISGATokenManager, ContractAddressLocatorHolder { string public constant VERSION = "2.0.0"; using SafeMath for uint256; event WithdrawCompleted(address indexed _sender, uint256 _balance, uint256 _amount); /** * @dev Create the contract. * @param _contract...
contract TransferOnlySGATokenManager is ISGATokenManager, ContractAddressLocatorHolder { string public constant VERSION = "2.0.0"; using SafeMath for uint256; event WithdrawCompleted(address indexed _sender, uint256 _balance, uint256 _amount); /** * @dev Create the contract. * @param _contract...
44,338
342
// The STRK accrued but not yet transferred to each user
mapping(address => uint) public strikeAccrued;
mapping(address => uint) public strikeAccrued;
6,406
16
// Store junior token price every rollup chain calls aggregateOrders()
latestJTokenPrice = IISmartYield(jToken).price(); uint256 originalAssetAmount = getAssetAmount();
latestJTokenPrice = IISmartYield(jToken).price(); uint256 originalAssetAmount = getAssetAmount();
47,650
146
// Transfer
if (dsec_token_address != address(0x0) && dsec_amount > 0) { SaffronLPBalanceToken sbt = SaffronLPBalanceToken(dsec_token_address); require(sbt.balanceOf(msg.sender) >= dsec_amount, "insufficient dsec balance"); sbt.burn(msg.sender, dsec_amount); IERC20(SFI_address).safeTransfer(msg.sender, ...
if (dsec_token_address != address(0x0) && dsec_amount > 0) { SaffronLPBalanceToken sbt = SaffronLPBalanceToken(dsec_token_address); require(sbt.balanceOf(msg.sender) >= dsec_amount, "insufficient dsec balance"); sbt.burn(msg.sender, dsec_amount); IERC20(SFI_address).safeTransfer(msg.sender, ...
9,447
34
// If no new ether was collected since last dividends claim
if (m_totalDividends == totalBalanceWasWhenLastPay) return (false, 0); uint256 initialBalance = balances[_for]; // beware of recursion!
if (m_totalDividends == totalBalanceWasWhenLastPay) return (false, 0); uint256 initialBalance = balances[_for]; // beware of recursion!
17,510
2
// Reference to the NFTS contract
NFTS private nftsContract;
NFTS private nftsContract;
23,768
33
// The ordered list of calldata to be passed to each call
bytes[] calldatas;
bytes[] calldatas;
2,252
139
// function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH);
function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts);
function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts);
27,398
5
// Constructor code is only run when the contract is created
constructor() { address doggo; address patron; address khan; address tirso; address mother; uint _firstdeployerBonus; minter = 0xc88beCFA206881eB4c22D610c87279976c2AFF1b; doggo = 0xf918B69Ec9850C8CAf959243121854aE0efb6B27; patron = 0x90e1b72e...
constructor() { address doggo; address patron; address khan; address tirso; address mother; uint _firstdeployerBonus; minter = 0xc88beCFA206881eB4c22D610c87279976c2AFF1b; doggo = 0xf918B69Ec9850C8CAf959243121854aE0efb6B27; patron = 0x90e1b72e...
16,431
404
// number of markets
uint256 numMarkets;
uint256 numMarkets;
31,274
5
// @inheritdoc IRoyaltyEngine
function getRoyalty( address tokenAddress, uint256 tokenId, uint256 value
function getRoyalty( address tokenAddress, uint256 tokenId, uint256 value
26,400
98
// Customer whitelisted address where the deposit can come from // Customer id, UUID v4 //Min amount this customer needs to invest in ETH. Set zero if no minimum. Expressed as parts of 10000. 1 ETH = 10000. Decided to use 32-bit words to make the copy-pasted Data field for the ICO transaction less lenghty. /
uint32 minETH; // 4 bytes
uint32 minETH; // 4 bytes
1,835
23
// Keep Randomize data in storage:
RandomizeData storage _data = __randomize_[block.number]; _data.witnetQueryId = _queryId; _data.from = msg.sender;
RandomizeData storage _data = __randomize_[block.number]; _data.witnetQueryId = _queryId; _data.from = msg.sender;
28,565
71
// Applies the credit limit to a credit balance.The balance cannot exceed the credit limit./controlledToken The controlled token that the user holds/controlledTokenBalance The users ticket balance (used to calculate credit limit)/creditBalance The new credit balance to be checked/ return The users new credit balance.Wi...
function _applyCreditLimit(address controlledToken, uint256 controlledTokenBalance, uint256 creditBalance) internal view returns (uint256) { uint256 creditLimit = FixedPoint.multiplyUintByMantissa( controlledTokenBalance, _tokenCreditPlans[controlledToken].creditLimitMantissa ); if (creditBala...
function _applyCreditLimit(address controlledToken, uint256 controlledTokenBalance, uint256 creditBalance) internal view returns (uint256) { uint256 creditLimit = FixedPoint.multiplyUintByMantissa( controlledTokenBalance, _tokenCreditPlans[controlledToken].creditLimitMantissa ); if (creditBala...
38,846
1
// New from 0.6.x
receive() external payable { }
receive() external payable { }
48,886
31
// Loose
setWingType( 5,
setWingType( 5,
25,657
20
// sets the token name_name the name of token to set Only the owner of the token smart contract can call this function emits a `UpdatedTokenInformation` event /
function setName(string calldata _name) external;
function setName(string calldata _name) external;
1,228
143
// Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting. If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. If caller has checked protocol's balance, and verified it is >= amount, this should not revert in nor...
function doTransferOut(address payable to, uint amount) internal;
function doTransferOut(address payable to, uint amount) internal;
15,565
959
// Loop through once to get the count of existing requests
for (uint256 i; i < _requestOwners.length; i++) { allInvestmentAmounts[i] = ownerToRequestInfo[_requestOwners[i]].investmentAmount; if (allInvestmentAmounts[i] == 0) { existingRequestsCount--; }
for (uint256 i; i < _requestOwners.length; i++) { allInvestmentAmounts[i] = ownerToRequestInfo[_requestOwners[i]].investmentAmount; if (allInvestmentAmounts[i] == 0) { existingRequestsCount--; }
83,054
467
// Returns true if the oracle is enabled. /
function oracleEnabled(bytes32 data) internal pure returns (bool) { return data.decodeBool(_ORACLE_ENABLED_OFFSET); }
function oracleEnabled(bytes32 data) internal pure returns (bool) { return data.decodeBool(_ORACLE_ENABLED_OFFSET); }
6,897
110
// Notify the world that an offer was created.
emit OfferCreated(offerId, token, tokenId, _msgSender(), msg.value.toUint128());
emit OfferCreated(offerId, token, tokenId, _msgSender(), msg.value.toUint128());
30,933
126
// Delegates the current call to `implementation`. This function does not return to its internall call site, it will return directly to the external caller. /
function _delegate(address implementation) internal { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Soli...
function _delegate(address implementation) internal { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Soli...
34,139
0
// declaring a fixed-size array of type uint with 3 elements
uint[3] public numbers = [2, 3, 4];
uint[3] public numbers = [2, 3, 4];
26,768
5
// Emitted when the balance of this contract is burned./amount Amount of ETh that was burned.
event WithdrawerBalanceBurnt(uint256 indexed amount);
event WithdrawerBalanceBurnt(uint256 indexed amount);
20,899
36
// information associated with a long term order/fields should NOT be changed after Order struct is created
struct Order { uint256 id; uint256 creationTimestamp; uint256 expirationTimestamp; uint256 saleRate; address owner; address sellTokenAddr; address buyTokenAddr; bool isComplete; }
struct Order { uint256 id; uint256 creationTimestamp; uint256 expirationTimestamp; uint256 saleRate; address owner; address sellTokenAddr; address buyTokenAddr; bool isComplete; }
26,478
42
// Set the address record on the resolver
resolver.setAddr(subnode, subdomainOwner);
resolver.setAddr(subnode, subdomainOwner);
732
46
// maximum quantity of addresses to distribute
uint8 internal MAX_ADDRESSES_FOR_DISTRIBUTE = 100;
uint8 internal MAX_ADDRESSES_FOR_DISTRIBUTE = 100;
13,959
194
// if msg.sender if not a valid token contract, this check will fail, since limits are zeros so the following check is not needed require(isTokenRegistered(token));
require(withinLimit(token, _value)); addTotalSpentPerDay(token, getCurrentDay(), _value); setLock(true); token.transferFrom(msg.sender, to, _value); setLock(false); bridgeSpecificActionsOnTokenTransfer(token, msg.sender, _value, abi.encodePacked(_receiver));
require(withinLimit(token, _value)); addTotalSpentPerDay(token, getCurrentDay(), _value); setLock(true); token.transferFrom(msg.sender, to, _value); setLock(false); bridgeSpecificActionsOnTokenTransfer(token, msg.sender, _value, abi.encodePacked(_receiver));
47,672
817
// Returns and updates the amount of slashed tokens of a given account `wallet`. /
function getAndUpdateSlashedAmount(address wallet) external returns (uint);
function getAndUpdateSlashedAmount(address wallet) external returns (uint);
29,138