file_name stringlengths 71 779k | comments stringlengths 0 29.4k | code_string stringlengths 20 7.69M | __index_level_0__ int64 2 17.2M |
|---|---|---|---|
pragma solidity ^0.4.18;
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(uint256 a, uint256 b) internal constant returns (uint256) {
// assert(b > 0); // Solidity autom... | calculate amount _value ether to be converted to tokens _totalEthers total received ETH return tokens amount that we should send to our dear investor return odd ethers amount, which contract should send back/ | function calcAmount(
uint256 _amount,
uint256 _totalEthers
) public constant returns (uint256 estimate, uint256 amount) {
Round memory round;
uint256 totalEthers = _totalEthers;
amount = _amount;
for(uint256 i; i<rounds.length; i++) {
round = ... | 6,440,706 |
// File contracts/libraries/SafeMath.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.7.5;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
f... | calculate how far into vesting a depositor is _depositor address return percentVested_ uint/ | function percentVestedFor( address _depositor ) public view returns ( uint percentVested_ ) {
Bond memory bond = bondInfo[ _depositor ];
uint blocksSinceLast = block.number.sub( bond.lastBlock );
uint vesting = bond.vesting;
if ( vesting > 0 ) {
percentVested_ = blocksSi... | 33,442 |
./partial_match/56/0xba3141Aba8247Bb46d6f1a15770df227de2dF5e5/sources/ErnteSwapBEP20.sol | if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) | function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IErnteSwapFactory(factory).feeTo();
feeOn = feeTo != address(0);
if (feeOn) {
if (_kLast != 0) {
uint256 rootK = SafeMath.sqrt(uint256(_reserve0).mul(_reserve1))... | 11,059,572 |
./partial_match/42/0xE230251D53D04DA2DbaBaEcA92F59E1E8d7c7064/sources/_contracts/JoysNFTMinning.sol | Add a new lp to the pool. Can only be called by the owner. | function add(uint256 _allocPoint, bool _withWeapon, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > bonusBeginBlock? block.number : bonusBeginBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
... | 3,475,710 |
./partial_match/1/0x74911b2B9192c0DA4171C7a7Bb48b02Af9365797/sources/WOLFYINU.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), "BEP20: approve from the zero address");
require(spender != address(0), "BEP20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner,... | 4,395,541 |
./full_match/56/0xab84Cd8946F4589c2342B733C908cc84d2eCEd1e/sources/contracts/E-RON.sol | method which allows the owner to unblacklist an address addr - the address to unblacklist only callable by the owner only callable if the token is not paused only callable if the token supports blacklisting only callable if the address is blacklisted/ | function removeFromBlacklist(address addr) external onlyOwner whenNotPaused {
LibCommon.validateAddress(addr);
if (!isBlacklistEnabled()) {
revert BlacklistNotEnabled();
}
if (!_isBlacklisted[addr]) {
revert AddrAlreadyUnblacklisted(addr);
}
delete _isBlacklisted[addr];
emit Us... | 3,252,276 |
./full_match/40/0xAdD4aba2E0C5919A8dA2E061F85edEDaB9Bc5d91/sources/contracts/ZappyBnbTlos.sol | Modular function to set the wrapped to bnb path | function setWrappedToLp1Path(address[] memory _path) external onlyAdmin {
require (_path[0] == wrapped && _path[_path.length - 1] == bnb, "!path");
wrappedToLp1Path = _path;
emit SetWrappedToLp1Path(_path);
}
| 9,545,106 |
./partial_match/1/0x926C777c091a5A070dC24ac94fF498b5a556f92A/sources/contracts/periphery/SmardexRouter.sol | @inheritdoc ISmardexRouter fetch data | function getAmountOutFromPair(
uint256 _amountIn,
address _tokenIn,
address _tokenOut
)
external
view
returns (
uint256 amountOut_,
uint256 newReserveIn_,
uint256 newReserveOut_,
uint256 newFictiveReserveIn_,
... | 4,280,033 |
pragma solidity ^0.4.24;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/SafeMath.sol";
import "./interfaces/IERC20Token.sol";
contract ERC20Token is IERC20Token, SafeMath {
using LibBytes for bytes;
// EXTERNAL FUNCTIONS
constructor() public {
... | Sends `value` amount of tokens to account `to` from account `from` if enough amount of tokens are approved by account `from` to spend by account `msg.sender`. from The address of the tokens sender. to The address of the tokens recipient. value The amount of tokens to be transferred. return True if transfer was succe... | function transferFrom(address from, address to, uint256 value) external returns (bool) {
_decreaseAllowance(from, msg.sender, value);
_transfer(from, to, value);
return true;
}
| 12,796,313 |
./full_match/1/0x96a7c18650DEDf9E76355f3f0458B027B789e201/sources/localhost/presale.sol | Close presale if threshold is reached/ | function close() external onlyOwner {
require(reached(), "threshold is not reached");
closed = true;
}
| 9,776,493 |
/*
Copyright 2019 ZeroEx Intl.
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 to in writing, ... | Decompose an ABI-encoded IncompleteFillError. encoded ABI-encoded revert error. return orderHash Hash of the order being filled. | function decodeIncompleteFillError(bytes memory encoded)
public
pure
returns (
LibExchangeRichErrors.IncompleteFillErrorCode errorCode,
uint256 expectedAssetFillAmount,
uint256 actualAssetFillAmount
)
{
return LibExchangeRichErrorDecode... | 1,834,483 |
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/GSN/Context.sol
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not b... | See {IERC721-safeTransferFrom}./ | function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
ERR
);
_safeTransfer(from, to, tokenId, _data);
}
| 613,871 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IStakingRewardsVault.sol";
import "../commons/MetaTransactionsMixin.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
... | View function to see pending TSX on frontend. _pid The index of the pool. See `poolInfo`. _user Address of user. return pending TSX reward for a given user./ | function pendingRewards(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo memory pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accTSXPerShare = pool.accTSXPerShare;
uint256 lpSupply = lpToken[_pid].balanceOf(address(this)... | 13,138,823 |
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0;
import "../interfaces/IControllable.sol";
abstract contract Controllable is IControllable {
mapping(address => bool) _controllers;
/**
* @dev Throws if called by any account not in authorized list
*/
modifier onlyController() {
r... | the external version of the above/ | function nextGemHash() external view override returns (uint256) {
return _nextGemHash();
}
| 11,794,166 |
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.6.12;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@bancor/token-g... | returns the specific reserve token's share of all rewards/ | function _rewardShare(IReserveToken reserveToken, PoolProgram memory program) private pure returns (uint32) {
if (reserveToken == program.reserveTokens[0]) {
return program.rewardShares[0];
}
return program.rewardShares[1];
}
| 7,268,396 |
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
/**
* @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... | Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for ``sender``'s tokens of at ... | function transferFrom(address sender, address recipient, uint256 value)
override
external
returns (bool)
{
_allowances[sender][msg.sender] = _allowances[sender][msg.sender].sub(value,"ERC20: transfer amount exceeds allowance");
uint256 rAmount = _calculateFragments(value... | 6,068,296 |
/**
*Submitted for verification at Etherscan.io on 2020-02-11
*/
// File: @aragon/os/contracts/common/EtherTokenConstant.sol
/*
* SPDX-License-Identitifer: MIT
*/
pragma solidity ^0.4.24;
// aragonOS and aragon-apps rely on address(0) to denote native ETH, in
// contracts where both tokens and ETH are accept... | Initialize Vault app As an AragonApp it needs to be initialized in order for roles (`auth` and `authP`) to work/ | function initialize() external onlyInit {
initialized();
setDepositable(true);
}
| 450,894 |
./full_match/1/0x08C986972dD7d08c235B3F86520Eb6718d7371aF/sources/contracts/Rewards/CvgQuest.sol | Remove a quest _answer quest's correct answer/ | function removeQuest(bytes32 _answer) external onlyOwner {
if (quests[_answer].rewardAmount > 0) {
quests[_answer].rewardToken.transfer(msg.sender, quests[_answer].rewardAmount);
}
if (quests[_answer].rewardTokenId > 0) {
quests[_answer].rewardNft.transferFrom(addres... | 17,027,454 |
pragma solidity ^0.5.0;
library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev give an account access to this role
*/
function add(Role storage role, address account) internal {
require(account != address(0));
require(!has(role, acc... | To be overriden to add functionality | function canUpgrade() public view returns(bool) {
return upgradesAllowed;
}
| 933,273 |
/**
*Submitted for verification at Etherscan.io on 2021-09-08
*/
// SPDX-License-Identifier: NONE
pragma solidity 0.6.2;
// Part: OpenZeppelin/[email protected]/Address
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contrac... | validate enough days have passed from initiating the withdrawalTODO Need for testcalculate withdrawed rewards in single distribution cycle | function executeWithdrawal() external virtual nonReentrant whenNotPaused {
StakeDeposit memory stakeDeposit = _stakeDeposits[msg.sender];
WithdrawalState memory withdrawState = _withdrawStates[msg.sender];
require(
stakeDeposit.endDate != 0 || withdrawState.amount != 0,
... | 2,462,027 |
./full_match/1/0x879Cf19800308eC7ccc673B68cFeaF3c6c08CCc2/sources/contracts/Database.sol | Returns amount of audits completed at each level for `auditorAdderss_` auditorAddress_ Address of auditor return levelsCompleted_ Array of levels of audits completed for `auditorAddress_` | function levelsCompleted(address auditorAddress_) external view returns (uint256[4] memory levelsCompleted_) {
return (_levelsCompleted[auditorAddress_]);
}
| 9,799,971 |
pragma solidity ^0.5.0;
import '../TokenSwap.sol';
/**
* A TokenSwap with additional functionality added for tests.
*
* Note: This should be an independent contract, as it has pure functions only,
* but for the legacy reasons it is subcontract of TokenSwap.
*/
contract TestTokenSwap is TokenSwap {
/**
* A ... | Expose ecrecover, so we can call it from console/tests and compare results./ | function recoverAddress(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public pure returns(address) {
return ecrecover(hash, v, r, s);
}
| 983,782 |
pragma solidity ^0.4.23;
/**
* SafeMath <https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/math/SafeMath.sol/>
* Copyright (c) 2016 Smart Contract Solutions, Inc.
* Released under the MIT License (MIT)
*/
/// @title Math operations with safety checks
library SafeMath {
function mul(u... | it will return status of white listing return true if user is white listed and false if is not | function isWhiteListed(address _user) external view returns (bool) {
return shareholders[_user].allowed;
}
| 6,700,498 |
pragma solidity ^0.5.16;
interface IERC20 {
function TOTALSUPPLY344() external view returns (uint256); //inject NONSTANDARD NAMING
function BALANCEOF995(address account) external view returns (uint256); //inject NONSTANDARD NAMING
function ... | inject NONSTANDARD NAMING | function WITHDRAWALL744() external returns (uint balance) { | 5,414,288 |
import { RoleManagement } from "./RoleManagement.sol";
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
pragma solidity ^0.5.0;
contract Registry {
function updateProperty(address ownerAddress, uint256 pin) public returns(bool success);
function grantPermission(address _operator,string m... | function that link this contract with the registry, allows to own a property on the registry contract/ | function buyProperty() internal {
require(pendingBuying!=0,"Check that pendingBuying is different form 0 to forbid reentrancy attack.");
pendingBuying=0;
Registry reg = Registry(regaddr);
reg.getPropertyOwner(pin).transfer(address(this).balance);
reg.updateProperty(address(th... | 12,656,528 |
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract SwearJar {
struct Swear {
string word;
uint256 count;
uint256 spent;
}
mapping(address => Swear []) public swears;
uint256 private percent = 3;
uint2... | redeem - withdraw amount of SCARG stored in a swear word swearer word/ | function redeem(address payable swearer, string memory word) public payable {
for (uint256 i = 0; i < swears[swearer].length; i++) {
if (keccak256(abi.encodePacked(swears[swearer][i].word)) == keccak256(abi.encodePacked(word))) {
uint256 amount = swears[swearer][i].spent;
uint256 t... | 1,084,304 |
//Address: 0x39f73ec09e135bbf5c7f38875db6093115866c96
//Contract name: EZTanks
//Balance: 0.000625 Ether
//Verification Date: 1/16/2018
//Transacion Count: 4
// CODE STARTS HERE
pragma solidity ^0.4.0;
contract EZTanks{
// STRUCTS HERE
struct TankObject{
// type of tank
uint256 typeID;... | [health, attack, armor, speed] | function getCurrentStats(uint256 _tankID) public constant returns (uint256[4]) {
require(_tankID > 0 && _tankID < newTankID);
TankType memory baseType = baseTanks[tanks[_tankID].typeID];
uint8[4] memory upgrades = tanks[_tankID].upgrades;
uint256[4] memory out;
out[0] = bas... | 12,927,036 |
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software releas... | Close any announce. Use in emergency case. opCode TimeLockOpCodes uint8 value opHash keccak256(abi.encode()) code with attributes. target Address for multi time lock. Set zero address if not required. | function closeAnnounce(TimeLockOpCodes opCode, bytes32 opHash, address target) external onlyGovernance {
clearAnnounce(opHash, opCode, target);
emit AnnounceClosed(opHash);
}
| 14,610,378 |
./full_match/4/0x68eC73Ec4AB3edC6B4DB66d7584De2CB06b2E005/sources/browser/DealC.sol | storing multiple deal against single invitee | function addDealForInvitee(string memory inviteeA,address dealA) public{
totalDealI[inviteeA].push(dealA);
}
| 781,764 |
/*
Copyright 2018 ZeroEx Intl.
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 to in writing, ... | Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value. Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipie... | function marketSellOrdersWithEth(
LibOrder.Order[] memory orders,
bytes[] memory signatures,
LibOrder.Order[] memory feeOrders,
bytes[] memory feeSignatures,
uint256 feePercentage,
address feeRecipient
)
public
payable
returns (
... | 881,042 |
pragma solidity 0.5.16;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "../../escrow/EscrowBaseInterface.sol";
import "../../lib/priceoracle/PriceOracleInterface.sol";
import "../../lib/protobuf/BorrowingData.sol";
import "../../lib/protobuf/TokenTransfer.sol";
import "../../lib/protobuf/SupplementalLineI... | Processes the Engagement Due event./ Engagement Due will be processed only when: 1. Issuance is in Engageable state 2. Engagement due timestamp is passed Emits Borrowing Complete Not Engaged event Updates to Complete Not Engaged state Collateral token intra-issuance transfer: Custodian --> Maker Mark payable 1 as paid ... | function processEngagementDue()
private
returns (bytes memory transfersData)
{
if (
_state == IssuanceProperties.State.Engageable &&
now >= _engagementDueTimestamp
) {
emit BorrowingCompleteNotEngaged(_issuanceId);
_state = Issuanc... | 916,135 |
./full_match/3/0xe3E78C43980456568eE5902C155079e725dcBB99/sources/browser/ERC1400ERC20.sol | [ERC1400 INTERFACE (8/9)] Know the reason on success or failure based on the EIP-1066 application-specific status codes. partition Name of the partition. to Token recipient. value Number of tokens to transfer. data Information attached to the transfer, by the token holder. [CONTAINS THE CONDITIONAL OWNERSHIP CERTI... | function canTransferByPartition(bytes32 partition, address to, uint256 value, bytes calldata data)
external
view
returns (byte, bytes32, bytes32)
{
if(!_checkCertificate(data, 0, functionSig)) {
return _canTransfer(functionSig, partition, msg.sender, msg.sender, to, value, data, "");
}
}... | 14,141,612 |
pragma solidity ^0.5.0;
import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contr... | checkCollateralCanDecrease checks if the specified amount of collateral can be removed from account without breaking collateral to debt ratio rule. | function checkCollateralCanDecrease(address _account, address _token, uint256 _amount) public view returns (bool) {
return collateralCanDecrease(_account, _token, _amount);
}
| 13,127,165 |
pragma solidity ^0.8.2;
// SPDX-License-Identifier: MIT
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
// ▓▓▀ ▀▓▌▐▓▓▓▓▓▀▀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
// ▓▓▓ ▓▓▌▝▚▞▜▓ ▀▀ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓... | Next, initialize the new commission | function batchCommission (string[] memory _ids, uint[] memory _bids )
public
callNotStarted
payable
{
require(_ids.length == _bids.length, "arrays unequal length");
uint sum = 0;
for (uint i = 0; i < _ids.length; i++){
Commission storage newCommission = co... | 1,811,607 |
./partial_match/1/0xD59BcAbd00721B754aCB79FE668faE4B6A063fF8/sources/contracts/token/Token.sol | returns the allowance of an `owner` to a `spender`/ | function allowance(Token token, address owner, address spender) view returns (uint256) {
if (isNative(token)) {
return 0;
}
return toIERC20(token).allowance(owner, spender);
}
| 2,647,123 |
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155... | Issue function for DAO (on limited mode) or admin to manually pass issuer Must be called from Timelock contract through a successful proposal or by admin if limited mode is set to false/ | function issueOnBehalf(
address issuee,
address issuer,
uint8 tokenTypeId,
uint256 quantity,
uint256 fromDate,
uint256 thruDate,
uint256 automaticRetireDate,
string memory metadata,
string memory manifest,
string memory description
... | 6,352,300 |
/*
Copyright 2021 Set Labs 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 to in... | Invoke borrow from the SetToken during issuance hook. Since we only need to interact with AAVE once we fetch the lending pool in this function to optimize vs forcing a fetch twice during lever/delever./ | function _repayBorrowForHook(ISetToken _setToken, IERC20 _asset, uint256 _notionalQuantity) internal {
_repayBorrow(_setToken, ILendingPool(lendingPoolAddressesProvider.getLendingPool()), _asset, _notionalQuantity);
}
| 462,703 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.6;
import "../../token/KIP17/IKIP17.sol";
import "../../token/KIP17/KIP17.sol";
import "../../token/KIP17/IKIP17Receiver.sol";
import "../../token/KIP17/IKIP17Metadata.sol";
import "../../token/KIP17/IKIP17Enumerable.sol";
import "../../utils/Address.sol";
import "... | Explicitly set `owners` to eliminate loops in future calls of ownerOf()./ | function _setOwnersExplicit(uint256 quantity) internal {
uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet;
require(quantity > 0, "quantity must be nonzero");
uint256 endIndex = oldNextOwnerToSet + quantity - 1;
if (endIndex > collectionSize - 1) {
endIndex = collectionSize - 1;
}
for... | 2,512,975 |
./full_match/3/0x50b072F04c0af201bA19239957a2fD2bDd96EcB4/sources/contracts/5_my_contract.sol | Return value return value of 'number'/ | function retrieveNumber() public view returns (uint8){
return num1;
}
| 8,135,627 |
./full_match/5/0xDd075Ee118E993A9C18806561635a5a74974F556/sources/project_/contracts/base/MetawinERC721.sol | Return the alternative token URI. _tokenId Token ID/ | function tokenURI_alternative(uint256 _tokenId) public view virtual returns (string memory){
string memory baseURI = useMetawinUri ? getUri('base') : getUri("baseMW");
return _getTokenURI(baseURI, _tokenId);
}
| 1,879,301 |
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
import "../interfaces/AccessControlledInterface.sol";
import "../vendor/AccessControllerInterface.sol";
import "../vendor/ConfirmedOwner.sol";
contract AccessControlled is AccessControlledInterface, ConfirmedOwner(msg.sender) {
AccessControllerInterface intern... | return the previous round id of a given round asset asset address denomination denomination address roundId the round id number to retrieve the updated timestamp for Note that this is not the aggregator round id, but the proxy round id To get full ranges of round ids of different phases, use getPhaseRange() return ... | function getPreviousRoundId(
address asset,
address denomination,
uint80 roundId
) external
view
override
returns (
uint80 previousRoundId
)
{
uint16 phaseId = _getPhaseIdByRoundId(asset, denomination, roundId);
return _getPreviousRoundId(asset, denomination, phaseId, rou... | 14,647,449 |
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import {PercentageMath} from '../protocol/libraries/math/PercentageMath.sol';
import {SafeMath} from '../dependencies/openzeppelin/contracts/SafeMath.sol';
import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.... | Tells if the permit method should be called by inspecting if there is a valid signature. If signature params are set to 0, then permit won't be called. signature struct containing the permit signature return whether or not permit should be called/ | function _usePermit(PermitSignature memory signature) internal pure returns (bool) {
return
!(uint256(signature.deadline) == uint256(signature.v) && uint256(signature.deadline) == 0);
}
| 68,091 |
/**
*Submitted for verification at Etherscan.io on 2022-01-09
*/
// SPDX-License-Identifier: MIT
/**
!Disclaimer!
These contracts have been used to create tutorials,
and was created for the purpose to teach people
how to create smart contracts on the blockchain.
please review this code on ... | Converts a `uint256` to its ASCII `string` decimal representation./ Inspired by OraclizeAPI's implementation - MIT licence https:github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol | function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = n... | 2,403,063 |
pragma solidity 0.7.0;
interface IOwnershipTransferrable {
function transferOwnership(address owner) external;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
}
abstract contract Ownable is IOwnershipTransferrable {
address private _owner;
constructor(address ... | Ensure the SEED token was included as an owned contract | function proposeStakeUpgrade(address newStake, address[] calldata owned, string calldata info) external returns (uint64) {
uint64 proposalID = _createNewProposal(ProposalType.StakeUpgrade);
for (uint i = 0; i < owned.length; i++) {
if (owned[i] == address(_SEED)) {
break;
}
... | 7,332,463 |
./full_match/1/0xDf7D56E526eD37834be0e4D2C8aecE552f54cFea/sources/contracts/BaseSmartVaultDeployer.sol | Create and setup action Set funder token in Set funder balance limits Set funder max slippage Transfer admin permissions to admin Authorize action to swap, unwrap, and withdraw from Smart Vault | function _setupFunderAction(SmartVault smartVault, FunderActionParams memory params) internal {
Funder funder = Funder(params.impl);
Deployer.setupBaseAction(funder, params.admin, address(smartVault));
address[] memory executors = Arrays.from(params.admin, params.managers, new address[](0));... | 17,182,575 |
/**
*Submitted for verification at Etherscan.io on 2022-04-15
*/
//-------------DEPENDENCIES--------------------------//
// File: @openzeppelin/contracts/utils/math/SafeMath.sol
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be ... | Mints a token to an address with a tokenURI. fee may or may not be required _to address of the future owner of the token _amount number of tokens to mint/ | function mintToMultiple(address _to, uint256 _amount) public payable {
require(_amount >= 1, "Must mint at least 1 token");
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction");
require(mintingOpen == true, "Minting is not open right now!");
require(canM... | 10,605,971 |
pragma solidity ^0.4.11;
contract owned {
address public owner;
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
}
... | Transfer tokens Send `_value` tokens to `_to` from your account _to The address of the recipient _value the amount to send/ | function transfer(address _to, uint256 _value) public canSend {
_transfer(msg.sender, _to, _value);
}
| 198,222 |
./full_match/40/0x62dfB99c4d0ac8764B75a132cE0C4C433AF46Cf4/sources/contracts/ElkDexOracle_flattened.sol | given the cumulative prices of the start and end of a period, and the length of the period, compute the average price in terms of how much amount out is received for the amount in. _priceCumulativeStart the cumulative price at the beginning of the period _priceCumulativeEnd the cumulative price at the end of the peri... | function computeAmountOut(
uint _priceCumulativeStart,
uint _priceCumulativeEnd,
uint _timeElapsed,
uint _amountIn
) private pure returns (uint amountOut) {
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(
uint224((_priceCumulativeEnd - _priceC... | 9,544,147 |
./full_match/5/0x3a5945b2a247c5077e59A968b5ec07543c498520/sources/contracts/da/BVM_EigenDataLayrChain.sol | update l2 latest block number _l2SubmittedBlockNumber l2 latest block number/ | function updateSubmittedL2BlockNumber(uint256 _l2SubmittedBlockNumber) external {
require(msg.sender == sequencer, "Only the sequencer can set latest l2 block number");
l2SubmittedBlockNumber = _l2SubmittedBlockNumber;
}
| 1,931,680 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.11;
pragma experimental ABIEncoderV2;
import "deps/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "deps/@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "deps/@openzeppelin/contracts-upgradeable/math/MathUpgr... | Should we check if the amount requested is more than what we can return on withdrawal? | function setWithdrawalSafetyCheck(bool newWithdrawalSafetyCheck) external {
_onlyGovernance();
withdrawalSafetyCheck = newWithdrawalSafetyCheck;
}
| 1,604,823 |
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.6;
import "@yield-protocol/vault-interfaces/IFYToken.sol";
import "@yield-protocol/vault-interfaces/IOracle.sol";
import "@yield-protocol/vault-interfaces/DataTypes.sol";
import "@yield-protocol/utils-v2/contracts/access/AccessControl.sol";
import "@yield-protoco... | Set a rate oracle. Can be reset. | function setLendingOracle(bytes6 baseId, IOracle oracle)
external
auth
{
require (assets[baseId] != address(0), "Base not found");
lendingOracles[baseId] = oracle;
emit RateOracleAdded(baseId, address(oracle));
}
| 5,747,719 |
./full_match/3/0x022EE58dF81Cf5C65B05E51208F23cc9B9e9c49B/sources/contracts/token.sol | Send coins / Check if the sender has enough Check for overflows Subtract from the sender Add the same to the recipient | function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value; ... | 8,150,639 |
/**
*Submitted for verification at Etherscan.io on 2021-04-04
*/
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount o... | copies the conversion fee from the old converter to the new one _oldConverter old converter contract address _newConverter new converter contract address/ | function copyConversionFee(IConverter _oldConverter, IConverter _newConverter) private {
uint32 conversionFee = _oldConverter.conversionFee();
_newConverter.setConversionFee(conversionFee);
}
| 6,775,129 |
./full_match/80001/0x517b04a17D4b5cc8145f0328aAb295703414B589/sources/StakingContract.sol | require(msg.value >= STANDARD_PRICE, "Insufficient BNB sent"); Set the NFT referral ID Emit the NFTMinted event Update the referral count for the referrer if a referral ID was provided | function mintStandard(
uint256 _referralId
) public payable returns (uint256) {
address _to = msg.sender;
require(
_referralId >= STANDARD_MIN_ID && _referralId <= DIAMOND_MAX_ID
);
uint256 newTokenId = _typeTokenIds[STANDARD].current() +
STANDARD_... | 9,437,676 |
./full_match/42220/0xBd44Fd1339C3B5Cd95E88501b1A6AB7e54cf5622/sources/contracts/community/CommunityImplementation.sol | Locks beneficiary _beneficiaryAddress address of beneficiary to be locked/ | function _lockBeneficiary(address _beneficiaryAddress) internal {
Beneficiary storage _beneficiary = _beneficiaries[_beneficiaryAddress];
if (_beneficiary.state == BeneficiaryState.Valid) {
_changeBeneficiaryState(_beneficiary, BeneficiaryState.Locked);
emit BeneficiaryLocke... | 16,317,586 |
./full_match/1/0xb59D5E435927816B40A9300D16c95dE9796f538D/sources/contracts/ERC20FriendlyRewardModule.sol | @inheritdoc IRewardModule/ | function unstake(
bytes32 account,
address sender,
address receiver,
uint256 shares,
bytes calldata
) external override onlyOwner returns (uint256, uint256) {
_update();
return _unstake(account, sender, receiver, shares);
}
| 17,087,070 |
pragma solidity ^0.4.15;
import './interfaces/ERC20Interface.sol';
/**
* @title Token
* @dev Contract that implements ERC20 token standard
* Is deployed by `Crowdsale.sol`, keeps track of balances, etc.
*/
contract Token is ERC20Interface {
// YOUR CODE HERE
mapping (address => uint256) balanceBook;
uint256 p... | send `_value` token to `_to` from `msg.sender` _to The address of the recipient _value The amount of token to be transferred return Whether the transfer was successful or not check sender has enough money | function transfer(address _to, uint256 _value) returns (bool success) {
if (balanceBook[msg.sender] < _value) return false;
if (balanceBook[_to] + _value < balanceBook[_to]) return false;
Transfer(msg.sender, _to, _value);
balanceBook[msg.sender] -= _value;
balanceBook[_to] += _... | 12,606,854 |
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
import "../interfaces/IBentoBoxMinimal.sol";
import "../interfaces/IMasterDeployer.sol";
import "../interfaces/IPool.sol";
import "../interfaces/ITridentCallee.sol";
import "./TridentERC20.sol";
/// @notice Trident exchange pool template... | Burns LP tokens sent to this contract and swaps one of the output tokens for another - i.e., the user gets a single token out by burning LP tokens. This is safe from underflow - only logged amounts handled. | function burnSingle(bytes calldata data) public override lock returns (uint256 amountOut) {
(address tokenOut, address recipient, bool unwrapBento, uint256 toBurn) = abi.decode(data, (address, address, bool, uint256));
Record storage outRecord = records[tokenOut];
amountOut = _computeSingl... | 901,597 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@openzeppelin/upgrades-core/contracts/Initializable.sol";
import "./interfaces/IPriceModule.sol";
contract APContract is Initializable {
address public yieldsterDAO;
address public yieldsterTreasury;
address public yieldsterGOD;
addres... | Price Module Function to set Yieldster price module. _priceModule Address of the price module. | function setPriceModule(address _priceModule) external onlyManager {
priceModule = _priceModule;
}
| 13,825,055 |
./partial_match/1/0x07880D44b0f7b75464ad18fc2b980049c40A8bc3/sources/MSOW.sol | Gets current NFT Price/ | function getNFTPrice() public view returns (uint256) {
return MINT_PRICE;
}
| 4,155,202 |
pragma solidity ^0.4.25;
// ----------------------------------------------------------------------------
// Fxxx Land Rush Contract - Purchase land parcels with GZE and ETH
//
// Deployed to : {TBA}
//
// Enjoy.
//
// (c) BokkyPooBah / Bok Consulting Pty Ltd for GazeCoin 2018. The MIT Licence.
// ---------------------... | Internal function to mint tokens and disable minting if maxParcels sold | function mintParcelTokens(address account, uint parcels) internal returns (bool _lock) {
require(parcels > 0);
parcelsSold = parcelsSold.add(parcels);
_lock = parcelToken.balanceOf(account).add(parcelUsd.mul(parcels)) >= usdLockAccountThreshold;
require(parcelToken.mint(account, parc... | 2,548,911 |
pragma solidity ^0.4.11;
import "./bytesutils.sol";
import "./ECMath.sol";
library tlsnutils{
using bytesutils for *;
/*
* @dev Returns the complete conversation part of one peer (all generator records).
* @param proof The proof.
* @param conversation_part 0 = Requester(Client), 1 = Generator(Server).
... | Verify a proof signed by the specified key. proof The proof. return True iff valid./ Returns ECC signature parts and the evidence hash Convert evidence hash to uint Verify signature | function verifyProof(bytes memory proof, uint256 qx, uint256 qy) returns(bool) {
(sig_r, sig_s, m) = parseProof(proof);
e = uint256(m);
return ECMath.ecdsaverify(qx, qy, e, sig_r, sig_s);
}
| 12,733,253 |
//Address: 0xA4c8A48414d80B22c50BE7b6f3CfAE3EfA6a8716
//Contract name: PPNAirdrop
//Balance: 0 Ether
//Verification Date: 6/12/2018
//Transacion Count: 2
// CODE STARTS HERE
pragma solidity ^0.4.18;
contract PPNAirdrop {
/**
* @dev Air drop Public Variables
*/
address public ... | Token Contract transfer _to - Address to transfer to _value - Value to transfer return bool - Result of transfer "Overloaded" Function of ERC20Basic's transfer/ | function transfer(address _to, uint256 _value) public
onlyWhenTransferAllowed
isValidDestination(_to)
returns (bool)
{
return super.transfer(_to, _value);
}
| 6,440,665 |
./full_match/80001/0xB447B59d547Ba4BCD85269d6b700a84A01bb381f/sources/contracts/Battle.sol | Remove battle from the activeBattlesId array Add credit score to player playerCredit[msg.sender] += 1; | function cancelBattle(uint256 _battleId) external {
BattleData storage battle = battles[_battleId];
require(
battle.players[0] == msg.sender,
"Only the creator can cancel the battle"
);
require(
battle.battleStatus == BattleStatus.PENDING,
... | 852,421 |
/**
*Submitted for verification at Etherscan.io on 2021-08-11
*/
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.6;
// Part: IBetaConfig
interface IBetaConfig {
/// @dev Returns the risk level for the given asset.
function getRiskLevel(address token) external view returns (uint);
/// @dev Returns... | Returns the safety LTV of the given token. Must be greater than zero. | function getSafetyLTV(address _token) external view override returns (uint) {
uint ltv = rConfigs[getRiskLevel(_token)].safetyLTV;
require(ltv > 0, 'getSafetyLTV/no-ltv');
return ltv;
}
| 2,084,865 |
/**
*Submitted for verification at Etherscan.io on 2021-06-25
*/
/*
Welcome to $FuckFlokiScam
Every time musk tweets, there are always some idiots who buy tokens without thinking, it's all honeypots out there, but mine's safe.
don't be fool, check liquidity lock, mint function, tranfer function!
This ... | Update the min amount to liquify. Can only be called by the current operator./ | function updateMinAmountToLiquify(uint256 _minAmount) public onlyowner {
emit MinAmountToLiquifyUpdated(msg.sender, minAmountToLiquify, _minAmount);
minAmountToLiquify = _minAmount;
}
| 10,634,117 |
pragma solidity 0.4.18;
// File: contracts/ERC20Interface.sol
// https://github.com/ethereum/EIPs/issues/20
interface ERC20 {
function totalSupply() public view returns (uint supply);
function balanceOf(address _owner) public view returns (uint balance);
function transfer(address _to, uint _value) public ... | maker dst quantity is the requested quantity he wants to receive. user src quantity is what user gives. so user src quantity is matched with maker dst quantity | function doTrade(
ERC20 srcToken,
uint srcAmount,
ERC20 dstToken
)
internal
returns(uint)
{
OrderListInterface list = (srcToken == ETH_TOKEN_ADDRESS) ? tokenToEthList : ethToTokenList;
uint32 orderId;
OrderData memory orderData;
uint12... | 1,205,975 |
pragma solidity 0.4.15;
import '../Snapshot/DailyAndSnapshotable.sol';
import '../SnapshotToken/StandardSnapshotToken.sol';
contract TestSnapshotToken is
DailyAndSnapshotable,
StandardSnapshotToken
{
////////////////////////
// Mutable state
////////////////////////
bool private _enableTrans... | Mutable state Constructor continue snapshot series of the parent, also will prevent using incompatible scheme | {
bool private _enableTransfers;
bool private _enableApprovals;
function TestSnapshotToken(
IClonedTokenParent parentToken,
uint256 parentSnapshotId
)
StandardSnapshotToken(
parentToken,
parentSnapshotId
)
DailyAndSnapshotable(parentTok... | 2,498,473 |
./partial_match/42/0xB40ea11f489300d0F4DCC9890Fc70b4444F003Eb/sources/DController.sol | Claim all the defi99+ accrued by holder in all markets holder The address to claim BRID+ for/ | function claimDefi99Plus(address holder) public {
return claimDefi99Plus(holder, allMarkets);
}
| 3,428,495 |
pragma solidity 0.5.16;
import "./ProtoBufRuntime.sol";
import "./IssuanceData.sol";
library BorrowingMakerParameters {
//struct definition
struct Data {
address collateralTokenAddress;
address borrowingTokenAddress;
uint256 borrowingAmount;
uint32 collateralRatio;
uint32 tenorDays;
uint3... | The decoder for reading a field p The offset of bytes array to start decode bs The bytes array to be decoded r The in-memory struct counters The counters for repeated fields return The number of bytes decoded/ if `r` is NULL, then only counting the number of fields./ | function _read_collateralTokenAddress(
uint256 p,
bytes memory bs,
Data memory r,
uint[7] memory counters
) internal pure returns (uint) {
(address x, uint256 sz) = ProtoBufRuntime._decode_sol_address(p, bs);
if (isNil(r)) {
counters[1] += 1;
r.collateralTokenAddress = x;
... | 5,489,890 |
./full_match/1/0x333545b0A1fc0675c8022Aa5685beBA31B1d62e9/sources/t2.sol | fetches and sorts the reserves for a pair | function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = ISushiSwap(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = to... | 4,858,126 |
pragma solidity ^0.4.15;
import './FinalizeAgent.sol';
import '../math/SafeMath.sol';
import './AlgoryCrowdsale.sol';
/**
* A finalize agent that does nothing.
* Token transfer must be manually released by the owner
*/
contract NullFinalizeAgent is FinalizeAgent {
AlgoryCrowdsale public crowdsale;
functi... | Called once by crowdsale finalize() if the sale was success. / nothing to do | function finalizeCrowdsale() public {
}
| 12,889,818 |
./full_match/1/0x2355839B2757880d08b978fc5BA73FdC6159B832/sources/contracts/Shard.sol | check if the price is correct refund excess ETH | function claimTokens(
address to,
uint256 tokenId,
uint256 amount,
uint256 price,
string calldata nonce,
bytes memory signature
) external payable nonReentrant {
_claimTokens(to, tokenId, amount, price, nonce, signature);
if (price > 0) {
... | 5,007,114 |
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.11;
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "./b... | Subtract a unsigned 256-bit integer from a fixed point decimal. self The left hand operand. value The right hand operand. This will be converted to a fixed point decimal. return The result./ | function sub(Number memory self, uint256 value) internal pure returns (Number memory) {
return sub(self, FixedPointMath.encode(value));
}
| 157,643 |
./full_match/43114/0xbd8D369470169f9976c5bCc60318955836843a71/sources/src/Facets/AmarokFacet.sol | Contains the business logic for the bridge via Amarok _bridgeData The core information needed for bridging _amarokData Data specific to Amarok give max approval for token to Amarok bridge, if not already initiate bridge transaction | function _startBridge(
BridgeData memory _bridgeData,
AmarokData calldata _amarokData
) private {
LibAsset.maxApproveERC20(
IERC20(_bridgeData.sendingAssetId),
address(connextHandler),
_bridgeData.minAmount
);
_amarokData.destChain... | 4,641,528 |
pragma solidity ^0.4.13;
contract AbstractENS {
function owner(bytes32 node) constant returns(address);
function resolver(bytes32 node) constant returns(address);
function ttl(bytes32 node) constant returns(uint64);
function setOwner(bytes32 node, address owner);
function setSubnodeOwner(bytes32 no... | Submit a new sealed bid on a desired hash in a blind auction Bids are sent by sending a message to the main contract with a hash and an amount. The hash contains information about the bid, including the bidded hash, the bid amount, and a random salt. Bids are not tied to any one auction until they are revealed. The val... | function newBid(bytes32 sealedBid) payable {
if (address(sealedBids[msg.sender][sealedBid]) > 0 ) throw;
if (msg.value < minPrice) throw;
Deed newBid = (new Deed).value(msg.value)(msg.sender);
sealedBids[msg.sender][sealedBid] = newBid;
NewBid(sealedBid, msg.sender, msg.value... | 11,898,229 |
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6.8;
pragma experimental ABIEncoderV2;
import "../../interfaces/IClientManager.sol";
import "../../interfaces/IClient.sol";
import "../../interfaces/IAccessManager.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openze... | get the name of this chain/ | function getChainName() external view override returns (string memory) {
return nativeChainName;
}
| 6,474,791 |
./full_match/80001/0xBd99517e1994226FB8124D37087A0b835829D593/sources/contracts/Portfolio.sol | Write function to get all projects | function getAllProjects() public view returns (Project[] memory) {
return _projects;
}
| 5,572,193 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8;
/*
Invariant - price of trade and amount of liquidity are determined by this equation
An^n sum(x_i) + D = ADn^n + D^(n + 1) / (n^n prod(x_i))
Topics
0. Newton's method x_(n + 1) = x_n - f(x_n) / f'(x_n)
1. Invariant
2. Swap
- Calculate Y
- Calculate D
3. Ge... | Estimate value of 1 share How many tokens is one share worth? | function getVirtualPrice() external view returns (uint) {
uint d = _getD(_xp());
uint _totalSupply = totalSupply;
if (_totalSupply > 0) {
return (d * 10**DECIMALS) / _totalSupply;
}
return 0;
}
| 5,511,232 |
pragma solidity 0.4.21;
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function trans... | Function to access decimals of token. return _decimals uint8 decimal point of token fractions./ | function decimals() public view returns (uint8 _decimals) {
return decimals;
}
| 1,962,819 |
/**
*Submitted for verification at Etherscan.io on 2022-04-29
*/
//*********************************************************************//
//*********************************************************************//
//
// __ _______ ___
// / / / / ___// |
// / / / /\__ \/ /| |
// / /_/ /___/ / ___ |
// \____//... | Mints a token to an address with a tokenURI. fee may or may not be required _to address of the future owner of the token _amount number of tokens to mint/ | function mintToMultiple(address _to, uint256 _amount) public payable {
require(_amount >= 1, "Must mint at least 1 token");
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction");
require(mintingOpen == true, "Minting is not open right now!");
require(canM... | 2,004,214 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@manifoldxyz/libraries-solidity/contracts/access/AdminControl.sol";
import "@manifoldxyz/creator-core-solidity/contracts/core/IERC721CreatorCore.sol";
import "@manifoldxyz/creator-core-solidity/contracts/extensions/ERC721/ERC7... | Get the balance for the owner for this extension/ | function balanceOf(address owner) public view virtual returns(uint256) {
return _ownerBalance[owner];
}
| 49,018 |
./full_match/11155111/0x1259Aa9FaCd0feFB5a91da65682C7EDD51608D4b/sources/contracts/base/GuardManager.sol | Guard Interface | interface Guard is IERC165 {
function checkTransaction(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
byte... | 3,822,627 |
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "../../interfaces/common/IUniswapRouterETH.sol";
import "../../interfaces/common/IUnis... | compounds earnings and charges performance fee | function _harvest(address callFeeRecipient) internal whenNotPaused {
IMasterChef(chef).deposit(poolId, 0);
uint256 outputBal = IERC20(output).balanceOf(address(this));
if (outputBal > 0) {
chargeFees(callFeeRecipient);
addLiquidity();
uint256 wantHarvested... | 444,701 |
pragma solidity ^0.4.21;
// -----------------
//begin SafeMath.sol
/**
* @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 (ui... | daysPassed will be less than 15 so no worries about overflow here | function _getBonusPercent() internal view returns (uint16) {
if (isPresale()) {
return 20;
}
uint256 daysPassed = (now - openingTime) / 1 days;
uint16 calcPercent = 0;
if (daysPassed < 15) {
calcPercent = (15 - uint8(daysPassed));
}
ca... | 15,803,585 |
// SPDX-License-Identifier: MIT
// Special Thanks to @BoringCrypto for his ideas and patience
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SignedSafeMath.sol
library SignedSafeMath {
int256 constant private _I... | Add a new LP to the pool. Can only be called by the owner. DO NOT add the same LP token more than once. Rewards will be messed up if you do. allocPoint AP of the new pool. _lpToken Address of the LP ERC-20 token. _rewarder Address of the rewarder delegate. | function add(uint256 allocPoint, IERC20 _lpToken, IRewarder _rewarder) public onlyOwner {
uint256 lastRewardBlock = block.number;
totalAllocPoint = totalAllocPoint.add(allocPoint);
lpToken.push(_lpToken);
rewarder.push(_rewarder);
poolInfo.push(PoolInfo({
allocPo... | 1,099,146 |
./full_match/1/0x702860f8fBaCecAbE4Fe21b88BE490D3740276CE/sources/contracts/Credits.sol | Function for owner to update the payment wallet address. _paymentWallet Address to be the new paymentWallet./ | function updatePaymentWallet(address _paymentWallet) external onlyOwner {
require(_paymentWallet != address(0), "Zero address provided!");
address oldPaymentWallet = paymentWallet;
paymentWallet = _paymentWallet;
emit PaymentWalletUpdated(
msg.sender,
oldPaym... | 9,737,204 |
./full_match/1/0x80cdC7CF8670B922EF86c6F0e7f237bD4598439A/sources/MRaceNFT.sol | Allows admin to set a penalty on a spot, normally occurs when an off chain issue triggers this/ | function setPenalty(string calldata spotId, bool isPenalized) public onlyOwner {
_penalizedSpots[spotId] = isPenalized;
emit Penalty(spotId, isPenalized);
}
| 8,413,075 |
/**
*Submitted for verification at Etherscan.io on 2022-04-26
*/
// SPDX-License-Identifier: MIT
/*
____ ____ ____ ________ _ ______ ____ __ ____
/ __ \/ __ \/ __ \/ _/ __ \___| | / / __ \/ __ \/ / / __ \
/ / / / /_/ / / / // // / / /_ / | /| / / / / / /_/ / / / / / /
... | Internal for marketing, devs, etc | function internalMint(uint256 _mintAmount, address _to) external onlyOwner nonReentrant {
require(totalSupplyForTeam + _mintAmount <= maxSupplyForTeam, "Exceeded max supply for team");
require(totalSupply() + _mintAmount <= maxSupply, "Exceeded max supply");
_safeMint(_to, _mintAmount);
totalSup... | 6,809,340 |
// 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 o... | Converts a collateral amount in its relative shares for Vesper Grow Pool | function _convertToShares(uint256 _collateralAmount) internal view returns (uint256) {
uint256 _totalValue = vToken.totalValue();
return (_totalValue != 0) ? (_collateralAmount * vToken.totalSupply()) / _totalValue : 0;
}
| 13,171 |
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
/**
* @title Contract for setting abilities.
* @dev For optimization purposes the abilities are represented as a bitfield. Maximum number of
* abilities is therefore 256. This is an example(for simplicity is made for max 8 abilities) of how
* this works.
* 0... | Grants specific abilities to specified address. _target Address to grant abilities to. _abilities Number representing bitfield of abilities we are granting./ | function grantAbilities(
address _target,
uint256 _abilities
)
external
hasAbilities(SUPER_ABILITY)
{
addressToAbility[_target] |= _abilities;
emit SetAbilities(_target, addressToAbility[_target]);
}
| 7,290,609 |
pragma solidity 0.5.6;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/ownership/Ownable.sol";
import "./interfaces/I... | refresh cache variables | function buyCS7() external payable {
require(msg.value > 0, 'CS7Pool: INSUFFICIENT_AMOUNT');
uint256 addedKlay = msg.value;
uint256 cs7Before = _reserveCS7;
uint256 klayBefore = _reserveKLAY;
uint256 newCS7 = addedKlay.mul(cs7Before).div(klayBefore.add(addedKlay));
r... | 6,445,304 |
/**
MIT License
Copyright (c) 2019 Mavennet Systems Inc. https://mavennet.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use,... | checks if given signatory is selected for this bridge's transfer process _signatory signatory address return true or false | function isValidSignatory(address _signatory) public returns (bool) {
return signatories[_signatory];
}
| 1,088,842 |
pragma solidity ^0.4.21;
/* ERC20 contract interface */
/* With ERC23/ERC223 Extensions */
/* Fully backward compatible with ERC20 */
/* Recommended implementation used at https://github.com/Dexaran/ERC223-token-standard/tree/Recommended */
contract ERC20 {
uint public totalSupply;
// ERC223 and ER... | Creator/Owner can unlocked it once and it can never be locked again Use after airdrop is complete | function unlockForever() onlyOwner public {
unlocked = true;
}
| 5,389,341 |
pragma solidity ^0.5.0;
//Functions for retrieving min and Max in 51 length array (requestQ)
//Taken partly from: https://github.com/modular-network/ethereum-libraries-array-utils/blob/master/contracts/Array256Lib.sol
library Utilities{
/**
* @dev Returns the minimum value in an array.
*/
function g... | Getter for the variables saved under the TellorStorageStruct uintVars variable _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is the variables/strings used to save the data in the mapping. The variables names are commented out under the uintVars under the TellorStor... | function getUintVar(TellorStorage.TellorStorageStruct storage self,bytes32 _data) view internal returns(uint){
return self.uintVars[_data];
}
| 12,548,468 |
/**
*Submitted for verification at Etherscan.io on 2021-10-29
*/
// SPDX-License-Identifier: MIT
/*
contract created by
__ __
| \ | \
______ ____ ______ _|... | Mints `tokenId` and transfers it to `to`. WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible Requirements: - `tokenId` must not exist. - `to` cannot be the zero address. Emits a {Transfer} event./ | function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to... | 2,231,200 |
//Address: 0x84119cb33e8f590d75c2d6ea4e6b0741a7494eda
//Contract name: GigaWattToken
//Balance: 0 Ether
//Verification Date: 8/10/2017
//Transacion Count: 13493
// CODE STARTS HERE
/*
* Giga Watt Token Smart Contract. Copyright © 2016 by ABDK Consulting.
* Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>... | return true if tokens were transferred successfully, false otherwise/ | function transferFrom (address _from, address _to, uint256 _value)
returns (bool success)
{
if (_value > approved [_from][msg.sender]) return false;
if (doTransfer (_from, _to, _value)) {
approved [_from][msg.sender] =
safeSub (approved[_from][msg.sender], _value);
return true;
} e... | 5,503,186 |
./partial_match/8453/0x15879074Bd6c89a8a5d88A7Be08fEfb174a54511/sources/ZKWRouterV2.sol | LIBRARY FUNCTIONS | function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return ZKWLibrary.quote(amountA, reserveA, reserveB);
}
| 16,794,095 |
// Copyright (C) 2021 Argent Labs Ltd. <https://argent.xyz>
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// T... | Returns the release time of a wallet lock or 0 if the wallet is unlocked. _wallet The target wallet. return _releaseAfter The epoch time at which the lock will release (in seconds)./ | function getLock(address _wallet) external view returns(uint64 _releaseAfter) {
return _isLocked(_wallet) ? locks[_wallet].release : 0;
}
| 2,524,183 |
pragma solidity ^0.4.18;
/**
* @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) {
if (a == 0) {
return 0;
}
uin... | Required for ERC-721 compliance. | function totalSupply() public view returns (uint256 total) {
return avatars.length;
}
| 6,799,650 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.