file_name
stringlengths
71
779k
comments
stringlengths
0
29.4k
code_string
stringlengths
20
7.69M
__index_level_0__
int64
2
17.2M
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contrac...
Update reward variables for all pools. Be careful of gas spending!
function massUpdatePools() internal { uint256 length = poolInfo.length; require(length < 6, "ChipRewardPool.massUpdatePools(): Pool size exceeded."); for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } }
1,773,189
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; contract Owned { address payable internal owner; event feePaid(address to, uint256 amount); // creator is owner constructor() { owner = payable(msg.sender); } // only owner is allowed to call restricted function modifier res...
allow update of the owner
function changeOwner(address payable newOwner) public restrict { owner = newOwner; }
7,272,158
pragma solidity ^0.5.0; contract Voting { struct Proposal { string title; uint256 voteCountPos; uint256 voteCountNeg; uint256 voteCountAbs; mapping(address => Voter) voters; address[] votersAddress; } struct Voter { uint256 value; bool voted;...
check duplicate key
function vote(uint256 proposalInt, uint256 voteValue) public returns (bool) { if (proposals[proposalInt].voters[msg.sender].voted == false) { if (voteValue == 1) { p.voteCountPos += 1; p.voteCountNeg += 1; p.voteCountAbs += 1; ...
12,604,856
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.7.0; pragma abicoder v2; import "./TradingAction.sol"; import "./ActionGuards.sol"; import "./nTokenMintAction.sol"; import "./nTokenRedeemAction.sol"; import "../SettleAssetsExternal.sol"; import "../FreeCollateralExternal.sol"; import "../../math/SafeInt256...
Sets the account context of a given account
function setAccountContext(AccountContext memory accountContext, address account) internal { mapping(address => AccountContext) storage store = LibStorage.getAccountStorage(); store[account] = accountContext; emit AccountContextUpdate(account); }
12,187
/* "SPDX-License-Identifier: UNLICENSED" ElonMoon.finance */ pragma solidity ^0.6.12; /* * @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 accessed in such...
Moves tokens `amount` from `sender` to `recipient`. This is internal function is equivalent to {transfer}, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements: - `sender` cannot be the zero address. - `recipient` cannot be the zero address. - `sender`...
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 amount_burn = amount.mul(_burnRate).div(100); ...
254,054
./partial_match/3/0xd95209cBb12652C10e0B49a0CdfD8bDDc27848E9/sources/testcontract.sol
Uniswap srcToken => dstToken Approve Uniswap to spend tokens Setup transfer uint[] memory minOuts = uniswap.getAmountsOut(amount, path); As you can see I changed the address to msg.sender and added time
function runTokenUniswapTransfer(uint amount, uint minOuts, address srcTokenAddress, address dstTokenAddress) onlyOwner() external { IERC20 srcToken = IERC20(srcTokenAddress); IERC20 dstToken = IERC20(dstTokenAddress); IUniswapV2Router01 uniswap = IUniswapV2Router01(0x7a250d5630B4cF539739dF2C5dAcb4c659F...
5,062,490
pragma solidity ^0.6.0; import "../utils/GasBurner.sol"; import "../interfaces/IAToken.sol"; import "../interfaces/ILendingPool.sol"; import "../interfaces/ILendingPoolAddressesProvider.sol"; import "../utils/SafeERC20.sol"; /// @title Basic compound interactions through the DSProxy contract AaveBasicProxy is GasBur...
Approves CToken contract to pull underlying tokens from the DSProxy _tokenAddr Token we are trying to approve _cTokenAddr Address which will gain the approval
function approveToken(address _tokenAddr, address _cTokenAddr) internal { if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeApprove(_cTokenAddr, uint(-1)); } }
381,000
// File: @openzeppelin/contracts/utils/cryptography/ECDSA.sol pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum...
standard ERC721 burn interface
function burn(uint256 _tokenId) external { _burnToken(_tokenId, msg.sender); }
640,521
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./interfaces/IUniswapV2Router.sol"; import "./interfaces/IUniswapV2Factory...
Emit event to query unlock liquidity
function removeUnlockedLiquidity( uint256 liquidityLockID, uint256 liquidity, PairAmounts memory minAmounts, uint256 deadline ) public returns (PairAmounts memory amounts) { LiquidityLock storage liquidityLock = liquidityLocks[liquidityLockID]; require( block.timestamp >= liquidityLoc...
891,685
pragma solidity ^0.4.24; import "../story/story.sol"; import "../register.sol"; import "../world_info.sol"; /// @title Identity /// @author ["Cryptape Technologies <contact@cryptape.com>"] contract Identity { Register register; address owner; uint public record; uint public weapon; address public...
Set scene leave old scene enter new scene Update the world info Update the secene
function setScene(address _scene, address _owner) public onlyOperator onlyOwner(_owner) returns (bool) { WorldInfo world = WorldInfo(register.worldInfoAddr()); world.userLeave(scene, owner); world.userEnter(_scene, owner); scene = _scene; r...
12,965,467
./full_match/5/0x3287983f852bd6d56fF175A7BcDDCd0e3008F99B/sources/src/zkbob/utils/ZkBobAccounting.sol
for full correctness, next line should use "while" instead of "if" however, in order to keep constant gas usage, "if" is being used this can lead to a longer sliding window (> 1 week) in some cases, but eventually it will converge back to the 1 week target if tail is more than 1 week behind, we move tail pointer to the...
function _recordOperation( address _user, int256 _txAmount ) internal returns (uint56 maxWeeklyAvgTvl, uint32 maxWeeklyTxCount, uint256 txCount) { Slot0 memory s0 = slot0; Slot1 memory s1 = slot1; uint24 curSlot = uint24(block.timestamp / SLOT_DURATION...
7,063,076
pragma solidity ^0.4.15; // ---------------------------------------------------------------------------- // HAZ 'Hazza Network Token' contract locked tokens // // Refer to http://hazza.network for further information. // // Enjoy. (c) ANX International and BokkyPooBah / Bok Consulting Pty Ltd 2017. // The MIT Licence....
------------------------------------------------------------------------ locked balances for an account ------------------------------------------------------------------------
function balanceOfLocked(address account) constant returns (uint balance) { return balancesLocked6M[account].add(balancesLocked8M[account]).add(balancesLocked12M[account]); }
1,823,850
./full_match/43113/0xc48Be674DE92202d505Ba1ACDa28837b2D96f4Dd/sources/contracts/lens/Quoter.sol
@inheritdoc IElkDexV3SwapCallback
function ElkDexV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes memory path ) external view override { (address tokenIn, address tokenOut, uint24 fee) = path.decodeFirstPool(); CallbackValidation.verifyCallback(factory, tokenIn, tokenOut, fee); (bo...
13,187,393
./partial_match/1/0x095527F5bEa113E9575B662c5ba01D990A280f2F/sources/TrueFi.sol
Writes are allowed only if the accessManager approves
function setAttribute( address _who, bytes32 _attribute, uint256 _value, bytes32 _notes ) public { require(confirmWrite(_attribute, msg.sender)); attributes[_who][_attribute] = AttributeData(_value, _notes, msg.sender, block.timestamp); emit SetAttribute(_...
3,986,978
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.4; import "./DirectLoanBaseMinimal.sol"; import "../../../utils/ContractKeys.sol"; /** * @title DirectLoanFixed * @author NFTfi * @notice Main contract for NFTfi Direct Loans Fixed Type. This contract manages the ability to create NFT-backed * peer-to-pee...
A convenience function with shared functionality between `payBackLoan` and `liquidateOverdueLoan`. _loanId A unique identifier for this particular loan, sourced from the Loan Coordinator. _nftReceiver - The receiver of the collateral nft. The borrower when `payBackLoan` or the lender when `liquidateOverdueLoan`. _l...
function _resolveLoan( uint32 _loanId, address _nftReceiver, LoanTerms memory _loanTerms, IDirectLoanCoordinator _loanCoordinator ) internal { _resolveLoanNoNftTransfer(_loanId, _loanTerms, _loanCoordinator); _transferNFT(_loanTerms, address(this), _nftReceiver); ...
1,474,512
/* 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, ...
THIS IS A SELF-CONTAINED CONVENIENCE CONTRACT FOR TESTING THE DYDX BRIDGE ON MAINNET. Currently deployed at 0xeb58c2caa96f39626dcceb74fdbb7a9a8b54ec18. Steps: 1. Deploy to mainnet (can copy-paste this into Remix and deploy). 2. Send some DAI to the contract. 3. Call `init()` to configu...
interface IERC20Token { function approve(address spender, uint256 value) external returns (bool); function balanceOf(address owner) external view returns (uint256); }
12,752,694
//SPDX-License-Identifier: Unlicense pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@chainlink/contracts/src/v0.7/interfaces/AggregatorV2V3Interface.sol"; import "./interfaces/IBPool.sol"; import...
Gets how many SMT represents the `_amount` of `_asset`. _asset address of asset to get the amount. _assetAmountIn amount of `_asset`./ pools will include the wrapepd SMT get amount from some of the pools not pool with SMT/asset pair -> calculate base on SMT/ETH pool and Asset/ETH external price feed pools will includ...
function calculateAmount(address _asset, uint256 _assetAmountIn) public view returns (uint256) { address xSMT = xTokenWrapper.tokenToXToken(smt); address xETH = xTokenWrapper.tokenToXToken(ETH_TOKEN_ADDRESS); uint256 amount = getAvgAmountFromPools(_asset, xSMT, _assetAmountIn); if ...
13,799,068
./partial_match/42/0xfF28153F4a59f59a3cCb1c24B7331B42a4e89EAf/sources/FixedSwap.sol
Action Functions / Confirm Amount is positive / Confirm Amount is less than tokens available / Confirm the user has funds for the transfer, confirm the value is equal / Confirm Amount is bigger than minimum Amount / Confirm Amount is smaller than maximum Amount / Verify all user purchases, loop thru them /
function swap(uint256 _amount) payable external whenNotPaused isFunded isSaleOpen { require(_amount > 0, "Amount has to be positive"); require(_amount <= tokensLeft(), "Amount is less than tokens available"); require(msg.value == cost(_amount), "User has to cover the cost of t...
3,342,572
pragma solidity 0.4.24; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./IKODAV2Controls.sol"; /** * @title Artists self minting for KnownOrigin (KODA) * * Allows for t...
Sets the KODA address Only callable from owner/
function setKodavV2(IKODAV2Controls _kodaAddress) onlyOwner public { kodaAddress = _kodaAddress; }
1,836,385
./full_match/80001/0x65d63958fc1Bf199e8a44762F77b329c864898fA/sources/contracts/Battle.sol
Player 1 attacks, player 2 does nothing
function _handleAttackDoNothing( BattleData storage battle, CharacterProxy storage proxyA, CharacterProxy storage proxyB ) private returns ( uint256[2] memory damageDealt, address[2] memory damagedPlayers ) { uint256 damageA = (...
5,549,113
./full_match/80001/0x6ee73E980d53C4c60b63E8a6A8B34E6b15dBE718/sources/contracts/CloudArtworkGenerator.sol
gets the inner code for the image. In this case, this includes filters to geenrate the cloud effect tokenId the tokenId for the image/
function getFragment(uint tokenId) public view returns (string memory fragment){ Theme memory theme = themesMap[randomInRange(0, maxTheme, Strings.toString(tokenId))]; string memory width = Strings.toString(randomInRange(200, 370, Strings.toString(tokenId))); string memory fillString = getColor(th...
9,434,829
// Copyrights(c) 2020 Zhou Le, Tang Jingyao // Course project of EE357 spring semester, 2020, Shanghai JiaoTong University // The contract source file of game "Crypto Galaxy" // ONLY used for research and study // Version 1.0.0 pragma solidity >=0.4.22 <0.5.2; pragma experimental ABIEncoderV2; contract Random {...
delete saleList[_id];
function executeSale(address _to, uint _sale_type, uint _said) internal { if (_sale_type == 1) { transferShip(saleList[_said].seller, _to, saleList[_said].data[1]); shipList[saleList[_said].data[1]].data[2] = 3; transferTreasure(saleList[_said].seller, _to, saleList[_said...
14,034,925
./partial_match/1/0x5F1127EcbEeC10cb614A62869AD7DA2f9358343d/sources/NiftyBuilderInstance.sol
Prevent the minting of additional NFTs of this 'niftyType'./
function setFinalized(uint256 niftyType) public onlyValidSender { uint256 quotient = niftyType / 256; bytes32 chunk = _finalized[quotient]; _finalized[quotient] = chunk | bytes32(1 << (niftyType % 256)); }
4,355,425
./full_match/1/0x2b7b2aF75f588C81EdBccBc832c20dDdc58D7484/sources/contract-5512c8d244.sol
Transfer amount minus tax Transfer tax to tax address
function transfer(address recipient, uint256 amount) public override returns (bool) { super.transfer(recipient, amount.sub(taxAmount)); super.transfer(taxAddress, taxAmount); return true; }
3,068,400
./full_match/1/0x7132c10A5fDeb8236Be65F451c1973E26E8515EF/sources/contracts/sugartown/SugartownOrasNFT.sol
Overriden safeTransferFrom function for operator filtering./
function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId); }
3,072,400
./partial_match/42/0x5bFa399a5a2c6d20192b4Fa4704D38bAF5e241B4/sources/H2OChef.sol
Deposit LP tokens to MasterChef for PICKLE allocation.
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user .amount .mul(pool.accWaterP...
3,354,119
./full_match/80001/0xf416854209769796f3367c785A3F155a9fe2D6B7/sources/@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol
Deterministically computes the pool address given the factory and PoolKey factory The Uniswap V3 factory contract address key The PoolKey return pool The contract address of the V3 pool Convert to bytes20 and then to address
function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); bytes32 salt = keccak256(abi.encode(key.token0, key.token1, key.fee)); bytes32 rawAddress = keccak256( abi.encodePacked( bytes1(0x...
5,572,225
pragma solidity 0.4.26; import '../utility/ContractRegistryClient.sol'; import './interfaces/IBancorConverterRegistry.sol'; import './interfaces/IBancorConverterRegistryData.sol'; import '../token/interfaces/ISmartToken.sol'; import '../token/interfaces/ISmartTokenController.sol'; /** * @dev The BancorConverterRegis...
checks if a liquidity pool with given reserve tokens/ratios is already registered _converter converter with specific reserve tokens/ratios return if a liquidity pool with the same reserve tokens/ratios is already registered/ get the reserve-configuration of the converter
function isSimilarLiquidityPoolRegistered(IBancorConverter _converter) internal view returns (bool) { uint reserveTokenCount = _converter.connectorTokenCount(); address[] memory reserveTokens = new address[](reserveTokenCount); uint[] memory reserveRatios = new uint[](reserveTokenCount); ...
14,018,074
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of...
Returns the symbol of the token, usually a shorter version of the name./
function symbol() external view virtual returns (string memory) { return _symbol; }
63,216
pragma solidity 0.5.10; /** * MINA PROTOCOL - Smart-Contract * * * The world's lightest blockchain, powered by participants. * * By design, the entire Mina blockchain is and will always be about 22kb - the size of a couple of tweets. * So anyone with a smartphone will be able to sync and verify the network ...
Calculate amount of tokens to recieve for a given amount of wei weiAmount Value in wei to be converted into tokens return Number of tokens that can be purchased with the specified _weiAmount/
function getTokenAmount(uint256 weiAmount) public view returns(uint256) { return weiAmount.mul(_rate).div(1e18); }
310,707
./full_match/5/0x999512dC124371E6B9ff43CE8D1AF83252F0C851/sources/src/BaseVault.sol
Returns the amounts that can be redeemed for an user on the round. round The round. user The user. return amountX The amount of token X that can be redeemed. return amountY The amount of token Y that can be redeemed./ Get the queued withdrawal of the round. Get the total amount of tokens that were queued for the roun...
function getRedeemableAmounts(uint256 round, address user) public view virtual override returns (uint256 amountX, uint256 amountY) { QueuedWithdrawal storage queuedWithdrawal = _queuedWithdrawalsByRound[round]; uint256 totalAmountX = queuedWithdrawal.tota...
1,894,033
pragma solidity ^0.5.1; interface ERC20 { function BALANCEOF565(address _owner) external view returns (uint256); //inject NONSTANDARD NAMING function ALLOWANCE851(address _owner, address _spender) external view returns (uint256); //inject NONST...
inject NONSTANDARD NAMING
function MUL1000(uint256 a, uint256 b) internal pure returns (uint256) {
13,119,262
// File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises...
/ make sure name fees paid filter name + condition checks if names already has been used set up address set up our tx event data and determine if player is new or not fetch player id if names already has been used add name to player profile, registry, and name booktry bind a refer
function registerNameXName(string memory nameString, string memory affCode) public payable { require (msg.value >= this.getRegistrationFee(), "umm..... you have to pay the name fee"); bytes32 name = NameFilter.nameFilter(nameString); require(_pIDxName[name] == 0, "sor...
948,495
./partial_match/42/0xc3Fa8D75Ec3cb35f6cb7D640FcF1F0318f2cF9d7/sources/StakingRewards.sol
called by join when user unlocks his collaterals allowed to call only from join contract (GemJoinWithReward)/
function withdraw( uint256 amount, address gem, address usr ) public nonReentrant updateReward(usr) checkFinish checkStart { require(amount > 0, "Cannot withdraw 0"); require(pairDescs[gem].staker == msg.sender, "Stake from join only allowed"); withdrawLp(amount,...
8,846,350
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.2 <0.9.0; import "hardhat/console.sol"; contract Auction { type UserType is uint256; enum Status { Pending, Shipped, Accepted, Rejected, Canceled } struct TodoStruct { string text; bool ...
mapping(address => uint) memory localMapping; Local Accesses console.log(localMapping);
function locals() external view virtual returns (uint256) { string memory localString = this.getText(); bool localBool = true; uint256 localInt = 456; address localAddr = msg.sender; UserType localUserType = UserType.wrap(uint256(456)); Status localEnum = Status.Pendi...
12,967,322
pragma solidity ^0.4.24; // File: libs/EC.sol contract EC { uint256 constant public gx = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798; uint256 constant public gy = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8; uint256 constant public n = 0xFFFFFFFFFFFFFFFFFFFFF...
https:bitcoin.stackexchange.com/questions/48586
function complexityForBtcAddressPrefixWithLength(bytes prefix, uint length) public pure returns(uint) { require(prefix.length >= length); uint8[128] memory unbase58 = [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 25...
2,367,793
pragma solidity ^0.5.10; // File: openzeppelin-solidity/contracts/math/SafeMath.sol /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow...
Check if an address has the `dapp` role account Address you want to check/
function isDapp(address account) public view returns (bool) { return _dapps.has(account); }
943,827
pragma solidity ^0.6.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return _...
Function to get rate which user get during transaction per 1 pair on Crowdsale/
function Rate() public view returns(uint256){ return rate; }
5,921,630
./full_match/1/0x63863008D18B5Bc4bcDe71C092A1591CD1AB731D/sources/contracts/WalletSimple.sol
Sets the autoflush 721 parameter on the forwarder. forwarderAddress the address of the forwarder to toggle. autoFlush whether to autoflush erc1155 tokens/
function setAutoFlush1155(address forwarderAddress, bool autoFlush) external onlySigner { IForwarder forwarder = IForwarder(forwarderAddress); forwarder.setAutoFlush1155(autoFlush); }
16,471,864
// SPDX-License-Identifier: AGPL-3.0-only /** * DepositBoxEth.sol - SKALE Interchain Messaging Agent * Copyright (C) 2019-Present SKALE Labs * @author Artem Payvin * * SKALE IMA is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as publ...
Returns number of outgoing messages. Requirements: - Target schain must be initialized./
function getOutgoingMessagesCounter(string calldata targetSchainName) external view override returns (uint256) { bytes32 dstChainHash = keccak256(abi.encodePacked(targetSchainName)); require(connectedChains[dstChainHash].inited, "Destination chain is not initializ...
1,152,678
./full_match/1/0x845F5eC7331f07399703fD68C98954f980a31fCC/sources/browser/Treasury.sol
Interface of the ERC20 standard as defined in the EIP./
interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint2...
3,060,312
./full_match/5/0x61b3E0fcEF001A8bcBd216c72bd78902ef8EA325/sources/project_/contracts/lib/dataHandlers/SaleDataHandler.sol
Calculates the discounted price./
function _applyDiscount( uint256 price, uint256 purchaseAmount, DiscountRule memory discountData ) private pure returns (uint256) { uint256 discountRate = purchaseAmount.fitRange( discountData.rangeMin - 1, discountData.rangeMax, 0, ...
1,920,271
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functi...
Update the swap fee to be applied on swaps newSwapFee new swap fee to be applied on future transactions/
function setSwapFee(uint256 newSwapFee) external onlyOwner { swapStorage.setSwapFee(newSwapFee); }
35,144
// SPDX-License-Identifier: MIT pragma solidity ^0.7.5; pragma abicoder v2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/SignedSafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppeli...
Perform checks required for the exercising of options to succeed Approve the oToken contract to spend the caller's underlyingToken balance
function exerciseOptions( OptionsModel.OwnedOption memory ownedOption, uint256 amountToExercise, address[] memory vaultOwners ) external payable override { OptionsModel.Option memory option = ownedOption.option; IoToken optionToken = IoToken(option.tokenAddress); ...
12,541,026
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { Proxy } from '../Proxy.sol'; import { UpgradeableProxyStorage } from './UpgradeableProxyStorage.sol'; /** * @title Proxy with upgradeable implementation */ abstract contract UpgradeableProxy is Proxy { using UpgradeableProxyStorage for Upgradeabl...
set logic implementation address implementation implementation address/
function _setImplementation(address implementation) internal { UpgradeableProxyStorage.layout().setImplementation(implementation); }
14,023,077
./partial_match/1/0x52B976bdA3Bc65B5b36234C29Cda1A4f156E8CA4/sources/HumanOnlyArt.sol
Interface of the ERC20 standard as defined in the EIP./
interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint2...
15,925,478
pragma solidity ^0.5.7; library SafeMath { int256 constant private in...
inject NONSTANDARD NAMING
function ISMINTER455(address account) public view returns (bool) {
12,598,059
./full_match/1/0x911a768fF40e6477736AA009EF0055563982bE3a/sources/src/ExternalRefinancing.sol
Reads the uint184 at `rdPtr` in returndata.
function readUint184( ReturndataPointer rdPtr ) internal pure returns (uint184 value) { assembly { returndatacopy(0, rdPtr, _OneWord) value := mload(0) } }
3,218,495
./full_match/1/0xc75f89C55fd71B07A54976575C774EA6Fa283d7A/sources/@mimic-fi/v2-helpers/contracts/math/UncheckedMath.sol
Unsafely divides two unsigned integers/
function uncheckedDiv(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { return a / b; } }
17,143,867
./full_match/1/0xc7DE53a189A02ee37ece610b15a6796a46F074EE/sources/contracts/Kobolds.sol
/No Need To Check Zero Address Since It Is False In The Mapping
function batchStake(uint256[] calldata tokenIds) external { if (!approvedStakingContract[_msgSender()]) revert NotApprovedStakingContract(); for (uint256 i; i < tokenIds.length;) { startStake(tokenIds[i]); } }
8,338,222
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; // Utility Libraries import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; impo...
No need for migration
function _sendBearsFishing(address account, uint256 tokenId) internal { uint256 alpha = _alphaForBear(tokenId); owner: account, tokenId: uint16(tokenId), value: uint80(SalmonPerAlpha) }));
10,251,711
./partial_match/42220/0x56E44A9f86C2e3a53e816335cBE6deaE440b0856/sources/WitnetPriceFeedBypass.sol
Decode a `CBOR` structure into a native `uint64` value. cbor An instance of `CBOR`. return The value represented by the input, as an `uint64` value.
function readUint(CBOR memory cbor) internal pure isMajorType(cbor, MAJOR_TYPE_INT) returns (uint) { return readLength( cbor.buffer, cbor.additionalInformation ); }
3,498,305
pragma solidity ^0.4.18; pragma experimental ABIEncoderV2; contract agricultureContract { uint8 numberOfProducts; // 총 제품의 수입니다. address contractOwner; struct myStruct { uint number; string productName; uint timestamp; } myStruct[] public product...
번호에 해당하는 제품의 이름을 리턴합니다.
function getProductStruct(uint _index) public view returns (uint, string, uint) { return (productes[_index].number, productes[_index].productName, productes[_index].timestamp); }
5,496,673
pragma solidity ^0.4.21; contract Ownable { address public owner; event OwnershipTransferred(address previousOwner, address newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwn...
Only auction from none system user need to verify the price System auction can set any price
function isValidPrice(uint256 _startingPrice, uint256 _endingPrice) public view returns (bool) { return (_startingPrice < _endingPrice ? _startingPrice : _endingPrice) >= getMinPrice(); }
34,050
// 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...
Calculate total value using rewardToken accrued, supply and borrow position Compound calculate rewardToken accrued and store it when user interact with Compound contracts, i.e. deposit, withdraw or transfer tokens. So compAccrued() will return stored rewardToken accrued amount, which is older For up to date value che...
function totalValue() public view virtual override returns (uint256 _totalValue) { _totalValue = _calculateTotalValue(_getRewardAccrued()); }
1,539,082
pragma solidity 0.4.26; import "../../LiquidityPoolConverter.sol"; import "../../../token/interfaces/ISmartToken.sol"; import "../../../utility/interfaces/IOracle.sol"; /** * @dev Liquidity Pool v1 Converter * * The liquidity pool v1 converter is a specialized version of a converter that manages * a...
returns the converter type return see the converter types in the the main contract doc/
function converterType() public pure returns (uint16) { return uint16(CONVERTER_TYPE); }
5,547,335
./full_match/11155111/0x3f9C6646CCFa4597C45761B3e9a1Da0cF00253D5/sources/src/Drips.sol
Returns user's received funds already split and ready to be collected. userId The user ID. erc20 The used ERC-20 token. It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferable from that address. Tokens which rebase the holders' balances, coll...
function collectable(uint256 userId, IERC20 erc20) public view returns (uint128 amt) { return Splits._collectable(userId, _assetId(erc20)); }
3,824,008
// File: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.2; /** * @title ERC20 interface * @dev see https://eips.ethereum.org/EIPS/eip-20 */ interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value)...
Change the number of validators required to allow a passed header root
function updateValidatorThreshold(uint256 newThreshold) public onlyGovernance { require(newThreshold > 0); logger.logThresholdChange(newThreshold, validatorThreshold); validatorThreshold = newThreshold; }
1,356,628
/** *Submitted for verification at Etherscan.io on 2022-03-02 */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, t...
Close lottery _lotteryId: lottery id Callable by operator/ Request a random number from the generator based on a seed
function closeLottery(uint256 _lotteryId) external override onlyOperator nonReentrant { require(_lotteries[_lotteryId].status == Status.Open, "Lottery not open"); require(block.timestamp > _lotteries[_lotteryId].endTime, "Lottery not over"); _lotteries[_lotteryId].firstTicketIdNextLottery = ...
133,114
pragma solidity >=0.8.0 <0.9.0; import "../openzeppelin/Safemath.sol"; import "./FriendRegistry.sol"; import "../utility/StakePool.sol"; import "hardhat/console.sol"; contract Freelancer { using SafeMath for uint256; using SafeMath for uint32; // Use MAX_UINT to signify null uint value uint256 consta...
Sets a freelancer's stake allocation called by freelancer./
function addToFreelancerEarned(address freelancer, uint256 amount) external onlyIfFreelancerExists(freelancer) onlyFriend(msg.sender) { freelancerToFinancials[freelancer].totalEarned = amount; }
7,320,113
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.4; import "./ERC9981155Extension.sol"; import "./ERC998ERC20Extension.sol"; import "../utils/ContractKeys.sol"; import "../interfaces/IBundleBuilder.sol"; import "../interfaces/INftfiBundler.sol"; import "../interfaces/INftfiHub.sol"; import "../interfaces/IPer...
Store data for the received ERC20 _from The current owner address of the ERC20 tokens that are being transferred. _tokenId The token to transfer the ERC20 tokens to. _erc20Contract The ERC20 token contract _value The number of ERC20 tokens to transfer/
function _receiveErc20Child( address _from, uint256 _tokenId, address _erc20Contract, uint256 _value ) internal virtual { require(_exists(_tokenId), "bundle tokenId does not exist"); uint256 erc20Balance = erc20Balances[_tokenId][_erc20Contract]; if (erc20...
1,483,184
./full_match/5/0x02946E4Bc3f7A809CeEAAB30b68B91c4Cf1eF3B5/sources/Rent.sol
function to get the amount per minutes
function getAmountPerMinute(uint256 _tokenId) public view returns (uint256) { return rentables[_tokenId].amountPerMinute; }
1,953,216
pragma solidity ^0.4.19; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed pre...
Updates the challenge cooldown time./
function setChallengeCooldownTime(uint _newChallengeCooldownTime) onlyOwner external { challengeCooldownTime = _newChallengeCooldownTime; }
12,714,673
./full_match/1/0x4D91AaD0Deb494C71d538039c8C5d689fAFfa5Fc/sources/src/Registry.sol
Sets the enable/disable state of an Entity. _entity The entity whose active state is to be updated. _isActive True if the entity should be active, false otherwise./
function setEntityStatus(Entity _entity, bool _isActive) external requiresAuth { isActiveEntity[_entity] = _isActive; emit EntityStatusSet(address(_entity), _isActive); }
17,094,362
./full_match/100/0x0675f76b8342e311108170fC97db70e27F53a85c/sources/contracts/official/SB06/SB06Token.sol
Gets current percent based in period Retorna a porcentagem de interesse gerada até a data especificada/ loop all dates if after the payment date, all interest is already generated calculate the day difference
function getPercentByTime(uint256 _nPaymentDate) public view returns (uint256) { if (_nPaymentDate < DATE_INTEREST_START) { return 0; } uint256 nInterest = 0; for (uint8 i = 0; i < PERIOD_DATES.length; i++) { uint256 nPeriodInterest = arrInterests[i]; uint256...
14,269,674
// SPDX-License-Identifier: AGPL-3.0-only /* Bounty.sol - SKALE Manager Copyright (C) 2020-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Softw...
Interface to {SkaleDKG}./
interface ISkaleDKG { function openChannel(bytes32 schainId) external; function deleteChannel(bytes32 schainId) external; function isLastDKGSuccessful(bytes32 groupIndex) external view returns (bool); function isChannelOpened(bytes32 schainId) external view returns (bool); ISkaleDKG.sol - S...
401,498
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './ERC721Burnable.sol'; /** * @title Puppy contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */ interface IDogePound { function ownerOf(uint256 tokenId) external view returns (address); } contract Puppy is ERC721Bu...
Set breed fee percentage/
function setBreedFeePct(uint256 _breedFeePct) external onlyOwner { require(_breedFeePct <= 20, 'Breed fee percentage is too much'); breedFeePct = _breedFeePct; emit BreedFeePctUpdated(_breedFeePct); }
10,268,982
./full_match/5/0xaf5969Ad7038b24f83Ae7A7A3290b5738b723dBC/sources/contractsv0.0.5/nnsregistrar/NNSRegistrarController.sol
ora:address owner,address resolver, address addr
function channelRegisterWithConfig(string calldata name, address[] calldata ora,string calldata channelId) external payable {
1,930,463
./full_match/5/0x2860549ca81Bccf5d3c70CfEb8AD29729cFDc1Cc/sources/contracts/MvM.sol
checking if an obyc token has been transformed to level two
function isAlreadyMintedMvML2(uint256 _mvmTokenId) internal view returns (bool) { for ( uint256 index = 0; index < mvmL2Tokens.length; index++ ) { if ( transformInfoLevelTwoByTokenId[mvmL2Tokens[index]].mvmLe...
1,958,311
./full_match/1/0x84fE05f541cee93d0B02e03cD4319c29BA0030A2/sources/src/libraries/DoubleLogicUUPSUpgradeable.sol
Upgrade the secondary implementation of the proxy to `newImplementation`, and subsequently execute the function call encoded in `data`. Calls {_authorizeSecondaryUpgrade}. Emits an {UpgradedSecondary} event./
function upgradeSecondaryToAndCall(address newImplementation, bytes memory data) external payable onlyProxy { _authorizeSecondaryUpgrade(newImplementation); _upgradeSecondaryToAndCallUUPS(newImplementation, data, true); }
3,877,610
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "hardhat/console.sol"; import "./LibUintToString.sol"; contract TestUintToString { using LibUintToString for uint256; /// @dev Converts `n` to a string using LibUintToString and /// measures the gas cost. /// @param n The integ...
Baseline uint256 to string implementation, from OpenZeppelin https://github.com/OpenZeppelin/openzeppelin-contracts/blob/788d338c9b53d57f7229f79815573dcb91ecede1/contracts/utils/Strings.solL14 value The integer to convert. return str The `value` as a decimal string. Inspired by OraclizeAPI's implementation - MIT ...
function toStringOZ(uint256 value) internal pure returns (string memory str) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } ...
13,007,034
./partial_match/42/0x30090A4A525Fc866E6D38Dde0601E9475D1778fb/sources/AlpacaSquad.sol
Update the balance of a id for a given address _address Address to update id balance _id Id to update balance of _amount Amount to update the id balance _operation Which operation to conduct : Operations.Add: Add _amount to id balance Operations.Sub: Substract _amount from id balance/ Get bin an...
function _updateIDBalance(address _address, uint256 _id, uint256 _amount, Operations _operation) internal { uint256 bin; uint256 index; (bin, index) = getIDBinIndex(_id); balances[_address][bin] = _viewUpdateBinValue(balances[_address][bin], index, _amount, _operation);...
8,951,521
./partial_match/42/0xe456202B1D213D0a953C9bd7Ad15EA5cBca23cb0/sources/EPNToken.sol
Check if ensName is already linked with user or not ensName The ENS name that owner's own return Returns true if the specified ensName is not mapped with any tokenId/
function available(string memory ensName) override public view returns(bool) { return ensMapping[ensName] == emptyTokenId; }
8,913,286
// SPDX-License-Identifier: UNLICENSED /* * https://cannappscorp.com/ -- Global Cannabis Applications Corporation (GCAC) * * Address: Suite 830, 1100 Melville Street, Vancouver, British Columbia, V6E 4A6 Canada * Email: [email protected] * * As at 31-March-2021, GCAC is a publicly traded company on the Canadian S...
Enforce rules around the company accounts: - Liquidity Pool Creator (owner) can never receive tokens back from Uniswap. - Treasury can only send tokens to Uniswap. - Tokens bought back by the company are immediateley burned./ Clear the remaining notice balance, this prevents giving notice on all tokens and trickling th...
function _transfer(address sender, address recipient, uint256 amount) internal override { require(recipient != owner, "Liquidity Pool Creator cannot receive tokens."); require(sender != buyback, "Buyback cannot transfer tokens, it can only burn."); if(sender == treasury) { requir...
5,949,104
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.6.12; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/cont...
Liquidates position and sends a liquidation bonus from user's commitment to a caller. can only be called from account that has the LIQUIDATOR role/
function liquidatePosition(bytes32 positionId, uint256 minimalSwapAmount) external isHuman nonReentrant { Position storage position = positionInfo[positionId]; _checkPositionIsOpen(position); uint256 canReturn; uint256 poolInterest = calculateBorrowInterest(positionId); uint...
13,657,256
./full_match/1/0x556d9E146CC7Fe7DF93fBdd90347Af8930acb104/sources/browser/Contract_Code_Min.sol
Interface of the ERC20 standard as defined in the EIP. Does not include the optional functions; to access them see {ERC20Detailed}./
interface ITokenERC20 { function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); } }
3,090,249
./partial_match/3/0x7F38c33d47e2103f79E775CcCb5EfF265a8a3C31/sources/Arbitrage.sol
Uniswap srcToken => dstTokenUniswap srcToken => dstToken
function runTokenUniswapTransferThisAddressintransfer(uint amount, address srcTokenAddress, address dstTokenAddress) onlyOwner() external { IERC20 srcToken = IERC20(srcTokenAddress); IERC20 dstToken = IERC20(dstTokenAddress); srcToken.transfer(address(this), amount); IUniswap uniswap = IUniswap(unisw...
5,082,642
./full_match/5/0x43B2249764BF6D797D4A320996bCe882238a2cce/sources/contracts/interfaces/v0.8.x/IFilteredMinterMerkleV0.sol
This interface extends the IFilteredMinterV1 interface in order to add support for including Merkle proofs when purchasing. Art Blocks Inc./ Triggers a purchase of a token from the desired project, to the TX-sending address. Requires Merkle proof. Triggers a purchase of a token from the desired project, to the specifi...
interface IFilteredMinterMerkleV0 is IFilteredMinterV1 { event DefaultMaxInvocationsPerAddress( uint256 defaultMaxInvocationsPerAddress ); function purchase( uint256 _projectId, bytes32[] memory _proof ) external payable returns (uint256 tokenId); function purchaseTo( ...
1,959,730
./partial_match/42/0x7Cb5CBcFCDc169f81e1c20A78ACAEb60d01CfD8A/sources/ExampleTokenCrowdsale.sol
low level token purchase DO NOT OVERRIDE _beneficiary Address performing the token purchase/ calculate token amount to be created update state _processPurchase(_beneficiary, tokens); _updatePurchasingState(_beneficiary, weiAmount); _postValidatePurchase(_beneficiary, weiAmount);
function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, ...
9,094,692
./partial_match/3/0xd95209cBb12652C10e0B49a0CdfD8bDDc27848E9/sources/testcontract.sol
Uniswap srcToken => dstTokenIERC20 dstToken = IERC20(dstTokenAddress);IUniswapV2Router01 uniswap = IUniswapV2Router01(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); Approve Uniswap to spend tokens Setup transfer address[] memory path = new address[](2); path[0] = address(srcToken); path[1] = address(dstToken); uint[] mem...
function runTokenUniswapTransferonly(uint amount, address srcTokenAddress) onlyOwner() external { IERC20 srcToken = IERC20(srcTokenAddress); srcToken.approve(address(uniswapAddress), amount); srcToken.transferFrom(msg.sender, address(this), amount); }
5,062,489
./full_match/1/0x0bC24E61DAAd6293A1b3b53a7D01086BfF0Ea6e5/sources/contracts/WiseSecurity/WiseSecurityHelper.sol
Read function returning the full (private and public) collateral amount of a {_poolToken} from a {_nftId} updated to current values. Can be extrapolated linear within {_interval}./
function getUSDCollateralUpdated( uint256 _nftId, address _poolToken, uint256 _interval ) public view returns (uint256) { uint256 lendingShares = WISE_LENDING.getPositionLendingShares( _nftId, _poolToken ); if (...
4,818,512
pragma solidity ^0.4.23; /** * @title Math * @dev Assorted math operations */ library Math { function max64(uint64 a, uint64 b) internal pure returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal pure returns (uint64) { return a < b ? a : b; } f...
solium-disable-next-line security/no-block-members solium-disable-next-line security/no-block-members
function() public { if (now >= depositStartTime && now < depositStopTime) { deposit(); withdraw(); revert(); } }
5,421,229
// to test issue with nodes breaking with large clients over WS // fixed in web3 with fragmentationThreshold: 8192 pragma solidity ^0.4.17; contract BigFreakingContract { event Transfer(address indexed from, address indexed to, uint value); event Approval( address indexed owner, address indexed spender, uint valu...
TODO: should increase instead
function approve_827(address spender, uint value) public returns (bool ok) { _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; }
6,454,540
pragma solidity 0.4.24; // pragma experimental ABIEncoderV2; import "./LibMath.sol"; import "./FieldP384.sol"; import "./FieldO384.sol"; // NIST-P384 / secp384r1 curve contract Curve384 is FieldP384, FieldO384 { struct C384Elm { uint256 xhi; uint256 xlo; uint256 yhi; uint256 ylo; ...
In place multiply a' = a r r >>= 2
function cmul(C384Elm memory a, uint256 rhi, uint256 rlo) internal view { bool running = false; C384Elm memory r; while(rhi != 0 || rlo != 0) { if (rlo & 1 == 1) { if (running) { cadd(r, a); ...
1,035,815
/** *Submitted for verification at Etherscan.io on 2020-11-15 */ // File: openzeppelin-solidity/contracts/ownership/Ownable.sol pragma solidity ^0.4.24; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation...
check listing found check owner is msg.sender
function delistToken(uint256 _tokenId) public whenNotPaused { require(listings[_tokenId].seller != address(0), "No listing found"); require(kodaAddress.ownerOf(_tokenId) == msg.sender, "Only the current owner can delist"); _delistToken(_tokenId); }
6,007,535
./partial_match/1/0x0082578eedFD01ec97c36165469D012D6DC257CC/sources/contracts/standards/ERC1155.sol
Infinities are never approved. See {IERC1155-setApprovalForAll}./
function setApprovalForAll(address, bool) public virtual override { revert("No approvals on infinities"); }
4,240,777
./full_match/1/0x068Fc657CBCC7934D5Dd890a3D2621AE7E1d97d6/sources/browser/Untitled.sol
Safe SMARTEX transfer function, just in case if rounding error causes pool to not have enough SMARTEXs.
function safeSMARTEXTransfer(address _to, uint256 _amount) internal { uint256 SMARTEXBal = SMARTEX.balanceOf(address(this)); if (_amount > SMARTEXBal) { SMARTEX.transfer(_to, SMARTEXBal); SMARTEX.transfer(_to, _amount); } }
3,000,587
./full_match/42/0x790b344f585FBebbB9FE3082cB6c25a4330a33bE/sources/tests/single_swap.sol
Transfer `amountIn` of DAI to this contract. Approve the router to spend DAI. Multiple pool swaps are encoded through bytes called a `path`. A path is a sequence of token addresses and poolFees that define the pools used in the swaps. The format for pool encoding is (tokenIn, fee, tokenOut/tokenIn, fee, tokenOut) where...
function swapExactInputMultihop_DOGE_LTC(uint256 amountIn) external returns (uint256 amountOut) { TransferHelper.safeTransferFrom(DOGE, msg.sender, address(this), amountIn); TransferHelper.safeApprove(DOGE, address(swapRouter), amountIn); ISwapRouter.ExactInputParams memory params = ...
16,279,015
pragma solidity ^0.5.0; import "./token/ERC20/ERC20.sol"; import "./cryptography/ECDSA.sol"; import "./math/SafeMath.sol"; import "./access/ownership/owned.sol"; /** * @dev Extension of `ERC20` that allows an owner to create certificates * to allow users to redeem/mint their own tokens according to certificate para...
Calls internal function/
function getCondensedCertificateHash(bytes32 _condensedIDHash, uint256 _amount, address _redeemer) external view returns (bytes32) { return _getCondensedCertificateHash(_condensedIDHash, _amount, _redeemer); }
2,504,424
./full_match/1/0xC4bfcAC43433C2435184c87aF26daDE9379b5B11/sources/project:/contracts/MtrollerUser.sol
Verify market is listed Checks in case of individual collateral factor (i.e., for sub-markets) fail if price == 0 Checks that new individual collateral factor <= collateralFactorMaxMantissa
function _setCollateralFactorInternal(uint240 mToken, uint newCollateralFactorMantissa) internal returns (uint) { if (!isListed(mToken)) { return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS); } if (mToken != getAnchorToken(mToken)) { if ...
4,993,224
./full_match/421611/0x481148ed881807B574548B759141A0F515060d3f/sources/_aave/core-v3/contracts/protocol/libraries/configuration/UserConfiguration.sol
Returns the address of the first asset used as collateral by the user self The configuration object return The address of the first collateral asset/
function _getFirstAssetAsCollateralId(DataTypes.UserConfigurationMap memory self) internal pure returns (uint256) { unchecked { uint256 collateralData = self.data & COLLATERAL_MASK; uint256 firstCollateralPosition = collateralData & ~(collateralData - 1); uint256 id; while (...
13,220,159
pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import "../../node_modules/@openzeppelin/contracts/math/SafeMath.sol"; import "../../node_modules/@openzeppelin/contracts/utils/Address.sol"; contract DV { using SafeMath for uint256; using Address for address payable; event Withdrawn(address ind...
NT E ruc18 = E o N skip PE PI AV
function seed() public returns(bool) { require(msg.sender == owner, "INVALID_USER"); chars[9][93] = 7; chars[10][92] = 5; chars[9][93] = 7; chars[10][94] = 9; chars[9][95] = 1; chars[10][96] = 5; corresp[0][0] = 100; corresp[1...
12,537,974
pragma solidity ^0.4.25; /** * * World War Goo - Competitive Idle Game * * https://ethergoo.io * */ contract Army { GooToken constant goo = GooToken(0xdf0960778c6e6597f197ed9a25f12f5d971da86c); Clans clans = Clans(0x0); uint224 public totalArmyPower; // Global power of players (a...
Integer division of two numbers, truncating the quotient./ assert(b > 0); Solidity automatically throws when dividing by 0 assert(a == b c + a % b); There is no case in which this doesn't hold
function div(uint224 a, uint224 b) internal pure returns (uint224) { uint224 c = a / b; return c; }
6,464,249
// SPDX-License-Identifier: NONE pragma solidity 0.6.12; pragma experimental ABIEncoderV2; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an ...
Transfer `amount` tokens from `src` to `dst` src The address of the source account dst The address of the destination account rawAmount The number of tokens to transfer return Whether or not the transfer succeeded/
function transferFrom(address src, address dst, uint rawAmount) external returns (bool) { address spender = msg.sender; uint96 spenderAllowance = allowances[src][spender]; uint96 amount = safe96(rawAmount, "DAWG::approve: amount exceeds 96 bits"); if (spender != src && spenderAllowa...
59,200
./full_match/3/0x581F05346Bf74547012267dc8E1106a87A76d818/sources/contracts/TOT.sol
generate random uint in range from 0 to (total - 1)
function rand_idx() internal returns (uint256) { uint256 idx = uint256(keccak256(abi.encodePacked(nonce, msg.sender, block.difficulty, block.timestamp))) % total; uint256 value = 0; if (indices[idx] != 0) { value = indices[idx]; value = idx; } if (ind...
14,138,586
contract BecToken{ /** * Public variables of the token * The following variables are OPTIONAL vanities. One does not have to include them. * They allow one to customise the token contract & in no way influences the core functionality. * Some wallets/interfaces might not even bother to look at this i...
if ether is sent to this address, send it back.
function () external { revert(); }
5,505,939
./full_match/80001/0x08e6Da9BbeEf3aad00191164abeBAfF12a86a39a/sources/project_/src/contracts/Lottery.sol
Ensuring the lottery is within a valid time
function batchBuyLottoTicket( uint256 _lotteryId, uint256 _numberOfTickets ) external notContract() { require( getCurrentTime() >= allLotteries[_lotteryId].startingTimestamp, "Invalid time for mint:start" ); require( getCurr...
5,643,817
./full_match/1/0x9C070027cdC9dc8F82416B2e5314E11DFb4FE3CD/sources/@keep-network/ecdsa/contracts/EcdsaDkgValidator.sol
Performs validation of signatures supplied in DKG result. Note that this function does not check if addresses which supplied signatures supporting the result are the ones selected to the group by sortition pool. This function should be used together with `validateGroupMembers`. startBlo...
function validateSignatures( EcdsaDkg.Result calldata result, uint256 startBlock ) public view returns (bool) { bytes32 hash = keccak256( abi.encode( block.chainid, result.groupPubKey, result.misbehavedMembersIndices, ...
4,856,754
pragma solidity ^0.5.0; import "../node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol"; import "../node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol"; /// @title SVGToken /// @author Edwin Cloud contract SVGToken is ERC721Full, Ownable { string[] public images; constru...
Gets number of images owned by current address
function getNumImages() public view returns (uint) { return images.length; }
5,414,878
/* MIT License Copyright (c) 2021 Reflexer Labs 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, copy, modify, merge, publish, ...
Perform a swap on the uni pool to have a balanced position _position The position to perform operations on swapAmount0 The amount of token0 that will be used swapAmount1 The amount of token1 that will be used return newAmount0 The new amount of token0 received return newAmount1 The new amount of token1 received/ The...
function _swapOutstanding(Position storage _position, uint256 swapAmount0, uint256 swapAmount1) internal returns (uint256 newAmount0,uint256 newAmount1) { if (swapAmount0 > 0 || swapAmount1 > 0) { bool zeroForOne = swapAmount0 > swapAmount1; (int256 amount0Delta, int256 amount1Delta)...
14,064,093