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
268
// ========== SETTERS ========== / These functions are useful for setting parameters of the strategy that may need to be adjusted. Set optimal token to sell harvested funds for depositing to Curve. Default is EURS, but can be set to EURT or agEUR as needed by strategist or governance.
function setOptimal(uint256 _optimal) external onlyAuthorized { if (_optimal == 0) { middleStable = address(usdc); targetStable = address(ageur); optimal = 0; } else if (_optimal == 1) { middleStable = address(usdt); targetStable = address(...
function setOptimal(uint256 _optimal) external onlyAuthorized { if (_optimal == 0) { middleStable = address(usdc); targetStable = address(ageur); optimal = 0; } else if (_optimal == 1) { middleStable = address(usdt); targetStable = address(...
37,514
14
// Avoid balanceOf to not compute an unnecesary require
uint256 landsSize; uint256 balance = ownedTokensCount[_owner]; for (uint256 i; i < balance; i++) { uint256 estateId = ownedTokens[_owner][i]; landsSize += estateLandIds[estateId].length; }
uint256 landsSize; uint256 balance = ownedTokensCount[_owner]; for (uint256 i; i < balance; i++) { uint256 estateId = ownedTokens[_owner][i]; landsSize += estateLandIds[estateId].length; }
36,584
14
// Check if the mintpass has been used to mint an ERC-1155
function checkIfRedeemed(address _contractAddress, uint256 _tokenId) view public returns(bool) { return usedToken[_contractAddress][_tokenId]; }
function checkIfRedeemed(address _contractAddress, uint256 _tokenId) view public returns(bool) { return usedToken[_contractAddress][_tokenId]; }
36,530
165
// Compound tokens to Arc pool.
function compound(uint256 _pid) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require( address(pool.lpToken) == address(arc), "compound: not able to compound" ); updatePool(_pid); ...
function compound(uint256 _pid) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require( address(pool.lpToken) == address(arc), "compound: not able to compound" ); updatePool(_pid); ...
53,656
2
// Comp version of the {getPastVotes} accessor, with `uint96` return type. /
function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96) { return SafeCast.toUint96(getPastVotes(account, blockNumber)); }
function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96) { return SafeCast.toUint96(getPastVotes(account, blockNumber)); }
21,742
156
// reward tokens distributed based on bonus percentage and amount staked
earned = earned + (pool.bonusPercentageNumerator * _periodStaked) / pool.bonusPercentageDenominator;
earned = earned + (pool.bonusPercentageNumerator * _periodStaked) / pool.bonusPercentageDenominator;
17,185
191
// Returns the base URI set via {_setBaseURI}. This will be automatically added as a prefix in {tokenURI} to each token's URI, or to the token ID if no specific URI is set for that token ID./
function baseURI() public view returns (string memory) { return _baseURI; }
function baseURI() public view returns (string memory) { return _baseURI; }
2,591
16
// Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant function which does not alter the state of the contract and therefore does not require any gas or a signature to be executed._addressOfToken The address of the token being queried.return true if the token being queried has ...
function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; }
function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; }
85,643
14
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
uint256 public totalAllocPoint = 0;
15,473
100
// Player has won a two gold pyramid prize!
profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 133), 100); category = 18; emit TwoGoldPyramids(target, spin.blockn);
profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 133), 100); category = 18; emit TwoGoldPyramids(target, spin.blockn);
69,998
55
// From this point forward, _sharesPerFragment is taken as the source of truth. We recalculate a new _totalSupply to be in agreement with the _sharesPerFragment conversion rate. This means our applied supplyDelta can deviate from the requested supplyDelta, but this deviation is guaranteed to be < (_totalSupply^2)/(TOTA...
emit LogRebase(epoch, _totalSupply); return _totalSupply;
emit LogRebase(epoch, _totalSupply); return _totalSupply;
32,742
31
// withdrawing Ether
if (address(token) == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { if (address(this).balance > 0){ tokenBalance = address(this).balance; payable(msg.sender).transfer(address(this).balance); }
if (address(token) == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { if (address(this).balance > 0){ tokenBalance = address(this).balance; payable(msg.sender).transfer(address(this).balance); }
16,011
87
// so that we can easily check that we don't add duplicates to our array
mapping (address => bool) public tokensTraded;
mapping (address => bool) public tokensTraded;
11,921
35
// This contract should not have funds at the end of each tx (except for stkAAVE), this method is just for leftovers/Emergency method/_token address of the token to transfer/value amount of `_token` to transfer/_to receiver address
function transferToken( address _token, uint256 value, address _to ) external onlyOwner nonReentrant { IERC20Detailed(_token).safeTransfer(_to, value); }
function transferToken( address _token, uint256 value, address _to ) external onlyOwner nonReentrant { IERC20Detailed(_token).safeTransfer(_to, value); }
14,919
252
// Add additional assets. Duplicates of trackedAssets are ignored.
bool[] memory indexesToAdd = new bool[](_additionalAssets.length); uint256 additionalItemsCount; for (uint256 i; i < _additionalAssets.length; i++) { if (!trackedAssetsToPayout.contains(_additionalAssets[i])) { indexesToAdd[i] = true; additionalItemsCo...
bool[] memory indexesToAdd = new bool[](_additionalAssets.length); uint256 additionalItemsCount; for (uint256 i; i < _additionalAssets.length; i++) { if (!trackedAssetsToPayout.contains(_additionalAssets[i])) { indexesToAdd[i] = true; additionalItemsCo...
18,589
32
// Revert with an error if supplied signed feeBps is greater than the maximum specified, or less than the minimum. /
error InvalidSignedFeeBps(uint256 got, uint256 minimumOrMaximum);
error InvalidSignedFeeBps(uint256 got, uint256 minimumOrMaximum);
12,718
8
// Also stakes in vault, no fees
require(uint(msg.value) > MIN_AMT, "INPUT_TOO_LOW"); (address vaultWant,) = IVaultChef(vaultChefAddress).poolInfo(vaultPid); require(vaultWant == _to, "Wrong wantAddress for vault pid");
require(uint(msg.value) > MIN_AMT, "INPUT_TOO_LOW"); (address vaultWant,) = IVaultChef(vaultChefAddress).poolInfo(vaultPid); require(vaultWant == _to, "Wrong wantAddress for vault pid");
18,753
62
// Removes a liquidity gauge from gauge controller. Only governance can remove a plus token. _gauge The liquidity gauge to remove from gauge controller. /
function removeGauge(address _gauge) external onlyGovernance { require(_gauge != address(0x0), "gauge not set"); require(gaugeData[_gauge].isSupported, "gauge not exist"); uint256 _gaugeSize = gauges.length; uint256 _gaugeIndex = _gaugeSize; for (uint256 i = 0; i < _gaugeSiz...
function removeGauge(address _gauge) external onlyGovernance { require(_gauge != address(0x0), "gauge not set"); require(gaugeData[_gauge].isSupported, "gauge not exist"); uint256 _gaugeSize = gauges.length; uint256 _gaugeIndex = _gaugeSize; for (uint256 i = 0; i < _gaugeSiz...
16,636
69
// If the delegator wants to reduce withdrawal value, add them to delegator list of the pool if it hasn't already done
_addPoolDelegator(poolId, staker);
_addPoolDelegator(poolId, staker);
22,645
287
// sdMAVOft/StakeDAO/A token that represents the Token deposited by a user into the Depositor/Minting & Burning was modified to be used by the operator
contract sdMAV is OFT { error ONLY_OPERATOR(); address public operator; constructor(string memory _name, string memory _symbol, address _lzEndpoint) OFT(_name, _symbol, _lzEndpoint) { operator = msg.sender; }
contract sdMAV is OFT { error ONLY_OPERATOR(); address public operator; constructor(string memory _name, string memory _symbol, address _lzEndpoint) OFT(_name, _symbol, _lzEndpoint) { operator = msg.sender; }
2,817
66
// Ensure new sanitizer is not null.
if (newSanitizer == address(0)) { revert SanitizerCannotBeNullAddress(); }
if (newSanitizer == address(0)) { revert SanitizerCannotBeNullAddress(); }
19,330
38
// - Function that allows foreground contract to spend (burn) the tokens. _from - Account to withdraw from. _value - Number of tokens to withdraw.return - A boolean that indicates if the operation was successful. /
function spend(address _from, uint256 _value) public returns (bool) { require(_value > 0); if (balances[_from] < _value || allowed[_from][msg.sender] < _value) { return false; }
function spend(address _from, uint256 _value) public returns (bool) { require(_value > 0); if (balances[_from] < _value || allowed[_from][msg.sender] < _value) { return false; }
41,278
7
// _amountForPoints amount of ETH to boost earnings of {loyalty, tier} points/_snapshotEthAmount exact balance that the user has in the merkle snapshot/_points EAP points that the user has in the merkle snapshot/_merkleProof array of hashes forming the merkle proof for the user
function wrapEthForEap( uint256 _amount, uint256 _amountForPoints, uint256 _snapshotEthAmount, uint256 _points, bytes32[] calldata _merkleProof ) external payable whenNotPaused returns (uint256) { if (_points == 0 || msg.value < _snapshotEthAmount || msg.value > _...
function wrapEthForEap( uint256 _amount, uint256 _amountForPoints, uint256 _snapshotEthAmount, uint256 _points, bytes32[] calldata _merkleProof ) external payable whenNotPaused returns (uint256) { if (_points == 0 || msg.value < _snapshotEthAmount || msg.value > _...
27,413
67
// Staking/Manages stake and unstake requests by users, keeps track of the total amount of ETH controlled by the/ protocol, and initiates new validators.
contract Staking is Initializable, AccessControlEnumerableUpgradeable, IStaking, StakingEvents, ProtocolEvents { // Errors. error DoesNotReceiveETH(); error InvalidConfiguration(); error MaximumValidatorDepositExceeded(); error MaximumMETHSupplyExceeded(); error MinimumStakeBoundNotSatisfied(); ...
contract Staking is Initializable, AccessControlEnumerableUpgradeable, IStaking, StakingEvents, ProtocolEvents { // Errors. error DoesNotReceiveETH(); error InvalidConfiguration(); error MaximumValidatorDepositExceeded(); error MaximumMETHSupplyExceeded(); error MinimumStakeBoundNotSatisfied(); ...
32,762
89
// If currentPeriod > anchorPeriod:Set anchors[asset] = (currentPeriod, price)The new anchor is if we're in a new period or we had a pending anchor, then we become the new anchor
if (localVars.currentPeriod > localVars.anchorPeriod) { anchors[asset] = Anchor({period : localVars.currentPeriod, priceMantissa : localVars.price.mantissa});
if (localVars.currentPeriod > localVars.anchorPeriod) { anchors[asset] = Anchor({period : localVars.currentPeriod, priceMantissa : localVars.price.mantissa});
33,962
1
// Overallocate memory
nstr = new string(MAX_UINT256_STRING_LENGTH); uint256 k = MAX_UINT256_STRING_LENGTH;
nstr = new string(MAX_UINT256_STRING_LENGTH); uint256 k = MAX_UINT256_STRING_LENGTH;
22,797
66
// Depool Debot v1 (with debot interfaces).
contract DepoolDebot is Debot, Upgradable, Transferable { address m_depool; uint128 m_balance; address m_wallet; uint128 m_walletBalance; uint128 m_stake; uint128 m_instantStake; /* Storage */ struct DepoolInfo { bool poolClosed; uint64 minStake; uint...
contract DepoolDebot is Debot, Upgradable, Transferable { address m_depool; uint128 m_balance; address m_wallet; uint128 m_walletBalance; uint128 m_stake; uint128 m_instantStake; /* Storage */ struct DepoolInfo { bool poolClosed; uint64 minStake; uint...
5,758
6
// enable voting
uint256 mask = 1 << 3; uint256 currentData = VoterData[_address]; VoterData[_address] = currentData | mask;
uint256 mask = 1 << 3; uint256 currentData = VoterData[_address]; VoterData[_address] = currentData | mask;
5,418
18
// 获取课件的上传信息
function getCourseUploadInfo(uint256 _id) public view returns (string[] memory, string[] memory){ string[] memory names = Filenames[_id]; uint sum = 0; for (uint i = 0; i < names.length; i++) { string memory filename = names[i]; if (Files[_id][filename].enable) { ...
function getCourseUploadInfo(uint256 _id) public view returns (string[] memory, string[] memory){ string[] memory names = Filenames[_id]; uint sum = 0; for (uint i = 0; i < names.length; i++) { string memory filename = names[i]; if (Files[_id][filename].enable) { ...
24,409
281
// Gets the price for `identifier` and `time` if it has already been requested and resolved. If the price is not available, the method reverts. identifier uniquely identifies the price requested. eg BTC/USD (encoded as bytes32) could be requested. time unix timestamp for the price request.return int256 representing the...
function getPrice(bytes32 identifier, uint256 time) public view virtual returns (int256);
function getPrice(bytes32 identifier, uint256 time) public view virtual returns (int256);
26,779
14
// ensure that the signature is on the proper updater
require( Replica(_replica).updater() == TypeCasts.bytes32ToAddress(_updater), "!current updater" );
require( Replica(_replica).updater() == TypeCasts.bytes32ToAddress(_updater), "!current updater" );
19,094
4
// Distribution Model Parameter editer
event SetRewardParams(uint256 rewardPerBlock, uint256 decrementUnitPerBlock); event RegisterRewardParams(uint256 atBlockNumber, uint256 rewardPerBlock, uint256 decrementUnitPerBlock); event DeleteRegisterRewardParams(uint256 index, uint256 atBlockNumber, uint256 rewardPerBlock, uint256 decrementUnitPerBlock...
event SetRewardParams(uint256 rewardPerBlock, uint256 decrementUnitPerBlock); event RegisterRewardParams(uint256 atBlockNumber, uint256 rewardPerBlock, uint256 decrementUnitPerBlock); event DeleteRegisterRewardParams(uint256 index, uint256 atBlockNumber, uint256 rewardPerBlock, uint256 decrementUnitPerBlock...
13,987
61
// Trade Dai for Ether using reserves.
totalDaiSold = _tradeDaiForEther( daiAmountFromReserves, quotedEtherAmount, deadline, true );
totalDaiSold = _tradeDaiForEther( daiAmountFromReserves, quotedEtherAmount, deadline, true );
19,367
2
// NOLINTNEXTLINE: low-level-calls.
(bool success, bytes memory returndata) = tokenAddress.call(callData); require(success, string(returndata)); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "TOKEN_OPERATION_FAILED"); }
(bool success, bytes memory returndata) = tokenAddress.call(callData); require(success, string(returndata)); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "TOKEN_OPERATION_FAILED"); }
18,348
22
// update
guardian = newGuardian;
guardian = newGuardian;
48,090
80
// ability for controller to step down
function detachController() external onlyController { address was = m_controller; m_controller = address(0); ControllerRetired(was); }
function detachController() external onlyController { address was = m_controller; m_controller = address(0); ControllerRetired(was); }
6,588
20
// Check that the auction endTime has not already passed.
require( idToMarketItem[tokenId].endTime > block.timestamp, "This auction has ended." );
require( idToMarketItem[tokenId].endTime > block.timestamp, "This auction has ended." );
33,096
12
// Transfer all eth in this contract address to another address _to The eth will be send to this address/
function msReclaimEther(address _to) external onlyOwner returns(bool success) { _initOrSignOwnerAction("msReclaimEther"); if (ownerAction.approveSigs > 1) { _to.transfer(address(this).balance); emit ActionExecuted("msReclaimEther"); _deleteOwnerActon(); ...
function msReclaimEther(address _to) external onlyOwner returns(bool success) { _initOrSignOwnerAction("msReclaimEther"); if (ownerAction.approveSigs > 1) { _to.transfer(address(this).balance); emit ActionExecuted("msReclaimEther"); _deleteOwnerActon(); ...
27,273
21
// ------------------------------------------------------------------------ Transfer the balance from token owner's account to to account - Owner's account must have sufficient balance to transfer - 0 value transfers are allowed ------------------------------------------------------------------------
function transfer(address _to, uint _tokens) public afterFrozenDeadline returns (bool success) { require(now > frozenAccountByOwner[msg.sender]); balances[msg.sender] = safeSub(balances[msg.sender], _tokens); balances[_to] = safeAdd(balances[_to], _tokens); emit Transfer(msg.sender,...
function transfer(address _to, uint _tokens) public afterFrozenDeadline returns (bool success) { require(now > frozenAccountByOwner[msg.sender]); balances[msg.sender] = safeSub(balances[msg.sender], _tokens); balances[_to] = safeAdd(balances[_to], _tokens); emit Transfer(msg.sender,...
33,419
4
// Minor adaptation on `factory` and `WETH` to help conform to compiler bump.
interface IUniswapV2Router01x { function factory() external view returns (address); function WETH() external view returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountB...
interface IUniswapV2Router01x { function factory() external view returns (address); function WETH() external view returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountB...
33,452
49
// Initial distribution
uint96 pixTreasuryDist = 20000 * 1e18; uint96 dflectTreasuryDist = 15000 * 1e18;
uint96 pixTreasuryDist = 20000 * 1e18; uint96 dflectTreasuryDist = 15000 * 1e18;
24,605
50
// Cannot safely transfer to a contract that does not implement theERC721Receiver interface. /
error TransferToNonERC721ReceiverImplementer();
error TransferToNonERC721ReceiverImplementer();
1,025
95
// Clear the stake state for a wallet and a rarity./
function _clearStake(address wallet, address _erc20Token, uint256 _tokenRarity) internal { stakingsMap[wallet][_erc20Token][_tokenRarity].endDate = 0; stakingsMap[wallet][_erc20Token][_tokenRarity].tokenImage = 0; stakingsMap[wallet][_erc20Token][_tokenRarity].tokenBackground = 0; st...
function _clearStake(address wallet, address _erc20Token, uint256 _tokenRarity) internal { stakingsMap[wallet][_erc20Token][_tokenRarity].endDate = 0; stakingsMap[wallet][_erc20Token][_tokenRarity].tokenImage = 0; stakingsMap[wallet][_erc20Token][_tokenRarity].tokenBackground = 0; st...
38,144
512
// Save current value for inclusion in log
address oldBorrowCapGuardian = borrowCapGuardian;
address oldBorrowCapGuardian = borrowCapGuardian;
1,038
22
// the structure to track all the members in the DAO
uint256 flags; // flags to track the state of the member: exists, etc
uint256 flags; // flags to track the state of the member: exists, etc
31,406
0
// IFakeERC173Facet/Martin Wawrusch for Roji Inc./Exposes an ERC173 ownership facet. The actual ownership is handled differently, this is only used for OpenSea and similar indexers
interface IFakeERC173Facet { /// @dev This emits when ownership of a contract changes. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /// @notice Get the address of the owner /// @return The address of the owner. function owner() view external returns(a...
interface IFakeERC173Facet { /// @dev This emits when ownership of a contract changes. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /// @notice Get the address of the owner /// @return The address of the owner. function owner() view external returns(a...
15,153
55
// uint256 constant public REFERRAL_PERCENTS = 1e11;
uint256 public REFERRAL_PERCENTS = 1e11; uint256 constant public TIME_STEP = 1 days ; //days uint256 constant public BASE_AMOUNT_DALIY = 1e11; // 10w USDT uint256 constant public START_POINT = 1606828881; // Singapore time at: 2020-11-11 11:11:11 uint256 constant public PERCENT_INVEST = 10; // increase percent p...
uint256 public REFERRAL_PERCENTS = 1e11; uint256 constant public TIME_STEP = 1 days ; //days uint256 constant public BASE_AMOUNT_DALIY = 1e11; // 10w USDT uint256 constant public START_POINT = 1606828881; // Singapore time at: 2020-11-11 11:11:11 uint256 constant public PERCENT_INVEST = 10; // increase percent p...
77,907
149
// stake into LiquidityGauge
uint lpBal = IERC20(LP).balanceOf(address(this)); if (lpBal > 0) { IERC20(LP).safeApprove(GAUGE, 0); IERC20(LP).safeApprove(GAUGE, lpBal); LiquidityGauge(GAUGE).deposit(lpBal); }
uint lpBal = IERC20(LP).balanceOf(address(this)); if (lpBal > 0) { IERC20(LP).safeApprove(GAUGE, 0); IERC20(LP).safeApprove(GAUGE, lpBal); LiquidityGauge(GAUGE).deposit(lpBal); }
15,633
15
// This shouldn't fail.
require( block.timestamp - lastObservation.timestamp >= MIN_TWAP_TIME, "UniswapV2PriceOracle: Bad TWAP time." ); uint256 px0Cumulative = price0Cumulative(pair); unchecked {
require( block.timestamp - lastObservation.timestamp >= MIN_TWAP_TIME, "UniswapV2PriceOracle: Bad TWAP time." ); uint256 px0Cumulative = price0Cumulative(pair); unchecked {
32,420
7
// Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. /
function isApprovedForAll(address owner, address operator) override public view returns (bool)
function isApprovedForAll(address owner, address operator) override public view returns (bool)
9,826
17
// Transfers Governance of the contract to a new account (`newGovernor`).Can only be called by the current Governor. Must be claimed for this to complete _newGovernor Address of the new Governor /
function transferGovernance(address _newGovernor) external onlyGovernor { _setPendingGovernor(_newGovernor); emit PendingGovernorshipTransfer(_governor(), _newGovernor); }
function transferGovernance(address _newGovernor) external onlyGovernor { _setPendingGovernor(_newGovernor); emit PendingGovernorshipTransfer(_governor(), _newGovernor); }
28,300
42
// Arrays of 31 bytes or less have an even value in their slot, while longer arrays have an odd value. The actual length is the slot divided by two for odd values, and the lowest order byte divided by two for even values. If the slot is even, bitwise and the slot with 255 and divide by two to get the length. If the slo...
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength)
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength)
28,535
103
// validates reserve weight
modifier validReserveWeight(uint32 _weight) { _validReserveWeight(_weight); _; }
modifier validReserveWeight(uint32 _weight) { _validReserveWeight(_weight); _; }
36,801
178
// Assets supported by the Vault, i.e. Stablecoins
struct Asset { bool isSupported; }
struct Asset { bool isSupported; }
75,086
118
// Future proof storage
mapping(bytes32 => AdditionalStorage) additionalStorage;
mapping(bytes32 => AdditionalStorage) additionalStorage;
1,207
16
// Fetching all market items.
function fetchMarketItems() public view returns (MarketItem[] memory) { uint256 itemCount = _itemIds.current(); uint256 unsoldItemCount = _itemIds.current() - _itemsSold.current(); uint256 currentIndex = 0; MarketItem[] memory items = new MarketItem[](unsoldItemCount); for ...
function fetchMarketItems() public view returns (MarketItem[] memory) { uint256 itemCount = _itemIds.current(); uint256 unsoldItemCount = _itemIds.current() - _itemsSold.current(); uint256 currentIndex = 0; MarketItem[] memory items = new MarketItem[](unsoldItemCount); for ...
37,691
247
// internal function that transfers ETH Calling conditions: - Only the owner of the smart contract i.e Unicus platform transfer ETH bidder_ Address where the ETH will be transfered amount_ amount of the ETH that will be transfered /
function _transferETH(address bidder_, uint256 amount_) private onlyOwner { require(amount_ > 0, "Amount to transfer should not be zero."); (bool success,bytes memory data ) = payable(bidder_).call{value:amount_,gas:_GAS_LIMIT}(""); emit EthPaymentSuccess(success,data,address(this), bidder_,...
function _transferETH(address bidder_, uint256 amount_) private onlyOwner { require(amount_ > 0, "Amount to transfer should not be zero."); (bool success,bytes memory data ) = payable(bidder_).call{value:amount_,gas:_GAS_LIMIT}(""); emit EthPaymentSuccess(success,data,address(this), bidder_,...
11,981
6
// ProofPresale ProofPresale allows investors to maketoken purchases and assigns them tokens basedon a token per ETH rate. Funds collected are forwarded to a wallet as they arrive. /
library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint...
library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint...
5,806
34
// `balances` is the map that tracks the balance of each address, in thiscontract when the balance changes the block number that the changeoccurred is also included in the map
mapping (address => Checkpoint[]) balances;
mapping (address => Checkpoint[]) balances;
19,871
28
// Ensure Issuer contract can suspend issuance - see SIP-165;
systemstatus_i.updateAccessControl("Issuance", new_Issuer_contract, true, false);
systemstatus_i.updateAccessControl("Issuance", new_Issuer_contract, true, false);
30,000
26
// Encodes calldata for startBridgeTokensViaCBridgeNativePacked/transactionId Custom transaction ID for tracking/receiver Receiving wallet address/destinationChainId Receiving chain/nonce A number input to guarantee uniqueness of transferId./maxSlippage Destination swap minimal accepted amount
function encode_startBridgeTokensViaCBridgeNativePacked( bytes32 transactionId, address receiver, uint64 destinationChainId, uint64 nonce, uint32 maxSlippage
function encode_startBridgeTokensViaCBridgeNativePacked( bytes32 transactionId, address receiver, uint64 destinationChainId, uint64 nonce, uint32 maxSlippage
11,688
7
// tracking events
event newOraclizeQuery(string description); event newPriceTicker(uint price); event Deposit(address _from, uint256 _value, bytes32 _horse, uint256 _date); event Withdraw(address _to, uint256 _value);
event newOraclizeQuery(string description); event newPriceTicker(uint price); event Deposit(address _from, uint256 _value, bytes32 _horse, uint256 _date); event Withdraw(address _to, uint256 _value);
14,082
70
// Returns the multiplication of two signed integers, reverting onoverflow. Counterpart to Solidity's `` operator. Requirements: - Multiplication cannot overflow. /
function mul(int256 a, int256 b) internal pure returns (int256) { return a * b; }
function mul(int256 a, int256 b) internal pure returns (int256) { return a * b; }
39,833
4
// Deposits `amount` of `token` into the specified `DelegationShare`, with the resultant shares credited to `depositor` delegationShare is the specified shares record where investment is to be made, token is the ERC20 token in which the investment is to be made, amount is the amount of token to be invested in the deleg...
function depositInto(IDelegationShare delegationShare, IERC20 token, uint256 amount) external returns (uint256);
function depositInto(IDelegationShare delegationShare, IERC20 token, uint256 amount) external returns (uint256);
4,035
26
// Get the current mint fee. Returns the current transfer amount required to minta new token. /
function mintFee() public view returns (uint) { return _mintFee; }
function mintFee() public view returns (uint) { return _mintFee; }
80,469
104
// if round has ended.but round end has not been run (so contract has not distributed winnings)
if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) {
if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) {
7,651
3
// limit our copy to 256 bytes
_toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy }
_toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy }
361
159
// Get current balance of the deposit token before withdrawal
uint256 depositTokenBalanceBeforeWithdrawal = ERC20Wrapper.balanceOf(depositTokenAddress, address(this));
uint256 depositTokenBalanceBeforeWithdrawal = ERC20Wrapper.balanceOf(depositTokenAddress, address(this));
47,609
227
// get the actual weapon class and greatness
uint256 rand = random(string(abi.encodePacked("WEAPON", toString(tokenId)))); string memory output = sourceArray[rand % sourceArray.length]; uint256 greatness = rand % 21; uint256 stat; if (keccak256(abi.encodePacked((output))) == keccak256(abi.encodePacked(("Warhammer")))) { ...
uint256 rand = random(string(abi.encodePacked("WEAPON", toString(tokenId)))); string memory output = sourceArray[rand % sourceArray.length]; uint256 greatness = rand % 21; uint256 stat; if (keccak256(abi.encodePacked((output))) == keccak256(abi.encodePacked(("Warhammer")))) { ...
37,048
13
// Setup has to complete successfully or transaction fails.
require(executeDelegateCall(to, data, gasleft()), 'Could not finish initialization');
require(executeDelegateCall(to, data, gasleft()), 'Could not finish initialization');
30,928
60
// get owner addressreturn address owner /
function getOwner() external override view returns (address) { return owner(); }
function getOwner() external override view returns (address) { return owner(); }
12,159
7
// Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was notalready present. /
function approve(address spender, uint256 tokens) public returns (bool success); function transferFrom( address from, address to, uint256 tokens ) public returns (bool success);
function approve(address spender, uint256 tokens) public returns (bool success); function transferFrom( address from, address to, uint256 tokens ) public returns (bool success);
48,739
118
// Transfer tax rate in basis points. (default 5%)
uint16 public transferTaxRate = 500;
uint16 public transferTaxRate = 500;
17,722
2
// Solidity only automatically asserts when dividing by 0
require(b > 0); uint256 c = a / b;
require(b > 0); uint256 c = a / b;
23,459
26
// Total amount of tokens
uint256 private totalTokens;
uint256 private totalTokens;
82,240
15
// Final amount of tokens returned to issuer
uint256 public finalAmountReturned;
uint256 public finalAmountReturned;
25,473
38
// Token being sold
ERC20 public constant TOKEN = ERC20(TOKEN_ADDRESS);
ERC20 public constant TOKEN = ERC20(TOKEN_ADDRESS);
19,232
10
// internal approve functionality. needed, so we can check the payloadsize if called externally, but smaller payload allowed internally /
function _approve(address _spender, uint _value) internal returns(bool success) { // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowance[msg.sender][_spender] == 0)); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return tr...
function _approve(address _spender, uint _value) internal returns(bool success) { // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowance[msg.sender][_spender] == 0)); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return tr...
3,014
312
// Uniswap V2 ============================================
// { // uint256 total_frax_reserves; // (uint256 reserve0, uint256 reserve1, ) = (stakingToken.getReserves()); // if (frax_is_token0) total_frax_reserves = reserve0; // else total_frax_reserves = reserve1; // frax_per_lp_token = (total_frax_reserves *...
// { // uint256 total_frax_reserves; // (uint256 reserve0, uint256 reserve1, ) = (stakingToken.getReserves()); // if (frax_is_token0) total_frax_reserves = reserve0; // else total_frax_reserves = reserve1; // frax_per_lp_token = (total_frax_reserves *...
50,462
79
// The traditional divUp formula is: divUp(x, y) := (x + y - 1) / y To avoid intermediate overflow in the addition, we distribute the division and get: divUp(x, y) := (x - 1) / y + 1 Note that this requires x != 0, which we already tested for.
return ((product - 1) / ONE) + 1;
return ((product - 1) / ONE) + 1;
13,330
2
// Deploy the proposal contract for a campaign. _manager The campaign manager address. Can only be called by an existing campaign contract. /
function deployProposalContract(address _manager) external;
function deployProposalContract(address _manager) external;
38,963
50
// An external method that get infomation of the fighter/_tokenId The ID of the fighter.
function getFighter(uint _tokenId) external view returns (uint32) { RabbitData storage rbt = rabbits[_tokenId]; uint32 strength = uint32(rbt.explosive + rbt.endurance + rbt.nimble); return strength; }
function getFighter(uint _tokenId) external view returns (uint32) { RabbitData storage rbt = rabbits[_tokenId]; uint32 strength = uint32(rbt.explosive + rbt.endurance + rbt.nimble); return strength; }
24,981
94
// Permits this contract to spend on a users behalf, and deposits into the prize pool./The Dai permit params match the Daipermit function, but it expects the `spender` to be/ the address of this contract./holder The address spending the tokens/nonce The nonce of the tx.Should be retrieved from the Dai token/expiry The ...
function permitAndDepositTo(
function permitAndDepositTo(
67,220
370
// Change delegation for `delegator` to `delegatee`.
* Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}. */ function _delegate(address delegator, address delegatee) internal virtual { address currentDelegate = delegates(delegator); uint256 delegatorBalance = balanceOf(delegator); _delegates[delegator] = delegat...
* Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}. */ function _delegate(address delegator, address delegatee) internal virtual { address currentDelegate = delegates(delegator); uint256 delegatorBalance = balanceOf(delegator); _delegates[delegator] = delegat...
32,213
22
// If `_token` is a zero address then the order will treat it as being WETH./_bidder Address that placed the bid./_tokenContractAddress The ERC721 asset contract address./_tokenId ID of the desired ERC721 asset./_expiration Time of order expiration defined as a UNIX timestamp./_offer The offered amount in wei for the g...
function exerciseBuyOrder( address payable _bidder, address _tokenContractAddress, uint256 _tokenId, uint256 _expiration, uint256 _offer, address _token ) external payable;
function exerciseBuyOrder( address payable _bidder, address _tokenContractAddress, uint256 _tokenId, uint256 _expiration, uint256 _offer, address _token ) external payable;
26,742
64
// Termination of the pool // Exit a terminated pool _user the user to exit from the pool only pt are required as therearen't any new FYTs /
function exitTerminatedFuture(address _user) external nonReentrant onlyController { require(terminated, "FutureVault: ERR_NOT_TERMINATED"); uint256 amount = pt.balanceOf(_user); require(amount > 0, "FutureVault: ERR_PT_BALANCE"); _withdraw(_user, amount); emit FundsWithdrawn(...
function exitTerminatedFuture(address _user) external nonReentrant onlyController { require(terminated, "FutureVault: ERR_NOT_TERMINATED"); uint256 amount = pt.balanceOf(_user); require(amount > 0, "FutureVault: ERR_PT_BALANCE"); _withdraw(_user, amount); emit FundsWithdrawn(...
20,495
118
// calculate the amount of tokens the customer receives over his purchase
_fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
_fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
15,865
134
// Empty donations are disallowed.
uint balance = state.balanceOf(sender); require(balance != 0);
uint balance = state.balanceOf(sender); require(balance != 0);
25,600
6
// transfer funds to owner
items[index].owner.transfer(msg.value);
items[index].owner.transfer(msg.value);
12,423
37
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime; uint256 public endTime;
uint256 public startTime; uint256 public endTime;
7,850
2
// check if a hash is in the merkle tree for rootHash rootHash the merkle root index the index of the node to check hash the hash to check proofHashes the proof, i.e. the sequence of siblings from the node to root /
function validProof( bytes32 rootHash, uint256 index, bytes32 hash, bytes32[] memory proofHashes
function validProof( bytes32 rootHash, uint256 index, bytes32 hash, bytes32[] memory proofHashes
27,660
10
// ´:°•.°+.•´.:˚.°.˚•´.°:°•.°•.•´.:˚.°.˚•´.°:°•.°+.•´.:// ETH OPERATIONS //.•°:°.´+˚.°.˚:.´•.+°.•°:´.´•.•°.•°:°.´:•˚°.°.˚:.´+°.•//Sends `amount` (in wei) ETH to `to`./ Reverts upon failure.
function safeTransferETH(address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { // Transfer the ETH and check if it succeeded or not. if iszero(call(gas(), to, amount, 0, 0, 0, 0)) { // Store the function selector of `ETHTransferF...
function safeTransferETH(address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { // Transfer the ETH and check if it succeeded or not. if iszero(call(gas(), to, amount, 0, 0, 0, 0)) { // Store the function selector of `ETHTransferF...
5,515
38
// Withdraw ethereum for a specified address _to The address to transfer to _value The amount to be transferred /
function withdraw(address _to, uint256 _value) onlyOwner public returns (bool) { require(_to != address(0)); require(_value <= address(this).balance); _to.transfer(_value); return true; }
function withdraw(address _to, uint256 _value) onlyOwner public returns (bool) { require(_to != address(0)); require(_value <= address(this).balance); _to.transfer(_value); return true; }
66,819
16
// MAINNET ADDRESSES The contracts in this list should correspond to MCD core contracts, verify against the current release list at: https:changelog.makerdao.com/releases/mainnet/1.1.0/contracts.json
address constant MCD_VAT = 0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B; address constant MCD_VOW = 0xA950524441892A31ebddF91d3cEEFa04Bf454466; address constant MCD_ADM = 0x9eF05f7F6deB616fd37aC3c959a2dDD25A54E4F5; address constant MCD_END = 0xaB14d3CE3F733...
address constant MCD_VAT = 0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B; address constant MCD_VOW = 0xA950524441892A31ebddF91d3cEEFa04Bf454466; address constant MCD_ADM = 0x9eF05f7F6deB616fd37aC3c959a2dDD25A54E4F5; address constant MCD_END = 0xaB14d3CE3F733...
57,089
0
// Generate a unique ID for an execution request _to address being called (msg.sender) _value ether being sent (msg.value) _data ABI encoded call data (msg.data) /
function execute(address _to, uint256 _value, bytes _data) public whenNotPaused returns (uint256 executionId)
function execute(address _to, uint256 _value, bytes _data) public whenNotPaused returns (uint256 executionId)
28,301
35
// Add a beneficiary for the airdrop. _beneficiary The address of the beneficiary /
function addBeneficiary(address _beneficiary) private
function addBeneficiary(address _beneficiary) private
38,453
175
// cr / (1 - c) <= x <= b
uint repayAmount = redeemAmount.mul(safeCol).div(uint(1e18).sub(safeCol)); if (repayAmount > borrowed) { repayAmount = borrowed; }
uint repayAmount = redeemAmount.mul(safeCol).div(uint(1e18).sub(safeCol)); if (repayAmount > borrowed) { repayAmount = borrowed; }
43,855
0
// Indicated the highest level of bug found in the version/
enum BugLevel {NONE, LOW, MEDIUM, HIGH, CRITICAL}
enum BugLevel {NONE, LOW, MEDIUM, HIGH, CRITICAL}
1,222
5
// Transfers a specific NFT (`tokenId`) from one account (`from`) toanother (`to`). Requirements:- `from`, `to` cannot be zero.- `tokenId` must be owned by `from`.- If the caller is not `from`, it must be have been allowed to move this
* NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be appro...
* NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be appro...
39,805
29
// origin vesting contracts have different dateswe need to add 2 weeks to get end of period (by default, it's start)
if (adjustedDate != date) { date = adjustedDate + TWO_WEEKS; }
if (adjustedDate != date) { date = adjustedDate + TWO_WEEKS; }
19,227