file_name
stringlengths
71
779k
comments
stringlengths
0
29.4k
code_string
stringlengths
20
7.69M
__index_level_0__
int64
2
17.2M
// File: @openzeppelin\contracts\token\ERC20\IERC20.sol pragma solidity ^0.6.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); /** * @...
Make as much capital as possible "free" for the Vault to take. Some slippage is allowed./
function exitPosition() internal override { uint balance = crETH.balanceOfUnderlying(address(this)); if(balance > 0){ _withdrawSome(balance); } reserve = 0; }
14,005,346
pragma solidity ^0.4.24; import './token/Token.sol'; import './bondingCurve/BancorFormula.sol'; import 'openzeppelin-solidity/contracts/math/SafeMath.sol'; import 'openzeppelin-solidity/contracts/ownership/Ownable.sol'; contract BondingCurve is BancorFormula, Ownable { using SafeMath for uint256; using Safe...
/ Bonding Curve Module/
function buyDrops(uint256 _ocn) public returns (uint256 _drops) { tokensToMint = calculatePurchaseReturn(ndrops, nOcean / scale, reserveRatio, _ocn / scale); ndrops = ndrops.add(tokensToMint); nOcean = nOcean.add(_ocn); balances[msg.sender] = balances[msg.sender].add(_ocn); ...
6,358,773
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; // Token + Access Control import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import "@openzep...
when mint conditions is reset, the next mint timestamp is reset too the input of startTimestamp is the number of seconds from now.
function setPublicMintConditions(PublicMintCondition[] calldata conditions) external onlyModuleAdmin { if (mintConditions.length > 0) { nextMintTimestampConditionStartIndex += mintConditions.length; delete mintConditions; } for (uint256 i = 0; i < conditions.length; ...
12,781,209
pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/SignedSafeMath.sol"; /// @dev Implements simple fixed point math add, sub, mul and div operations. /// @author Alberto Cuesta Cañada library DecimalMath { using SafeMath for uint256; using SignedSa...
Multiplies x and y, assuming they are both fixed point with `decimals` digits.
function muld(int256 x, int256 y, uint8 decimals) internal pure returns (int256) { return x.mul(y).div(int256(unit(decimals))); }
5,361,037
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { IEmissionsController } from "../interfaces/IEmissionsController.sol"; import { IMasset } from "../interfaces/IMasset.sol"; import { IRevenueRecipient } from "../interfaces/IRevenueRecipient.sol"; import { DialData } from "../emissions/Emissi...
Validates a given uniswap path - valid if sellToken at position 0 and bAsset at end _sellToken Token harvested from the integration contract _bAsset New asset to buy on Uniswap _uniswapPath The Uniswap V3 bytes encoded path./ check sellToken is first 20 bytes and bAsset is the last 20 bytes of the uniswap path
function _validUniswapPath( address _sellToken, address _bAsset, bytes calldata _uniswapPath ) internal pure returns (bool) { uint256 len = _uniswapPath.length; require(_uniswapPath.length >= 43, "Uniswap path too short"); return keccak256(abi.encodePa...
89,293
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.4; contract BlindAuction { struct Bid { bytes32 blindedBid; uint deposit; } address payable public beneficiary; uint public biddingEnd; uint public revealEnd; bool public ended; mapping(address => Bid[]) public bids; ...
End the auction and send the highest bid to the beneficiary.
function auctionEnd() public onlyAfter(revealEnd) { if (ended) revert AuctionEndAlreadyCalled(); emit AuctionEnded(highestBidder, highestBid); ended = true; beneficiary.transfer(highestBid); }
14,082,505
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./libraries/MoneyPool.sol"; import "./interfaces/IFountain.sol"; /** @title...
/ An Active moneyPool must be either the latest moneyPool or the moneyPool immediately before it.
function _activeMp(address _owner) private view returns (MoneyPool.Data storage _mp) { _mp = mps[latestMpNumber[_owner]]; if (!_mp.exists) return mps[0]; if (_mp._state() == MoneyPool.State.Active) return _mp; _mp = mps[previousMpNumber[_mp.number]]; ...
14,074,868
pragma solidity ^0.4.18; // https://github.com/ethereum/EIPs/issues/20 interface ERC20 { function totalSupply() public view returns (uint supply); function decimals() public view returns(uint digits); function balanceOf(address _owner) public view returns (uint balance); function transfer(ad...
Proxy transfer token. When some users of the ethereum account has no ether, he or she can authorize the agent for broadcast transactions, and agents may charge agency fees _from _to _value feeProxy _v _r _s/
function transferProxy(address _from, address _to, uint256 _value, uint256 _feeProxy, uint8 _v,bytes32 _r, bytes32 _s) public transferAllowed(_from) returns (bool){ require(_value + _feeProxy >= _value); require(balances[_from] >=_value + _feeProxy); uint256 nonce = nonces[_from]; ...
15,862,102
./partial_match/1/0x1fF4434e0A41DBF903aa68923d6Da76904546F23/sources/FeesCalculator.sol
Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow./
function sub(uint80 a, uint80 b) internal pure returns (uint80) { return sub(a, b, "SafeMath: subtraction overflow"); }
3,590,034
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC721/ERC721.sol'; import '../ERC2981ContractWideRoyalties.sol'; /// @title Example of ERC721 contract with ERC2981 /// @author Simon Fremaux (@dievardump) /// @notice This is a mock, mint and mintBatch are no...
Mint several tokens at once recipients an array of recipients for each token
function mintBatch(address[] memory recipients) external { uint256 tokenId = nextTokenId; for (uint256 i; i < recipients.length; i++) { _safeMint(recipients[i], tokenId, ''); tokenId++; } nextTokenId = tokenId; }
12,546,276
pragma solidity 0.5.11; /** * @notice Interface of the spending condition * @dev For the interface design and discussion, see the following GH issue * https://github.com/omisego/plasma-contracts/issues/214 */ interface ISpendingCondition { /** * @notice Verifies the spending condition * @param ...
Interface of the spending condition For the interface design and discussion, see the following GH issue/
interface ISpendingCondition { function verify( bytes calldata inputTx, uint16 outputIndex, uint256 inputTxPos, bytes calldata spendingTx, uint16 inputIndex, bytes calldata witness, bytes calldata optionalArgs ) external view returns (bool); }
998,123
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // interfaces import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol"; /** * @dev LSP7 extension, adds token supply cap. */ interface ILSP7CappedSupply is ILSP7DigitalAsset { /** * @dev Returns the number of tokens that can be minted * @retur...
LSP7 extension, adds token supply cap./
interface ILSP7CappedSupply is ILSP7DigitalAsset { function tokenSupplyCap() external view returns (uint256); import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol"; }
5,390,061
/* Copyright 2020 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...
Initializes this module to the SetToken. Only callable by the SetToken's manager. _setToken Instance of the SetToken to issue/
function initialize(ISetToken _setToken) external onlySetManager(_setToken, msg.sender) onlyValidAndPendingSet(_setToken) { _setToken.initializeModule(); }
7,283,865
pragma solidity ^0.6.0; ...
inject NONSTANDARD NAMING
function LOG40(string memory p0, uint p1, string memory p2, uint p3) internal view {
1,019,028
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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 re...
Dynamically return slippage length return Reward slippage slots/
function _getRewardSlippageSlots() internal view override returns(uint256) { return crvRewards.extraRewardsLength() + BASE_REWARDS_COUNT; }
6,160,581
./partial_match/1/0xF13e21653AEB763595D5E4baA1dC115689Da49b9/sources/contracts/core/impl/libtransactions/WithdrawTransaction.sol
Only the 20 MSB are used, which is still 80-bit of security, which is more than enough, especially when combined with validUntil.
function hashOnchainData( uint248 minGas, address to, uint248 amount ) private view returns (bytes20) { return bytes20( abi.encodePacked( minGas, to, amount ).fastSHA256() ...
4,025,439
./full_match/4/0x29d932Ccd887860f8f29c15fD7f09D5Bd82080e8/sources/util/ABDKMath64x64.sol
Calculate x / y rounding towards zero, where x and y are signed 256-bit integer numbers. Revert on overflow or when y is zero. x signed 256-bit integer number y signed 256-bit integer number return signed 64.64-bit fixed point number/
function divi (int256 x, int256 y) internal pure returns (int128) { unchecked { require (y != 0); bool negativeResult = false; if (x < 0) { negativeResult = true; } if (y < 0) { negativeResult = !negativeResult; } uint128 absoluteR...
717,088
/// SPDX-License-Identifier: MIT /// FOR DEMONSTRATION ONLY, unaudited, not recommended to be used for any purpose, carries absolutely no warranty of any kind /// @dev ETHsign an API3 Token Delegation and Voting Policy, with reference to their own Delegation Disclosure, only if address has staked API3 in API3 governanc...
interface to check signer's voting power in API3 governance pool contract
function userSharesAt(address userAddress, uint256 block) external view returns (uint256);
12,669,656
// SPDX-License-Identifier: MIT pragma solidity ^0.8.3; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "./ProductToken.sol"; import "./interface/IVNFT.sol"; /// @title ProductTokenV1 /// @notice This is version 1 of the...
calculates the return for a given conversion (in product token) This function validate whether is enough to purchase token. If enough, the function will deduct, and then mint one token for the user. Any extras are return as change. If not enough, will return as change directly then replace the _amount with the actual a...
function _buy(uint256 _deposit) internal virtual returns (uint32, uint256, uint256, uint256) { require(getAvailability() > 0, "Sorry, this token is sold out."); require(_deposit > 0, "Deposit must be non-zero."); (uint price, uint fee ) = _getPriceForN(1); if (price > _deposit) { return (...
5,914,628
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; // import "./IPawn.sol"; enum LoanDurationType { WEEK, MONTH } enum CollateralStatus { OPEN, DOING, COMPLETED, CANCEL } struct Collateral { addr...
duedateTimestampInterest = 2 24 3600; duedateTimestampInterest = 7 24 3600;
function calculatedueDateTimestampInterest(LoanDurationType durationType) internal pure returns (uint256 duedateTimestampInterest) { if (durationType == LoanDurationType.WEEK) { } }
1,011,153
pragma solidity ^0.4.0; /*contract ERC20_Interface { function totalSupply() public constant returns (uint256 supply); function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, ...
Returns the amount which _spender is still allowed to withdraw from _owner
function allowance(address _owner, address _spender) public constant returns (uint256) { return allowances[_owner][_spender]; }
13,089,724
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; abstract contract AccessControl { address internal _admin; address internal _owner; modifier onlyAdmin() { require(msg.sender == _admin, "unauthorized"); _; } modifier onlyOwner() { require(msg.sender == _owner, "unauthoriz...
Transfers `tokenId` from `from` to `to`. As opposed to {transferFrom}, this imposes no restrictions on msg.sender. Requirements: - `to` cannot be the zero address. - `tokenId` token must be owned by `from`. Emits a {Transfer} event./ Clear approvals from the previous owner
function _transfer( address from, address to, uint256 tokenId ) private { require(_owners[tokenId] == from, "transfer of token that is not own"); require(to != address(0), "transfer to the zero address"); _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; ...
13,125,642
pragma solidity ^0.5.17; pragma experimental ABIEncoderV2; import "../openzeppelin/Ownable.sol"; contract MultiSigKeyHolders is Ownable { uint256 public constant MAX_OWNER_COUNT = 50; string private constant ERROR_INVALID_ADDRESS = "Invalid address"; string private constant ERROR_INVALID_REQUIRED = "Invalid requi...
adds bitcoin address to the key holders _address the address to be added/
function addBitcoinAddress(string memory _address) public onlyOwner { _addBitcoinAddress(_address); }
7,312,717
./full_match/1/0x8b35c25eD7f60bDeCacA2AC093f1DC8522642B48/sources/src/lender/tranche.sol
closes an epoch by changes the state of the contract to waitingForUpdate and returns the totalSupply and totalRedeem for this epoch new supplies or redeems will be accounted for the next epoch return totalSupplyCurrency_ total amount of supply orders return totalRedeemToken_ total amount of redeem orders in token
function closeEpoch() public auth returns (uint256 totalSupplyCurrency_, uint256 totalRedeemToken_) { require(waitingForUpdate == false); waitingForUpdate = true; return (totalSupply, totalRedeem); }
8,342,340
./full_match/97/0x1613b8cc98b200CbD3d43DF3830ff0e043628B51/sources/contracts/AaveTokenV2.sol
returns the delegation data (snapshot, snapshotsCount, list of delegates) by delegation type NOTE: Ideal implementation would have mapped this in a struct by delegation type. Unfortunately, the AAVE token and StakeToken already include a mapping for the snapshots, so we require contracts who inherit from this to provid...
function _getDelegationDataByType(DelegationType delegationType) internal virtual view returns ( ); function _writeSnapshot( mapping(address => mapping(uint256 => Snapshot)) storage snapshots, mapping(address => uint256) storage snapshotsCounts, address owner, uint128 oldValue, ...
5,045,852
//SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; struct StakeInfo { uint256 tokens; ...
Withdraw all stake, claim all pending rewards and burn all bonus stake/
function withdrawAll() public whenNotPaused { uint256 pending = pendingRewards(msg.sender); wavax.transfer(msg.sender, pending); StakeInfo memory s = stake[msg.sender]; uint256 tokens = s.tokens; uint256 total = s.tokens + s.bonus; delete stake[msg.sender]; ...
5,528,281
./partial_match/4/0x53a61f637588805e72F3947E5e5C30C7a104972d/sources/SecretNote.sol
return the generator of G2
function P2() pure internal returns (G2Point) { return G2Point( [11559732032986387107991004021392285783925812861821192530917403151452391805634, 10857046999023057135944570762232829481370756359578518086990519993285655852781], [40823678758634336813322034031454355683168513275...
8,783,987
./partial_match/7700/0xae2BF8e822C5f92d8E5F9aD3225C8F815893BB32/sources/motorChef.sol
Add reserves by transferring from caller Requires fresh interest accrual addAmount Amount of addition to reserves return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees/ totalReserves + actualAddAmount We fail gracefully unles...
function _addReservesFresh(uint addAmount) internal returns (uint, uint) { uint totalReservesNew; uint actualAddAmount; if (accrualBlockNumber != getBlockNumber()) { revert AddReservesFactorFreshCheck(actualAddAmount); } actualAddAmount = doTransferIn(msg.sender...
3,505,835
// Sources flattened with hardhat v2.0.5 https://hardhat.org // File deps/@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in ...
Specify tokens used in yield process, should not be available to withdraw via withdrawOther() Internal logic for strategy migration. Should exit positions as efficiently as possible Internal logic for partial withdrawals. Should exit positions as efficiently as possible. The withdraw() function shell automatically u...
interface IUnitVaultParameters { function tokenDebtLimit(address asset) external view returns (uint256); }
5,731,820
./full_match/1/0xD8969609d81d4D72dc0a4cF533178Bf72788d9F3/sources/contracts/vaults/roles/Gatekeeperable.sol
this can be used internally to update the gatekeep. If you want to expose it, create an external function in the implementation contract and call this.
function _updateGatekeeper(address _gatekeeper) internal { require(_gatekeeper != address(0), "address is not valid"); require(_gatekeeper != gatekeeper, "already the gatekeeper"); gatekeeper = _gatekeeper; emit GatekeeperUpdated(_gatekeeper); }
4,964,773
// File: @OpenZeppelin/contracts/GSN/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.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 be...
You can transfer tokens under two circumstances You haven't voted in the current voting period OR You voted in the current voting period and are trading unstaked tokens
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); if(timeLeftToVestRewards() > 0) { require(balanceOf(from).sub(amount) >= amountStaked[from], "You can't send any of the tokens you sta...
6,178,619
/** *Submitted for verification at Etherscan.io on 2022-04-26 */ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity 0.8.11; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } fu...
Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract. from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred _d...
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (isContract(to)) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { ...
10,816,483
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.4; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {IStandardERC20} from '../../../base/interfaces/IStandardERC20.sol'; import { MintableBurnableIERC20 } from '../../../tokens/interfaces/MintableBurnableIERC20.sol'; import {...
Get the collateral for a position of a token sponsor on a self-minting derivative if any or return that this token sponsor does not have such a position sponsor Address of the token sponsor to check/
function _onlyCollateralizedPosition(address sponsor) internal view { require( positions[sponsor] .rawCollateral .getFeeAdjustedCollateral(feePayerData.cumulativeFeeMultiplier) .isGreaterThan(0), 'Position has no collateral' ); }
1,791,560
./full_match/8453/0x69298fFe05627268D32dd32762e364bfeb42206b/sources/src/JoeV21LegacyDexLens.sol
Returns the prices of each token in Native, scaled with `DECIMALS` decimals _tokens The list of address of the tokens return prices The prices of each token in Native, with `DECIMALS` decimals
function getTokensPricesNative(address[] calldata _tokens) external view override returns (uint256[] memory prices) { return _getTokenWeightedAveragePrices(_WNATIVE, _tokens); }
11,556,651
./full_match/1/0x7af62458e41E2F490D2Df54A8FeDc56fFedB8c17/sources/lib/solady/src/tokens/ERC721.sol
Sets `account` as the approved account to manage token `id`. Requirements: - Token `id` must exist. - The caller must be the owner of the token, or an approved operator for the token owner. Emits a {Approval} event.
function approve(address account, uint256 id) public payable virtual { _approve(msg.sender, account, id); }
3,202,242
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol"; /** * @dev This contract allows cross chain token transfers. * * There ...
allows the owner to withdraw all commissions accumulated _to the address to withdraw commissions to/ reset total commissions no need to require, reverts on failure
function withdrawCommissions(address _to) public onlyOwner validAddress(_to) { totalCommissions = 0; token.transfer(_to, totalCommissions); emit CommissionsWithdraw(_to, totalCommissions); }
12,961,037
./full_match/4/0x8f86C8bC0a7b75e9Ce7039F46A452B36405ce31C/sources/contracts/PriceConsumerV3.sol
Returns the latest price/
function getTokenPrice(address token) public view returns (int256) { address oracle = oracle_addresses[token]; AggregatorV3Interface priceFeed = AggregatorV3Interface(oracle); ( uint80 roundID, int256 price, uint256 startedAt, ui...
12,483,618
./partial_match/1/0xef0757CDDec0384A8EEbc9d199E2A90819af1198/sources/NonPlayableCustoms.sol
Used to update the owner of the token and clear the approvals associated with the previous owner. The `destinationId` should equal `0` if the new owner is an externally owned account. tokenId ID of the token being updated destinationId ID of the token to receive the given token to Address of account to receive the ...
function _updateOwnerAndClearApprovals( uint256 tokenId, uint256 destinationId, address to ) internal { _RMRKOwners[tokenId] = DirectOwner({ ownerAddress: to, tokenId: destinationId }); _cleanApprovals(tokenId); }
15,564,719
pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./interfaces/IMintableCollection.sol"; import "./interfaces/IRewardable.sol"; import "./abstract/EmergencyWithdrawable...
returns the stake with multiplier for an nftId
function getStakeWithMultiplier(uint256 nftId) external view returns (uint256 stakeWithMultiplier){ StakerInfo memory staker = stakes[nftId]; stakeWithMultiplier = virtualAmount(staker.amount, staker.multiplier); }
13,132,048
./full_match/80001/0x784665Fb071C433CA4d2c9Fe413c93FA07Ca036B/sources/src/GameAccessControl.sol
Checks whether verier exists within role _account Address of the sender/
function _verifierExists(address _account) internal view returns (bool) { return hasRole(VERIFIER_ROLE, _account); }
9,465,610
// 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 o...
convert from HUSD to CCrv (HUSD -> 3Crv -> DAI -> CCrv) convert to 3Crv convert 3Crv to DAI add DAI to cpool to get back CCrv
function _convert_husd_to_shares(uint _amount) internal returns (uint _shares) { uint _before = token3Crv.balanceOf(address(this)); stableSwapHUSD.exchange(int128(0), int128(1), _amount, 1); uint _after = token3Crv.balanceOf(address(this)); _amount = _after.sub(_before); uin...
7,006,550
/* Exchange contract. This is an outer contract with public or convenience functions and includes no state-modifying functions. */ // SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./ExchangeCore.sol"; /** * @title Exch...
Test write address to bytes addr Address to write return byte array/
function testCopyAddress(address addr) public pure returns (bytes memory) { bytes memory arr = new bytes(0x14); uint index; assembly { index := add(arr, 0x20) } ArrayUtils.unsafeWriteAddress(index, addr); return arr; }
6,393,798
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@uniswap/v2-peri...
Resumes transfers of tokens on contract/
function continueExecution() external onlyOwner { _unpause(); }
624,905
./full_match/1/0x6A2ffABcfE8583bcA023225E66008b709820b39e/sources/ERC721A.sol
Transfers `tokenId` from `from` to `to`. Requirements: - `to` cannot be the zero address. - `tokenId` token must be owned by `from`. Emits a {Transfer} event./ Clear approvals from the previous owner If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. Set the slot of tok...
function _transfer(address from, address to, uint256 tokenId) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _m...
16,570,744
// File: @openzeppelin\upgrades\contracts\Initializable.sol pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer...
ERC900 Simple Staking Interface/ NOTE: Not implementing the optional functions function lastStakedFor(address addr) external view returns (uint256); function totalStakedForAt(address addr, uint256 blockNumber) external view returns (uint256); function totalStakedAt(uint256 blockNumber) external view returns (uint256...
interface IERC900 { event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); function stake(uint256 amount, bytes calldata data) external; function stakeFor(address user, uint256 amount, bytes calldata data)...
2,361,544
pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./Ligh...
Withdraw LP tokens from LightMain.
function slaveWithdraw(uint256 _pid, uint256 _amount) public { SlavePoolInfo storage pool = slavePoolInfo[_pid]; SlaveUserInfo storage user = slaveUserInfo[_pid][msg.sender]; AreaInfo storage area = areaInfo[_pid][user.aid]; require(user.amount >= _amount, "withdraw: not good"); ...
6,453,559
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721EnumerableLemon.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import ...
get token ids by wallet/
function walletOfOwner(address owner) external view returns(uint256[] memory) { uint256 tokenCount = balanceOf(owner); uint256[] memory tokensId = new uint256[](tokenCount); for(uint256 i; i < tokenCount; i++){ tokensId[i] = tokenOfOwnerByIndex(owner, i); } retur...
624,666
./full_match/56/0xab84Cd8946F4589c2342B733C908cc84d2eCEd1e/sources/contracts/lib/LibCommon.sol
Helper function to transfer ERC20 tokens without the need for SafeERC20. Reverts if the ERC20 transfer fails. tokenAddress The address of the ERC20 token. from The address to transfer the tokens from. to The address to transfer the tokens to. amount The amount of tokens to transfer. solhint-disable-next-line avoid...
function safeTransferFrom( address tokenAddress, address from, address to, uint256 amount ) internal returns (bool) { (bool success, bytes memory data) = tokenAddress.call( abi.encodeWithSignature( "transferFrom(address,address,uint256)", from, to, amount ...
3,252,334
./full_match/1/0xE517aa81408236CF3Fd1170b708741614BeCB631/sources/Users/qijunlin/MyWorkSpace/SolidityWorkSpace/gamer_truffle/contracts/token/GAMER.sol
sets the teamPool teamPool_ The address of the teamPool contract to use for authentication./
function _setTeamPool(address teamPool_) external onlyGov { address oldTeamPool = teamPool; teamPool = teamPool_; emit NewTeamPool(oldTeamPool, teamPool_); }
4,854,108
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.7.0; // import "./Memory.sol"; import "./Blake2b.sol"; library Hash { using Blake2b for Blake2b.Instance; // function hash(bytes memory src) internal view returns (bytes memory des) { // return Memory.toBytes(keccak256(src)); // Bla...
return keccak256(src);
function blake2bHash(bytes memory src) internal view returns (bytes32 des) { Blake2b.Instance memory instance = Blake2b.init(hex"", 32); return abi.decode(instance.finalize(src), (bytes32)); }
15,783,461
./partial_match/1313161554/0xA5dF6D8D59A7fBDb8a11E23FDa9d11c4103dc49f/sources/contracts/distribution/SpolarRewardPool.sol
Safe spolar transfer function, just in case if rounding error causes pool to not have enough spolars.
function safeSpolarTransfer(address _to, uint256 _amount) internal { uint256 _spolarBal = spolar.balanceOf(address(this)); if (_spolarBal > 0) { if (_amount > _spolarBal) { spolar.safeTransfer(_to, _spolarBal); spolar.safeTransfer(_to, _amount); ...
16,943,304
./full_match/3/0x195E0680d54E161C29E8251Ccc537259033Ae59f/sources/browser/MasterChef.sol
Internal function that buys back MKB with the amount of ETH specified
function _buyMkb(uint256 _amount) public returns (uint256 mkbBought) { uint256 ethBalance = address(this).balance; if (_amount > ethBalance) _amount = ethBalance; if (_amount > 0) { uint256 deadline = block.timestamp + 5 minutes; address[] memory mkbPath = new address...
8,208,255
// SPDX-License-Identifier: Unlimited pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementat...
See {IERC165-supportsInterface}./
function _beforeTokenTransfer( address from, address to, uint256 tokenId } function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interface...
2,930
/** *Submitted for verification at Etherscan.io on 2022-03-30 */ pragma solidity 0.6.0; // File: @openzeppelin/contracts-upgradeable/proxy/Initializable.sol // SPDX-License-Identifier: MIT pragma solidity >=0.4.24 <0.7.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of con...
Sets the content data associated with an Series and key. May only be called by the owner of that series. series The series to update. key The key to set. value The text data value to set./
function setContent(address series, uint16 key, string memory value) public onlySeriesOwner(series, key) { contents[series][key] = value; emit ContentChanged(series, key, value); }
6,522,330
//Address: 0x20bAC7E1f662c74Be4234Ec545619470C65e7D7d //Contract name: Prether //Balance: 0 Ether //Verification Date: 6/21/2017 //Transacion Count: 1 // CODE STARTS HERE pragma solidity ^0.4.11; contract ERC20 { //Sets functions and events to comply with ERC20 event Approval(address indexed _owner, address index...
Transfers tokens an approved account
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balance[_from] >= _value && allowed[_from][msg.sender] >= _value && balance[_to] + _value > balance[_to]) { balance[_to] += _value; balance[_from] -= _value; allowed[_from][msg....
14,109,364
./full_match/4/0x84fd322327155b0E56847897Bba4A9C423bf2050/sources/contracts/CheekyLionClub.sol
Hide identity or show identity from here
function setBaseURI(string memory __baseURI) external onlyOwner { baseURI = __baseURI; }
759,740
./partial_match/1/0x14cC8DfaF2258E1B8B2869300dBa1B734dc0fE43/sources/KtuneTokenBlocks.sol
Internal function that burns an amount of the token of a given account, deducting from the sender's allowance for said account. Uses the internal burn function. Emits an Approval event (reflecting the reduced allowance). account The account whose tokens will be burnt. value The amount that will be burnt./
function _burnFrom(address account, uint256 value) internal { _burn(account, value); _approve(account, msg.sender, _allowed[account][msg.sender].sub(value)); }
2,737,057
// Verified using https://dapp.tools // hevm: flattened sources of src/spell.sol // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.7.0; ////// src/addresses.sol /* pragma solidity >=0.7.0; */ contract Addresses { address constant public BR3_ACTIONS = 0x80F33ED0A69935dd74310b9D0009D0BA647Cf223; address...
risk group: 1 - , APR: 5% risk group: 2 - , APR: 5.25% risk group: 3 - , APR: 5.5% risk group: 4 - , APR: 5.75% risk group: 5 - , APR: 6% risk group: 6 - , APR: 6.25% risk group: 7 - , APR: 6.5% risk group: 8 - , APR: 6.75% risk group: 9 - , APR: 7% risk group: 10 - , APR: 7.25% risk group: 11 - , APR: 7.5% risk group:...
function updateHTC2() internal { TinlakeRootLike root = TinlakeRootLike(address(HTC2_ROOT_CONTRACT)); NAVFeedLike navFeed = NAVFeedLike(address(HTC2_FEED)); root.relyContract(HTC2_ASSESSOR, address(this)); root.relyContract(HTC2_FEED, address(this)); root.relyContract(HTC2_F...
293,645
./partial_match/1/0x00000000000006c7676171937C444f6BDe3D6282/sources/contracts/lib/ZoneInteraction.sol
Calls the specified target with the given data and checks the status of the call. Revert reasons will be "bubbled up" if one is returned, otherwise reverting calls will throw a generic error based on the supplied error handler. target The address of the contract to call. orderHash The hash o...
function _callAndCheckStatus( address target, bytes32 orderHash, MemoryPointer callData, uint256 size, uint256 errorSelector ) internal { bool success; bool magicMatch; assembly { let magic := and(mload(callData), MaskOverFirstFourBytes...
4,300,969
/** * @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(uint256 a, uint256 b) internal con...
fallback function can't accept ether
function () { throw; }
12,581,723
./partial_match/42/0x30C86C9D42Af3B908F2adE741536B1cA872cb24c/sources/KBaseQuestions.sol
request.add("get", "https:min-api.cryptocompare.com/data/pricemultifull?fsyms=ETH&tsyms=USD");
function createAnswer(string memory answerText, string memory answerTitle) public returns (bytes32 requestId){ Chainlink.Request memory request = buildChainlinkRequest(ipfsJobId, address(this), this.fulfillAnswerQuestion.selector); request.add("text_for_file", answerText); request.add("text_...
3,327,311
./full_match/5/0x7Dd32d83fDb32988F19Be85DEbf284DdFfA0991a/sources/browser/TMEHatchery.sol
called by backend to find out hatch result
function getResultOfIncubation(uint256 id) public view returns (bool, uint256){ require (id < incubations.length, "invalid id"); Incubation memory toHatch = incubations[id]; require (toHatch.targetBlock < block.number, "not reached block"); uint256 randomN = traitOracle.getRandomN(t...
1,904,325
pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import "../../common/implementation/FixedPoint.sol"; // Simple contract used to withdraw liquidations using a DSProxy from legacy contracts (1.2.2 and below). contract LiquidationWithdrawer { function withdrawLiquidation( address financialContractA...
Optimistic Requester. Optional interface that requesters can implement to receive callbacks. this contract does _not_ work with ERC777 collateral currencies or any others that call into the receiver on transfer(). Using an ERC777 token would allow a user to maliciously grief other participants (while also losing mone...
interface OptimisticRequester { function priceProposed( bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) external; function priceDisputed( bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, uint256 refund ) exter...
99,309
/** *Submitted for verification at Etherscan.io on 2021-04-15 */ /** *Submitted for verification at Etherscan.io on 2021-04-14 */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.2; /******************************************************* * Interfaces * ************...
Fetch asset balance in underlying tokens/
function assetBalance(address assetAddress) public view returns (uint256) { IEarnToken earnToken = IEarnToken(assetAddress); return earnToken.calcPoolValueInToken(); }
7,903,281
./full_match/137/0x11d455366ba5D590e7838c4CEcE9aCC95C567e46/sources/contracts/trove-factory.sol
returns the previous trove by collaterization ratio/
function prevTrove(address _token, address _trove) public view override returns (address) { return _troves[_token].list._values[_trove].prev; }
4,722,836
./full_match/56/0x569bDE4d1720f078Ad8460Cf7dF2F5EEb80c6395/sources/contracts/ERC20Prismatic.sol
Validate voucher list for applicable discounts for `sender` and `recipient`./ Check if transaction has originated from a router pair
function _checkVoucherStatus(address sender, address recipient) private { if (vouchersStatus == 1) { for (uint256 series = 0; series < totalVouchers; series++) { IERC20 discountToken = IERC20(vouchers[series].discountAddress); if (vouchers[series].status == 1 &...
3,250,393
/**The MIT License (MIT) Copyright (c) 2016 Smart Contract Solutions, Inc. 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 /**The MIT License (MIT) Copyright (c) 2016...
remove a role from an address _operator address _role the name of the role/
function removeRole(address _operator, string _role) internal{ roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); }
2,564,466
pragma solidity >=0.4.24 <0.6.0; // https://ethernaut.openzeppelin.com/level/0xe3545ebaa3a0381ebd9f0868ae61b5dc89962ef5 contract SamplePreservation { // public library contracts address public timeZone1Library; address public timeZone2Library; address public owner; uint public storedTime;...
set the time for timezone 1
function setFirstTime(uint _timeStamp) public { timeZone1Library.delegatecall(abi.encodeWithSelector(setTimeSignature, _timeStamp)); }
7,275,257
pragma solidity ^0.5.0; import "./EpochTokenLocker.sol"; import "@dijetsEx.pm/solidity-data-structures/contracts/libraries/IdToAddressBiMap.sol"; import "@dijetsEx.pm/solidity-data-structures/contracts/libraries/IterableAppendOnlySet.sol"; import "@dijetsEx.pm/owl-token/contracts/TokenOWL.sol"; import "@openzeppelin/c...
Used to list a new token on the contract: Hence, making it available for exchange in an auction. token ERC20 token to be listed. Requirements: - `maxTokens` has not already been reached - `token` has not already been added/ Only charge fees for tokens other than the fee token itself
function addToken(address token) public { require(numTokens < MAX_TOKENS, "Max tokens reached"); if (numTokens > 0) { feeToken.burnOWL(msg.sender, FEE_FOR_LISTING_TOKEN_IN_OWL); } require(IdToAddressBiMap.insert(registeredTokens, numTokens, token), "Token already register...
7,246,459
./full_match/3/0x9B5f343d7f1e93A701b4d8A27E6fcF0edcbFD895/sources/browser/Untitled.sol
클라이언트가 이용할 doSerivce 함수 - 이 함수를 이용하기 위해서 토큰을 이 스마트 컨트랙트 주소로 보내야 한다.
function doService(uint _tokenValue) public {
14,217,166
./full_match/1/0x92b377187bcCC6556FceD2f1e6DAd65850C20630/sources/contracts/StaticATokenManualRebalancer.sol
if unwrap is called with 0, we use the full balance of the caller pull main tokens to the rebalancer swap mainToken -> wrappedToken
function unwrap( bytes32 linearPoolId, uint256 numLoops, uint256 mainTokenAmountOrZeroForAll ) external returns (uint256) { address caller = msg.sender; (IERC20 mainToken, IERC20 wrappedToken, IBGDStaticATokenLM vaultToken) = _getLinearPoolTokens(linearPoolId); u...
8,442,155
pragma solidity ^0.6.0; interface TokenInterface { function approve(address, uint) external; function transfer(address, uint) external; function deposit() external payable; function withdraw(uint) external; function balanceOf(address) external view returns (uint); } interface ManagerLike { fun...
Withdraw ETH/ERC20_Token Collateral. vault Vault ID. amt token amount to withdraw. getId Get token amount at this ID from `InstaMemory` Contract. setId Set token amount at this ID in `InstaMemory` Contract./
function withdraw( uint vault, uint amt, uint getId, uint setId ) external payable { ManagerLike managerContract = ManagerLike(getMcdManager()); uint _amt = getUint(getId, amt); uint _vault = getVault(managerContract, vault); (bytes32 ilk, address...
2,430,012
pragma solidity ^0.5.0; import "../lib/BN256.sol"; import "../Ownable.sol"; contract UserContractInterface { // Query callback. function __callback__(uint, bytes calldata) external; // Random number callback. function __callback__(uint, uint) external; } contract DOSProxyMock is Ownable { using B...
Remove id from a storage linkedlist. Need to check tail after this done
function removeIdFromList(mapping(uint => uint) storage list, uint id) private returns(uint, bool) { uint prev = HEAD_I; uint curr = list[prev]; while (curr != HEAD_I && curr != id) { prev = curr; curr = list[prev]; } if (curr == HEAD_I) { ...
886,777
./full_match/8453/0xE4AD80eD0c7d12A8B687c6C987d07f1D486fEd85/sources/src/factory/AnotherCloneFactory.sol
Log collection info Allow the new collection contract to register drop within ABDropRegistry contract Increment the number of collection created emit Collection creation event
function _setupCollection(address _collection, address _publisher) internal { collections.push(ABDataTypes.Collection(_collection, _publisher)); abDataRegistry.grantCollectionRole(_collection); ++collectionCount; emit ABEvents.CollectionCreated(_collection, _publisher); }
11,535,389
/* Copyright 2020 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...
Check that components match the pool tokens
function getProvideLiquidityCalldata( address /* _setToken */, address _pool, address[] calldata _components, uint256[] calldata _maxTokensIn, uint256 _minLiquidity ) external view returns (address _target, uint256 _value, bytes memory _calldata) ...
6,387,136
./full_match/1/0xd08CC7ff1371feb67B2fc401fA172c560d3c3817/sources/deploy/Contract.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 map( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; ...
2,977,876
// File: contracts/Dependencies/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; /* * @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 an...
rush to purchase by anyone check the validity check whether the end time arrives the flash sale has been set an end time and expired
function purchase(uint _saleID, uint _amount) external nonReentrant { FlashSale memory flashSale = _getFlashSaleByID(_saleID); require(_amount > 0, "amount should be > 0"); require(flashSale.base.isAvailable, "the flash sale isn't available"); require(flashSal...
11,923,154
./partial_match/1/0xD5948d2e09fE3282bb462B8f7c0b07660aed549D/sources/DAO.sol
decrement full amount but withdraw only redeem amount
function redeemCoupons(uint256 couponEpoch, uint256 amount) external { require(epoch().sub(couponEpoch) >= 2, "Market: Too early to redeem"); require(amount != 0, "Market: Amount too low"); uint256 couponAmount = balanceOfCoupons(msg.sender, couponEpoch) .mul(amount).div(balanceOfCo...
4,165,581
./full_match/80001/0xEB4F28E7D71902e64F2DfAEA41496051E9093bf0/sources/project_/contracts/extensions/non-fungible-jade/JadeMetadataUpgradeable.sol
Internal set `Jade` encoded metadata id Token id metadata Encoded metadata/
function _setJadeMetadata(uint256 id, uint40 metadata) internal virtual { emit ChangeJadeMetadata(id, metadata); _jadeMetadata[id] = metadata; }
874,204
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.7; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzep...
Update user index for each reward, based on the amount being staked _user user who is staking _amountToStake amount staked Set the user address equal to the global one which means 0 reward for the user Calculate the new user idx The user already staked something so he already have some accrued rewards which are: r = ...
function _updateUserIdx(address _user, uint256 _amountToStake) internal { address[] memory _rewards = rewards; uint256 userIndex; address reward; uint256 _currStake = usersStakes[_user]; for (uint256 i = 0; i < _rewards.length; i++) { reward = _rewards[i]; if (_currStake == 0) { ...
11,824,194
./full_match/42220/0x2607740A4959Ed125e27dc9D02f67e5d42A46CB5/sources/contracts/MasterChef.sol
overrides transfer function to meet tokenomics of FARMING swap and liquify default tax is 5% of every transfer default 95% of transfer sent to recipient
function _transfer(address sender, address recipient, uint256 amount) internal virtual override antiWhale(sender, recipient, amount) { if ( swapAndLiquifyEnabled == true && _inSwapAndLiquify == false && address(blackfarmingSwapRouter) != address(0) && blackfar...
16,321,225
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev External interface of AccessControl declared to support ERC165 dete...
Creates a V2 token ID from a tier ID and tier token ID. tokenId V2 NFT token ID. return tierId_ Index of the token tier. return tierTokenId_ ID of the token within the tier./
function _splitTokenId(uint256 tokenId) internal pure returns (uint128 tierId_, uint128 tierTokenId_) { tierId_ = SafeCast.toUint128(tokenId / ID_PADDING); tierTokenId_ = SafeCast.toUint128(tokenId % ID_PADDING); }
6,317,332
./partial_match/1/0x98B3588651c4FDC38a67628259EBbF9456Fe28B2/sources/WiserToken.sol
Determine the prior number of votes for an account as of a block number Block number must be a finalized block or else this function will revert to prevent misinformation. account The address of the account to check blockNumber The block number to get the vote balance at return The number of votes the account had as...
function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "Token::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return...
2,788,436
pragma solidity ^0.4.25; /** .----------------. .----------------. .----------------. .----------------. | .--------------. || .--------------. || .--------------. || .--------------. | | | ____ ____ | || | ____ | || | _____ | || | ________ | | | | |_ || _| | || | ...
--o Utility Address Only valid for onetime update, cannot be changed !
function Utility_Address(address tokenAddress) public restricted { if (Utility_address == 0x0000000000000000000000000000000000000000) { Utility_address = tokenAddress; } else { revert(); } }
2,492,882
./partial_match/1/0xd6F2E30B99214B6eaffBE2B270d2e42c762a929B/sources/DisputeManager.sol
Internal function to compute the juror weight for the final round. Note that for a final round the weight of each juror is equal to the number of times the min active balance the juror has. This function will try to collect said amount from the active balance of a juror, acting as a lock to allow them to vote...
function _computeJurorWeightForFinalRound(Config memory _config, AdjudicationRound storage _round, address _juror) internal returns (uint64) { IJurorsRegistry jurorsRegistry = _jurorsRegistry(); uint256 activeBalance = jurorsRegistry.activeBalanceOfAt(_juror, _round.draftTermId); ...
4,343,489
pragma solidity ^0.4.23; import "../../../util/SafeMath.sol"; import "../../../storage/KeyValueStorage.sol"; /** * @title PatentToken is an ERC-721 NFT * Code is based on Open Zeppelin Library (https://github.com/OpenZeppelin/openzeppelin-solidity) * Includes modification for Patent metadata & licensing * Includes m...
Sets whether the token is transferrable _tokenId uint256 ID of the token to set licensibility _transferrable Is is licensable or not?/
function setTransferrable(uint256 _tokenId, bool _transferrable) external onlyOwnerOf(_tokenId) { storageContract.setBool(keccak256("patent.transferrable", _tokenId), _transferrable); }
12,845,986
pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; /* * Merkle Tree Utilities for Rollup */ contract RollupMerkleUtils { /* Structs */ // A partial merkle tree which can be updated with new nodes, recomputing the root struct SparseMerkleTree { // The root bytes32 root; uint...
Store a particular leaf hash & its intermediate nodes in the tree _leaf The leaf we're storing. _path The path from the leaf to the root / the index of the leaf. _siblings The sibling nodes along the way./ First compute the leaf node Store the node! Store the node!
function storeLeaf(bytes32 _leaf, uint _path, bytes32[] memory _siblings) public { bytes32 computedNode = _leaf; for (uint i = 0; i < _siblings.length; i++) { bytes32 parent; bytes32 sibling = _siblings[i]; uint8 isComputedRightSibling = getNthBitFromRight(_path, ...
5,448,926
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../../../access-control-registry/RoleDeriver.sol"; import "../../../access-control-registry/AccessControlClient.sol"; import "../../../access-control-registry/interfaces/IAccessControlRegistry.sol"; import "./interfaces/IAirnodeFeeRegistryRolesWithManager....
Derives the admin role for the specific manager address _manager Manager address return _adminRole Admin role
function _deriveAdminRole(address _manager) private view returns (bytes32 _adminRole) { _adminRole = _deriveRole( _deriveRootRole(_manager), adminRoleDescriptionHash ); }
1,053,048
pragma solidity 0.4.15; /* Crypto Market Prices via Ethereum Smart Contract A community driven smart contract that lets your contracts use fiat amounts in USD, EURO, and GBP. Need to charge $10.50 for a contract call? With this contract, you can convert ETH and other crypto&#39;s. Repo: https://...
delete a token from the contract
function deleteToken(uint id) { require(msg.sender==creator); DeletePrice(id); delete tokens[id]; }
6,818,303
pragma solidity ^0.4.19; contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant public returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ...
calculate ether for refunds
function sendEtherToMultisig() public returns(uint256 e) { uint256 req; require(msg.sender==owner || msg.sender==multisig); require(saleStatus!=0); if(saleStatus==2) { req=tokensFromEther.mul(1 ether).div(step0Rate).div(2); if(bDbgEnabled) emit DebugLog("This bal...
1,066,195
./partial_match/3/0x25BfA7A89EEc683D2d1dF562f9c818019BBC84e9/sources/TokenController.sol
ratifier ratifies a request mint. If the number of ratifiers that signed off is greater than the number of approvals required, the request is finalized _index the index of the requestMint to ratify _to the address to mint to _value the amount requested/
function ratifyMint( uint256 _index, address _to, uint256 _value ) external mintNotPaused onlyMintRatifierOrOwner { MintOperation memory op = mintOperations[_index]; require(op.to == _to, "to address does not match"); require(op.value == _value, "amount does not m...
5,198,298
pragma solidity ^0.4.24; 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 r...
The owner of the contract modifies the recovery address of the token/
function modifyCollectorAddress(address newCollectorAddress) public onlyOwner returns (bool) { collectorAddress = newCollectorAddress; }
5,472,482
pragma solidity ^0.5.0; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./ERC777FeeIncome.sol"; /** * @title ERC777SendFee * @author Rafael Kallis <rk@rafaelkallis.com> */ contract ERC777SendFee is ERC777FeeIncome { using SafeMath for uint256; uint256 private _sendFee; constructor(uint2...
Charges `account` a send-fee relative to `sendAmount`. Usage example: ``` function send(address recipient, uint256 amount, bytes calldata data) public { super.send(recipient, amount, data); _chargeSendFee(msg.sender, amount); } function operatorSend( address sender, address recipient, uint256 amount, bytes...
function _chargeSendFee(address account, uint256 sendAmount) internal { _chargeFee(account, sendFee(sendAmount)); }
14,040,139
./partial_match/1/0x61e42A3d56687C94DBc216E534eF5d162Fd59f69/sources/DeFiBot.sol
These are the initial fees, they will be reconfigured as the project matures look at https:docs.defibot.app where the plan is described or come to our telegram channel Telegram: t.me/DeFiBotHub Supply is fixed at 10 million, there is no further minting. Initially 1% is the most any wallet can hold this is to minimise w...
constructor() ERC20("DeFiBot", "DEFIBOT") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IU...
15,491,879
./full_match/137/0x712A6aa3396291839357b6545DEb24AE8c2e2618/sources/contracts/TieredAccessControl.sol
Revokes `role` from `account`. Internal function without access restriction. May emit a {RoleRevoked} event./
function _revokeRole(uint8 role, address account) internal virtual { if (hasRole(role, account)) { roles[account] = 0; emit RoleRevoked(role, account, _msgSender()); } }
4,773,364
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol"; import "@chainlink/contracts/src/v0.8/ConfirmedOwner.sol"; contract DecentralizedNFTDao is ChainlinkClient, ConfirmedOwner { using Chainlink for Chainlink.Request; constructor(address oracle, s...
expire appraisal requests after 30 days if not enough votesreimburse the appraisal creator with the eth they locked in the contract.
function expireAppraisals() public { for (uint256 i=0;i<appraisals.length;i++) { if (((block.timestamp - appraisals[i].request_time) > (60*60*24*30)) && appraisals[i].status==NFTAppraisalStatus.Open) { appraisals[i].status==NFTAppraisalStatus.Failed; ...
1,042,954
// Sources flattened with hardhat v2.0.5 https://hardhat.org // File deps/@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in ...
to avoid repay all debt resulting to close the CDP unexpectedly
function _capMaxDebtPaid(uint256 _actualPaidDebt, uint256 _totalDebtWithoutFee) internal view returns (uint256) { uint256 _maxDebtToRepay = _totalDebtWithoutFee.sub(ratioBuffMax); return _actualPaidDebt >= _maxDebtToRepay ? _maxDebtToRepay : _actualPaidDebt; }
5,731,843
pragma solidity 0.5.10; import 'ROOT/reporting/IShareToken.sol'; import 'ROOT/libraries/token/ERC1155.sol'; import 'ROOT/libraries/ReentrancyGuard.sol'; import 'ROOT/libraries/ITyped.sol'; import 'ROOT/libraries/Initializable.sol'; import 'ROOT/reporting/IMarket.sol'; import 'ROOT/trading/IProfitLoss.sol'; import 'ROO...
solium-disable indentation
function burnCompleteSets(IMarket _market, address _account, uint256 _amount, address _affiliateAddress) private returns (uint256 _payout, uint256 _creatorFee, uint256 _reportingFee) { uint256 _numOutcomes = markets[address(_market)].numOutcomes; uint256 _numTicks = markets[address(_market)].numTick...
12,667,859
// SPDX-License-Identifier: BUSL-1.1 // For further clarification please see https://license.premia.legal pragma solidity ^0.8.0; import {EnumerableSet} from "@solidstate/contracts/utils/EnumerableSet.sol"; import {ABDKMath64x64} from "abdk-libraries-solidity/ABDKMath64x64.sol"; import {IPoolIO} from "./IPoolIO.sol"...
@inheritdoc IERC1155/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require( accounts.length == ids.length, 'ERC1155: accounts and ids length mismatch' ); mappi...
104,056
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.12; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ /...
accrue Interest of all whitelisted FraxLendPairs
function accrueInterestAllFraxLendPair() public onlyByOwnGov { for (uint i=0; i < fraxlendpairs_array.length; i++) { accrueInterestFraxLendPair(fraxlendpairs_array[i]); } }
6,346,817