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
0
// Mint 100 tokens to msg.sender Similar to how 1 dollar = 100 cents 1 token = 1(10decimals)
_mint(msg.sender, 100 * 10**uint(decimals()));
_mint(msg.sender, 100 * 10**uint(decimals()));
336
23
// Returns true if given address is on the list of approved withdrawers/addressToCheck the address to check/ return true if address is withdrawer
function isWithdrawer(address addressToCheck) external view returns(bool) { return hasRole(WITHDRAW_ROLE, addressToCheck); }
function isWithdrawer(address addressToCheck) external view returns(bool) { return hasRole(WITHDRAW_ROLE, addressToCheck); }
31,194
83
// Calculate the new tree mass
uint256 _treeMass = _mass(_seed);
uint256 _treeMass = _mass(_seed);
25,435
55
// Sets the next call's msg.sender to be the input address, and the tx.origin to be the second input
function prank(address, address) external;
function prank(address, address) external;
28,370
296
// An event emitted when collateral is removed from a vault
event CollateralRemoved( address indexed _owner, uint256 indexed _id, uint256 _amount );
event CollateralRemoved( address indexed _owner, uint256 indexed _id, uint256 _amount );
32,249
29
// Trader can call this function to withdraw collateral (eth) from the contract.Eth is withdrawable up to the extent of: sv + cv > lv(1+im)amt The amount of Eth to withdraw. return Whether the withdraw was successful./
function traderWithdrawEth(uint amt) public payable
function traderWithdrawEth(uint amt) public payable
13,695
35
// change leven token address
function setTokenAddress(address tokenAddress) public { lvnAddress = tokenAddress; lvnContract = IERC20Leven(lvnAddress); }
function setTokenAddress(address tokenAddress) public { lvnAddress = tokenAddress; lvnContract = IERC20Leven(lvnAddress); }
83,578
138
// Requirements
require(_tokenIds.length == _amounts.length, "Inconsistent array length between args"); require(_to != address(0), "Invalid to address");
require(_tokenIds.length == _amounts.length, "Inconsistent array length between args"); require(_to != address(0), "Invalid to address");
29,796
6
// Move the funds to the TerminalV1.
_beneficiary.transfer(_amount);
_beneficiary.transfer(_amount);
40,493
8
// showing the vote
function getVote (address _address) public view rightStatus(WorkflowStatus.VotesTallied) returns(uint){ require(whiteList[_address].isRegistered, "This person is not on the whitelist "); return whiteList[_address].votedProposalId; }
function getVote (address _address) public view rightStatus(WorkflowStatus.VotesTallied) returns(uint){ require(whiteList[_address].isRegistered, "This person is not on the whitelist "); return whiteList[_address].votedProposalId; }
28,223
23
// Deactivate the perpetual for the trader. Active means the trader's account is not empty in the perpetual. Empty means cash and position are zero. Can only called by a liquidity pool.traderThe address of the trader. perpetualIndexThe index of the perpetual in the liquidity pool.returnTrue if the deactivation is succe...
function deactivatePerpetualFor(address trader, uint256 perpetualIndex) external onlyLiquidityPool returns (bool)
function deactivatePerpetualFor(address trader, uint256 perpetualIndex) external onlyLiquidityPool returns (bool)
9,933
22
// Get Bounty Tokens
function getBountyTokens() onlyOwner{ require(bountyTokens>0); payment(bountyAddress,bountyTokens); bountyTokens=0; }
function getBountyTokens() onlyOwner{ require(bountyTokens>0); payment(bountyAddress,bountyTokens); bountyTokens=0; }
20,524
6
// Produce a block/_index the index of the instance of pos you want to interact with/this function can only be called by a worker, user never calls it directly
function produceBlock(uint256 _index) public returns (bool) { PoSCtx storage pos = instance[_index]; require( pos.workerAuth.isAuthorized(msg.sender, address(this)), "msg.sender is not authorized to make this call" ); address user = pos.workerAuth.getOwner(m...
function produceBlock(uint256 _index) public returns (bool) { PoSCtx storage pos = instance[_index]; require( pos.workerAuth.isAuthorized(msg.sender, address(this)), "msg.sender is not authorized to make this call" ); address user = pos.workerAuth.getOwner(m...
29,091
41
// Used to decode 5 values from one uint256 value encoded by `encodeBillingMetadata` function.
function decodeBillingMetadata (uint256 encodedData) public pure returns ( uint256 value, uint256 lastChargeAt, uint256 merchantId, uint256 period
function decodeBillingMetadata (uint256 encodedData) public pure returns ( uint256 value, uint256 lastChargeAt, uint256 merchantId, uint256 period
38,291
17
// Ending block number of the distribution. /
uint256 public distributionEndBlock;
uint256 public distributionEndBlock;
69,658
172
// Change the creator address for given tokens_to Address of the new creator_idsArray of Token IDs to change creator/
function setCreator( address _to, uint256[] memory _ids
function setCreator( address _to, uint256[] memory _ids
45,602
120
// calcPoolOutGivenSingleIn pAo = poolAmountOut /\ tAi = tokenAmountIn// wI \\\ \ wI \wI = tokenWeightIn| tAi | 1 - || 1 - --|sF || + tBi \--\ tW = totalWeight pAo=||\\ \\tW / | ^ tW |pS - pStBi = tokenBalanceIn\\------------------------------------- // pS = poolSupply\\tBi //sF = swapFee\//
{ // Charge the trading fee for the proportion of tokenAi /// which is implicitly traded to the other pool tokens. // That proportion is (1- weightTokenIn) // tokenAiAfterFee = tAi * (1 - (1-weightTi) * poolFee); uint normalizedWeight = bdiv(tokenWeightIn, totalWeight); ...
{ // Charge the trading fee for the proportion of tokenAi /// which is implicitly traded to the other pool tokens. // That proportion is (1- weightTokenIn) // tokenAiAfterFee = tAi * (1 - (1-weightTi) * poolFee); uint normalizedWeight = bdiv(tokenWeightIn, totalWeight); ...
36,966
0
// USING Registry / Returned by .getRegistry()
interface IRegistry { function owner() external view returns (address _addr); function addressOf(bytes32 _name) external view returns (address _addr); }
interface IRegistry { function owner() external view returns (address _addr); function addressOf(bytes32 _name) external view returns (address _addr); }
17,763
174
// freezes token amount specified for given address. _userAddress The address for which to update frozen tokens _amount Amount of Tokens to be frozenThis function can only be called by a wallet set as agent of the tokenemits a `TokensFrozen` event/
function freezePartialTokens(address _userAddress, uint256 _amount) external;
function freezePartialTokens(address _userAddress, uint256 _amount) external;
19,725
21
// Generates `_amount` reputation that are assigned to `_owner`/_user The address that will be assigned the new reputation/_amount The quantity of reputation generated/ return True if the reputation are generated correctly
function mint(address _user, uint256 _amount) public onlyOwner returns (bool) { uint256 curTotalSupply = totalSupply(); require(curTotalSupply + _amount >= curTotalSupply, "total supply overflow"); // Check for overflow uint256 previousBalanceTo = balanceOf(_user); require(previousBa...
function mint(address _user, uint256 _amount) public onlyOwner returns (bool) { uint256 curTotalSupply = totalSupply(); require(curTotalSupply + _amount >= curTotalSupply, "total supply overflow"); // Check for overflow uint256 previousBalanceTo = balanceOf(_user); require(previousBa...
6,214
1
// the mapping of vault number to vault contract
mapping(uint256 => address) public vaults;
mapping(uint256 => address) public vaults;
63,010
5
// Given the total amount invested by the Vault, we want to findout how many of this investor's deposits were actuallyused. Use findUpperBound on the prefixSum to find the pointwhere total deposits were accepted. For example, if $2000 wasdeposited by all investors and $1000 was invested, then someposition in the prefix...
function getInvestedAndExcess(Investor storage investor, uint256 invested) internal view returns (uint256 userInvested, uint256 excess)
function getInvestedAndExcess(Investor storage investor, uint256 invested) internal view returns (uint256 userInvested, uint256 excess)
23,290
17
// ONLY EOA AND ALLOWED CALLER: Iterate a rebalance when in TWAP. TWAP cooldown period must have elapsed. If price moves advantageously, then exit without rebalancingand clear TWAP state. This function can only be called when below incentivized leverage ratio and in TWAP state._exchangeName the exchange used for tradin...
function iterateRebalance(string memory _exchangeName) external onlyEOA onlyAllowedCaller(msg.sender) { LeverageInfo memory leverageInfo = _getAndValidateLeveragedInfo( execution.slippageTolerance, exchangeSettings[_exchangeName].twapMaxTradeSize, _exchangeName );...
function iterateRebalance(string memory _exchangeName) external onlyEOA onlyAllowedCaller(msg.sender) { LeverageInfo memory leverageInfo = _getAndValidateLeveragedInfo( execution.slippageTolerance, exchangeSettings[_exchangeName].twapMaxTradeSize, _exchangeName );...
51,613
2
// metadata renderer contract for each token
mapping(uint256 => address) public metadataRendererContract;
mapping(uint256 => address) public metadataRendererContract;
6,315
32
// Add the taylor series for log(1 + z), where z = x - 1
z = y = x - FIXED_1; w = (y * y) / FIXED_1; r += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02 r += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000; ...
z = y = x - FIXED_1; w = (y * y) / FIXED_1; r += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02 r += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000; ...
25,734
0
// fulfillRandomness handles the VRF response. /
function fulfillRandomness(bytes32 requestId, uint256 randomness) internal virtual;
function fulfillRandomness(bytes32 requestId, uint256 randomness) internal virtual;
24,298
6
// Returns the address that signed a hashed message (`hash`) with`signature` or error string. This address can then be used for verification purposes. The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:this function rejects them by requiring the `s` value to be in the lowerhalf order, and the `v` v...
* be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available s...
* be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available s...
13,975
338
// check max number of bach finish pve
require(length <= 20); uint256 blockNumber = block.number; uint256 index;
require(length <= 20); uint256 blockNumber = block.number; uint256 index;
24,129
46
// Swap tokenA<>tokenB, ETH<>ERC20 or ERC20<>ETH on 1Inch.function swap(IERC20 fromToken,IERC20 destToken,uint256 amount,uint256 minReturn,uint256[] memory distribution,uint256 flagsSee contants in IOneSplit.sol) public returns (uint256);
function execute( address[] calldata path, uint256[] calldata amounts, address[] calldata addresses, string[] calldata data
function execute( address[] calldata path, uint256[] calldata amounts, address[] calldata addresses, string[] calldata data
37,089
167
// Returns upgrade freeze-time start. return freeze-time start. /
function getPendingVersionTimestamp() public view returns (uint) { return pendingVersionTimestamp; }
function getPendingVersionTimestamp() public view returns (uint) { return pendingVersionTimestamp; }
7,779
39
// ERC721 token receiver interface Interface for any contract that wants to support safeTransfersfrom ERC721 asset contracts. /
interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is r...
interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is r...
106
61
// Last, use the fallback override
if (result.length == 0) { if (_fallbackMockType == MockType.Revert) { revert(_fallbackRevertMessage); }
if (result.length == 0) { if (_fallbackMockType == MockType.Revert) { revert(_fallbackRevertMessage); }
18,656
45
// Changes the exclusive role holder of `roleId` to `newMember`. Reverts if the caller is not a member of the managing role for `roleId` or if `roleId` is not aninitialized, exclusive role. /
function resetMember(uint roleId, address newMember) public onlyExclusive(roleId) onlyRoleManager(roleId) { roles[roleId].exclusiveRoleMembership.resetMember(newMember); }
function resetMember(uint roleId, address newMember) public onlyExclusive(roleId) onlyRoleManager(roleId) { roles[roleId].exclusiveRoleMembership.resetMember(newMember); }
13,664
113
// Do not put selected to-be-dissolved expired working group back to pending node pool.
dissolveWorkingGroup(grpToDissolve.groupId, false, HEAD_A); expiredWorkingGroupIds[idx] = expiredWorkingGroupIds[expiredWorkingGroupIds.length - 1]; expiredWorkingGroupIds.length--;
dissolveWorkingGroup(grpToDissolve.groupId, false, HEAD_A); expiredWorkingGroupIds[idx] = expiredWorkingGroupIds[expiredWorkingGroupIds.length - 1]; expiredWorkingGroupIds.length--;
38,804
36
// Delegate votes. delegatee The address to delegate votes to./
function delegate(address delegatee) external payable { COMPInterface compToken = COMPInterface(getCompTokenAddress()); require(compToken.delegates(address(this)) != delegatee, "Already delegated to same delegatee."); compToken.delegate(delegatee); emit LogDelegate(delegatee); ...
function delegate(address delegatee) external payable { COMPInterface compToken = COMPInterface(getCompTokenAddress()); require(compToken.delegates(address(this)) != delegatee, "Already delegated to same delegatee."); compToken.delegate(delegatee); emit LogDelegate(delegatee); ...
60,694
7
// Update staking status
isStaking[msg.sender] = true; hasStaked[msg.sender] = true;
isStaking[msg.sender] = true; hasStaked[msg.sender] = true;
39,462
90
// Updates parameters of the position to the current ones asset The address of the main collateral token user The owner of a position /
function update(address asset, address user) public hasVaultAccess notLiquidating(asset, user) { // calculate fee using stored stability fee uint debtWithFee = getTotalDebt(asset, user); tokenDebts[asset] = tokenDebts[asset].sub(debts[asset][user]).add(debtWithFee); debts[asset][use...
function update(address asset, address user) public hasVaultAccess notLiquidating(asset, user) { // calculate fee using stored stability fee uint debtWithFee = getTotalDebt(asset, user); tokenDebts[asset] = tokenDebts[asset].sub(debts[asset][user]).add(debtWithFee); debts[asset][use...
22,982
43
// receive approval to spend some tokens.used for teleport and protection. sender the sender address value the transferred value tokenContract the address of the token contract callData the data passed by the token contract/
function receiveApproval(address sender, uint256 value, address tokenContract, bytes callData) public { uint32 id; uint256 price; if (msg.sender == address(teleportToken)) { id = toUint32(callData); price = teleportPrice * (characters[id].characterType/numDragonTypes);//double price in case of balloon r...
function receiveApproval(address sender, uint256 value, address tokenContract, bytes callData) public { uint32 id; uint256 price; if (msg.sender == address(teleportToken)) { id = toUint32(callData); price = teleportPrice * (characters[id].characterType/numDragonTypes);//double price in case of balloon r...
49,298
31
// ------------------------------------------------ Functions Setters Public ------------------------------------------------
function _remove() private
function _remove() private
28,901
206
// Retrieve the number of votes for `account` at the end of `blockNumber`. Requirements: - `blockNumber` must have been already mined /
function getPastVotes(address account, uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_checkpoints[account], blockNumber); }
function getPastVotes(address account, uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_checkpoints[account], blockNumber); }
4,367
76
// Emits a {Transfer} event with `to` set to the zero address. Requirements - `account` cannot be the zero address.- `account` must have at least `amount` tokens. /
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _tot...
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _tot...
1,431
60
// Update staker's fees w.r.t the gage fee, gage rewards and liquidity rewards and buy ETRNL with the fee Fees and rewards are both calculated in terms of ETRNL
{ uint256 totalFee = eternalRewards + _swapTokensForETRNL(eternalFee, rAsset); eternalStorage.setUint(entity, reserveStakedBalances, eternalStorage.getUint(entity, reserveStakedBalances) - convertToReserve(totalFee)); }
{ uint256 totalFee = eternalRewards + _swapTokensForETRNL(eternalFee, rAsset); eternalStorage.setUint(entity, reserveStakedBalances, eternalStorage.getUint(entity, reserveStakedBalances) - convertToReserve(totalFee)); }
32,055
78
// Emitted when `account` burns Volts
event BurnVolts(address indexed account, uint256 voltsBurned);
event BurnVolts(address indexed account, uint256 voltsBurned);
23,857
139
// returns the revision of the implementation contract/
function getRevision() internal virtual override pure returns (uint256) { return REVISION; }
function getRevision() internal virtual override pure returns (uint256) { return REVISION; }
49,232
6
// Overrides for Admin enumerable.
function grantAdmin(address to) public override onlyOwner { super.grantAdmin(to); }
function grantAdmin(address to) public override onlyOwner { super.grantAdmin(to); }
18,756
10
// Checks if sender has been added to authorised list. Throw if not authorised to sign.
if (doc.authorisedSignerList.length != 0) { require( isAuthorised(signerDocHash), 'Provided address not authorised to sign the document.' ); }
if (doc.authorisedSignerList.length != 0) { require( isAuthorised(signerDocHash), 'Provided address not authorised to sign the document.' ); }
50,496
86
// Initial Token is Ether
tokenAddresses.push(address(ETH_TOKEN_ADDRESS));
tokenAddresses.push(address(ETH_TOKEN_ADDRESS));
97
1,316
// _borrowAddress underlying token address/_user users address
function getMaxBorrow(address _borrowAddress, address _user) public view returns (uint256) { address lendingPoolAddress = ILendingPoolAddressesProvider(AAVE_LENDING_POOL_ADDRESSES).getLendingPool(); address priceOracleAddress = ILendingPoolAddressesProvider(AAVE_LENDING_POOL_ADDRESSES).getPriceOracle(); (,,,,ui...
function getMaxBorrow(address _borrowAddress, address _user) public view returns (uint256) { address lendingPoolAddress = ILendingPoolAddressesProvider(AAVE_LENDING_POOL_ADDRESSES).getLendingPool(); address priceOracleAddress = ILendingPoolAddressesProvider(AAVE_LENDING_POOL_ADDRESSES).getPriceOracle(); (,,,,ui...
26,181
68
// Constructs a position ID from a collateral token and an outcome collection. These IDs are used as the ERC-1155 ID for this contract./collateralToken Collateral token which backs the position./collectionId ID of the outcome collection associated with this position.
function getPositionId(IERC20 collateralToken, bytes32 collectionId) internal pure returns (uint) { return uint(keccak256(abi.encodePacked(collateralToken, collectionId))); }
function getPositionId(IERC20 collateralToken, bytes32 collectionId) internal pure returns (uint) { return uint(keccak256(abi.encodePacked(collateralToken, collectionId))); }
45,869
114
// Close a deed and refund a specified fraction of the bid value /
function destroyDeed() public { require(!active); // Instead of selfdestruct(owner), invoke owner fallback function to allow // owner to log an event if desired; but owner should also be aware that // its fallback function can also be invoked by setBalance if (owner.send(thi...
function destroyDeed() public { require(!active); // Instead of selfdestruct(owner), invoke owner fallback function to allow // owner to log an event if desired; but owner should also be aware that // its fallback function can also be invoked by setBalance if (owner.send(thi...
34,682
177
// functions callable by HolyValor investment proxies pool would transfer funds to HolyValor (returns actual amount, could be less than asked)
function borrowToInvest(uint256 amount) external returns(uint256);
function borrowToInvest(uint256 amount) external returns(uint256);
56,455
206
// Manual trigger for unpausing contract in case of a black swan event that caused the iToken price to not return to the normal level
bool public manualPlay = false; bool private _notLocalEntered;
bool public manualPlay = false; bool private _notLocalEntered;
37,603
54
// If we need to update price tiers/priceTier the tier index from the array/price the new price to set
function updatePriceTier(uint8 priceTier, uint price) public onlyOwner { tableStakesOptions[priceTier] = price; }
function updatePriceTier(uint8 priceTier, uint price) public onlyOwner { tableStakesOptions[priceTier] = price; }
32,983
13
// Function modifier to require caller to be contract deployer /
modifier onlyOwner() { require(isOwner(msg.sender), "!Owner"); _; }
modifier onlyOwner() { require(isOwner(msg.sender), "!Owner"); _; }
15,412
71
// Remove. Will not affect current deposits, since rewards are calculated at deposit time.
function removeStakeMultiplier(uint256 _amount) public onlyOwner { require(stakeMultipliers[_amount].registered, "removeStakeMultiplier: nothing to remove"); delete(stakeMultipliers[_amount]); }
function removeStakeMultiplier(uint256 _amount) public onlyOwner { require(stakeMultipliers[_amount].registered, "removeStakeMultiplier: nothing to remove"); delete(stakeMultipliers[_amount]); }
26,207
3
// Publius Bean is the ERC-20 Stablecoin for Beanstalk./
contract Bean is Ownable, ERC20Burnable { using SafeMath for uint256; constructor() ERC20("Bean", "BEAN") { } function mint(address account, uint256 amount) public onlyOwner returns (bool) { _mint(account, amount); return true; } function transferFrom(address sender, add...
contract Bean is Ownable, ERC20Burnable { using SafeMath for uint256; constructor() ERC20("Bean", "BEAN") { } function mint(address account, uint256 amount) public onlyOwner returns (bool) { _mint(account, amount); return true; } function transferFrom(address sender, add...
83,616
9
// Gets the integration for the module with the passed in hash. Validates that the address is not empty /
function getAndValidateAdapterWithHash(bytes32 _integrationHash) internal view returns(address) { address adapter = controller.getIntegrationRegistry().getIntegrationAdapterWithHash( address(this), _integrationHash ); require(adapter != address(0), "Must be valid ad...
function getAndValidateAdapterWithHash(bytes32 _integrationHash) internal view returns(address) { address adapter = controller.getIntegrationRegistry().getIntegrationAdapterWithHash( address(this), _integrationHash ); require(adapter != address(0), "Must be valid ad...
17,173
26
// Returns the current beacon. /
function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; }
function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; }
4,861
43
// Payment is accepted in the following scenarios:(1) Auction already created - can accept ETH or Specified Token --------> Cannot bid with ETH & an ERC20 Token together in any circumstance<------(2) Auction not created - only ETH accepted (cannot early bid with an ERC20 Token(3) Cannot make a zero bid (no ETH or Token...
function _isPaymentAccepted( address _nftContractAddress, uint256 _tokenId, address _bidERC20Token, uint128 _tokenAmount
function _isPaymentAccepted( address _nftContractAddress, uint256 _tokenId, address _bidERC20Token, uint128 _tokenAmount
23,643
13
// This function checks if you can change your bond back to money /
{ return bond.issueTime > 0 && // a bond should be issued bond.owner != 0 && // it should should have an owner bond.redeemTime == 0 && // it should not be already redeemed bond.sellingPrice ==...
{ return bond.issueTime > 0 && // a bond should be issued bond.owner != 0 && // it should should have an owner bond.redeemTime == 0 && // it should not be already redeemed bond.sellingPrice ==...
32,005
18
// 2- Effects
ended = true; emit AuctionEnded(highestBidder, highestBid);
ended = true; emit AuctionEnded(highestBidder, highestBid);
47,319
32
// Burns a specific amount of tokens from the target address and decrements allowance from address The address which you want to send tokens from _value uint256 The amount of token to be burned /
function burnFrom(address from, uint256 _value) public returns (bool success) { require(balances[from] >= _value); require(_value <= allowed[from][msg.sender]); balances[from] = balances[from].sub(_value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(_value); _to...
function burnFrom(address from, uint256 _value) public returns (bool success) { require(balances[from] >= _value); require(_value <= allowed[from][msg.sender]); balances[from] = balances[from].sub(_value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(_value); _to...
46,007
25
// User must be able to vote on the poll so we don't waste gas submitting invalid transactions
require( DAO.getACL().canVoteOnPoll(address(DAO), ProposalId.wrap(request.proposalId), request.voter) );
require( DAO.getACL().canVoteOnPoll(address(DAO), ProposalId.wrap(request.proposalId), request.voter) );
25,137
73
// Enables a client to recover his funds on chain tokenAddress address of the token corresponding to the recovery /
function recoverOnChainFundsOnly(address tokenAddress) public returns (bool)
function recoverOnChainFundsOnly(address tokenAddress) public returns (bool)
2,375
13
// required that dcaSwap has enough ether
require(dai.balanceOf(address(this)) >= daiAmount);
require(dai.balanceOf(address(this)) >= daiAmount);
10,081
45
// return Returns current liquidity providers reward address. /
function liquidityProvidersRewardAddress() public view returns (address) { AddressParam memory param = liquidityProvidersRewardAddressParam; return _paramUpdateDelayElapsed(param.timestamp) ? param.newValue : param.oldValue; }
function liquidityProvidersRewardAddress() public view returns (address) { AddressParam memory param = liquidityProvidersRewardAddressParam; return _paramUpdateDelayElapsed(param.timestamp) ? param.newValue : param.oldValue; }
48,588
9
// Returns the downcasted int128 from int256, reverting onoverflow (when the input is less than smallest int128 orgreater than largest int128). Counterpart to Solidity's `int128` operator. Requirements: - input must fit into 128 bits _Available since v3.1._ /
function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); }
function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); }
1,067
117
// ============ Functions ============ // ============ Constructor ============ /
constructor(string memory _name, string memory _symbol) VoteToken(_name, _symbol) { tokenTransfersEnabled = true; }
constructor(string memory _name, string memory _symbol) VoteToken(_name, _symbol) { tokenTransfersEnabled = true; }
34,031
259
// set the address of our randomizer contract _randomizer the address /
function setRandomizer(address _randomizer) external onlyOwner { randomizer = IRandomizer(_randomizer); }
function setRandomizer(address _randomizer) external onlyOwner { randomizer = IRandomizer(_randomizer); }
46,878
193
// Need additional work in here to seperate funds between all the different funding wallets
function withdrawPresale() public onlyOwner { require(presaleBal > 0, "Insufficent balance"); _widthdraw(walletA, ((presaleBal * 1500) / 10000)); _widthdraw(walletB, ((presaleBal * 125) / 10000)); _widthdraw(walletC, ((presaleBal * 125) / 10000)); _widthdraw(walletD, ((presal...
function withdrawPresale() public onlyOwner { require(presaleBal > 0, "Insufficent balance"); _widthdraw(walletA, ((presaleBal * 1500) / 10000)); _widthdraw(walletB, ((presaleBal * 125) / 10000)); _widthdraw(walletC, ((presaleBal * 125) / 10000)); _widthdraw(walletD, ((presal...
2,996
121
// (c) Copyright 2020 IC SG PTE LTD, all rights reserved. Contract: Investa AdminNo part of this source code may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, printing, photocopying,recording, or otherwise, without the prior written permission of IC SG PTE LTD.Bin...
interface ITransferable { function transfer(address recipient, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); }
interface ITransferable { function transfer(address recipient, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); }
14,567
195
// Safely mints `tokenId` and transfers it to `to`. Requirements:- `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ''); }
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ''); }
39,234
29
// Set staking conditions.
function _setStakingCondition( uint256 _timeUnit, uint256 _numerator, uint256 _denominator
function _setStakingCondition( uint256 _timeUnit, uint256 _numerator, uint256 _denominator
25,028
5
// See {ERC721Enumerable-totalSupply}.
uint256 public totalSupply;
uint256 public totalSupply;
6,523
40
// SMILE Token Alex Papageorgiou - <alex.ppg@protonmail.com> The Smile Token token & airdrop contract which conforms to EIP-20 & partially ERC-223 /
contract SMILE { /** * Constant EIP-20 / ERC-223 variables & getters */ string constant public name = "Smile Token"; string constant public symbol = "SMILE"; uint256 constant public decimals = 18; uint256 constant public totalSupply = 100000000 * (10 ** decimals); /** * A varia...
contract SMILE { /** * Constant EIP-20 / ERC-223 variables & getters */ string constant public name = "Smile Token"; string constant public symbol = "SMILE"; uint256 constant public decimals = 18; uint256 constant public totalSupply = 100000000 * (10 ** decimals); /** * A varia...
37,676
42
// Emitted when the administration has been transferred. previousAdmin Address of the previous admin. newAdmin Address of the new admin. /
event AdminChanged(address previousAdmin, address newAdmin);
event AdminChanged(address previousAdmin, address newAdmin);
11,377
1
// Disable normal token transfer
function _transfer(address from, address to, uint256) internal view override { bool _mint = (from == minter) && (to != address(0)); bool _burn = (_msgSender() == minter) && (from != address(0)) && (to == address(0)); if (!_mint && !_burn) { revert Unsupported(); } }
function _transfer(address from, address to, uint256) internal view override { bool _mint = (from == minter) && (to != address(0)); bool _burn = (_msgSender() == minter) && (from != address(0)) && (to == address(0)); if (!_mint && !_burn) { revert Unsupported(); } }
25,124
5
// Mapping which stores all calls
mapping ( address => Call[] ) public callDatabase;
mapping ( address => Call[] ) public callDatabase;
9,258
60
// solhint-enable code-complexity // Revoke votes on all proposals of sender in the referendum stage.return Whether or not all votes of an account were successfully revoked. /
function revokeVotes() external nonReentrant returns (bool) { address account = getAccounts().voteSignerToAccount(msg.sender); Voter storage voter = voters[account]; for ( uint256 dequeueIndex = 0; dequeueIndex < dequeued.length; dequeueIndex = dequeueIndex.add(1) ) { VoteRecor...
function revokeVotes() external nonReentrant returns (bool) { address account = getAccounts().voteSignerToAccount(msg.sender); Voter storage voter = voters[account]; for ( uint256 dequeueIndex = 0; dequeueIndex < dequeued.length; dequeueIndex = dequeueIndex.add(1) ) { VoteRecor...
29,872
4
// This generates a public event for frozen (blacklisting) accounts
event FrozenAccounts(address target, bool frozen);
event FrozenAccounts(address target, bool frozen);
12,620
36
// EIP712 A library that provides EIP712 helper functions /
library EIP712 { // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)") bytes32 public constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; /** * @notice Make EIP712 domain separator * @param name...
library EIP712 { // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)") bytes32 public constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; /** * @notice Make EIP712 domain separator * @param name...
17,779
10
// https:docs.synthetix.io/contracts/source/libraries/addresssetlib/
library AddressSetLib { struct AddressSet { address[] elements; mapping(address => uint) indices; } function contains(AddressSet storage set, address candidate) internal view returns (bool) { if (set.elements.length == 0) { return false; } uint index = se...
library AddressSetLib { struct AddressSet { address[] elements; mapping(address => uint) indices; } function contains(AddressSet storage set, address candidate) internal view returns (bool) { if (set.elements.length == 0) { return false; } uint index = se...
49,193
1
// in the event currentSqrtP == targetSqrtP because of tick movements, return eg. swapped up tick where specified price limit is on an initialised tick then swapping down tick will cause next tick to be the same as the current tick
if (currentSqrtP == targetSqrtP) return (0, 0, 0, currentSqrtP); usedAmount = calcReachAmount( liquidity, currentSqrtP, targetSqrtP, feeInFeeUnits, isExactInput, isToken0 );
if (currentSqrtP == targetSqrtP) return (0, 0, 0, currentSqrtP); usedAmount = calcReachAmount( liquidity, currentSqrtP, targetSqrtP, feeInFeeUnits, isExactInput, isToken0 );
27,309
102
// split the contract balance into halves
uint256 half = amount.div(2); uint256 otherHalf = amount.sub(half);
uint256 half = amount.div(2); uint256 otherHalf = amount.sub(half);
5,266
19
// onlyOwner modifer will first check the condition inside itandif true, withdraw function will be executed
function withdraw() payable onlyOwner public { // If you are using version eight (v0.8) of chainlink aggregator interface, // you will need to change the code below to // payable(msg.sender).transfer(address(this).balance); msg.sender.transfer(address(this).balance); //iterate ...
function withdraw() payable onlyOwner public { // If you are using version eight (v0.8) of chainlink aggregator interface, // you will need to change the code below to // payable(msg.sender).transfer(address(this).balance); msg.sender.transfer(address(this).balance); //iterate ...
4,416
108
// With `magnitude`, we can properly distribute dividends even if the amount of received ether is small. For more discussion about choosing the value of `magnitude`,see https:github.com/ethereum/EIPs/issues/1726issuecomment-472352728
uint256 constant internal magnitude = 2**128; uint256 internal magnifiedDividendPerShare;
uint256 constant internal magnitude = 2**128; uint256 internal magnifiedDividendPerShare;
4,046
35
// default is the primary color as the background
string memory background = _svgRect( 0, 0, 100, 100, palette.hasWhiteBackground ? _DEFAULT_BOTTOM_COLOR : palette.p1 ); if (palette.bgStyle == BackgroundStyle.rainbow) { uint256 stripeCount = 6;
string memory background = _svgRect( 0, 0, 100, 100, palette.hasWhiteBackground ? _DEFAULT_BOTTOM_COLOR : palette.p1 ); if (palette.bgStyle == BackgroundStyle.rainbow) { uint256 stripeCount = 6;
16,458
47
// Base accrual rates are set a per-day rate so we change them to per-minute to allow for more frequent claiming
uint64 private _baseRateDivisor = 1440;
uint64 private _baseRateDivisor = 1440;
44,244
4
// INTERNAL FUNCTIONS /
function swapFromTokens(uint amount, address to) internal { uint balance = balanceOf(address(this)); address[] memory path = new address[](2); path[0] = address(this); path[1] = WETH; if (amount > _swapThreshold) amount = _swapThreshold; if (amount > balance) amount ...
function swapFromTokens(uint amount, address to) internal { uint balance = balanceOf(address(this)); address[] memory path = new address[](2); path[0] = address(this); path[1] = WETH; if (amount > _swapThreshold) amount = _swapThreshold; if (amount > balance) amount ...
21,070
38
// Returns if the `operator` is allowed to manage all of the assets of `owner`. See {setApprovalForAll}. /
function isApprovedForAll(address owner, address operator)
function isApprovedForAll(address owner, address operator)
5,142
5
// 关卡号
uint256 public no;
uint256 public no;
22,101
47
// // import "erc20/erc20.sol"; // import "ds-math/math.sol"; /
contract DSTokenBase is ERC20, DSMath { uint256 _supply; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _approvals; function DSTokenBase(uint supply) public { _balances[msg.sender] = sup...
contract DSTokenBase is ERC20, DSMath { uint256 _supply; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _approvals; function DSTokenBase(uint supply) public { _balances[msg.sender] = sup...
36,140
110
// event for buy tokens request loggingbeneficiary address for which buy tokens is requestedtokens number of tokensweiAmount number of ethers investednonce request recorded at this particular nonce/
event ContributionRegistered( address beneficiary,
event ContributionRegistered( address beneficiary,
39,698
27
// ================== Set Functions End =======================
5,344
81
// Catch typos, if decimals are pre-added
if (_stakeCreateCost > 1_000) revert AmountOutOfRange(); stakeCreateCost = _stakeCreateCost * (10**18) / (10**numOfDecimals); emit StakeCreateCostUpdated(_stakeCreateCost);
if (_stakeCreateCost > 1_000) revert AmountOutOfRange(); stakeCreateCost = _stakeCreateCost * (10**18) / (10**numOfDecimals); emit StakeCreateCostUpdated(_stakeCreateCost);
13,569
11
// Emitted when `catId` resell is canceled.
event CancelResell(uint256 indexed catId);
event CancelResell(uint256 indexed catId);
23,560
3
// Add a IERC4671Enumerable contract address to the caller's record/token Address of the IERC4671Enumerable contract to add
function add(address token) external;
function add(address token) external;
16,376
170
// Owner can allow a crowdsale contract to mint new tokens./
function setMintAgent(address addr, bool state) public onlyOwner canMint { mintAgents[addr] = state; emit MintingAgentChanged(addr, state); }
function setMintAgent(address addr, bool state) public onlyOwner canMint { mintAgents[addr] = state; emit MintingAgentChanged(addr, state); }
110
55
// Only Deployer can execute
modifier onlyDeployer() { require(msg.sender == DEPLOYER, "DeployerErr"); _; }
modifier onlyDeployer() { require(msg.sender == DEPLOYER, "DeployerErr"); _; }
24,142
4
// Storage / Owner metadata
address public owner = msg.sender;
address public owner = msg.sender;
2,289