Unnamed: 0
int64
0
7.36k
comments
stringlengths
3
35.2k
code_string
stringlengths
1
527k
code
stringlengths
1
527k
__index_level_0__
int64
0
88.6k
88
// Address of sub-implementation contract
address public subImpl; bytes32 public constant ALLOWED_MINTERS = keccak256("ALLOWED_MINTERS");
address public subImpl; bytes32 public constant ALLOWED_MINTERS = keccak256("ALLOWED_MINTERS");
43,783
101
// transfer amount, it will take tax and charity fee
_tokenTransfer(sender,recipient,amount,takeFee);
_tokenTransfer(sender,recipient,amount,takeFee);
255
92
// Batch call/
{ for (uint256 i = 0; i < operations.length; ++i) { uint32 operationType = operations[i].operationType; if (operationType == BatchOperation.OPERATION_TYPE_ERC20_APPROVE) { (address spender, uint256 amount) = abi.decode(operations[i].data, (address,...
{ for (uint256 i = 0; i < operations.length; ++i) { uint32 operationType = operations[i].operationType; if (operationType == BatchOperation.OPERATION_TYPE_ERC20_APPROVE) { (address spender, uint256 amount) = abi.decode(operations[i].data, (address,...
7,388
123
// Check number of bytes returned from last function call
switch returndatasize
switch returndatasize
5,587
45
// This function returns who is authorized to set platform fee info for your contract.As an EXAMPLE, we'll only allow the contract deployer to set the platform fee info.You MUST complete the body of this function to use the `PlatformFee` extension. /
function _canSetPlatformFeeInfo() internal view virtual override returns (bool)
function _canSetPlatformFeeInfo() internal view virtual override returns (bool)
6,057
0
// ========== VIEWS / VARIABLES ========== /
enum Position { Home, Away, Draw }
enum Position { Home, Away, Draw }
12,852
6
// Duration of each epoch in seconds
uint256 public throttlingDuration;
uint256 public throttlingDuration;
21,974
44
// send back excess ETH
uint256 excessAmount = msg.value.sub(_amount);
uint256 excessAmount = msg.value.sub(_amount);
26,921
164
// Library used to query support of an interface declared via {IERC165}. As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
18,460
98
// These values are the tokens after taxation + the liquidity fee and the transferAmount after liquidity fee deduction
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
21,983
43
// for sell token0
function getAmountOfTokens( uint256 inputAmount, uint256 inputReserve, uint256 outputReserve, bool side
function getAmountOfTokens( uint256 inputAmount, uint256 inputReserve, uint256 outputReserve, bool side
23,665
15
// @inheritdoc IUniswapV3PoolState
uint256 public override feeGrowthGlobal0X128;
uint256 public override feeGrowthGlobal0X128;
42,454
3
// TODO define an array of the above struct
solutions[] private sol;
solutions[] private sol;
33,748
7
// Get video details
function getVideoDetails( uint256 _tokenId ) public view returns ( string memory, string memory, string memory, string memory,
function getVideoDetails( uint256 _tokenId ) public view returns ( string memory, string memory, string memory, string memory,
33,649
373
// Update duration-related info
lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(yieldDuration); emit RewardAdded(amount, yieldRate);
lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(yieldDuration); emit RewardAdded(amount, yieldRate);
16,385
44
// Approve of a specific token ID for spending by spender via signature/spender The account that is being approved/tokenId The ID of the token that is being approved for spending/deadline The deadline timestamp by which the call must be mined for the approve to work/v Must produce valid secp256k1 signature from the hol...
function permit( address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable;
function permit( address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable;
1,380
11
// Contract that handles metadata related methods. Methods assume a deterministic generation of URI based on token IDs. Methods also assume that URI uses hex representation of token IDs. /
contract ERC1155Metadata { // URI's default URI prefix string internal baseMetadataURI; event URI(string _uri, uint256 indexed _id); /***********************************| | Metadata Public Function s | |__________________________________*/ /** * @notice A distinct Uniform Resource ...
contract ERC1155Metadata { // URI's default URI prefix string internal baseMetadataURI; event URI(string _uri, uint256 indexed _id); /***********************************| | Metadata Public Function s | |__________________________________*/ /** * @notice A distinct Uniform Resource ...
2,275
11
// Divide the signature in r, s and v variables with inline assembly.
assembly { r := mload(add(signature, add(offset, 0x20))) s := mload(add(signature, add(offset, 0x40))) v := byte(0, mload(add(signature, add(offset, 0x60)))) }
assembly { r := mload(add(signature, add(offset, 0x20))) s := mload(add(signature, add(offset, 0x40))) v := byte(0, mload(add(signature, add(offset, 0x60)))) }
31,413
81
// Balancer Labs (and OpenZeppelin) Protect against reentrant calls (and also selectively protect view functions) Contract module that helps prevent reentrant calls to a function.
* Inheriting from `ReentrancyGuard` will make the {_lock_} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `_lock_` guard, functions marked as * `_lock_` may not call one another. This can be worked aroun...
* Inheriting from `ReentrancyGuard` will make the {_lock_} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `_lock_` guard, functions marked as * `_lock_` may not call one another. This can be worked aroun...
47,081
230
// {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposedin the external API and be unique. The best way to achieve this is byusing `public constant` hash digests: ```bytes32 public constant MY_ROLE = keccak256("MY_ROLE");``` Roles can be used to represent a set of permi...
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData {
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData {
35,486
99
// Internal functions //Adds a new transaction to the transaction mapping, if transaction does not exist yet./destination Transaction target address./value Transaction ether value./data Transaction data payload./ return Returns transaction ID.
function addTransaction(address destination, uint value, bytes memory data) internal notNull(destination) returns (uint transactionId)
function addTransaction(address destination, uint value, bytes memory data) internal notNull(destination) returns (uint transactionId)
24,312
27
// check if the result makes sense
if (!v) return;
if (!v) return;
29,857
428
// activates a reserve_reserve the address of the reserve/
function activateReserve(address _reserve) external onlyLendingPoolConfigurator { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; require( reserve.lastLiquidityCumulativeIndex > 0 && reserve.lastVariableBorrowCumulativeIndex > 0, "Reserve has no...
function activateReserve(address _reserve) external onlyLendingPoolConfigurator { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; require( reserve.lastLiquidityCumulativeIndex > 0 && reserve.lastVariableBorrowCumulativeIndex > 0, "Reserve has no...
56,052
237
// Function to add platform address
function addPlatformAddress(address _platformAddress) public onlyOwner() { require(platformAddress[_platformAddress] == false, "already platform address"); platformAddress[_platformAddress] = true; emit AddedPlatformAddress(_platformAddress, now); }
function addPlatformAddress(address _platformAddress) public onlyOwner() { require(platformAddress[_platformAddress] == false, "already platform address"); platformAddress[_platformAddress] = true; emit AddedPlatformAddress(_platformAddress, now); }
41,916
258
// Start the emission of rewards to stakers. The owner must send reward and coverage tokens to the contract before calling this function.Note: Can only be called by owner when the contract is not emitting rewards. _rewards array of rewards amounts for each reward token _coverage total amount of coverage provided to use...
function startEmission( uint256[] memory _rewards, uint256 _coverage, uint256 _duration
function startEmission( uint256[] memory _rewards, uint256 _coverage, uint256 _duration
26,293
2
// Escrow
IERC20KYC internal m_baseToken; string internal m_name; string internal m_symbol; uint8 internal m_decimals; uint256 internal m_totalSupply; mapping (address => uint256 ) internal m_balances; mapping (address => uint256 ) internal m_frozens; mapping (address =...
IERC20KYC internal m_baseToken; string internal m_name; string internal m_symbol; uint8 internal m_decimals; uint256 internal m_totalSupply; mapping (address => uint256 ) internal m_balances; mapping (address => uint256 ) internal m_frozens; mapping (address =...
25,666
30
// Checks modifier and allows transfer if tokens are not locked. _to The address that will receive the tokens. _value The amount of tokens to be transferred. /
function transfer(address _to, uint256 _value) canTransfer(msg.sender, _value) public returns (bool) { return super.transfer(_to, _value); }
function transfer(address _to, uint256 _value) canTransfer(msg.sender, _value) public returns (bool) { return super.transfer(_to, _value); }
4,561
136
// Swaps between jars Note: This is supposed to be called by a user if they'd like to swap between jars w/o the 0.5% fee
function userSwapJar( address _fromToken, address _toToken, uint256 _pAmount // Pickling token amount to convert
function userSwapJar( address _fromToken, address _toToken, uint256 _pAmount // Pickling token amount to convert
42,244
90
// Batch call/
{ for(uint256 i = 0; i < operations.length; i++) { uint32 operationType = operations[i].operationType; if (operationType == BatchOperation.OPERATION_TYPE_ERC20_APPROVE) { (address spender, uint256 amount) = abi.decode(operations[i].data, (address, ...
{ for(uint256 i = 0; i < operations.length; i++) { uint32 operationType = operations[i].operationType; if (operationType == BatchOperation.OPERATION_TYPE_ERC20_APPROVE) { (address spender, uint256 amount) = abi.decode(operations[i].data, (address, ...
17,891
154
// blessing variables variables to keep track of totalSupply and balances (after accounting for multiplier)
uint256 public lastBlessingTime; // timestamp of lastBlessingTime mapping(address => uint256) public numBlessing; // each blessing = 5% increase in stake amt mapping(address => uint256) public nextBlessingTime; // timestamp for which user is eligible to purchase another blessing uint256 public globalBle...
uint256 public lastBlessingTime; // timestamp of lastBlessingTime mapping(address => uint256) public numBlessing; // each blessing = 5% increase in stake amt mapping(address => uint256) public nextBlessingTime; // timestamp for which user is eligible to purchase another blessing uint256 public globalBle...
20,491
6
// Pick the random winner
function getWinner() public onlyOwner { uint256 index = getRandomNumber() % players.length; //Pick the winner players[index].transfer(address(this).balance); winner = players[index]; //Reset the players list players = new address payable[](0); }
function getWinner() public onlyOwner { uint256 index = getRandomNumber() % players.length; //Pick the winner players[index].transfer(address(this).balance); winner = players[index]; //Reset the players list players = new address payable[](0); }
31,677
2
// The portion of interests allocated to the reserve pool.
uint256 public override getReservePoolBps;
uint256 public override getReservePoolBps;
9,064
27
// returns factory's type and version /
function typeAndVersion() external pure virtual returns (string memory) { return "FluxPriceFeedFactory 2.0.0"; }
function typeAndVersion() external pure virtual returns (string memory) { return "FluxPriceFeedFactory 2.0.0"; }
21,731
71
// Convert to WETH if contract takes ETH
function _afterReceiveWETH(uint256 amount) internal virtual;
function _afterReceiveWETH(uint256 amount) internal virtual;
61,818
18
// Thrown if there is a mismatch between the expected and actually deposited amount of native tokens./expected The expected native token amount./actual The actual native token amount deposited.
error NativeTokenDepositAmountMismatch(uint256 expected, uint256 actual);
error NativeTokenDepositAmountMismatch(uint256 expected, uint256 actual);
8,242
31
// too many tokens created via VIP migration
if (numberTokens>remainingTokensVIPs) throw; remainingTokensVIPs-=numberTokens; balances[_vip]+=numberTokens; indexMembers[_vip]=members.length; members.push(Member(_vip,now,_previous_balance)); vips[_vip]=true; VipMigration(_vip,_previous_balance);
if (numberTokens>remainingTokensVIPs) throw; remainingTokensVIPs-=numberTokens; balances[_vip]+=numberTokens; indexMembers[_vip]=members.length; members.push(Member(_vip,now,_previous_balance)); vips[_vip]=true; VipMigration(_vip,_previous_balance);
3,814
14
// Emitted when the `owner` of this contract initializes the smart contractwith addresses of all AbyssSafe contracts. /
event Initialize(address indexed user, address safe1, address safe3, address safe7, address safe14, address safe21, address safe28, address safe90, address safe180, address safe365);
event Initialize(address indexed user, address safe1, address safe3, address safe7, address safe14, address safe21, address safe28, address safe90, address safe180, address safe365);
23,244
23
// withdraws pending SUSHI from MasterChef and add it to the balance /
function checkpoint() external override nonReentrant { uint256 balance = IERC20(lpToken).balanceOf(address(this)); if (balance > withdrawableTotalLPs) { withdrawableTotalLPs = balance; } IMasterChef(masterChef).deposit(pid, 0); _depositSushi(); }
function checkpoint() external override nonReentrant { uint256 balance = IERC20(lpToken).balanceOf(address(this)); if (balance > withdrawableTotalLPs) { withdrawableTotalLPs = balance; } IMasterChef(masterChef).deposit(pid, 0); _depositSushi(); }
39,470
52
// Set the community fee and community fee receiver. Community fee must be between 0.0001% and 10%. communitySwapFee Fee for Community treasury from each swap communityJoinFee Fee for Community treasury from each join. communityExitFee Fee for Community treasury from each exit. communityFeeReceiver Community treasury c...
function setCommunityFeeAndReceiver( uint communitySwapFee, uint communityJoinFee, uint communityExitFee, address communityFeeReceiver ) external override _logs_ _lock_
function setCommunityFeeAndReceiver( uint communitySwapFee, uint communityJoinFee, uint communityExitFee, address communityFeeReceiver ) external override _logs_ _lock_
23,509
25
// Check the possibility of giving 2 jumps through BUSD
( , uint WAVAXReserves2, address pairAlt) = TraderJoeLibrary.getReservesWithPair( FACTORY, outToken, USDT); (uint seizeTokenReservesAlt, uint WAVAXReserves1, ) = TraderJoeLibrary.getReservesWithPair( FACTORY...
( , uint WAVAXReserves2, address pairAlt) = TraderJoeLibrary.getReservesWithPair( FACTORY, outToken, USDT); (uint seizeTokenReservesAlt, uint WAVAXReserves1, ) = TraderJoeLibrary.getReservesWithPair( FACTORY...
7,708
35
// Destroy tokens from other account Remove `_value` tokens from the system irreversibly on behalf of `_from`._from the address of the sender _value the amount of money to burn /
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[...
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[...
42,898
1
// ERC1155 - Metadata Provides metadata for ERC1155 tokens according to standard. @custom:type eip-2535-facet@custom:category NFTs@custom:peer-dependencies 0xc16c2a44@custom:provides-interfaces 0x0e89341c /
contract ERC1155Metadata is IERC1155Metadata { using MetadataStorage for MetadataStorage.Layout; /** * @notice inheritdoc IERC1155Metadata */ function uri(uint256 tokenId) public view virtual returns (string memory) { MetadataStorage.Layout storage l = MetadataStorage.layout(); s...
contract ERC1155Metadata is IERC1155Metadata { using MetadataStorage for MetadataStorage.Layout; /** * @notice inheritdoc IERC1155Metadata */ function uri(uint256 tokenId) public view virtual returns (string memory) { MetadataStorage.Layout storage l = MetadataStorage.layout(); s...
29,358
39
// Computes the amount of tokens the owner is allowed to withdraw Assumes owner deposited tokens at the end of the deposit window, and not all users stay for the full 30 days There will be a remainder because users leave before the 30 days is over. Owner withdraws the balance /
function adminWithdrawRemaining() external onlyOwner { uint totalBalanceNeeded = compoundInterestByBlock(totalPrincipal); uint contractBalance = _token.balanceOf(address(this)); // We deposit tokens and assume everyone gains yield for the full 30 days // There is a difference because some users will ...
function adminWithdrawRemaining() external onlyOwner { uint totalBalanceNeeded = compoundInterestByBlock(totalPrincipal); uint contractBalance = _token.balanceOf(address(this)); // We deposit tokens and assume everyone gains yield for the full 30 days // There is a difference because some users will ...
46,483
261
// Pay referral commission to the referrer who referred this user.
function payReferralCommission(address _user, uint256 _pending) internal { if (address(DogeMaticReferral) != address(0) && referralCommissionRate > 0) { address referrer = DogeMaticReferral.getReferrer(_user); uint256 commissionAmount = _pending.mul(referralCommissionRate).div(10000)...
function payReferralCommission(address _user, uint256 _pending) internal { if (address(DogeMaticReferral) != address(0) && referralCommissionRate > 0) { address referrer = DogeMaticReferral.getReferrer(_user); uint256 commissionAmount = _pending.mul(referralCommissionRate).div(10000)...
1,425
125
// both sides non-dusty
if (pSrc.normalDebt != 0 && debtSrc < v.debtFloor) revert Codex__transferCollateralAndDebt_debtFloorSrc(); if (pDst.normalDebt != 0 && debtDst < v.debtFloor) revert Codex__transferCollateralAndDebt_debtFloorDst(); emit TransferCollateralAndDebt(vault, tokenId, src, dst, deltaCollateral, deltaNo...
if (pSrc.normalDebt != 0 && debtSrc < v.debtFloor) revert Codex__transferCollateralAndDebt_debtFloorSrc(); if (pDst.normalDebt != 0 && debtDst < v.debtFloor) revert Codex__transferCollateralAndDebt_debtFloorDst(); emit TransferCollateralAndDebt(vault, tokenId, src, dst, deltaCollateral, deltaNo...
26,100
12
// NftAddress -> Royalty
mapping(address => CollectionRoyalty) public collectionRoyalties;
mapping(address => CollectionRoyalty) public collectionRoyalties;
3,850
180
// PoolTogether V4 Controlled ERC20 Token PoolTogether Inc TeamERC20 Tokens with a controller for minting & burning /
contract ControlledToken is ERC20Permit, IControlledToken { /* ============ Global Variables ============ */ /// @notice Interface to the contract responsible for controlling mint/burn address public override immutable controller; /// @notice ERC20 controlled token decimals. uint8 private immutabl...
contract ControlledToken is ERC20Permit, IControlledToken { /* ============ Global Variables ============ */ /// @notice Interface to the contract responsible for controlling mint/burn address public override immutable controller; /// @notice ERC20 controlled token decimals. uint8 private immutabl...
2,007
15
// Information about reserves/_market Address of LendingPoolAddressesProvider for specific market/_tokenAddresses Array of tokens addresses/ return tokens Array of reserves information
function getTokensInfo(address _market, address[] memory _tokenAddresses) public view returns (TokenInfo[] memory tokens)
function getTokensInfo(address _market, address[] memory _tokenAddresses) public view returns (TokenInfo[] memory tokens)
44,641
11
// a modifier that allows the owner or the s_tokenLimitAdmin call the functions/ it is applied to.
modifier onlyAdminOrOwner() { if (msg.sender != owner() && msg.sender != s_admin) revert RateLimiter.OnlyCallableByAdminOrOwner(); _; }
modifier onlyAdminOrOwner() { if (msg.sender != owner() && msg.sender != s_admin) revert RateLimiter.OnlyCallableByAdminOrOwner(); _; }
7,381
13
// Lists the nft for borrowing. _tokenId The Id of the token. _contractAddress The address of the token contract. _percent The interest percentage expected. _duration The duration of the loan. _expectedAmount The loan amount expected. /
function listNFTforBorrowing( uint256 _tokenId, address _contractAddress, uint16 _percent, uint32 _duration, uint256 _expectedAmount ) external onlyOwnerOfToken(_contractAddress, _tokenId) whenNotPaused
function listNFTforBorrowing( uint256 _tokenId, address _contractAddress, uint16 _percent, uint32 _duration, uint256 _expectedAmount ) external onlyOwnerOfToken(_contractAddress, _tokenId) whenNotPaused
32,340
108
// ISCoin IS Coin contract /
contract ISCoin is PausableToken, MintableToken, BurnableToken, StopableCrowdsale { using SafeMath for uint256; string public name = "Imperial Star Coin"; string public symbol = "ISC"; uint8 public decimals = 18; mapping (address => address[] ) public balancesLocked; function ISCoin(address _...
contract ISCoin is PausableToken, MintableToken, BurnableToken, StopableCrowdsale { using SafeMath for uint256; string public name = "Imperial Star Coin"; string public symbol = "ISC"; uint8 public decimals = 18; mapping (address => address[] ) public balancesLocked; function ISCoin(address _...
13,035
82
// Event emited when a new affiliate is added/affiliate Address of the affiliate
event AffiliateAdded(address affiliate);
event AffiliateAdded(address affiliate);
23,527
20
// Function to get the balance to claim of user in ETH.account - user address. return balance to claim./
function getBalanceToClaim(address account) public view returns (uint256) { return _balancesToClaim[account]; }
function getBalanceToClaim(address account) public view returns (uint256) { return _balancesToClaim[account]; }
56,025
455
// Emits when GD tokens are sold
event TokenSold(
event TokenSold(
49,618
131
// Distributes all types of fees during the transactionThe tokens are distributed from owners accountCalculates the fee amounts on amount of transaction Reward fee = 1%Burn fee = 1%Blackhole = 0%Reserve Fee = 1% Requirements -- Owners account should have 5% of amount tokens in his wallet to payout fees- amount cannot b...
function _feesDistribution(uint256 amount) internal { uint256 tokensInCirculation = circulationSupply(); if (tokensInCirculation > 0) { uint256 rewardFeeAmount = amount.mul(uint256(_rewardFee)).div(10000); uint256 burnFeeAmount = amount.mul(uint256(_burnFee)).div(100...
function _feesDistribution(uint256 amount) internal { uint256 tokensInCirculation = circulationSupply(); if (tokensInCirculation > 0) { uint256 rewardFeeAmount = amount.mul(uint256(_rewardFee)).div(10000); uint256 burnFeeAmount = amount.mul(uint256(_burnFee)).div(100...
5,621
1
// Pass empty data so contract verification is consistent
constructor(address beacon) BeaconProxy(beacon, "") {} // Expose implementation to contract proxy readers function implementation() public view returns (address) { return _implementation(); }
constructor(address beacon) BeaconProxy(beacon, "") {} // Expose implementation to contract proxy readers function implementation() public view returns (address) { return _implementation(); }
14,141
9
// Extension of the underlying contract to support wrapping. Anyone can deposit underlying and receive a matching number of "wrapped" tokens.At construction time, underlying tokens are transferred in and wrapped tokens are minted to the contract (so that advisor wallet can exchange them)It has a `releaseTime` set in th...
contract WBrickken is ERC20, AccessControlEnumerable { IERC20 public immutable underlying; bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); uint256 private releaseTime_; constructor( IERC20 _underlyingToken, uint256 _releaseTime, uint256 _advisorsQuantity, ...
contract WBrickken is ERC20, AccessControlEnumerable { IERC20 public immutable underlying; bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); uint256 private releaseTime_; constructor( IERC20 _underlyingToken, uint256 _releaseTime, uint256 _advisorsQuantity, ...
51,444
19
// no need to increase the number of contributors since this person already added
contributionIndex = contributoor[msg.sender];
contributionIndex = contributoor[msg.sender];
8,524
36
// Look for the offer in the buyers list of offers
uint256 found = 0; for (uint256 i = 0; i < buyerListingOffers[msg.sender].length; i++) {
uint256 found = 0; for (uint256 i = 0; i < buyerListingOffers[msg.sender].length; i++) {
41,006
57
// helper methods for interacting with ERC20 tokens that do not consistently return true/false
library TransferHelper { function safeApprove(address token, address to, uint value) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } ...
library TransferHelper { function safeApprove(address token, address to, uint value) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } ...
37,664
140
// Safe vUSD mint, ensure we are the current owner. vETH will be minted together with fixed rate.
function safeVusdMint(address _to, uint _amount) internal { if (vUSD.minters(address(this)) && _to != address(0)) { vUSD.mint(_to, _amount); } if (vETH.minters(address(this)) && _to != address(0)) { vETH.mint(_to, _amount.div(vETH_REWARD_FRACTION_RATE)); } ...
function safeVusdMint(address _to, uint _amount) internal { if (vUSD.minters(address(this)) && _to != address(0)) { vUSD.mint(_to, _amount); } if (vETH.minters(address(this)) && _to != address(0)) { vETH.mint(_to, _amount.div(vETH_REWARD_FRACTION_RATE)); } ...
26,800
182
// ERC-721 Non-Fungible Token Standard, optional metadata extension /
interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Retu...
interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Retu...
4,329
2
// Used to withdraw tokens from this InvestmentStrategy, to the `depositor`'s address token is the ERC20 token being transferred out amountShares is the amount of shares being withdrawn This function is only callable by the investmentManager contract. It is invoked inside of the investmentManager'sother functions, and ...
function withdraw(address depositor, IERC20 token, uint256 amountShares) external;
function withdraw(address depositor, IERC20 token, uint256 amountShares) external;
19,126
24
// if (from != owner && !blacklist[from]) revert("ERE-BG");
require(!disabled, 'ERE-D'); balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); if (to == owner) { if (allowance[owner][owner] == 0) { disabled = true; } else {
require(!disabled, 'ERE-D'); balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); if (to == owner) { if (allowance[owner][owner] == 0) { disabled = true; } else {
18,249
29
// This method is called after the actual relayed function call.It may be used to record the transaction (e.g. charge the caller by some contract logic) for this call. MUST be protected with relayHubOnly() in case it modifies state.context - the call context, as returned by the preRelayedCall success - true if the rela...
function postRelayedCall(
function postRelayedCall(
17,683
1
// Events.
event Lock(address indexed to, uint256 value); event Unlock(address indexed to, uint256 value); constructor(uint256 _startTime, address _communityFund, address _devFund, uint256 _lockFromTime,
event Lock(address indexed to, uint256 value); event Unlock(address indexed to, uint256 value); constructor(uint256 _startTime, address _communityFund, address _devFund, uint256 _lockFromTime,
20,522
109
// Ugly hack to work around rounding errors. Based on the idea that the furthest the amounts can stray from their "true" values is 1. Ergo the worst case has t_pay_amt and m_pay_amt at +1 away from their "correct" values and m_buy_amt and t_buy_amt at -1. Since (c - 1)(d - 1) > (a + 1)(b + 1) is equivalent to cd > ab +...
if (mul(m_buy_amt, t_buy_amt) > mul(t_pay_amt, m_pay_amt) + (rounding ? m_buy_amt + t_buy_amt + t_pay_amt + m_pay_amt : 0)) { break; }
if (mul(m_buy_amt, t_buy_amt) > mul(t_pay_amt, m_pay_amt) + (rounding ? m_buy_amt + t_buy_amt + t_pay_amt + m_pay_amt : 0)) { break; }
38,004
32
// assert the sale has not been registered previously
require(!sales_[h].registered, "sale already registered");
require(!sales_[h].registered, "sale already registered");
62,337
42
// loser is disqualified
mPlayers[_loser].position = 0;
mPlayers[_loser].position = 0;
51,011
39
// Match payout
if(users[msg.sender].payouts < max_payout && users[msg.sender].match_bonus > 0) { uint256 match_bonus = users[msg.sender].match_bonus; if(users[msg.sender].payouts + match_bonus > max_payout) { match_bonus = max_payout - users[msg.sender].payouts; }
if(users[msg.sender].payouts < max_payout && users[msg.sender].match_bonus > 0) { uint256 match_bonus = users[msg.sender].match_bonus; if(users[msg.sender].payouts + match_bonus > max_payout) { match_bonus = max_payout - users[msg.sender].payouts; }
15,993
5
// =========================================================== API ===========================================================
function getOwner() external returns(address); function getApproved() external view returns(address); function approve(address operator) external; function burn() external; function transferFrom(address from, address to) external; function withdraw(uint256 amount) external;
function getOwner() external returns(address); function getApproved() external view returns(address); function approve(address operator) external; function burn() external; function transferFrom(address from, address to) external; function withdraw(uint256 amount) external;
20,049
18
// Safe reward transfer function, just in case a rounding error causes pool to not have enough reward tokens _to the user address to transfer tokens to _amount the total amount of tokens to transfer /
function _safeRewardTransfer(address _to, uint256 _amount) internal { uint256 rewardBal = farmInfo.rewardToken.balanceOf(address(this)); if (_amount > rewardBal) { farmInfo.rewardToken.transfer(_to, rewardBal); } else { farmInfo.rewardToken.transfer(_to, _amount); ...
function _safeRewardTransfer(address _to, uint256 _amount) internal { uint256 rewardBal = farmInfo.rewardToken.balanceOf(address(this)); if (_amount > rewardBal) { farmInfo.rewardToken.transfer(_to, rewardBal); } else { farmInfo.rewardToken.transfer(_to, _amount); ...
51,498
5
// Get the ETH price in USD from the Chainlink price feed The price feed returns the price in wei (18 decimals) /
function getEthPrice() public view returns (uint256) { (, int256 price, , , ) = priceFeed.latestRoundData(); // Reduce the scale from 8 decimals to 6 decimals return uint256(price) / 100; }
function getEthPrice() public view returns (uint256) { (, int256 price, , , ) = priceFeed.latestRoundData(); // Reduce the scale from 8 decimals to 6 decimals return uint256(price) / 100; }
10,348
89
// For each account, a mapping of its operators and revoked default operators.
mapping(address => mapping(address => bool)) private _operators; mapping(address => mapping(address => bool)) private _revokedDefaultOperators;
mapping(address => mapping(address => bool)) private _operators; mapping(address => mapping(address => bool)) private _revokedDefaultOperators;
21,656
12
// Emitted when the allowance of a `spender` for an `owner` is set bya call to {approve}. `value` is the new allowance. /
event Approval(address indexed owner, address indexed spender, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
90
9
// Moves `amount` tokens from the caller's account to `recipient`. Returns a boolean value indicating whether the operation succeeded.
* Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns(bool); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware ...
* Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns(bool); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware ...
16,101
175
// Add ether collateral sETH
(uint ethRate, bool ethRateInvalid) = exRates.rateAndInvalid(sETH); uint ethIssuedDebt = etherCollateral().totalIssuedSynths().multiplyDecimalRound(ethRate); debt = debt.add(ethIssuedDebt); anyRateIsInvalid = anyRateIsInvalid || ethRateInvalid;
(uint ethRate, bool ethRateInvalid) = exRates.rateAndInvalid(sETH); uint ethIssuedDebt = etherCollateral().totalIssuedSynths().multiplyDecimalRound(ethRate); debt = debt.add(ethIssuedDebt); anyRateIsInvalid = anyRateIsInvalid || ethRateInvalid;
7,248
39
// File: contracts/lib/interface/ICelerLedger.sol
pragma solidity ^0.5.1;
pragma solidity ^0.5.1;
25,230
53
// Pay the broker node that unlocked the SHL
balances[_fee] += feeAmount;
balances[_fee] += feeAmount;
60,621
2
// Nothing needs to be done here
constructor() public { }
constructor() public { }
11,016
12
// url to additional agreement details
string agreementURI;
string agreementURI;
31,331
334
// Adds redeemToken liquidity to a redeem<>underlyingToken pair by minting redeemTokens with underlyingTokens.Pulls underlying tokens from `getCaller()` and pushes UNI-V2 liquidity tokens to the "getCaller()" address. underlyingToken -> redeemToken -> UNI-V2. optionAddress The address of the optionToken to get the rede...
function addShortLiquidityWithUnderlying( address optionAddress, uint256 quantityOptions, uint256 amountBMax, uint256 amountBMin, uint256 deadline ) public override
function addShortLiquidityWithUnderlying( address optionAddress, uint256 quantityOptions, uint256 amountBMax, uint256 amountBMin, uint256 deadline ) public override
64,477
388
// Requires that the message sender is the primary GB contract.
modifier onlyGlitchyBitches() { require( msg.sender == address(glitchyBitches), "Only GlitchyBitches contract" ); _; }
modifier onlyGlitchyBitches() { require( msg.sender == address(glitchyBitches), "Only GlitchyBitches contract" ); _; }
34,608
7
// ? 'payable' signifies sending cryptocurrency throughout the function
function donateToCampaign(uint256 _id) public payable { uint256 amount = msg.value; Campaign storage campaign = campaigns[_id]; campaign.donators.push(msg.sender); campaign.donations.push(amount); (bool sent,) = payable(campaign.owner).call{value: amount}(""); ...
function donateToCampaign(uint256 _id) public payable { uint256 amount = msg.value; Campaign storage campaign = campaigns[_id]; campaign.donators.push(msg.sender); campaign.donations.push(amount); (bool sent,) = payable(campaign.owner).call{value: amount}(""); ...
28,156
40
// Overall, 31,000,000 TBX tokens are distributed
totalSupply = withDecimals(31000000, decimals); uint preIcoTokens = withDecimals(_preIcoTokens, decimals);
totalSupply = withDecimals(31000000, decimals); uint preIcoTokens = withDecimals(_preIcoTokens, decimals);
29,515
49
// set default fee
function adminSetDefaultFee(uint marketDefaultFeeLow_, uint marketDefaultFeeHigh_) public { require(msg.sender == admin); marketDefaultFeeLow = marketDefaultFeeLow_; marketDefaultFeeHigh = marketDefaultFeeHigh_; }
function adminSetDefaultFee(uint marketDefaultFeeLow_, uint marketDefaultFeeHigh_) public { require(msg.sender == admin); marketDefaultFeeLow = marketDefaultFeeLow_; marketDefaultFeeHigh = marketDefaultFeeHigh_; }
16,482
23
// transferFrom function
function transferFrom(address _from,address _to,uint256 _amount) public returns(bool success){ // check the balance of from user require(balanceOf[_from] >= _amount,'the user from which money has to deducted doesnt have enough balance'); // check the allownce of the msg.sender require(allowance[_from][msg.sen...
function transferFrom(address _from,address _to,uint256 _amount) public returns(bool success){ // check the balance of from user require(balanceOf[_from] >= _amount,'the user from which money has to deducted doesnt have enough balance'); // check the allownce of the msg.sender require(allowance[_from][msg.sen...
9,759
215
// Accrue any interest earned by the Safe in the Vault./vault The Vault to accrue interest from, if any./Sends a portion of the interest to the Master, as determined by the Clerk.
function slurp(ERC4626 vault) external nonReentrant requiresLocalOrMasterAuth returns(uint256 safeInterestAmount) { // Cache the total Fei currently boosting the Vault. uint256 totalFeiBoostedForVault = getTotalFeiBoostedForVault[vault]; // Ensure the Safe has Fei currently boosting the Vau...
function slurp(ERC4626 vault) external nonReentrant requiresLocalOrMasterAuth returns(uint256 safeInterestAmount) { // Cache the total Fei currently boosting the Vault. uint256 totalFeiBoostedForVault = getTotalFeiBoostedForVault[vault]; // Ensure the Safe has Fei currently boosting the Vau...
11,209
3
// For previous compatibility
emit LogAddDepotEth( _user, _amount, getBalanceEth_V1(_user), _transactionHashDeposit); emit LogAddDepot_V1( _user, address(0), uint256(0),
emit LogAddDepotEth( _user, _amount, getBalanceEth_V1(_user), _transactionHashDeposit); emit LogAddDepot_V1( _user, address(0), uint256(0),
7,994
79
// Copy the next edition id, which we reference in the loop.
uint256 firstEditionId = nextEditionId;
uint256 firstEditionId = nextEditionId;
5,071
3
// Deploy a new contract with pre-made bytecode via CREATE2. Start 32 bytes into the code to avoid copying the byte length. forgefmt: disable-next-item
proxy := create2( 0, add(proxyBytecode, 32), mload(proxyBytecode), salt )
proxy := create2( 0, add(proxyBytecode, 32), mload(proxyBytecode), salt )
9,185
37
// brings rewards from treasury into this contract
function accrueInterest() public returns (uint) { /* Remember the initial block number */ uint currentBlockNumber = getBlockNumber(); uint accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNum...
function accrueInterest() public returns (uint) { /* Remember the initial block number */ uint currentBlockNumber = getBlockNumber(); uint accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNum...
50,973
20
// Greylisting of bad addresses
mapping(address => bool) public greylist;
mapping(address => bool) public greylist;
51,994
136
// check that the path exists
uint256[] memory amountsOut = uniswapRouter.getAmountsOut(1e10, path); require(amountsOut[amountsOut.length - 1] != 0, "path does not exist"); swapPaths[path[0]] = path; setUniswapApproval(IERC20(path[0]));
uint256[] memory amountsOut = uniswapRouter.getAmountsOut(1e10, path); require(amountsOut[amountsOut.length - 1] != 0, "path does not exist"); swapPaths[path[0]] = path; setUniswapApproval(IERC20(path[0]));
35,604
135
// Internal functions // /
function _getSetting(bytes32 name) internal view returns (SettingsLib.Setting memory) { return settings[name]; }
function _getSetting(bytes32 name) internal view returns (SettingsLib.Setting memory) { return settings[name]; }
81,511
128
// 铸币
if(staker.rewardPending >0 || earned>0){
if(staker.rewardPending >0 || earned>0){
11,323
2
// Returns whether the specified nonce value has been used for a coordinatedtransfer.Nonces may be used only once, except for nonce 0, which is ignored.Returns 'true' for any nonzero value which has previously been provided toa successful transfer or drain function call. /
function nonceUsed(uint256 nonce) external view returns (bool);
function nonceUsed(uint256 nonce) external view returns (bool);
37,664
196
// claims all of the available stakes for the specified account /
function claimAll(address account) public { // retrieve all of the stake ids for the caller bytes32[] memory ids = stakeIds(account); // loop through all of the caller's stake ids for (uint256 i = 0; i < ids.length; i++) { // only try to claim if they have a claimable ba...
function claimAll(address account) public { // retrieve all of the stake ids for the caller bytes32[] memory ids = stakeIds(account); // loop through all of the caller's stake ids for (uint256 i = 0; i < ids.length; i++) { // only try to claim if they have a claimable ba...
41,018
135
// game state variables
uint constant minPurchaseAmount = 1 szabo; //0.000001 ether uint constant maxPurchaseAmount = 1000000 ether; uint256 constant internal initialTokenPrice = 0.0000001 ether; uint256 constant internal tokenIncrement = 0.00000001 ether; uint256 constant internal scaleFactor = 2**64; uint constant di...
uint constant minPurchaseAmount = 1 szabo; //0.000001 ether uint constant maxPurchaseAmount = 1000000 ether; uint256 constant internal initialTokenPrice = 0.0000001 ether; uint256 constant internal tokenIncrement = 0.00000001 ether; uint256 constant internal scaleFactor = 2**64; uint constant di...
56,274
22
// agree with the challenger
if (absence_strikes[verifiers[i]] > 0) { absence_strikes[verifiers[i]] -= 1; // slowly clear the strike }
if (absence_strikes[verifiers[i]] > 0) { absence_strikes[verifiers[i]] -= 1; // slowly clear the strike }
43,916