file_name stringlengths 71 779k | comments stringlengths 0 29.4k | code_string stringlengths 20 7.69M | __index_level_0__ int64 2 17.2M |
|---|---|---|---|
/*
B.PROTOCOL TERMS OF USE
=======================
THE TERMS OF USE CONTAINED HEREIN (THESE “TERMS”) GOVERN YOUR USE OF B.PROTOCOL, WHICH IS A DECENTRALIZED PROTOCOL ON THE ETHEREUM BLOCKCHAIN (the “PROTOCOL”) THAT enables a backstop liquidity mechanism FOR DECENTRALIZED LENDING PLATFORMS (“DLPs”).
PLEASE READ THESE... | verify cdp is unsafe now | function bite(uint cdp, uint dart) external onlyPool returns(uint dink){
address urn = urns[cdp];
bytes32 ilk = ilks[cdp];
(uint ink, uint art) = vat.urns(ilk, urn);
art = add(art, cushion[cdp]);
(, uint rate, uint spotValue,,) = vat.ilks(ilk);
require(dart <= art, ... | 2,205,307 |
pragma solidity ^0.5.0;
/// @notice The interface of the identity registry contract
/// @author Merunas Grincalaitis <merunasgrincalaitis@gmail.com>
interface IdentityRegistryInterface {
function isSigned(address _address, bytes32 messageHash, uint8 v, bytes32 r, bytes32 s)
external pure returns (bool);
... | To add a new credit card to your account. All function will be encrypted the moment the data is added _cardNumber The number of the credit or debit card to add to your account _expiry When the card expires in timestamp _name The name of the card _cvv The 3 or 4 digit code for verifying the card return bytes32 Retur... | function addCard(uint256 _cardNumber, uint256 _expiry, string memory _name, uint256 _cvv) public returns(bytes32) {
require(_cardNumber != 0, 'The card number cannot be empty');
require(_expiry != 0, 'The card expiration date cannot be empty');
require(bytes(_name).length != 0, 'The card nam... | 5,376,512 |
// File: contracts/vaults/IStrategy.sol
... | inject NONSTANDARD NAMING | function ADD14(uint256 a, uint256 b) internal pure returns (uint256) { | 1,825,091 |
./full_match/137/0xC023011dC6fDd23a586629EF8546081b628c3498/sources/contracts/PToken/PToken.sol | @inheritdoc IPToken/ | function getDepositIndexById(uint256 id) external view override returns (uint256 index) {
_require(id < lockedDepositsIndexes.length, Errors.DEPOSIT_DOES_NOT_EXIST.selector);
return lockedDepositsIndexes[id];
}
| 3,749,151 |
// Sources flattened with hardhat v2.8.4 https://hardhat.org
// File @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol@v4.3.0
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be depl... | EIP2612 and Deposit./ | function permitEIP2612AndDepositErc20(
address tokenAddress,
address receiver,
uint256 amount,
uint256 toChainId,
PermitRequest calldata permitOptions,
string calldata tag
) external {
IERC20Permit(tokenAddress).permit(
_msgSender(),
... | 12,902,921 |
pragma solidity ^0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is ... | Counts the number of tokens depending on the funds deposited _beneficiary Address for which to get the tokens amount _weiAmount Value in wei involved in the purchase return Number of tokens/ | function _getTokensAmount(address _beneficiary, uint256 _weiAmount) internal view returns (uint256 tokens, uint256 bonus) {
(tokens, bonus) = getTokensAmount(_weiAmount, lockedValues[_beneficiary], tokensSold);
}
| 2,492,463 |
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.8.4;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";
import "./interfaces/IERC20Modified.sol";
import "./tokens/VolmexPositionToken.sol";
import "./VolmexProtocol.sol";
/**
* @titl... | Pause/unpause volmex position token. _isPause Boolean value to pause or unpause the position token { true = pause, false = unpause }/ | function togglePause(bool _isPause) external onlyOwner {
if (_isPause) {
volatilityToken.pause();
inverseVolatilityToken.pause();
volatilityToken.unpause();
inverseVolatilityToken.unpause();
}
emit ToggledVolatilityTokenPause(_isPause);
}
... | 326,092 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Sol... | / To change the approve amount you first have to reduce the addresses` allowance to zero by calling `approve(_spender, 0)` if it is not already 0 to mitigate the race condition described here: https:github.com/ethereum/EIPs/issues/20issuecomment-263524729 | function approve(address _spender, uint _value) unfreezed(_spender) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true... | 41,911 |
pragma solidity ^0.5.11;
import "mix-item-store/MixItemStoreInterface.sol";
contract MixItemMentions {
/**
* @dev Mapping of itemId to array of account addresses.
*/
mapping (bytes32 => address[]) itemIdMentionAccounts;
/**
* @dev Mapping of account address to array of itemIds.
*/
... | Query an acount's mentions. account Address of the account. offset Index of the first itemId to retreive. limit Maximum number of itemIds to retrieve. return The itemIds./ Get mention itemIds. Check if offset is beyond the end of the array. Populate memory array. | function getMentionItemsByQuery(address account, uint offset, uint limit) external view returns (bytes32[] memory itemIds) {
bytes32[] storage mentionItemIds = accountMentionItemIds[account];
if (offset >= mentionItemIds.length) {
return new bytes32[](0);
}
if (offset + l... | 15,790,923 |
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error,... | Claim reward/ Round valid, claim rewards Round invalid, refund bet amount | function claim(uint256 epoch) external notContract {
require(rounds[epoch].startBlock != 0, "Round has not started");
require(block.number > rounds[epoch].endBlock, "Round has not ended");
require(!ledger[epoch][msg.sender].claimed, "Rewards claimed");
uint256 reward;
if (ro... | 2,535,857 |
pragma solidity ^0.5.11;
contract Token {
function transfer(address to, uint256 value) public returns (bool success);
bool claimed_TOD20 = false;
address payable owner_TOD20;
uint256 reward_TOD20;
function setReward_TOD20() public payable {
require (!claimed_TOD20);
require(msg.sender == owner_TOD20... | array length should be within 10. | {
require(msg.sender==admin);
require(addr.length <10 && feeamount.length < 10 && addr.length==feeamount.length);
function setwithdrawfee(address[] memory addr,uint256[] memory feeamount)public returns(bool)
for(uint8 i=0;i<addr.length;i++){
withdrawfee[addr[i]]=fee... | 5,447,139 |
// contracts/staking/BalleRewardDistribution.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../token/BALLEv2.sol";
import ... | Function to change the rewardFund address./ | function setRewardFund(address _rewardFund) external onlyOwner {
require(_rewardFund != address(0), "zero address");
rewardFund = _rewardFund;
}
| 2,510,161 |
./partial_match/4/0x8915F3d8Dd4954788041671CB57Be0BE3f0C47a2/sources/SQUIDMASTER.sol | Update reward variables of the given pool to be up-to-date. | function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;... | 8,509,420 |
// "SPDX-License-Identifier: UNLICENSED"
pragma solidity >=0.6.10;
pragma experimental ABIEncoderV2;
/// @title IGelatoCondition - solidity interface of GelatoConditionsStandard
/// @notice all the APIs of GelatoConditionsStandard
/// @dev all the APIs are implemented inside GelatoConditionsStandard
interface IGelatoC... | all the APIs and events of GelatoActionsStandard all the APIs are implemented inside GelatoActionsStandard | interface IGelatoAction {
function termsOk(
uint256 _taskReceiptId,
address _userProxy,
bytes calldata _actionData,
DataFlow _dataFlow,
uint256 _value,
uint256 _cycleId
) external view returns (string memory);
}
}
| 5,783,545 |
./full_match/42/0xCCA4ab1723cDF01bbD89A1991B63d92Dc1eF9964/sources/contracts/FundMe.sol | ( uint80 roundID, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound | function getPrice() public view returns(uint256){
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
(,int256 answer,,,) = priceFeed.latestRoundData();
return uint256(answer * 1e10);
}
| 9,581,306 |
./full_match/80001/0xBd99517e1994226FB8124D37087A0b835829D593/sources/contracts/Portfolio.sol | Write function to add skill | function addSkill(string memory name, uint _rating) public onlyOwner {
require(bytes(name).length > 0, "Name cannot be empty");
require(
_rating >= 1 && _rating <= 10,
"Rating must be between 1 and 10"
);
_skills.push(Skill(name, _rating));
}
| 5,572,182 |
// SPDX-License-Identifier: MIT
// @unsupported: ovm
pragma solidity >0.5.0 <0.8.0;
pragma experimental ABIEncoderV2;
/* Interface Imports */
import { iOVM_L1CrossDomainMessenger } from
"../../../iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol";
import { iOVM_L1MultiMessageRelayer } from
"../../../iOVM/b... | Reads an RLP bool value into a bool. _in RLP bool value. return Decoded bool./ | function readBool(
bytes memory _in
)
internal
pure
returns (
bool
)
{
return readBool(
toRLPItem(_in)
);
}
| 83,218 |
./full_match/40/0xfB8eDeD3e963C1Ba0e5215DB124848400C7a69dA/sources/contracts/OmnidexBtcTlos.sol | Compounds the strategy's earnings and charges fees | function _harvest(address caller) internal whenNotPaused {
if (caller != vault){
require(!Address.isContract(msg.sender), "!EOA");
}
IZenMaster(chef).deposit(poolId, 0);
uint256 outputBal = IERC20(charm).balanceOf(address(this));
if (outputBal > 0 ) {
... | 9,543,303 |
./partial_match/1/0xE26A601Dec9FCd2d1079ACdeDC5ECcaBBcC89df8/sources/Staking.sol | Allows users to compound their pending rewards by adding them to their staked amount. | function compound() external isPoolOnline(1) nonReentrant {
UserInfo storage user = userInfo[msg.sender];
uint userAmnt = user.amount;
require(userAmnt != 0, "No amount stacked");
require(user.amountToWithdraw == 0, "Cant compound if withdraw initiated");
UserInfo storage use... | 15,767,224 |
./full_match/1/0x57c88D78f6D08b5c88b4A3b7BbB0C1AA34c3280A/sources/src/loan/terms/simple/loan/PWNSimpleLoan.sol | See {IERC5646-getStateFingerprint}./ The only mutable state properties are: - status, expiration Status is updated for expired loans based on block.timestamp. Others don't have to be part of the state fingerprint as it does not act as a token identification. | function getStateFingerprint(uint256 tokenId) external view virtual override returns (bytes32) {
LOAN storage loan = LOANs[tokenId];
if (loan.status == 0)
return bytes32(0);
return keccak256(abi.encode(
_getLOANStatus(tokenId),
loan.expiration
))... | 2,935,933 |
./full_match/137/0x7d561bE86eBCB1d8353f98c21Bef7232343598a8/sources/WebaverseERC721.sol | Add a collaborator to a single token (like land) tokenId ID of the token a Address to whitelist/ | function addSingleCollaborator(uint256 tokenId, address a) public {
require(
ownerOf(tokenId) == a || isSingleCollaborator(tokenId, msg.sender),
"you are not a collaborator"
);
require(
!isSingleCollaborator(tokenId, a),
"they are already a col... | 4,669,352 |
./partial_match/42/0x2E8fcdF765ec0AeE0693Aa2eA1ED70457F30080b/sources/LevelsVault.sol | Returns the address of the current super admin/ | function superAdmin() public view returns (address) {
return _superAdmin;
}
| 3,307,898 |
/**
* Crowdfunding.sol v1.0.0
*
* Bilal Arif - https://twitter.com/furusiyya_
* Notary Platform
*/
pragma solidity ^0.4.16;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
ret... | return investors Total of distinct investors/ | function distinctInvestors() external constant returns(uint256){
return investorCount;
}
| 933,816 |
pragma solidity ^0.4.24;
contract OraclizeI {
address public cbAddress;
function query(uint _timestamp, string _datasource, string _arg) external payable returns (bytes32 _id);
function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) external payable returns (bytes32 _i... | After ICO close it helps to lock tokens for pools/ | function close() onlyOwner public {
require(state == State.Active);
state = State.Closed;
emit Closed();
}
| 46,055 |
./full_match/5/0x54FFCE9bE0C17840103e5b28408932A2C6cC7ED4/sources/contracts/Balances.sol | function to allow referrers or contract owner to withdraw their ETH/get the address of the senderif the sender is the contract ownercalculate the amount that can be withdrawnsend the amount to the contract owner's address Require that the senders balance is greater than 0. Calculate the amount that the sender can withd... | function rentPrice(bytes memory name, uint256 duration)
public
view
virtual
returns (uint256);
function withdraw() public {
address payable sender = payable(msg.sender);
if(sender == owner()) {
uint256 ownerAmount = address(this).b... | 7,064,062 |
pragma solidity ^0.4.0;
contract VickreyAuction {
address public owner; //SP address
address[] public bidders; //InP addresses
address[] public packageBidders; //InP addresses
address public packageWinner;
uint8 public reservedPackagePrice;
// Set to true at the end, bid has been paid.
bool public end... | Check if bidder has already voted | function isBidderAllowed(address bidder, bytes32 idVirtualNode) public constant returns (bool){
for(uint i = 0; i < allowedInPsPerVirtualNode[idVirtualNode].length; i++) {
if (allowedInPsPerVirtualNode[idVirtualNode][i] == bidder) {
for (uint k = 0; k < bids[idVirtualNode].length; k ++) {
... | 1,832,871 |
// File: interfaces/DelegatorInterface.sol
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
contract DelegationStorage {
/**
* @notice Implementation address for this contract
*/
address public implementation;
}
abstract contract DelegatorInterface is DelegationStorage {
/**
* @no... | Deposit tokens to marketing mining for SHD allocation. | function deposit(uint256 _pid, uint256 _amount) public virtual {
require(address(poolInfo[_pid].token) != WETHToken, "invalid pid");
IERC20(poolInfo[_pid].token).safeTransferFrom(address(msg.sender), address(this), _amount);
updateAfterDeposit(_pid, _amount);
}
| 83,488 |
pragma solidity ^0.5.3;
import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "./interfaces/ILockedGold.sol";
import "./interfaces/IGovernance.sol";
import "./interfaces/IVa... | Returns the timestamp of the last time the account redeemed block rewards. _account The address of the account. return The timestamp of the last time `_account` redeemed block rewards./ | function getRewardsLastRedeemed(address _account) external view returns (uint96) {
Account storage account = accounts[_account];
return account.rewardsLastRedeemed;
}
| 14,091,296 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/proxy/utils/Initializable.sol';
contract Forwarder is Initializable{
address private destination;
event Token... | It is possible that funds were sent to this address before the contract was deployed. We can flush those funds to the parent address./ | function withdrawETH() public {
emit ETHWithdrawal(address(this),address(this).balance);
payable(destination).transfer(address(this).balance);
}
| 12,608,771 |
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.9;
import { IERC20, IPool, IPoolAddressesProvider, IWETHGateway} from './Interfaces.sol';
import { SafeERC20 } from './Libraries.sol';
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
/**
* @title JustCausePoolAaveV3 contract
* @author JustCaus... | return picHash ipfs hash of pic of JCP./ | function getPicHash() external view returns(string memory){
return picHash;
}
| 1,759,681 |
./partial_match/1/0x46955ccEc435465C8C70BD64E2f5FFBd33308C8C/sources/InsurancePool.sol | View rate return rate | function getFeeRate() external view returns(uint256) {
return feeRate;
}
| 4,268,499 |
/**
*Submitted for verification at Etherscan.io on 2021-09-27
*/
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
contract MerkleHashStorage {
struct MerkleHashData {
bytes32 hash;
uint256 block_timestamp;
}
address public contrat_owner;
mapping (bytes9 => MerkleHashData) public merkleHashData... | external view function / ---------------------- / | function getMerkleHashData(bytes9 merkle_ref) external view returns (MerkleHashData memory) {
require(merkle_ref != 0, "merkle_ref must be > 0");
MerkleHashData memory merkleHashData = merkleHashDataArray[merkle_ref];
if (merkleHashData.hash == 0)
return MerkleHashData(0, 0);
return merkleHashData;
}
| 2,418,430 |
./partial_match/1/0x48d77ce941bdB210091d7565A40c9fC987227895/sources/Swishatoshi.sol | Checks max transaction limitshouldSwapBackExchange tokens | function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) {
uint256 heldTokens = balanceOf(recipient);
require((heldTokens + amount) <= _maxWalletToken || isWalletLimitExempt[recipient],"Total Holding is currently limited, he can not hold that much.");
... | 3,659,415 |
pragma solidity ^0.4.16;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint25... | function to get the price of the token returns how many token units a buyer gets per wei, needs to be divided by 10 | function getRate() constant returns (uint8) {
if (now < START) return 166;
}
| 5,388,271 |
/**
*Submitted for verification at Etherscan.io on 2022-03-30
*/
// SPDX-License-Identifier: MIT
// ................................................................................
// ..........................................................................
// ............8888............................ | See {IERC721-getApproved}./ | function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721A: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
| 6,711,412 |
// File: contracts/interfaces/marketHandlerInterface.sol
pragma solidity 0.6.12;
interface marketHandlerInterface {
function setCircuitBreaker(bool _emergency) external returns (bool);
function setCircuitBreakWithOwner(bool _emergency) external returns (bool);
function getTokenName() external view returns (strin... | Set the address of the interestModel contract interestModelAddr The address of the interestModel contract return true (TODO: validate results)/ | function setInterestModel(address interestModelAddr) onlyOwner public returns (bool)
{
interestModelInstance = interestModelInterface(interestModelAddr);
return true;
}
| 1,540,244 |
pragma solidity ^0.4.10;
import '../common/Manageable.sol';
import './IERC20Token.sol';
import './ITokenHolder.sol';
/**@dev A convenient way to manage token's of a contract */
contract TokenHolder is ITokenHolder, Manageable {
function TokenHolder() {
}
/** @dev Withdraws tokens held by the contrac... | Withdraws tokens held by the contract and sends them to a given address / | function withdrawTokens(IERC20Token _token, address _to, uint256 _amount)
public
managerOnly
{
assert(_token.transfer(_to, _amount));
}
| 916,426 |
./partial_match/1/0x1a7728652BB5Bb42523389f2F06f5aa980f14017/sources/Paytience.sol | only use to disable contract sales if absolutely necessary (emergency use only) | function updateSwapBack(bool on) external onlyOwner {
swapBack = on;
}
| 3,909,115 |
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./SwapUtils.sol";
/**
* @title AmplificationUtils library
* @notice A library to calculate and ramp the A parameter of a given `SwapUtils.Swap` struct.
* This library assumes the struct is ... | Return A, the amplification coefficient n (n - 1) See the StableSwap paper for details self Swap struct to read from return A parameter/ | function _getA(Swap storage self) internal view returns (uint256) {
return _getAPrecise(self).div(A_PRECISION);
}
| 970,531 |
./full_match/1/0x670E428B165350c77AC7523854995486C1796ae3/sources/contracts/paymaster/GaslessPaymaster.sol | Sets the whitelist mode for the specified spender of the calling sponsor address. spender The address of the spender to set the whitelist mode for. mode The boolean value to set the whitelist mode to./ | function setSpenderWhitelistMode(address spender, bool mode) public payable {
_setSpenderWhitelistMode(msg.sender, spender, mode);
emit SetSpenderWhitelistMode(msg.sender, spender, mode);
}
| 3,059,858 |
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "contracts/protocol/futures/HybridFutureVault.sol";
import "contracts/interfaces/platforms/ItfToken.sol";
/**
* @title Contract for TrueFi Future
* @notice Handles the future mechanisms for tfTokens
*/
contract TrueFiFutureVault is HybridFutureVau... | Resume liquidity transfers/ | function resumeLiquidityTransfers() public {
require(hasRole(ADMIN_ROLE, msg.sender), "ERR_CALLER");
pt.unpause();
emit LiquidityTransfersResumed();
}
| 158,054 |
./full_match/4/0x0a50D64c77DE587E178db9245d9aff5f84D70D3a/sources/contracts/Stakeable.sol | calculateStakeReward is used to calculate how much a user should be rewarded for their stakes and the duration the stake has been active/ First calculate how long the stake has been active Use current seconds since epoch - the seconds since epoch the stake was made The output will be duration in SECONDS , We will rewar... | function calculateStakeReward(Stake memory _current_stake) internal view returns(uint256){
return (((block.timestamp - _current_stake.since) / 1 hours) * _current_stake.amount) / rewardPerHour;
}
| 709,532 |
/**
*Submitted for verification at Etherscan.io on 2021-04-16
*/
// Sources flattened with hardhat v2.1.1 https://hardhat.org
// File @openzeppelin/contracts/math/[email protected]
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arit... | stakes owners tokens & mints staking allowance tokens in return _amount amount to stake/ | function stake(uint256 _amount) external nonReentrant {
require(_amount > 0, "Cannot stake 0");
stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
_stake(msg.sender, _amount);
}
| 7,811,858 |
pragma solidity 0.5.16;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "./IStakingContract.sol";
import "./IStakeChangeNotifier.sol";
contract StakingContract is IStakingContract, IMigratableStakingContract {
using SafeMath for uint256;
struct Stake {
uint256 amount;
uint256 coo... | Migrates the stake of msg.sender from this staking contract to a new approved staking contract. _newStakingContract IMigratableStakingContract The new staking contract which supports stake migration. _amount uint256 The amount of tokens to migrate. Note: we aren't concerned with reentrancy since: 1. At this point, ... | function migrateStakedTokens(
IMigratableStakingContract _newStakingContract,
uint256 _amount
) external onlyWhenStakesNotReleased {
require(
isApprovedStakingContract(_newStakingContract),
"StakingContract::migrateStakedTokens - migration destination wasn't appro... | 1,815,885 |
./full_match/43114/0x17B4a4F3A21eF5318b1c485af92520a138E61A4B/sources/AbtRouterV8.sol | performs chained getAmountOut calculations on any number of pairsrequire(path.length >= 2, 'PancakeLibrary: INVALID_PATH'); | function getAmountsOut2CustomFees(uint amountIn, address[] memory path, address[] memory lps, uint[] memory fees) internal view returns (uint[] memory amounts) {
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, ui... | 4,547,931 |
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.5.16;
pragma experimental ABIEncoderV2;
import "./EIP20Interface.sol";
import "./Joetroller.sol";
import "./JToken.sol";
contract RewardDistributorStorage {
/**
* @notice Administrator for this contract
*/
address public admin;
/**
... | Calculate JOE/AVAX accrued by a borrower and possibly transfer it to them Borrowers will not begin to accrue until after the first interaction with the protocol. rewardType 0: JOE, 1: AVAX jToken The market in which the borrower is interacting borrower The address of the borrower to distribute JOE/AVAX to/ | function distributeBorrowerReward(
uint8 rewardType,
address jToken,
address borrower,
Exp memory marketBorrowIndex
) public {
require(rewardType <= 1, "rewardType is invalid");
RewardMarketState storage borrowState = rewardBorrowState[rewardType][jToken];
... | 1,821,355 |
./partial_match/56/0x5769dc4383D091fcA951b703F7E4f0d874c93BE8/sources/NotoriousFarming.sol | Safe big transfer function, just in case if rounding error causes pool to not have enough BIGs. | function safeBigTransfer(address _to, uint256 _amount) internal {
uint256 bigBal = big.balanceOf(address(this));
if (_amount > bigBal) {
big.transfer(_to, bigBal);
big.transfer(_to, _amount);
}
}
| 11,246,239 |
pragma solidity 0.4.22;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
functi... | Low level token purchase function beneficiary The address who will receive the tokens for this transaction/hard cap for this tier has not been reachedTotal tokens sold including current sale should be less than hard cap of this tier | function buyTokens(address beneficiary)public _saleActive nonZeroEth nonZeroAddress(beneficiary) payable returns(bool){
int8 currentTierIndex = getCurrentlyRunningTier();
assert(currentTierIndex>=0);
TierInfo storage currentlyRunningTier = tiers[uint256(currentTierIndex)];
... | 6,499,183 |
pragma solidity ^0.4.4;
import "./Owned.sol";
contract Bearchange is Owned {
address owner;
struct token {
string symbol;
address contract_address;
}
mapping(uint => token) tokens;
uint numTokens;
struct offer {
uint amount;
address who;
}
struct orderBook {
uint higherPrice;
... | Check if ERC20 token symbol exists | function hasSymbol(string _symbol) public constant returns (bool) {
if(numTokens == 0) {
return false;
}
for(uint i=0; i<numTokens; i++) {
if(keccak256(tokens[i].symbol) == keccak256(_symbol)) {
return true;
}
}
return false;
}
| 5,444,905 |
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view r... | See {IERC20-allowance}./ | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| 585 |
// Sources flattened with hardhat v2.6.4 https://hardhat.org
// File openzeppelin-solidity/contracts/utils/Context.sol@v4.3.2
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While t... | Function to check if an address is a contract for minting/ | function _isContract(
address _addr
)
internal
view
returns (bool)
{
uint32 _size;
assembly {
_size:= extcodesize(_addr)
}
return (_size > 0);
}
| 14,709,618 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol
// Subject to the MIT license.
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity w... | Add credit to a job to be paid out for work job the job being credited amount the amount of credit being added to the job/ | function addRLRCredit(address job, uint amount) external onlyGovernance{
require(jobs[job], "addRLRCredit: !job");
credits[job][address(this)] = credits[job][address(this)].add(amount);
emit AddCredit(address(this), job, msg.sender, block.number, amount);
}
| 1,429,880 |
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "./utils/EnumerableSet.sol";
import "./interfaces/... | Interface to Access APY.Finance's Asset Allocations APY.Finance Enables 3rd Parties (ie. Chainlink) to pull relevant asset allocations in order to compute the TVL across the entire APY.Finance system. | interface IAssetAllocation {
function getAssetAllocationIds() external view returns (bytes32[] memory);
function balanceOf(bytes32 allocationId) external view returns (uint256);
function symbolOf(bytes32 allocationId)
external
view
returns (string memory);
function decimalsOf(... | 195,619 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "./Ownable.sol";
import "./SafeMath.sol";
/**
* @notice Stakeable is a contract who is ment to be inherited by other contract that wants Staking capabilities
*/
contract Stakeable is Ownable{
// we don't want to have any security issues
using Safe... | getReward will get the reward value for a specific period/ | function getReward(uint8 index) public view returns (uint) {
return _rewards[index];
}
| 14,084,103 |
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.6;
import "@yield-protocol/utils-v2/contracts/token/IERC20.sol";
import "@yield-protocol/utils-v2/contracts/token/IERC20Metadata.sol";
import "@yield-protocol/utils-v2/contracts/token/ERC20Permit.sol";
import "@yield-protocol/utils-v2/contracts/token/SafeERC20Na... | Returns the "virtual" fyToken balance, which is the real balance plus the pool token supply. | function getFYTokenBalance()
public view override
returns(uint112)
{
return _getFYTokenBalance();
}
| 223,864 |
./full_match/97/0xb0b2dD90491Bc9091604793321b98aC863dE8C0C/sources/project_/contracts/piMarket.sol | executes a sale with a specified bid. _saleId The Id of the sale. _bidId The Id of the bid./ | function withdrawBidMoney(uint256 _saleId, uint256 _bidId)
external
nonReentrant
{
LibMarket.withdrawBid(_tokenMeta[_saleId], Bids[_saleId][_bidId]);
emit BidWithdrawn(_saleId, _bidId);
}
| 3,282,927 |
./full_match/11155111/0x41B80fC08eCaAbDC58b2dd5cAf7E8E33519BC0F0/sources/project_/contracts/PaymentProcessor.sol | uint256 adjustedPrice = uint256(price) 10 10; uint256 _minimumUSD = (minimumUSD 10 18) / adjustedPrice; return _minimumUSD; | function getLatestPrice() public view returns (int) {
(
,
int price,
,
,
) = priceFeed.latestRoundData();
return int(price * 1000000000);
}
| 3,803,461 |
pragma solidity ^0.6.3;
import "./ERC20Interface.sol";
import "./BlackCaspianUpgradeable.sol";
contract ERC20Proxy is ERC20Interface, BlackCaspianUpgradeable {
// MEMBERS
/// @notice Returns the name of the token.
string public name;
/// @notice Returns the symbol of the token.
string public ... | Transfers `_value` amount of tokens to address `_to`. Will fire the `Transfer` event. Will revert if the `_from` account balance does not have enough tokens to spend. return success true if transfer completes./ | function transfer(address _to, uint256 _value) public returns (bool success) {
return BlackCaspian.transferWithSender(msg.sender, _to, _value);
}
| 5,369,289 |
./full_match/3/0x6d977069Dadef5A30789C38c33645de3f4e391A3/sources/browser/ILUS.sol | Function for withdrawing staked tokens stakingId stake id for the stake/ | function withdrawStakedTokens(uint256 stakingId) public failSafe returns(bool){
require(_stakerAddress[stakingId] == msg.sender,"No staked token found on this address and ID");
require(_TokenTransactionstatus[stakingId] != true,"Either tokens are already withdrawn or blocked by admin");
require(balanceOf(... | 8,230,516 |
pragma solidity 0.4.21;
/**
* @title Array64 Library
* @author Modular Inc, https://modular.network
*
* version 1.2.0
* Copyright (c) 2017 Modular, Inc
* The MIT License (MIT)
* https://github.com/Modular-Network/ethereum-libraries/blob/master/LICENSE
*
* The Array64 Library provides a few utility functions t... | Returns the minimum value in an array. self Storage array containing uint256 type variables return minValue The highest value in the array | function getMin(uint64[] storage self) public view returns(uint64 minValue) {
uint256 term;
uint8 remainder;
assembly {
mstore(0x60,self_slot)
term := sload(add(sha3(0x60,0x20),div(i,4)))
remainder := mod(i,4)
term := div(term,4294967296)
}
term := and(... | 7,807,201 |
/*
* source https://github.com/blockbitsio/
* @name Funding Contract
* @package BlockBitsIO
* @author Micky Socaci <micky@nowlive.ro>
Contains the Funding Contract code deployed and linked to the Application Entity
*/
pragma solidity ^0.4.17;
import "./../ApplicationAsset.sol";
import ... | Asset States Funding Stage States | function setAssetStates() internal {
EntityStates["__IGNORED__"] = 0;
EntityStates["NEW"] = 1;
EntityStates["WAITING"] = 2;
EntityStates["FUNDING_FAILED_START"] = 10;
EntityStates["FUNDING_FAILED_PROGRESS"] ... | 919,760 |
pragma solidity ^0.4.24;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {return a / b;}
functi... | Increase Ticket Price every week | function bet(uint256[] _timestamps, address _referral) payable public{
require(msg.value>=costPerTicket.mul(_timestamps.length));
require(!announced);
if(now < expireDate){
for(i=0; i<_timestamps.length;i++){
timestampList.push(_timestamps[i]);
mi... | 5,471,582 |
pragma solidity ^0.4.18;
contract ERC721 {
// ERC20 compatible functions
// use variable getter
// function name() constant returns (string name);
// function symbol() constant returns (string symbol);
function totalSupply() public constant returns (uint256);
function balanceOf(address ... | transfer ownership of Giftid from msg sender to an address _to : address's received _GiftId : Gift id not transfer to zero address received different from sender sender must be owner of Giftid do not send to Gift contract | function transfer(address _to, uint256 _GiftId)
validGift(_GiftId)
external {
require(_to != 0x0);
require(msg.sender != _to);
require(msg.sender == ownerOf(_GiftId));
require(_to != address(this));
_transfer(msg.sender, _to, _GiftId);
}
| 15,884,082 |
./partial_match/42/0xb2A9c9cB4796dFc137a3EbBF312d73A7837CF708/sources/PobTokenPresale.sol | Gas optimization: this is cheaper than requiring 'a' not being zero, but the benefit is lost if 'b' is also tested. See: https:github.com/OpenZeppelin/openzeppelin-contracts/pull/522 | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| 3,460,823 |
pragma solidity ^0.4.18;
import 'zeppelin-solidity/contracts/math/SafeMath.sol';
import 'zeppelin-solidity/contracts/token/ERC20/MintableToken.sol';
import './Whitelist.sol';
/**
* @title Payout
* @dev Payout capacity: eth sent to this contract (by Tokenestate) will be distributed to their token holders
*/
contr... | Initialize the number of shares for payout for a beneficiary if needed addr The address to initialize. balance The number of shares./ | function initNbSharesForPayoutIfNeeded(address addr, uint256 balance) internal {
for (uint8 payoutId = 0; payoutId < payoutObjects.length; payoutId++) {
Beneficiary memory beneficiary = payoutObjects[payoutId].beneficiaries[addr];
if(!beneficiary.isNbSharesInitialized) {
initNbSharesForPayout(addr, balance... | 12,664,947 |
pragma solidity ^0.4.11;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) inter... | burn tokens from sender balance | function burn(uint256 _value) {
balances[msg.sender] = balances[msg.sender].sub(_value);
Burn(msg.sender, _value);
}
| 7,759,730 |
pragma solidity ^0.5.4;
/**
* ERC20 contract interface.
*/
contract ERC20 {
function totalSupply() public view returns (uint);
function decimals() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spen... | Handle the receipt of an NFT An ERC721 smart contract calls this function on the recipient contract after a `safeTransfer`. If the recipient is a BaseWallet, the call to onERC721Received will be forwarded to the method onERC721Received of the present module. operator The address which called `safeTransferFrom` functi... | function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)
external
returns (bytes4)
{
return ERC721_RECEIVED;
}
| 5,543,215 |
./full_match/4/0x0b08f24c0346337837C7B4031c531F4E2E4087Fa/sources/mynft.sol | ERC-721 Non-Fungible Token Standard, optional metadata extension/ | interface IERC721Metadata is IERC721 {
function name() external view returns(string memory);
function symbol() external view returns(string memory);
function tokenURI(uint256 tokenId) external view returns(string memory);
}
}
| 720,661 |
./full_match/42/0x857BbFEDEb123107F0Bb9990be49ebE88960Aac0/sources/uniswap-solidity-example/flatten/Flattened.sol | number / 100 is amount in ether require(wethToken.balanceOf(address(this)) > 0, "Weth amount is zero"); require(newAmount > 0, "Weth amount is zero"); | function test(uint256 _amount) external onlyAdmin {
uint256 newAmount = _amount * 1000000000000000;
address UNISWAP_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
uniswapRouter = IUniswapV2Router02(UNISWAP_ROUTER_ADDRESS);
uniswapRouterAddress = UNISWAP_ROUTER_... | 16,285,460 |
./full_match/5/0xa987Be2cE29A4EE51745604c0B83041c04a75FbB/sources/contracts/SBTnft.sol | uint256 amountToken = calculatePoint(_mintAmount); | function mintNFT(uint256 _mintAmountA , uint256 _mintAmountB ,uint256 _mintAmountC) public payable checkbalance(){
Auction memory currentAuction = auction;
require(lock,"Wait for public sale");
require(block.timestamp >= currentAuction.firstStat, "Auction not started");
require(point... | 11,621,460 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "../../openzeppelin-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
import "../libraries-solidity/access/AdminControlUpgradeable.sol";
import "./core/ERC1155CreatorCore.sol";
/**
* @dev ERC1155Creator implementation
*/
co... | See {IERC1155CreatorCore-mintExtensionNew}./ | function mintExtensionNew(
address[] calldata to,
uint256[] calldata amounts,
string[] calldata uris
)
public
virtual
override
nonReentrant
extensionRequired
returns (uint256[] memory tokenIds)
{
return _mintNew(msg.sender, to, ... | 11,819,365 |
./full_match/1/0xA1f35Da94D3C25c1c130092122Db690FF10d47c4/sources/contracts/PresaleV2.sol | Helper funtion to get USDT price for given amount amount No of tokens to buy/ | function usdtBuyHelper(
uint256 amount
) external view returns (uint256 usdPrice) {
usdPrice = amount * tokenPrice;
usdPrice = usdPrice / (10 ** 12);
}
| 9,813,394 |
./full_match/43113/0x01dACB86c63dD654093781d6Ed177D52532c23C2/sources/contracts/AG.sol | string memory _name, string memory _descr, uint duration, uint _ballotType 0=perAPA 1=perAddressBallotType _ballotType proposals[nextPropId].id = nextPropId; proposals[nextPropId].name = _name; proposals[nextPropId].description = _descr; proposals[nextPropId].end = block.timestamp + duration; ... | function createProposal(
string[] memory _options
) external verifyNumApas(proposerApas) returns(uint) {
for(uint i=0; i < _options.length; i++) {
Option memory tempStruct;
tempStruct.id = i;
tempStruct.name = _options[i];
temp... | 7,191,519 |
pragma solidity 0.5.10;
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
/**
* @title Commit-Reveal Voting logic for use/adaptation in commit-reveal voting contracts
* @author TruSet
* @dev The functions that change state are all internal, so to make use of this logic
* this contract must be subclasse... | Gets the vote counts for a poll N.B. Ensure that the reveal period is over before assuming that these results are final. _pollID Bytes32 identifier associated with target poll return Total number of 'For' votes, 'Against' votes, and committed votes that were not revealed. (3 integers, in that order.)/ | function getVoteCounts(bytes32 _pollID) view public
returns (
uint numForVotes,
uint numAgainstVotes,
uint numCommittedButNotRevealedVotes) {
Poll memory p = pollMap[_pollID];
return (p.votesFor, p.votesAgainst, p.votesCommittedButNotRevealed);
}
| 1,798,975 |
/**
*Submitted for verification at Etherscan.io on 2020-01-30
*/
// File: contracts/math/SafeMath.sol
pragma solidity 0.5.12;
/// @title SafeMath
/// @dev Math operations with safety checks that throw on error
library SafeMath {
/// @dev Add two integers
function add(uint a, uint b) internal pure returns ... | Set the address of whitelist _newWhitelist An Ethereum address | function setWhitelist(Whitelist _newWhitelist) public onlyOwner {
require(address(_newWhitelist) != address(0x0), "Whitelist address is zero");
if (address(_newWhitelist) != address(whitelist)) {
emit WhitelistChange(address(whitelist), address(_newWhitelist));
whitelist = ... | 1,786,929 |
./partial_match/1/0x7e55ccB0bCe9A9094aE5cf75EF71b3275B45658A/sources/Tettoken.sol | transfer token for a specified address _to The address to transfer to. _value The amount to be transferred./ | function transfer(address _to, uint256 _value) public onlyPayloadSize(2 * 32) whenNotPaused returns (bool success) {
require (!(_to == 0x0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
... | 3,553,619 |
./full_match/1/0x5EE84583f67D5EcEa5420dBb42b462896E7f8D06/sources/contracts/tokens/ASIC.sol | Burns existing tokens. Only the owner of contract can run this function account Address of the account to have the tokens burned amount Amount of tokens to be burned | function burn(address account, uint256 amount) external onlyOwner {
_burn(account, amount);
}
| 3,068,869 |
./full_match/3/0x967328588D821b4306fe8F0592faFE94eC930429/sources/contracts/Token5.sol | Sets `amount` as the allowance of `spender` over the `owner` s tokens. This internal function is equivalent to `approve`, and can be used to e.g. set automatic allowances for certain subsystems, etc. Emits an {Approval} event. Requirements: - `owner` cannot be the zero address. - `spender` cannot be the zero address./ | function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "BSC: approve from the zero address");
require(spender != address(0), "BSC: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| 8,243,790 |
./full_match/1/0x29Cc5b56C25a7A2fcd933F4936E46347A648B427/sources/contracts/3_Ballot.sol | Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'. proposal index of proposal in the proposals array/ If 'proposal' is out of the range of the array, this will throw automatically and revert all changes. | function vote(uint proposal) public {
Voter storage sender = voters[msg.sender];
require(this.getUserJFCBalance(msg.sender) > 0, "You dont have JFC to vote!");
require(!sender.voted, "Out of votes.");
sender.vote = proposal;
sender.voted = true;
propo... | 4,887,260 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of... | Interface of the ERC20 standard as defined in the EIP./ | interface ISoulERC20 is IERC20 {
function mint(address to, uint256 amount) external;
}
| 12,558,927 |
pragma solidity ^0.5.16;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint... | uint256 profit_times = now.sub(profit_time).div(dfkImpl.profit_period()); | function calcProfitForFee(address miner,uint256 totalFee,uint256 lastFetchFee) public view returns (uint256)
{
(,uint256 profit_time,uint256 staking_value,) = dfkImpl.stakings(miner);
if(staking_value == 0) {
return 0;
}
if(profit_time < dfkImpl.cleanup_t... | 9,826,440 |
/* HTTPS://SYNCBOND.COM HTTPS://APP.SYNCBOND.COM
███████╗██╗░░░██╗███╗░░░██╗░██████╗░░░░██████╗░░██████╗░██╗░░░░██╗███████╗██████╗░███████╗██████╗░
██╔════╝╚██╗░██╔╝████╗░░██║██╔════╝░░░░██╔══██╗██╔═══██╗██║░░░░██║██╔════╝██╔══██╗██╔════╝██╔══██╗
███████╗░╚████╔╝░██╔██╗... | returns usd value of SYNC | function syncValue() external view returns(uint); | 7,280,082 |
// SPDX-License-Identifier: MIT
pragma experimental ABIEncoderV2;
pragma solidity ^0.6.12;
import "./Interfaces/LiquidityMathModelInterface.sol";
import "./MToken.sol";
import "./Utils/ErrorReporter.sol";
import "./Utils/ExponentialNoError.sol";
import "./Utils/AssetHelpers.sol";
import "./Moartroller.sol";
import "./... | Sets new value for max protection composition parameter newMPC New value of MPC return uint 0=success, otherwise a failure/ | function _setMaxProtectionComposition(uint256 newMPC) external returns(uint){
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK);
}
maxProtectionComposition = newMPC;
emit MpcUpdated(newMPC);
return uint(E... | 11,818,159 |
./full_match/1/0x6C32D8DC35A4063E0AD3AAC756111e462eA38D27/sources/contracts/periphery/utils/AvailableRootsRegistry.sol | Unregister a root, available for all contracts root Root to unregister/ | function unregisterRootForAll(uint256 root) external onlyOwner {
_unregisterRootForAttester(address(0), root);
}
| 3,849,621 |
pragma solidity ^0.4.13;
contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei.
// The rate is the conversion between wei and the smallest and indivisible tok... | Adds single address to whitelist _beneficiary Address to be added to the whitelist | function addToWhitelist(address _beneficiary) external onlyOwner {
whitelist[_beneficiary] = true;
WhitelistAddressAdded(_beneficiary);
}
| 14,484,598 |
pragma solidity ^0.4.24;
import "../../TransferManager/ITransferManager.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
/**
* @title Transfer Manager module to automate blacklist and restrict transfers
*/
contract BlacklistTransferManager is ITransferManager {
using SafeMath for uint256;
... | Used to assign the multiple blacklist type to the multiple investor _investors Address of the investor _blacklistNames Name of the blacklist/ | function addMultiInvestorToBlacklistMulti(address[] _investors, bytes32[] _blacklistNames) external withPerm(ADMIN){
require (_investors.length == _blacklistNames.length, "Input array's length mismatch");
for(uint256 i = 0; i < _investors.length; i++){
addInvestorToBlacklist(_investors[... | 12,896,674 |
pragma solidity 0.5.12;
import "./Handler.sol";
import "./interface/ILendFMe.sol";
import "./library/ReentrancyGuard.sol";
contract MoneyMarketHandler is Handler, ReentrancyGuard {
address public targetAddr; // market address
mapping(address => uint256) public interestDetails;
event NewdTargetAddr(
... | --- Init --- This function is used with contract proxy, do not modify this function. | function initialize(address _HNITokenController, address _targetAddr) public {
super.initialize(_HNITokenController);
initReentrancyStatus();
targetAddr = _targetAddr;
}
| 2,543,653 |
pragma solidity ^0.4.18;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/ContestManager.sol";
import "../contracts/Contest.sol";
contract TestContestManager
{
ContestManager cm = new ContestManager();
function testBalanceOf0() public
{
uint b = cm.balance... | solium-disable-next-line security/no-block-members | function testSpendLastToken() public
{
Contest contest = Contest(cm.newContest(contestdeadline, contestdeadline + 1, "testClaimTicket",100, 2));
cm.setTotalTokens(address(this), 2);
contest.claimTicket();
Assert.equal(0, cm.balanceOf(address(this)), "testSpendLastToken() failed, ... | 12,800,431 |
./full_match/1/0x18faf3cdF637D6054C64fE76cEA218C6e009c261/sources/contracts/DogMoneyAuctionHouse.sol | Create a bid for an Auction, with a given amount. This contract only accepts payment in ETH./ Refund the last bidder, if applicable | function _createBid(
uint256 auctionId,
IERC20 token,
bytes memory swapPath,
uint256 amountIn,
uint256 amountOutMinimum,
address to
) internal {
IDogMoneyAuctionHouse.Auction memory _auction = auction;
require(
_auction.id == auctionId... | 8,448,292 |
pragma solidity ^0.4.25;
contract IStdToken {
function balanceOf(address _owner) public view returns (uint256);
function transfer(address _to, uint256 _value) public returns (bool);
function transferFrom(address _from, address _to, uint256 _value) public returns(bool);
}
contract EtheramaCommon {
... | Divide one real by another real. Truncates overflows./ We use the reverse of the multiplication trick: convert numerator from x.y to (x+z).(y+w) fixed point, then divide by denom in z.w fixed point. | function div(int128 real_numerator, int128 real_denominator) internal pure returns (int128) {
return int128((int256(real_numerator) * REAL_ONE) / int256(real_denominator));
}
| 1,321,914 |
./partial_match/1/0x6D061EBFd8BDF5D574A7029E918341B1736d6F6c/sources/SmolTingPot.sol | view function to calculate the total pending TINGs of address across all pools | function totalPendingTing(address _user) public view returns (uint256) {
uint256 total = 0;
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
total = total.add(pendingTing(pid, _user));
}
return total;
}
| 3,893,452 |
./full_match/80001/0x4Eafc934AB85740e7e1CF4DD0656db6567127399/sources/mastercheffinal.sol | Deposit LP tokens to MasterChef for CNT allocation. | function depositFor(uint256 _pid, uint256 _amount , address _user) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
whiteListedHandlers[_user][_user] = true;
updatePool(_pid);
payOrLockupPendingcnt(_pid,_user);
depositInt... | 5,680,315 |
/*
* Copyright 2021 ConsenSys Software Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed... | For this implementation, the signatures have already been checked in the relayEvent function below./ | function decodeAndVerifyEvent(
uint256 _blockchainId,
bytes32, /* _eventSig */
bytes calldata _encodedEvent,
bytes calldata /* _signature */
) external view override {
bytes32 eventDigest = keccak256(_encodedEvent);
uint256 threshold = registrar.getSigningThreshol... | 5,365,726 |
./partial_match/1/0x45D117011da1D49bA86aF6CEd94126488084186f/sources/contracts/VotingEscrow.sol | Calculate total voting power at some point in the past _block Block to calculate the total voting power at return Total voting power at `_block` | function totalSupplyAt(uint256 _block) external view returns (uint256) {
require(_block <= block.number);
uint256 _epoch = epoch;
uint256 target_epoch = _find_block_epoch(_block, _epoch);
Point memory point = point_history[target_epoch];
uint256 dt = 0;
if (target_ep... | 4,042,280 |
./full_match/1/0xe0767bED7527dcb36B29c42dE670f70877240Be5/sources/browser/HarvestUSDT.sol | ========== Harvest wrapper ========== / function withdraw(uint256 amount) external; unstake | interface IHarvest {
function getReward() external;
function balanceOf(address account) external view returns (uint256);
}
| 4,824,459 |
./full_match/1/0x07a24CA74a7592C16827d186b802E004cec33Bb3/sources/contracts/CLPCProxy.sol | Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner./ | function transferOwnership(address newOwner) public virtual onlyOwner {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
_transferOwnership(newOwner);
}
| 17,152,951 |
./full_match/97/0xd1390fa4eeBD96b5fd4AEeCa60671e8dF6cDbA50/sources/AiGameWithStructurePlayer.sol | Check if the player has enough stamina to enter the dungeon Deduct 1 stamina from the player Generate a random number to determine if the player wins the fight and a random number to determine the amount of gold as loot The player wins the fight Add the loot to the player's gold balance Call the generateRandomLoot func... | function enterDungeon(address player) public {
Player storage playerData = players[player];
require(playerData.stamina >= 1, "Not enough stamina to enter the dungeon");
playerData.stamina = playerData.stamina - 1;
uint randomNumber = uint(keccak256(abi.encodePacked(block.difficulty, block.timestam... | 5,020,308 |
//SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "./interface/IiToken.sol";
import "./interface/IRewardDistributorV3.sol";
import "./interface... | Add the iToken as receipient Admin function, only controller can call this _iToken the iToken to add as recipient _distributionFactor the distribution factor of the recipient/ | function _addRecipient(address _iToken, uint256 _distributionFactor)
external
override
onlyController
{
distributionFactorMantissa[_iToken] = _distributionFactor;
distributionSupplyState[_iToken] = DistributionState({
index: 0,
block: block.number
... | 1,317,987 |
./full_match/11155111/0x455d83fa7D8320147B80130861Df030A1f050097/sources/contracts/Predictor.sol | had faced issues while fetchings api from chainlink functions which is in closed beta. untill, hardcoded the contests and events. Emit an event when contest is created | function createContest() private {
uint256 randNum = randomNum(1000000);
ContestsId.push(
Game(randNum, "India", "Australia", matchStatus.Yet_to_Start)
);
emit Ongoing_Contests(randNum, "India", "Australia", "Yet_to_Start");
ContestsId.push(
Game(ra... | 3,811,696 |
./partial_match/1/0x14132D979fDdA62a56d9f552C9aa477b9c94851e/sources/@yield-protocol/yieldspace-tv/src/Exp64x64.sol | Calculate 2 raised into given power. x power to raise 2 into, multiplied by 2^121 return 2 raised into given power | function pow_2(uint128 x) internal pure returns (uint128) {
unchecked {
uint256 r = 0x80000000000000000000000000000000;
if (x & 0x1000000000000000000000000000000 > 0) r = (r * 0xb504f333f9de6484597d89b3754abe9f) >> 127;
if (x & 0x800000000000000000000000000000 > 0) r = (r... | 15,663,230 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.