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 |
|---|---|---|---|---|
186 | // start with current boosted amount | amount = balances[_user].boosted;
uint256 locksLength = locks.length;
| amount = balances[_user].boosted;
uint256 locksLength = locks.length;
| 4,887 |
6 | // Returns the amount which _spender is still allowed to withdraw from _owner | function allowance(address _owner, address _spender) constant returns (uint256 remaining);
| function allowance(address _owner, address _spender) constant returns (uint256 remaining);
| 48,716 |
62 | // Just in rare case, owner wants to transfer Ether from contract to owner address | function manualWithdrawEther()onlyOwner public{
address(address(uint160(owner))).transfer(address(this).balance);
}
| function manualWithdrawEther()onlyOwner public{
address(address(uint160(owner))).transfer(address(this).balance);
}
| 25,963 |
79 | // The zero address indicates there is no approved address. Throws unless `msg.sender` isthe current NFT owner, or an authorized operator of the current owner. Set or reaffirm the approved address for an NFT. This function can be changed to payable. _approved Address to be approved for the given NFT ID. _tokenId ID of the token to be approved. / | function approve(
address _approved,
uint256 _tokenId
)
external
override
canOperate(_tokenId)
validNFToken(_tokenId)
| function approve(
address _approved,
uint256 _tokenId
)
external
override
canOperate(_tokenId)
validNFToken(_tokenId)
| 2,962 |
29 | // The address of the controller is the only address that can call/a function with this modifier | modifier onlyController { if (msg.sender != controller) throw; _; }
address public controller;
constructor() public { controller = msg.sender;}
/// @notice Changes the controller of the contract
/// @param _newController The new controller of the contract
function changeController(address _newController) onlyController public {
controller = _newController;
}
| modifier onlyController { if (msg.sender != controller) throw; _; }
address public controller;
constructor() public { controller = msg.sender;}
/// @notice Changes the controller of the contract
/// @param _newController The new controller of the contract
function changeController(address _newController) onlyController public {
controller = _newController;
}
| 6,384 |
70 | // and cursor.next is still in same bucket, move head to cursor.next | if(infos[info.next].expiresAt.div(BUCKET_STEP) == bucket.div(BUCKET_STEP)){
checkPoints[bucket].head = info.next;
} else {
| if(infos[info.next].expiresAt.div(BUCKET_STEP) == bucket.div(BUCKET_STEP)){
checkPoints[bucket].head = info.next;
} else {
| 4,771 |
128 | // totalReserves + actualAddAmount | uint256 totalReservesNew;
uint256 actualAddAmount;
| uint256 totalReservesNew;
uint256 actualAddAmount;
| 27,496 |
209 | // Create a new token and return it to the caller. The caller will become the only minter and burner and the new owner capable of assigning the roles. tokenName used to describe the new token. tokenSymbol short ticker abbreviation of the name. Ideally < 5 chars. tokenDecimals used to define the precision used in the token's numerical representation.return newToken an instance of the newly created token interface. / | function createToken(
string calldata tokenName,
string calldata tokenSymbol,
uint8 tokenDecimals
| function createToken(
string calldata tokenName,
string calldata tokenSymbol,
uint8 tokenDecimals
| 30,719 |
6 | // send Token to UniPair | stakeGatling.stake(liquidity);
| stakeGatling.stake(liquidity);
| 72,629 |
13 | // pay out the dividends virtually | address _customerAddress = msg.sender;
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
| address _customerAddress = msg.sender;
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
| 5,189 |
0 | // iOVM_L2ToL1MessagePasser / | interface iOVM_L2ToL1MessagePasser {
/**********
* Events *
**********/
event L2ToL1Message(uint256 _nonce, address _sender, bytes _data);
/********************
* Public Functions *
********************/
function passMessageToL1(bytes calldata _message) external;
}
| interface iOVM_L2ToL1MessagePasser {
/**********
* Events *
**********/
event L2ToL1Message(uint256 _nonce, address _sender, bytes _data);
/********************
* Public Functions *
********************/
function passMessageToL1(bytes calldata _message) external;
}
| 31,671 |
143 | // Cyan Payment Plan contract transfers paid amount back to Vault | function earn(uint256 amount, uint256 profit)
external
payable
nonReentrant
onlyRole(CYAN_PAYMENT_PLAN_ROLE)
| function earn(uint256 amount, uint256 profit)
external
payable
nonReentrant
onlyRole(CYAN_PAYMENT_PLAN_ROLE)
| 36,179 |
3 | // set token | info.token = address(this);
| info.token = address(this);
| 14,007 |
40 | // desired, max sent, path, recipient, deadline | IUniswapV2Router02(ROUTER).swapTokensForExactTokens(debt, seized_uUnits, path, address(this), now + 1 minutes);
IERC20(seizeUToken).safeApprove(ROUTER, 0);
| IUniswapV2Router02(ROUTER).swapTokensForExactTokens(debt, seized_uUnits, path, address(this), now + 1 minutes);
IERC20(seizeUToken).safeApprove(ROUTER, 0);
| 25,372 |
240 | // Transition state to `Expired`. | loanState = State.Expired;
emit LoanStateChanged(State.Expired);
| loanState = State.Expired;
emit LoanStateChanged(State.Expired);
| 53,388 |
20 | // Validate Transcript Hash alone of a student _student - Address of student _transcriptHash - Transcript Hash of the GradeSheetreturn Returns true if validation is successful / | function validateTranscriptHash(address _student, uint _docIndx, bytes32 _transcriptHash) public view returns(bool) {
Certification storage certification = studentCertifications[_student];
return (certification.documents[_docIndx]).validateTranscriptHash(_transcriptHash);
}
| function validateTranscriptHash(address _student, uint _docIndx, bytes32 _transcriptHash) public view returns(bool) {
Certification storage certification = studentCertifications[_student];
return (certification.documents[_docIndx]).validateTranscriptHash(_transcriptHash);
}
| 39,869 |
0 | // Internal Functions//RLP encodes a byte string. _in The byte string to encode.return The RLP encoded string in bytes. / | function writeBytes(bytes memory _in) internal pure returns (bytes memory) {
bytes memory encoded;
if (_in.length == 1 && uint8(_in[0]) < 128) {
encoded = _in;
} else {
encoded = abi.encodePacked(_writeLength(_in.length, 128), _in);
}
return encoded;
}
| function writeBytes(bytes memory _in) internal pure returns (bytes memory) {
bytes memory encoded;
if (_in.length == 1 && uint8(_in[0]) < 128) {
encoded = _in;
} else {
encoded = abi.encodePacked(_writeLength(_in.length, 128), _in);
}
return encoded;
}
| 28,701 |
23 | // winner price | token.transfer(msg.sender, winnerAllocation*(firstSeasonRewards/(numberOfRewards-claimRewardsCount))/100);
| token.transfer(msg.sender, winnerAllocation*(firstSeasonRewards/(numberOfRewards-claimRewardsCount))/100);
| 8,194 |
249 | // Withdraw all current liquidity from Uniswap pool | _burnAllLiquidity(baseLower, baseUpper);
_burnAllLiquidity(limitLower, limitUpper);
| _burnAllLiquidity(baseLower, baseUpper);
_burnAllLiquidity(limitLower, limitUpper);
| 29,757 |
94 | // Toggle Bot Scanning external service ON/OFF: choose whether or not the external antibot scannel should be active / | function toggleBotScanner() external onlyOwner() returns (bool) {
bool _localBool;
if(botScanner){
botScanner = false;
_localBool = false;
}
else{
botScanner = true;
_localBool = true;
}
return _localBool;
}
| function toggleBotScanner() external onlyOwner() returns (bool) {
bool _localBool;
if(botScanner){
botScanner = false;
_localBool = false;
}
else{
botScanner = true;
_localBool = true;
}
return _localBool;
}
| 39,647 |
169 | // Do the same for private presale | uint privListLen = airdropPrivateList.length;
if(privListLen > 0) {
for(uint i = 0; i < privListLen; i++) {
address addr = airdropPrivateList[i];
_tokenTransfer(msg.sender, addr, airdropTokens[addr]);
| uint privListLen = airdropPrivateList.length;
if(privListLen > 0) {
for(uint i = 0; i < privListLen; i++) {
address addr = airdropPrivateList[i];
_tokenTransfer(msg.sender, addr, airdropTokens[addr]);
| 22,418 |
105 | // Mapping of message leaves to MessageStatus | mapping(bytes32 => MessageStatus) public messages;
| mapping(bytes32 => MessageStatus) public messages;
| 26,871 |
6 | // return the smaller of the two inputs (a or b) | function limitLessThan(uint a, uint b) internal pure returns (uint c) {
if(a > b) return b;
return a;
}
| function limitLessThan(uint a, uint b) internal pure returns (uint c) {
if(a > b) return b;
return a;
}
| 46,194 |
88 | // Vote NO on a loan by staking TRU id Loan ID stake Amount of TRU to stake / | function no(address id, uint256 stake) external override onlyPendingLoans(id) {
vote(id, stake, false);
}
| function no(address id, uint256 stake) external override onlyPendingLoans(id) {
vote(id, stake, false);
}
| 22,894 |
7 | // call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)it is assumed that when does this that the call should succeed, otherwise one would use vanilla approve instead. | require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
| require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
| 18,027 |
6 | // No error data was returned, revert with "EVMCALLS_CALL_REVERTED" See remix: doing a `revert("EVMCALLS_CALL_REVERTED")` always results in this memory layout | mstore(ptr, 0x08c379a000000000000000000000000000000000000000000000000000000000) // error identifier
mstore(add(ptr, 0x04), 0x0000000000000000000000000000000000000000000000000000000000000020) // starting offset
mstore(add(ptr, 0x24), 0x0000000000000000000000000000000000000000000000000000000000000016) // reason length
mstore(add(ptr, 0x44), 0x45564d43414c4c535f43414c4c5f524556455254454400000000000000000000) // reason
revert(ptr, 100) // 100 = 4 + 3 * 32 (error identifier + 3 words for the ABI encoded error)
| mstore(ptr, 0x08c379a000000000000000000000000000000000000000000000000000000000) // error identifier
mstore(add(ptr, 0x04), 0x0000000000000000000000000000000000000000000000000000000000000020) // starting offset
mstore(add(ptr, 0x24), 0x0000000000000000000000000000000000000000000000000000000000000016) // reason length
mstore(add(ptr, 0x44), 0x45564d43414c4c535f43414c4c5f524556455254454400000000000000000000) // reason
revert(ptr, 100) // 100 = 4 + 3 * 32 (error identifier + 3 words for the ABI encoded error)
| 32,798 |
537 | // to set the token exponent value_val is new value / | function _setTokenExponent(uint _val) internal {
tokenExponent = _val;
}
| function _setTokenExponent(uint _val) internal {
tokenExponent = _val;
}
| 29,122 |
152 | // The block number when TSTI mining starts. | uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
TestyToken _TSTI,
address _devaddr,
address _feeAddress,
| uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
TestyToken _TSTI,
address _devaddr,
address _feeAddress,
| 11,483 |
56 | // Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see{TransparentUpgradeableProxy}./ Initializes the upgradeable proxy with an initial implementation specified by `_logic`. If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encodedfunction call, and allows initializating the storage of the proxy like a Solidity constructor. / | constructor(address _logic, bytes memory _data) public payable {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
_setImplementation(_logic);
if(_data.length > 0) {
Address.functionDelegateCall(_logic, _data);
}
| constructor(address _logic, bytes memory _data) public payable {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
_setImplementation(_logic);
if(_data.length > 0) {
Address.functionDelegateCall(_logic, _data);
}
| 12,450 |
12 | // controlled, msg.sender is typically failed ETO | function destroyTokens(uint256 amount) public;
| function destroyTokens(uint256 amount) public;
| 26,360 |
26 | // ============ Constructor ============ //When a new SetToken is created, initializes Positions in default state and adds modules into pending state.All parameter validations are on the SetTokenCreator contract. Validations are performed already on the SetTokenCreator. Initiates the positionMultiplier as 1e18 (no adjustments)._components List of addresses of components for initial Positions _unitsList of units. Each unit is theof components per 10^18 of a SetToken _modulesList of modules to enable. All modules must be approved by the Controller _controller Address of the controller _managerAddress of the manager _name Name of the SetToken _symbol Symbol of the SetToken / | constructor(
address[] memory _components,
int256[] memory _units,
address[] memory _modules,
IController _controller,
address _manager,
string memory _name,
string memory _symbol
| constructor(
address[] memory _components,
int256[] memory _units,
address[] memory _modules,
IController _controller,
address _manager,
string memory _name,
string memory _symbol
| 6,414 |
33 | // "safeTransfer" which works for KIP7s which return bool or not | rawCall(coins[i], abi.encodeWithSignature("transfer(address,uint256)", msg.sender, value));
| rawCall(coins[i], abi.encodeWithSignature("transfer(address,uint256)", msg.sender, value));
| 20,250 |
248 | // uniswapPercentage = 0.25e18;25% minerLeaguePercentage = 0.1e18;10% operatorPercentage = 0.03e18;3% | err = _setDFLPercentagesFresh(0.25e18, 0.1e18, 0.03e18);
require(err == uint(Error.NO_ERROR), "setting DFL percentages failed");
| err = _setDFLPercentagesFresh(0.25e18, 0.1e18, 0.03e18);
require(err == uint(Error.NO_ERROR), "setting DFL percentages failed");
| 31,067 |
4 | // lendingPoolAddress the address of the lending pool this token is linked to. It is only used to add it as a minter. / | function initialize(address lendingPoolAddress) public {
require(lendingPoolAddress.isContract(), "LP_MUST_BE_CONTRACT");
lendingPool = LendingPoolInterface(lendingPoolAddress);
ERC20Detailed lendingToken = ERC20Detailed(lendingPool.lendingToken());
ERC20Detailed.initialize(
string(abi.encodePacked("Teller ", lendingToken.name())),
string(abi.encodePacked("t", lendingToken.symbol())),
lendingToken.decimals()
);
ERC20Mintable.initialize(lendingPoolAddress);
}
| function initialize(address lendingPoolAddress) public {
require(lendingPoolAddress.isContract(), "LP_MUST_BE_CONTRACT");
lendingPool = LendingPoolInterface(lendingPoolAddress);
ERC20Detailed lendingToken = ERC20Detailed(lendingPool.lendingToken());
ERC20Detailed.initialize(
string(abi.encodePacked("Teller ", lendingToken.name())),
string(abi.encodePacked("t", lendingToken.symbol())),
lendingToken.decimals()
);
ERC20Mintable.initialize(lendingPoolAddress);
}
| 15,090 |
4 | // ========== STATE VARIABLES ========== // ---------- Address Resolver Configuration ---------- // ========== CONSTRUCTOR ========== / | ) public Owned(_owner) Pausable() MixinResolver(_resolver, addressesToCache) {
// Temporarily change the owner so that the setters don't revert.
owner = msg.sender;
setExpiryDuration(_expiryDuration);
setMaxOraclePriceAge(_maxOraclePriceAge);
setMaxTimeToMaturity(_maxTimeToMaturity);
setCreatorCapitalRequirement(_creatorCapitalRequirement);
setCreatorSkewLimit(_creatorSkewLimit);
setPoolFee(_poolFee);
setCreatorFee(_creatorFee);
setRefundFee(_refundFee);
owner = _owner;
}
| ) public Owned(_owner) Pausable() MixinResolver(_resolver, addressesToCache) {
// Temporarily change the owner so that the setters don't revert.
owner = msg.sender;
setExpiryDuration(_expiryDuration);
setMaxOraclePriceAge(_maxOraclePriceAge);
setMaxTimeToMaturity(_maxTimeToMaturity);
setCreatorCapitalRequirement(_creatorCapitalRequirement);
setCreatorSkewLimit(_creatorSkewLimit);
setPoolFee(_poolFee);
setCreatorFee(_creatorFee);
setRefundFee(_refundFee);
owner = _owner;
}
| 2,528 |
101 | // calculates a new senior asset value based on senior redeem and senior supply | function calcSeniorAssetValue(uint seniorRedeem, uint seniorSupply,
uint currSeniorAsset, uint reserve_, uint nav_) public pure returns (uint seniorAsset) {
seniorAsset = safeSub(safeAdd(currSeniorAsset, seniorSupply), seniorRedeem);
uint assets = calcAssets(nav_, reserve_);
if(seniorAsset > assets) {
seniorAsset = assets;
}
| function calcSeniorAssetValue(uint seniorRedeem, uint seniorSupply,
uint currSeniorAsset, uint reserve_, uint nav_) public pure returns (uint seniorAsset) {
seniorAsset = safeSub(safeAdd(currSeniorAsset, seniorSupply), seniorRedeem);
uint assets = calcAssets(nav_, reserve_);
if(seniorAsset > assets) {
seniorAsset = assets;
}
| 22,387 |
78 | // user's stake gets slashed, converted to stablecoin and sent to treasury | uint256 amount = slash(proposals[id].proposer);
convertAndSendTreasuryFunds(amount);
| uint256 amount = slash(proposals[id].proposer);
convertAndSendTreasuryFunds(amount);
| 72,635 |
4 | // The security window | uint256 public securityWindow;
| uint256 public securityWindow;
| 28,353 |
5 | // Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend)./ | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
| function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
| 33,087 |
58 | // Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),reverting with custom message when dividing by zero. CAUTION: This function is deprecated because it requires allocating memory for the error | * message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
| * message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
| 250 |
41 | // This internal function is equivalent to {transfer}, and can be used toe.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.- `sender` must have a balance of at least `amount`. / | function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
| function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
| 1,254 |
54 | // Envelope container | mapping(uint256 => mapping(address => uint256)) internal _assetsEnvelope;
mapping(address => mapping(uint256 => bool)) internal _assetsEnveloped;
| mapping(uint256 => mapping(address => uint256)) internal _assetsEnvelope;
mapping(address => mapping(uint256 => bool)) internal _assetsEnveloped;
| 50,878 |
571 | // Calculate amount given to taker in the right order's maker asset if the right spread will be part of the profit. | if (doesRightMakerAssetProfitExist) {
matchedFillResults.profitInRightMakerAsset = matchedFillResults.right.makerAssetFilledAmount.safeSub(
matchedFillResults.left.takerAssetFilledAmount
);
}
| if (doesRightMakerAssetProfitExist) {
matchedFillResults.profitInRightMakerAsset = matchedFillResults.right.makerAssetFilledAmount.safeSub(
matchedFillResults.left.takerAssetFilledAmount
);
}
| 63,843 |
19 | // 获取单次转手具体信息 | function getSingleHistory(uint _nftId, uint _id) public view user returns(uint, address, address, uint) {
return (
historyOf[_nftId][_id].time,
historyOf[_nftId][_id]._from,
historyOf[_nftId][_id]._to,
historyOf[_nftId][_id].value);
}
| function getSingleHistory(uint _nftId, uint _id) public view user returns(uint, address, address, uint) {
return (
historyOf[_nftId][_id].time,
historyOf[_nftId][_id]._from,
historyOf[_nftId][_id]._to,
historyOf[_nftId][_id].value);
}
| 52,936 |
91 | // enforce minting rules | require(
_internalCall ||
_msgSender() == nameService.getAddress("FUND_MANAGER") ||
hasRole(RESERVE_MINTER_ROLE, _msgSender()),
"GoodReserve: not a minter"
);
require(
IGoodDollar(nameService.getAddress("GOODDOLLAR")).totalSupply() +
_gdToMint <=
| require(
_internalCall ||
_msgSender() == nameService.getAddress("FUND_MANAGER") ||
hasRole(RESERVE_MINTER_ROLE, _msgSender()),
"GoodReserve: not a minter"
);
require(
IGoodDollar(nameService.getAddress("GOODDOLLAR")).totalSupply() +
_gdToMint <=
| 32,126 |
5 | // The token and amount details for a transfer signed in the permit transfer signature | struct TokenPermissions {
// ERC20 token address
address token;
// the maximum amount that can be spent
uint256 amount;
}
| struct TokenPermissions {
// ERC20 token address
address token;
// the maximum amount that can be spent
uint256 amount;
}
| 242 |
28 | // for upgrades | uint256[50] private _gap;
| uint256[50] private _gap;
| 27,367 |
318 | // track the time | uint256 timeNew_ = now;
emit onBuyBlock(_customerAddress, _blockIDArray_, buyBlockPrice_, timeNew_);
| uint256 timeNew_ = now;
emit onBuyBlock(_customerAddress, _blockIDArray_, buyBlockPrice_, timeNew_);
| 37,028 |
8 | // Returns the total amount of tokens in existence. / | function totalSupply() external view returns (uint256 totalSupply_);
| function totalSupply() external view returns (uint256 totalSupply_);
| 4,205 |
773 | // Set ACL base | _setApp(KERNEL_APP_BASES_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, _baseAcl);
| _setApp(KERNEL_APP_BASES_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, _baseAcl);
| 5,947 |
37 | // report a car/part, ex. in 3 reports, get banned | Car memory carStr = cars[car];
return (
carStr.vin,
carStr.metaIpfsHash,
carStr.seller
);
| Car memory carStr = cars[car];
return (
carStr.vin,
carStr.metaIpfsHash,
carStr.seller
);
| 48,790 |
18 | // Verify computed and expected deposit data roots match | require(node == deposit_data_root, "DepositContract: reconstructed DepositData does not match supplied deposit_data_root");
| require(node == deposit_data_root, "DepositContract: reconstructed DepositData does not match supplied deposit_data_root");
| 30,445 |
137 | // Pool token is redeemed. / | event Redeemed(address indexed provider, uint256 redeemAmount, uint256[] amounts, uint256 feeAmount);
| event Redeemed(address indexed provider, uint256 redeemAmount, uint256[] amounts, uint256 feeAmount);
| 15,807 |
29 | // The oracle will have given you an ID for the VRF keypair they have committed to (let's call it keyHash), and have told you the minimum LINK price for VRF service. Make sure your contract has sufficient LINK, and call requestRandomness(keyHash, fee, seed), where seed is the input you want to generate randomness from.Once the VRFCoordinator has received and validated the oracle's response to your request, it will call your contract's fulfillRandomness method.The randomness argument to fulfillRandomness is the actual random value generated from your seed.The requestId argument is generated from the keyHash and the seed by makeRequestId(keyHash, seed). If | abstract contract VRFConsumerBase is VRFRequestIDBase {
using SafeMathChainlink for uint256;
/**
* @notice fulfillRandomness handles the VRF response. Your contract must
* @notice implement it. See "SECURITY CONSIDERATIONS" above for important
* @notice principles to keep in mind when implementing your fulfillRandomness
* @notice method.
*
* @dev VRFConsumerBase expects its subcontracts to have a method with this
* @dev signature, and will call it once it has verified the proof
* @dev associated with the randomness. (It is triggered via a call to
* @dev rawFulfillRandomness, below.)
*
* @param requestId The Id initially returned by requestRandomness
* @param randomness the VRF output
*/
function fulfillRandomness(bytes32 requestId, uint256 randomness)
internal virtual;
/**
* @notice requestRandomness initiates a request for VRF output given _seed
*
* @dev The fulfillRandomness method receives the output, once it's provided
* @dev by the Oracle, and verified by the vrfCoordinator.
*
* @dev The _keyHash must already be registered with the VRFCoordinator, and
* @dev the _fee must exceed the fee specified during registration of the
* @dev _keyHash.
*
* @dev The _seed parameter is vestigial, and is kept only for API
* @dev compatibility with older versions. It can't *hurt* to mix in some of
* @dev your own randomness, here, but it's not necessary because the VRF
* @dev oracle will mix the hash of the block containing your request into the
* @dev VRF seed it ultimately uses.
*
* @param _keyHash ID of public key against which randomness is generated
* @param _fee The amount of LINK to send with the request
* @param _seed seed mixed into the input of the VRF.
*
* @return requestId unique ID for this request
*
* @dev The returned requestId can be used to distinguish responses to
* @dev concurrent requests. It is passed as the first argument to
* @dev fulfillRandomness.
*/
function requestRandomness(bytes32 _keyHash, uint256 _fee, uint256 _seed)
internal returns (bytes32 requestId)
{
LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, _seed));
// This is the seed passed to VRFCoordinator. The oracle will mix this with
// the hash of the block containing this request to obtain the seed/input
// which is finally passed to the VRF cryptographic machinery.
uint256 vRFSeed = makeVRFInputSeed(_keyHash, _seed, address(this), nonces[_keyHash]);
// nonces[_keyHash] must stay in sync with
// VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
// successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
// This provides protection against the user repeating their input seed,
// which would result in a predictable/duplicate output, if multiple such
// requests appeared in the same block.
nonces[_keyHash] = nonces[_keyHash].add(1);
return makeRequestId(_keyHash, vRFSeed);
}
LinkTokenInterface immutable internal LINK;
address immutable private vrfCoordinator;
// Nonces for each VRF key from which randomness has been requested.
//
// Must stay in sync with VRFCoordinator[_keyHash][this]
mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces;
/**
* @param _vrfCoordinator address of VRFCoordinator contract
* @param _link address of LINK token contract
*
* @dev https://docs.chain.link/docs/link-token-contracts
*/
constructor(address _vrfCoordinator, address _link) public {
vrfCoordinator = _vrfCoordinator;
LINK = LinkTokenInterface(_link);
}
// rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
// proof. rawFulfillRandomness then calls fulfillRandomness, after validating
// the origin of the call
function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external {
require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill");
fulfillRandomness(requestId, randomness);
}
}
| abstract contract VRFConsumerBase is VRFRequestIDBase {
using SafeMathChainlink for uint256;
/**
* @notice fulfillRandomness handles the VRF response. Your contract must
* @notice implement it. See "SECURITY CONSIDERATIONS" above for important
* @notice principles to keep in mind when implementing your fulfillRandomness
* @notice method.
*
* @dev VRFConsumerBase expects its subcontracts to have a method with this
* @dev signature, and will call it once it has verified the proof
* @dev associated with the randomness. (It is triggered via a call to
* @dev rawFulfillRandomness, below.)
*
* @param requestId The Id initially returned by requestRandomness
* @param randomness the VRF output
*/
function fulfillRandomness(bytes32 requestId, uint256 randomness)
internal virtual;
/**
* @notice requestRandomness initiates a request for VRF output given _seed
*
* @dev The fulfillRandomness method receives the output, once it's provided
* @dev by the Oracle, and verified by the vrfCoordinator.
*
* @dev The _keyHash must already be registered with the VRFCoordinator, and
* @dev the _fee must exceed the fee specified during registration of the
* @dev _keyHash.
*
* @dev The _seed parameter is vestigial, and is kept only for API
* @dev compatibility with older versions. It can't *hurt* to mix in some of
* @dev your own randomness, here, but it's not necessary because the VRF
* @dev oracle will mix the hash of the block containing your request into the
* @dev VRF seed it ultimately uses.
*
* @param _keyHash ID of public key against which randomness is generated
* @param _fee The amount of LINK to send with the request
* @param _seed seed mixed into the input of the VRF.
*
* @return requestId unique ID for this request
*
* @dev The returned requestId can be used to distinguish responses to
* @dev concurrent requests. It is passed as the first argument to
* @dev fulfillRandomness.
*/
function requestRandomness(bytes32 _keyHash, uint256 _fee, uint256 _seed)
internal returns (bytes32 requestId)
{
LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, _seed));
// This is the seed passed to VRFCoordinator. The oracle will mix this with
// the hash of the block containing this request to obtain the seed/input
// which is finally passed to the VRF cryptographic machinery.
uint256 vRFSeed = makeVRFInputSeed(_keyHash, _seed, address(this), nonces[_keyHash]);
// nonces[_keyHash] must stay in sync with
// VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
// successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
// This provides protection against the user repeating their input seed,
// which would result in a predictable/duplicate output, if multiple such
// requests appeared in the same block.
nonces[_keyHash] = nonces[_keyHash].add(1);
return makeRequestId(_keyHash, vRFSeed);
}
LinkTokenInterface immutable internal LINK;
address immutable private vrfCoordinator;
// Nonces for each VRF key from which randomness has been requested.
//
// Must stay in sync with VRFCoordinator[_keyHash][this]
mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces;
/**
* @param _vrfCoordinator address of VRFCoordinator contract
* @param _link address of LINK token contract
*
* @dev https://docs.chain.link/docs/link-token-contracts
*/
constructor(address _vrfCoordinator, address _link) public {
vrfCoordinator = _vrfCoordinator;
LINK = LinkTokenInterface(_link);
}
// rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
// proof. rawFulfillRandomness then calls fulfillRandomness, after validating
// the origin of the call
function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external {
require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill");
fulfillRandomness(requestId, randomness);
}
}
| 18,557 |
586 | // The Nouns token URI descriptor | INounsDescriptor public descriptor;
| INounsDescriptor public descriptor;
| 15,271 |
74 | // Shows latest USDC price for given asset/ function toUSDC(address assetAdd, uint256 asset) public view | // returns(uint256) {
// if (asset == 0)
// return 0;
// uint256 value;
// // Asset Price
// uint256 backed = getPrice(assetAdd); //8
// // USDC Price
// uint256 USDCValue = getPrice(USDC); //8
// // Converting to gram
// backed = ((backed * 10E8)/ 2835); //8
// backed = (asset * backed) / 10E18; // (assetDecimal * 8)/8 ==== assetDecimal
// value = (USDCValue * backed * (10 ** uint(assetInfo[USDC].assetDecimal))) / (10E16);
// return value;
// }
| // returns(uint256) {
// if (asset == 0)
// return 0;
// uint256 value;
// // Asset Price
// uint256 backed = getPrice(assetAdd); //8
// // USDC Price
// uint256 USDCValue = getPrice(USDC); //8
// // Converting to gram
// backed = ((backed * 10E8)/ 2835); //8
// backed = (asset * backed) / 10E18; // (assetDecimal * 8)/8 ==== assetDecimal
// value = (USDCValue * backed * (10 ** uint(assetInfo[USDC].assetDecimal))) / (10E16);
// return value;
// }
| 24,928 |
6 | // up to 255 item types in 1 product | for(uint8 item_idx = 0; item_idx < counts.length; item_idx++ ){
require(indicies[item_idx] < release_count, "cannot include unreleased items");
require(!releases[indicies[item_idx]].limited, "cannot include limited release");
require(releases[indicies[item_idx]].total_created + counts[item_idx] > releases[indicies[item_idx]].total_created, "too many of specific release");
releases[indicies[item_idx]].total_created = releases[indicies[item_idx]].total_created + (counts[item_idx] * max_copies);
}
| for(uint8 item_idx = 0; item_idx < counts.length; item_idx++ ){
require(indicies[item_idx] < release_count, "cannot include unreleased items");
require(!releases[indicies[item_idx]].limited, "cannot include limited release");
require(releases[indicies[item_idx]].total_created + counts[item_idx] > releases[indicies[item_idx]].total_created, "too many of specific release");
releases[indicies[item_idx]].total_created = releases[indicies[item_idx]].total_created + (counts[item_idx] * max_copies);
}
| 76,563 |
8 | // | constructor(address _treasury) ERC20("Papi Pepe", "PAPIPEPE") {
IRouter _router = IRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address _pair = IFactory(_router.factory()).createPair(
address(this),
_router.WETH()
);
router = _router;
pair = _pair;
excludeFromMaxTransaction(address(_router), true);
excludeFromMaxTransaction(address(_pair), true);
excludeFromMaxWallet(address(_pair), true);
excludeFromMaxWallet(address(_router), true);
_setAutomatedMarketMakerPair(address(_pair), true);
buyTotalFees = buyTreasuryFee + buyBurnFee + buyReflectionFee;
sellTotalFees = sellTreasuryFee + sellBurnFee + sellReflectionFee;
Treasury = _treasury;
_rOwned[_msgSender()] = _rTotal;
_tSupply = _tTotal;
walletDigit = 10;
transDigit = 10;
swapDigit = 5;
maxTransactionAmount = (_tSupply * transDigit) / 1000;
swapTokensAtAmount = (_tSupply * swapDigit) / 10000; // 0.05% swap wallet;
maxWallet = (_tSupply * walletDigit) / 1000;
// exclude from paying fees or having max transaction amount, max wallet amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromFees(Treasury, true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
excludeFromMaxTransaction(Treasury, true);
excludeFromMaxWallet(owner(), true);
excludeFromMaxWallet(address(this), true);
excludeFromMaxWallet(address(0xdead), true);
excludeFromMaxWallet(Treasury, true);
_approve(owner(), address(_router), _tSupply);
_mint(msg.sender, _tSupply);
}
| constructor(address _treasury) ERC20("Papi Pepe", "PAPIPEPE") {
IRouter _router = IRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address _pair = IFactory(_router.factory()).createPair(
address(this),
_router.WETH()
);
router = _router;
pair = _pair;
excludeFromMaxTransaction(address(_router), true);
excludeFromMaxTransaction(address(_pair), true);
excludeFromMaxWallet(address(_pair), true);
excludeFromMaxWallet(address(_router), true);
_setAutomatedMarketMakerPair(address(_pair), true);
buyTotalFees = buyTreasuryFee + buyBurnFee + buyReflectionFee;
sellTotalFees = sellTreasuryFee + sellBurnFee + sellReflectionFee;
Treasury = _treasury;
_rOwned[_msgSender()] = _rTotal;
_tSupply = _tTotal;
walletDigit = 10;
transDigit = 10;
swapDigit = 5;
maxTransactionAmount = (_tSupply * transDigit) / 1000;
swapTokensAtAmount = (_tSupply * swapDigit) / 10000; // 0.05% swap wallet;
maxWallet = (_tSupply * walletDigit) / 1000;
// exclude from paying fees or having max transaction amount, max wallet amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromFees(Treasury, true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
excludeFromMaxTransaction(Treasury, true);
excludeFromMaxWallet(owner(), true);
excludeFromMaxWallet(address(this), true);
excludeFromMaxWallet(address(0xdead), true);
excludeFromMaxWallet(Treasury, true);
_approve(owner(), address(_router), _tSupply);
_mint(msg.sender, _tSupply);
}
| 28,612 |
174 | // Immutable bytecode template. | bytes template;
| bytes template;
| 19,751 |
14 | // Whether or not this market is listed | bool isListed;
| bool isListed;
| 28,115 |
63 | // We also modify the UNBASE supply held in excluded accounts to correctly reflect the circulating supply after the rebase event | for (uint256 i = 0; i < _excluded.length; i++) {
if (_unbaseBalances[_excluded[i]] > 0) {
_unbaseBalances[_excluded[i]] = _unbaseBalances[_excluded[i]].sub(_unbaseBalances[_excluded[i]].mul(_unbasePercent).div(100));
}
| for (uint256 i = 0; i < _excluded.length; i++) {
if (_unbaseBalances[_excluded[i]] > 0) {
_unbaseBalances[_excluded[i]] = _unbaseBalances[_excluded[i]].sub(_unbaseBalances[_excluded[i]].mul(_unbasePercent).div(100));
}
| 13,167 |
2 | // Called when a curve has reached its abump barrier. Because the barrier occurs at the final price in the tick, we need to "shave the price"over into the next tick. The curve has kicked in liquidity that's only activebelow this price, and we need the price to reflect the correct tick. So we burnan economically meaningless amount of collateral token wei to shift the price down by exactly one unit of precision into the next tick. / | pure internal returns (int128, int128, uint128) {
uint128 burnDown = CurveMath.priceToTokenPrecision
(curve.activeLiquidity(), curve.priceRoot_, inBaseQty);
require(swapLeft > burnDown, "BD");
if (isBuy) {
return setShaveUp(curve, inBaseQty, burnDown);
} else {
return setShaveDown(curve, inBaseQty, burnDown);
}
}
| pure internal returns (int128, int128, uint128) {
uint128 burnDown = CurveMath.priceToTokenPrecision
(curve.activeLiquidity(), curve.priceRoot_, inBaseQty);
require(swapLeft > burnDown, "BD");
if (isBuy) {
return setShaveUp(curve, inBaseQty, burnDown);
} else {
return setShaveDown(curve, inBaseQty, burnDown);
}
}
| 13,649 |
60 | // direct numerical comparison works here, because ((e,r) <= (e',r')) implies (epochAndRound <= epochAndRound') because alphabetic ordering implies e <= e', and if e = e', then r<=r', so e256+r <= e'256+r', because r, r' < 256 | require(r.hotVars.latestEpochAndRound < epochAndRound, "stale report");
require(_rs.length > r.hotVars.threshold, "not enough signatures");
require(_rs.length <= maxNumOracles, "too many signatures");
require(_ss.length == _rs.length, "signatures out of registration");
require(r.observations.length <= maxNumOracles,
"num observations out of bounds");
require(r.observations.length > 2 * r.hotVars.threshold,
"too few values to trust median");
| require(r.hotVars.latestEpochAndRound < epochAndRound, "stale report");
require(_rs.length > r.hotVars.threshold, "not enough signatures");
require(_rs.length <= maxNumOracles, "too many signatures");
require(_ss.length == _rs.length, "signatures out of registration");
require(r.observations.length <= maxNumOracles,
"num observations out of bounds");
require(r.observations.length > 2 * r.hotVars.threshold,
"too few values to trust median");
| 11,597 |
243 | // Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no otherfunction in the contract matches the call data. / | fallback() external virtual {
_fallback();
}
| fallback() external virtual {
_fallback();
}
| 846 |
12 | // Get token reserves in ethers | (uint112 reserve_0, uint112 reserve_1, ) = pair.getReserves();
uint256 ethTotal_0 = getEthBalanceByToken(0, reserve_0);
uint256 ethTotal_1 = getEthBalanceByToken(1, reserve_1);
if (hasDeviation(ethTotal_0, ethTotal_1)) {
| (uint112 reserve_0, uint112 reserve_1, ) = pair.getReserves();
uint256 ethTotal_0 = getEthBalanceByToken(0, reserve_0);
uint256 ethTotal_1 = getEthBalanceByToken(1, reserve_1);
if (hasDeviation(ethTotal_0, ethTotal_1)) {
| 30,384 |
112 | // tETH with Governance. | contract tETH_TOKEN is BEP20('tETH Token', 'tETH') {
/// @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);
}
constructor(uint256 initAmount) public {
_mint(msg.sender, initAmount);
}
}
| contract tETH_TOKEN is BEP20('tETH Token', 'tETH') {
/// @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);
}
constructor(uint256 initAmount) public {
_mint(msg.sender, initAmount);
}
}
| 13,331 |
3 | // The DAI TOKEN! | IBEP20 public token;
| IBEP20 public token;
| 391 |
484 | // if unfinished calculate payout vested | uint256 payout = info.payout.mul(percentVested).div(10000);
| uint256 payout = info.payout.mul(percentVested).div(10000);
| 23,186 |
4 | // @inheritdoc ERC165 / | function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == _INTERFACEID_LSP1_DELEGATE || super.supportsInterface(interfaceId);
}
| function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == _INTERFACEID_LSP1_DELEGATE || super.supportsInterface(interfaceId);
}
| 6,072 |
23 | // The use of `normalizedWeight.complement()` assumes that the sum of all weights equals FixedPoint.ONE. This may not be the case when weights are stored in a denormalized format or during a gradual weight change due rounding errors during normalization or interpolation. This will result in a small difference between the output of this function and the equivalent `_calcBptOutGivenExactTokensIn` call. | uint256 invariantRatioWithFees = balanceRatioWithFee.mulDown(normalizedWeight).add(
normalizedWeight.complement()
);
if (balanceRatioWithFee > invariantRatioWithFees) {
uint256 nonTaxableAmount = invariantRatioWithFees > FixedPoint.ONE
? balance.mulDown(invariantRatioWithFees - FixedPoint.ONE)
: 0;
uint256 taxableAmount = amountIn.sub(nonTaxableAmount);
uint256 swapFee = taxableAmount.mulUp(swapFeePercentage);
| uint256 invariantRatioWithFees = balanceRatioWithFee.mulDown(normalizedWeight).add(
normalizedWeight.complement()
);
if (balanceRatioWithFee > invariantRatioWithFees) {
uint256 nonTaxableAmount = invariantRatioWithFees > FixedPoint.ONE
? balance.mulDown(invariantRatioWithFees - FixedPoint.ONE)
: 0;
uint256 taxableAmount = amountIn.sub(nonTaxableAmount);
uint256 swapFee = taxableAmount.mulUp(swapFeePercentage);
| 8,793 |
216 | // expmods_and_points.points[9] = -(g^9z). | mstore(add(expmodsAndPoints, 0x3c0), point)
| mstore(add(expmodsAndPoints, 0x3c0), point)
| 63,453 |
55 | // Check if address is in the tier. The final tier is open to all. | require(
isAddressEligible(msg.sender, tier, merkleProof),
'Invalid Merkle proof'
);
| require(
isAddressEligible(msg.sender, tier, merkleProof),
'Invalid Merkle proof'
);
| 43,485 |
321 | // Event emitted when minting a new NFT. / | event Mint(uint256 indexed index, address indexed minter);
using SafeMath for uint256;
using ECDSA for bytes32;
using Address for address;
address private signVerifier;
uint16 public constant MAX_COUNT = 500;
uint256 public generativeScriptSegmentCount;
| event Mint(uint256 indexed index, address indexed minter);
using SafeMath for uint256;
using ECDSA for bytes32;
using Address for address;
address private signVerifier;
uint16 public constant MAX_COUNT = 500;
uint256 public generativeScriptSegmentCount;
| 5,861 |
94 | // Only owner address can set emergency pause 1 | function ownerPauseGame(bool newStatus) public
onlyOwner
| function ownerPauseGame(bool newStatus) public
onlyOwner
| 10,229 |
16 | // hasSendDirection / | function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
| function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
| 7,651 |
13 | // Allows only the owner of the contract to execute the function | modifier onlyOwner {
assert(msg.sender == owner);
_;
}
| modifier onlyOwner {
assert(msg.sender == owner);
_;
}
| 18,249 |
429 | // The EIP-712 typehash for the delegation struct used by the contract. | bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
| bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
| 41,460 |
97 | // low level token Pledge function | function procureTokens(address beneficiary) public payable {
uint256 tokens;
uint256 weiAmount = msg.value;
uint256 backAmount;
uint256 rate;
uint hardCap;
require(beneficiary != address(0));
rate = getRateIcoWithBonus();
//icoPreICO
hardCap = hardcapPreICO;
if (now >= startIcoPreICO && now < endIcoPreICO && totalSoldTokens < hardCap){
require(weiAmount >= minPurchasePreICO);
tokens = weiAmount.mul(rate);
if (hardCap.sub(totalSoldTokens) < tokens){
tokens = hardCap.sub(totalSoldTokens);
weiAmount = tokens.div(rate);
backAmount = msg.value.sub(weiAmount);
}
}
//icoMainSale
hardCap = hardcapMainSale.add(hardcapPreICO);
if (now >= startIcoMainSale && now < endIcoMainSale && totalSoldTokens < hardCap){
tokens = weiAmount.mul(rate);
if (hardCap.sub(totalSoldTokens) < tokens){
tokens = hardCap.sub(totalSoldTokens);
weiAmount = tokens.div(rate);
backAmount = msg.value.sub(weiAmount);
}
}
require(tokens > 0);
totalSoldTokens = totalSoldTokens.add(tokens);
balances[msg.sender] = balances[msg.sender].add(weiAmount);
token.mint(msg.sender, tokens);
unconfirmedSum = unconfirmedSum.add(tokens);
unconfirmedSumAddr[msg.sender] = unconfirmedSumAddr[msg.sender].add(tokens);
token.SetPermissionsList(beneficiary, 1);
if (backAmount > 0){
msg.sender.transfer(backAmount);
}
emit TokenProcurement(msg.sender, beneficiary, weiAmount, tokens);
}
| function procureTokens(address beneficiary) public payable {
uint256 tokens;
uint256 weiAmount = msg.value;
uint256 backAmount;
uint256 rate;
uint hardCap;
require(beneficiary != address(0));
rate = getRateIcoWithBonus();
//icoPreICO
hardCap = hardcapPreICO;
if (now >= startIcoPreICO && now < endIcoPreICO && totalSoldTokens < hardCap){
require(weiAmount >= minPurchasePreICO);
tokens = weiAmount.mul(rate);
if (hardCap.sub(totalSoldTokens) < tokens){
tokens = hardCap.sub(totalSoldTokens);
weiAmount = tokens.div(rate);
backAmount = msg.value.sub(weiAmount);
}
}
//icoMainSale
hardCap = hardcapMainSale.add(hardcapPreICO);
if (now >= startIcoMainSale && now < endIcoMainSale && totalSoldTokens < hardCap){
tokens = weiAmount.mul(rate);
if (hardCap.sub(totalSoldTokens) < tokens){
tokens = hardCap.sub(totalSoldTokens);
weiAmount = tokens.div(rate);
backAmount = msg.value.sub(weiAmount);
}
}
require(tokens > 0);
totalSoldTokens = totalSoldTokens.add(tokens);
balances[msg.sender] = balances[msg.sender].add(weiAmount);
token.mint(msg.sender, tokens);
unconfirmedSum = unconfirmedSum.add(tokens);
unconfirmedSumAddr[msg.sender] = unconfirmedSumAddr[msg.sender].add(tokens);
token.SetPermissionsList(beneficiary, 1);
if (backAmount > 0){
msg.sender.transfer(backAmount);
}
emit TokenProcurement(msg.sender, beneficiary, weiAmount, tokens);
}
| 58,849 |
49 | // transfer output tokens to recipient | if (recipient != address(this)) {
tokenOut.safeTransfer(recipient, tokenAmountOut);
}
| if (recipient != address(this)) {
tokenOut.safeTransfer(recipient, tokenAmountOut);
}
| 3,938 |
27 | // ab does not overflow, return exact math | value = _numA * _numB;
value /= _den;
return value;
| value = _numA * _numB;
value /= _den;
return value;
| 902 |
18 | // Get the token balance for account `tokenOwner` | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return tokenBalances[tokenOwner];
}
| function balanceOf(address tokenOwner) public constant returns (uint balance) {
return tokenBalances[tokenOwner];
}
| 12,414 |
278 | // Tell the information related to a Disputable app_disputable Address of the Disputable app return activated Whether the Disputable app is active return currentCollateralRequirementId Identification number of the current collateral requirement/ | function getDisputableInfo(address _disputable) external view returns (bool activated, uint256 currentCollateralRequirementId) {
DisputableInfo storage disputableInfo = disputableInfos[_disputable];
activated = disputableInfo.activated;
uint256 nextId = disputableInfo.nextCollateralRequirementsId;
// Since `nextCollateralRequirementsId` is initialized to 1 when disputable apps are activated, it is safe to consider the
// current collateral requirement ID of a disputable app as 0 if it has not been set yet, which means it was not activated yet.
currentCollateralRequirementId = nextId == 0 ? 0 : nextId - 1;
}
| function getDisputableInfo(address _disputable) external view returns (bool activated, uint256 currentCollateralRequirementId) {
DisputableInfo storage disputableInfo = disputableInfos[_disputable];
activated = disputableInfo.activated;
uint256 nextId = disputableInfo.nextCollateralRequirementsId;
// Since `nextCollateralRequirementsId` is initialized to 1 when disputable apps are activated, it is safe to consider the
// current collateral requirement ID of a disputable app as 0 if it has not been set yet, which means it was not activated yet.
currentCollateralRequirementId = nextId == 0 ? 0 : nextId - 1;
}
| 58,238 |
26 | // used to get key of combined StudyID and patientId -> ("StudyID:PatientID") | function getKey(uint256 _patientId, uint256 _studyId)
internal
pure
returns (string memory key)
| function getKey(uint256 _patientId, uint256 _studyId)
internal
pure
returns (string memory key)
| 38,092 |
408 | // Do pre-exchange validations | BorrowShared.validateTxPreSell(state, transaction);
| BorrowShared.validateTxPreSell(state, transaction);
| 17,885 |
67 | // Fetch the information about user. His claimable balance, fixed balance & stuff / | function fetchUser(address _user) public view returns(uint256[] memory _bundles,string memory username,uint256 claimable,uint256 staked_balance, bool active){
User storage us = user[_user];
return(us.bundles,us.username,us.freebal,us.balance,us.active);
}
| function fetchUser(address _user) public view returns(uint256[] memory _bundles,string memory username,uint256 claimable,uint256 staked_balance, bool active){
User storage us = user[_user];
return(us.bundles,us.username,us.freebal,us.balance,us.active);
}
| 12,350 |
31 | // Calculates the amount that has already vested. account address of the user / | function _vestedAmount(address account) internal view returns (uint256) {
VestedToken storage vested = vestedUser[account];
uint256 totalToken = vested.totalToken;
if(block.timestamp < vested.start.add(vested.cliff)){
return 0;
}else if(block.timestamp >= vested.start.add(vested.duration) || vested.revoked){
return totalToken;
}else{
uint256 numberOfPeriods = (block.timestamp.sub(vested.start)).div(vested.cliff);
return totalToken.mul(numberOfPeriods.mul(vested.cliff)).div(vested.duration);
}
}
| function _vestedAmount(address account) internal view returns (uint256) {
VestedToken storage vested = vestedUser[account];
uint256 totalToken = vested.totalToken;
if(block.timestamp < vested.start.add(vested.cliff)){
return 0;
}else if(block.timestamp >= vested.start.add(vested.duration) || vested.revoked){
return totalToken;
}else{
uint256 numberOfPeriods = (block.timestamp.sub(vested.start)).div(vested.cliff);
return totalToken.mul(numberOfPeriods.mul(vested.cliff)).div(vested.duration);
}
}
| 35,454 |
4 | // Depends on the number of requested values that you want sent to the fulfillRandomWords() function. Storing each word costs about 20,000 gas, so 100,000 is a safe default for this example contract. Test and adjust this limit based on the network that you select, the size of the request, and the processing of the callback request in the fulfillRandomWords() function. | uint32 callbackGasLimit = 300000;
| uint32 callbackGasLimit = 300000;
| 7,359 |
543 | // Sandalwood rewarded as part of the Opening Ceremony quests / | contract SandalwoodToken is ERC20, ERC20Burnable {
constructor() ERC20("Sandalwood", "Sandalwood") {
_mint(_msgSender(), 1e12 * 1e18);
}
}
| contract SandalwoodToken is ERC20, ERC20Burnable {
constructor() ERC20("Sandalwood", "Sandalwood") {
_mint(_msgSender(), 1e12 * 1e18);
}
}
| 49,100 |
18 | // Add in first position | if (isSale) {
if (value < orders[firstNode - 1].value) {
saleOrdersMappingByAssets[asset][0] = orderIndex;
saleOrdersMappingByAssets[asset][orderIndex] = firstNode;
numberOfSaleOrdersByAssets[asset] += 1;
return true;
}
| if (isSale) {
if (value < orders[firstNode - 1].value) {
saleOrdersMappingByAssets[asset][0] = orderIndex;
saleOrdersMappingByAssets[asset][orderIndex] = firstNode;
numberOfSaleOrdersByAssets[asset] += 1;
return true;
}
| 25,761 |
360 | // Updates user's fees reward | function _updateFeesReward(address account) internal {
uint liquidity = pool.positionLiquidity(tickLower, tickUpper);
if (liquidity == 0) return; // we can't poke when liquidity is zero
(uint256 collect0, uint256 collect1) = _earnFees();
token0PerShareStored = _tokenPerShare(collect0, token0PerShareStored);
token1PerShareStored = _tokenPerShare(collect1, token1PerShareStored);
if (account != address(0)) {
UserInfo storage user = userInfo[msg.sender];
user.token0Rewards = _fee0Earned(account, token0PerShareStored);
user.token0PerSharePaid = token0PerShareStored;
user.token1Rewards = _fee1Earned(account, token1PerShareStored);
user.token1PerSharePaid = token1PerShareStored;
}
}
| function _updateFeesReward(address account) internal {
uint liquidity = pool.positionLiquidity(tickLower, tickUpper);
if (liquidity == 0) return; // we can't poke when liquidity is zero
(uint256 collect0, uint256 collect1) = _earnFees();
token0PerShareStored = _tokenPerShare(collect0, token0PerShareStored);
token1PerShareStored = _tokenPerShare(collect1, token1PerShareStored);
if (account != address(0)) {
UserInfo storage user = userInfo[msg.sender];
user.token0Rewards = _fee0Earned(account, token0PerShareStored);
user.token0PerSharePaid = token0PerShareStored;
user.token1Rewards = _fee1Earned(account, token1PerShareStored);
user.token1PerSharePaid = token1PerShareStored;
}
}
| 8,715 |
0 | // ERC20 Token Standard, optional extension: Allowance./See https:eips.ethereum.org/EIPS/eip-20/Note: the ERC-165 identifier for this interface is 0x9d075186. | interface IERC20Allowance {
/// @notice Increases the allowance granted to an account by the sender.
/// @notice This is an alternative to {approve} that can be used as a mitigation for transaction ordering problems.
/// @dev Reverts if `spender` is the zero address.
/// @dev Reverts if `spender`'s allowance by the sender overflows.
/// @dev Emits an {IERC20-Approval} event with an updated allowance for `spender` by the sender.
/// @param spender The account whose allowance is being increased.
/// @param value The allowance amount increase.
/// @return result Whether the operation succeeded.
function increaseAllowance(address spender, uint256 value) external returns (bool result);
/// @notice Decreases the allowance granted to an account by the sender.
/// @notice This is an alternative to {approve} that can be used as a mitigation for transaction ordering problems.
/// @dev Reverts if `spender` is the zero address.
/// @dev Reverts if `spender` does not have at least `value` of allowance by the sender.
/// @dev Emits an {IERC20-Approval} event with an updated allowance for `spender` by the sender.
/// @param spender The account whose allowance is being decreased.
/// @param value The allowance amount decrease.
/// @return result Whether the operation succeeded.
function decreaseAllowance(address spender, uint256 value) external returns (bool result);
}
| interface IERC20Allowance {
/// @notice Increases the allowance granted to an account by the sender.
/// @notice This is an alternative to {approve} that can be used as a mitigation for transaction ordering problems.
/// @dev Reverts if `spender` is the zero address.
/// @dev Reverts if `spender`'s allowance by the sender overflows.
/// @dev Emits an {IERC20-Approval} event with an updated allowance for `spender` by the sender.
/// @param spender The account whose allowance is being increased.
/// @param value The allowance amount increase.
/// @return result Whether the operation succeeded.
function increaseAllowance(address spender, uint256 value) external returns (bool result);
/// @notice Decreases the allowance granted to an account by the sender.
/// @notice This is an alternative to {approve} that can be used as a mitigation for transaction ordering problems.
/// @dev Reverts if `spender` is the zero address.
/// @dev Reverts if `spender` does not have at least `value` of allowance by the sender.
/// @dev Emits an {IERC20-Approval} event with an updated allowance for `spender` by the sender.
/// @param spender The account whose allowance is being decreased.
/// @param value The allowance amount decrease.
/// @return result Whether the operation succeeded.
function decreaseAllowance(address spender, uint256 value) external returns (bool result);
}
| 41,961 |
123 | // we can take all | if (toWithdraw > liquidity) {
toWithdraw = liquidity;
}
| if (toWithdraw > liquidity) {
toWithdraw = liquidity;
}
| 29,831 |
26 | // Set offerReferrerAddressSlot0 to the first 16B of the referrer address. By shifting the referrer 32 bits to the right we obtain the first 16B. | offer.offerReferrerAddressSlot0 = uint128(uint160(address(referrer)) >> 32);
| offer.offerReferrerAddressSlot0 = uint128(uint160(address(referrer)) >> 32);
| 17,932 |
4 | // Behaviour201911 AZTEC Details the methods and the storage schema of a note registry.Methods are documented in interface. Copyright 2020 Spilsbury Holdings LtdLicensed under the GNU Lesser General Public Licence, Version 3.0 (the "License");you may not use this file except in compliance with the License. This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See theGNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License/ | contract Behaviour201911 is Behaviour201907 {
uint256 public constant slowReleaseEnd = 1585699199;
bool public isAvailableDuringSlowRelease = false;
modifier onlyIfAvailable() {
// Not sensitive to small differences in time
require(isAvailableDuringSlowRelease == true || slowReleaseEnd < block.timestamp,
"AZTEC is in burn-in period, and this asset is not available");
_;
}
function makeAvailable() public onlyOwner {
require(isAvailableDuringSlowRelease == false, "asset is already available");
isAvailableDuringSlowRelease = true;
}
function updateNoteRegistry(
uint24 _proof,
bytes memory _proofOutput
) public onlyOwner onlyIfAvailable returns (
address publicOwner,
uint256 transferValue,
int256 publicValue
) {
(
publicOwner,
transferValue,
publicValue
) = super.updateNoteRegistry(_proof, _proofOutput);
}
}
| contract Behaviour201911 is Behaviour201907 {
uint256 public constant slowReleaseEnd = 1585699199;
bool public isAvailableDuringSlowRelease = false;
modifier onlyIfAvailable() {
// Not sensitive to small differences in time
require(isAvailableDuringSlowRelease == true || slowReleaseEnd < block.timestamp,
"AZTEC is in burn-in period, and this asset is not available");
_;
}
function makeAvailable() public onlyOwner {
require(isAvailableDuringSlowRelease == false, "asset is already available");
isAvailableDuringSlowRelease = true;
}
function updateNoteRegistry(
uint24 _proof,
bytes memory _proofOutput
) public onlyOwner onlyIfAvailable returns (
address publicOwner,
uint256 transferValue,
int256 publicValue
) {
(
publicOwner,
transferValue,
publicValue
) = super.updateNoteRegistry(_proof, _proofOutput);
}
}
| 45,264 |
63 | // set the new player bool to true | return (true);
| return (true);
| 15,202 |
82 | // This is needed to avoid costly repeat calls to different getter functions It is cheaper gas-wise to just dump everything and only use some of the info | function frax_info() public view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
return (
oracle_price(PriceChoice.FRAX), // frax_price()
oracle_price(PriceChoice.FXS), // fxs_price()
totalSupply(), // totalSupply()
global_collateral_ratio, // global_collateral_ratio()
globalCollateralValue(), // globalCollateralValue
minting_fee, // minting_fee()
redemption_fee, // redemption_fee()
uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals) //eth_usd_price
);
}
| function frax_info() public view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
return (
oracle_price(PriceChoice.FRAX), // frax_price()
oracle_price(PriceChoice.FXS), // fxs_price()
totalSupply(), // totalSupply()
global_collateral_ratio, // global_collateral_ratio()
globalCollateralValue(), // globalCollateralValue
minting_fee, // minting_fee()
redemption_fee, // redemption_fee()
uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals) //eth_usd_price
);
}
| 3,980 |
40 | // setter/getter for digits constant (current 1018)/ | function setAdjConstant(uint256 new_adj_constant) external onlyOwner{
adj_constant = new_adj_constant;
}
| function setAdjConstant(uint256 new_adj_constant) external onlyOwner{
adj_constant = new_adj_constant;
}
| 40,084 |
573 | // slope of the stable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray | uint256 internal stableRateSlope1;
| uint256 internal stableRateSlope1;
| 39,883 |
131 | // Get the time remaining until the malicious DKG result/ slashing amount can be updated./ return Remaining time in seconds. | function getRemainingMaliciousDkgResultSlashingAmountUpdateTime()
external
view
returns (uint256)
| function getRemainingMaliciousDkgResultSlashingAmountUpdateTime()
external
view
returns (uint256)
| 35,616 |
65 | // Bad interface | require(upgradeAgent.isUpgradeAgent(), "The provided updateAgent contract is required to be compliant to the UpgradeAgent interface method when setting upgrade agent.");
| require(upgradeAgent.isUpgradeAgent(), "The provided updateAgent contract is required to be compliant to the UpgradeAgent interface method when setting upgrade agent.");
| 28,191 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.