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
4
// Sets a new owner address /
function setOwner(address newOwner) internal { _owner = newOwner; }
function setOwner(address newOwner) internal { _owner = newOwner; }
34,156
0
// Mint 100 tokens to msg.sender Similar to how 1 dollar = 100 cents 1 token = 1(10decimals)
_mint(msg.sender, 100 * 10**uint256(decimals()));
_mint(msg.sender, 100 * 10**uint256(decimals()));
793
37
// 提案投票
function proposalVote(uint256 _proposalIndex) external isProposalVoting(_proposalIndex){ require(!isProposalVote[_proposalIndex][msg.sender], "already vote."); uint256 votePower = getProposalVotePowerOfUser(); Template storage proposal = proposals[_proposalIndex]; proposal.votePower...
function proposalVote(uint256 _proposalIndex) external isProposalVoting(_proposalIndex){ require(!isProposalVote[_proposalIndex][msg.sender], "already vote."); uint256 votePower = getProposalVotePowerOfUser(); Template storage proposal = proposals[_proposalIndex]; proposal.votePower...
15,038
9
// Change or reaffirm the approved address for an NFT/The zero address indicates there is no approved address./Throws unless `msg.sender` is the current NFT owner, or an authorized/operator of the current owner./_approved The new approved NFT controller/_tokenId The NFT to approve
function approve(address _approved, uint256 _tokenId) external payable;
function approve(address _approved, uint256 _tokenId) external payable;
3,040
23
// recover tokens tha were not claimed
function recoverTokens() onlyAdmin public { require(now < (showTokenSaleClosingTime().add(61 days))); token.transfer(admin, token.balanceOf(thisContractAddress)); }
function recoverTokens() onlyAdmin public { require(now < (showTokenSaleClosingTime().add(61 days))); token.transfer(admin, token.balanceOf(thisContractAddress)); }
51,627
7
// Iterations for open mystery boxes
mapping(uint256=>uint16[]) private _mysteryBoxesIterations;
mapping(uint256=>uint16[]) private _mysteryBoxesIterations;
29,013
14
// get quantity of underlying paid
uint256 quote = _quoteIn(amountShortIn);
uint256 quote = _quoteIn(amountShortIn);
22,708
24
// Alters the seed to remove combinations that the artist has determined conflict with one another /seed, the post-rarity allocated traits for a token / return the modified seed
function enforceRequiredCombinations(uint8[10] memory seed) public view returns (uint8[10] memory) { for (uint8 i; i < seed.length; i++) { TraitDescriptor[] memory exclusions = traitExclusions[keccak256(abi.encodePacked(i, seed[i]))]; // check to see if seed contains any trait combinations th...
function enforceRequiredCombinations(uint8[10] memory seed) public view returns (uint8[10] memory) { for (uint8 i; i < seed.length; i++) { TraitDescriptor[] memory exclusions = traitExclusions[keccak256(abi.encodePacked(i, seed[i]))]; // check to see if seed contains any trait combinations th...
79,710
202
// Checks the actual balance of DAI in the vat after the pot exit
uint bal = DaiJoinLike(daiJoin).vat().dai(address(this));
uint bal = DaiJoinLike(daiJoin).vat().dai(address(this));
53,627
31
// Perform additional checks here, such as verifying sufficient approval from `from` ...
refundActive[tokenId] = false;
refundActive[tokenId] = false;
29,500
308
// Set new configuration
Configuration oldConfiguration = configuration; configuration = newConfiguration;
Configuration oldConfiguration = configuration; configuration = newConfiguration;
24,886
7
// Returns the identity registries linked to the storage contract /
function linkedIdentityRegistries() external view returns (address[] memory);
function linkedIdentityRegistries() external view returns (address[] memory);
1,313
6
// Get the interest rate per year (ie 0.10 USDC per USDC locked for 1 year)return the deposit rate /
function getDepositRate() public view returns (uint256) { return _getDepositRate(); }
function getDepositRate() public view returns (uint256) { return _getDepositRate(); }
10,702
116
// uint256 attrType = nonGenSeries[sId].attrType.current();
uint256 rand = vrf.getRandomVal(); uint256 rand1;
uint256 rand = vrf.getRandomVal(); uint256 rand1;
52,645
13
// A common scaling factor to maintain precision
uint public constant expScale = 1e18;
uint public constant expScale = 1e18;
56,181
0
// cETH TokenUtilities for CompoundETH/
interface cETH { //@dev functions from Compound that are going to be used function mint() external payable; // to deposit to compound function redeem(uint redeemTokens) external returns (uint); // to withdraw from compound //following 2 functions to determine how much you'll be able to withdraw ...
interface cETH { //@dev functions from Compound that are going to be used function mint() external payable; // to deposit to compound function redeem(uint redeemTokens) external returns (uint); // to withdraw from compound //following 2 functions to determine how much you'll be able to withdraw ...
51,506
60
// Mapping from owner to number of owned token
mapping (address => Counters.Counter) private _ownedTokensCount;
mapping (address => Counters.Counter) private _ownedTokensCount;
225
6
// Internal // Get the StripToken amount of vesting contract /
function getDepositedStrip() internal view returns (uint256) { address addrVesting = address(vestingContract); return stripToken.balanceOf(addrVesting); }
function getDepositedStrip() internal view returns (uint256) { address addrVesting = address(vestingContract); return stripToken.balanceOf(addrVesting); }
43,423
88
// enable these for debugging assert(flowData.deposit & type(uint32).max == 0); assert(flowData.owedDeposit & type(uint32).max == 0);
data = new bytes32[](1); data[0] = bytes32( ((uint256(flowData.timestamp)) << 224) | ((uint256(uint96(flowData.flowRate)) << 128)) | (uint256(flowData.deposit) >> 32 << 64) | (uint256(flowData.owedDeposit) >> 32) );
data = new bytes32[](1); data[0] = bytes32( ((uint256(flowData.timestamp)) << 224) | ((uint256(uint96(flowData.flowRate)) << 128)) | (uint256(flowData.deposit) >> 32 << 64) | (uint256(flowData.owedDeposit) >> 32) );
10,533
2
// Returns the ERC20 asset token used for deposits./ return The ERC20 asset token
function _token() internal virtual view returns (IERC20);
function _token() internal virtual view returns (IERC20);
38,553
52
// return the index of the current discount by date.
function currentStepIndexByDate() internal view returns (uint8 roundNum) { require(now <= endPreICO); if(now > preSale15) return 2; if(now > preSale20) return 1; if(now > preSale30) return 0; else return 0; }
function currentStepIndexByDate() internal view returns (uint8 roundNum) { require(now <= endPreICO); if(now > preSale15) return 2; if(now > preSale20) return 1; if(now > preSale30) return 0; else return 0; }
44,516
3
// Converts token1 dust (if any) to earned tokens
uint256 token1Amt = IERC20(token1Address).balanceOf(address(this)); if (token1Amt > 0 && token1Address != earnedAddress) {
uint256 token1Amt = IERC20(token1Address).balanceOf(address(this)); if (token1Amt > 0 && token1Address != earnedAddress) {
46,987
18
// If there is no struct, all values will be 0 including sender
return usersToId[sender][recipient][tokenAddress] != bytes32(0);
return usersToId[sender][recipient][tokenAddress] != bytes32(0);
27,572
21
// Registers manager with ManagerCore
managerCore.addManager(address(newManager)); emit DelegatedManagerCreated(_jasperVault, newManager, msg.sender); return newManager;
managerCore.addManager(address(newManager)); emit DelegatedManagerCreated(_jasperVault, newManager, msg.sender); return newManager;
14,663
38
// UpgradeabilityProxy This contract implements a proxy that allows to change theimplementation address to which it will delegate.Such a change is called an implementation upgrade. /
contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be calle...
contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be calle...
36,720
3
// ============ State Variables ============ / Mapping of underlying to CToken. If ETH, then map WETH to cETH
mapping(address => address) public underlyingToCToken;
mapping(address => address) public underlyingToCToken;
30,880
11
// Time that has to elapse for a withdrawal request to be considered passed, if no liquidations occur. !!Note: The lower the withdrawal liveness value, the more risk incurred by the contract. Extremely low liveness values increase the chance that opportunistic invalid withdrawal requests expire without liquidation, the...
uint256 public withdrawalLiveness;
uint256 public withdrawalLiveness;
27,446
64
// Return the contract which implements the IReserveManager interface. /
function getReserveManager() public view returns (IReserveManager) { return IReserveManager(getContractAddress(_IReserveManager_)); }
function getReserveManager() public view returns (IReserveManager) { return IReserveManager(getContractAddress(_IReserveManager_)); }
19,842
15
// Add new vesting to contract _user address of a holder _startTokens how many tokens are claimable at start date _totalTokens total number of tokens in added vesting _startDate date from when tokens can be claimed _endDate date after which all tokens can be claimed /
function _addHolder( address _user, uint256 _startTokens, uint256 _totalTokens, uint256 _startDate, uint256 _endDate
function _addHolder( address _user, uint256 _startTokens, uint256 _totalTokens, uint256 _startDate, uint256 _endDate
45,955
65
// What was the caller&39;s prediction for a given game?
function playerGuess(int8 _gameID) public view returns (string)
function playerGuess(int8 _gameID) public view returns (string)
38,429
299
// original forward function copied from https:github.com/uport-project/uport-identity/blob/develop/contracts/Proxy.sol
function forward(bytes memory sig, address signer, address destination, uint value, bytes memory data, address rewardToken, uint rewardAmount) public
function forward(bytes memory sig, address signer, address destination, uint value, bytes memory data, address rewardToken, uint rewardAmount) public
24,399
366
// In the event that we do not raise enough funds from the auctioning of a failed Basset, The Basket is deemed as failed, and is undercollateralised to a certain degree. The collateralisation ratio is used to calc Masset burn rate.
bool failed; uint256 collateralisationRatio;
bool failed; uint256 collateralisationRatio;
74,022
209
// 6. Check we haven't hit the debt cap for non snx collateral.
(bool canIssue, bool anyRateIsInvalid) = _manager().exceedsDebtLimit(amount, currency); require(canIssue && !anyRateIsInvalid, "Debt limit or invalid rate");
(bool canIssue, bool anyRateIsInvalid) = _manager().exceedsDebtLimit(amount, currency); require(canIssue && !anyRateIsInvalid, "Debt limit or invalid rate");
47,810
200
// AgroChef is the master of agro. He can make Agro and he is a fair guy. Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once AGRO is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's ...
contract AgroChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fan...
contract AgroChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fan...
39,880
294
// cooldown: amount of time before the (non-majority) poll can be reopened
uint256 cooldown;
uint256 cooldown;
14,897
86
// This function implement proxy for befor transfer hook form OpenZeppelin ERC20. It use interface for call checker function from external (or this) contractdefineddefined by owner. /
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override { require(to != address(this), "This contract not accept tokens" ); }
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override { require(to != address(this), "This contract not accept tokens" ); }
78,755
1
// mapping from pair address to a list of price observations of that pair
mapping(address => Observation) public pairObservations;
mapping(address => Observation) public pairObservations;
3,469
7
// Require that `msg.sender` has given permissionrole bytes32 permission ID /
modifier onlyPermission(bytes32 role) { _requirePermission(role); _; }
modifier onlyPermission(bytes32 role) { _requirePermission(role); _; }
18,088
15
// Get claimable amount from BoneLocker _user user address _boneLocker BoneLocker to check, pass zero address to check current /
function getClaimableRewardFromBoneLocker(address _user, IBoneLocker _boneLocker) public view returns (uint256) { WSSLPUserProxy userProxy = usersProxies[_user]; if (address(userProxy) == address(0)) { return 0; } return userProxy.getClaimableRewardFromBoneLocker(_boneLo...
function getClaimableRewardFromBoneLocker(address _user, IBoneLocker _boneLocker) public view returns (uint256) { WSSLPUserProxy userProxy = usersProxies[_user]; if (address(userProxy) == address(0)) { return 0; } return userProxy.getClaimableRewardFromBoneLocker(_boneLo...
52,287
103
// return tAmount.sub(tFee).sub(tLiquidity).sub(tMarketing).sub(tBurn).sub(tBuyback);
return tAmount.sub(tValues[1]).sub(tValues[2]).sub(tValues[3]).sub(tValues[4]).sub(tValues[5]).sub(tValues[6]);
return tAmount.sub(tValues[1]).sub(tValues[2]).sub(tValues[3]).sub(tValues[4]).sub(tValues[5]).sub(tValues[6]);
38,907
92
// helper constants to compute the vPURE/ETH ratio /
uint256 private constant _VPURENUMERATOR = 1000;
uint256 private constant _VPURENUMERATOR = 1000;
6,146
283
// Caches return values of `getPoolBalance` for the duration of the function. /
modifier cachePoolBalances() { bool cacheSetPreviously = _cachePoolBalances; _cachePoolBalances = true; _; if (!cacheSetPreviously) { _cachePoolBalances = false; if (!_cacheDydxBalances) _dydxBalancesCache.length = 0; for (uint256 i = 0; i < _sup...
modifier cachePoolBalances() { bool cacheSetPreviously = _cachePoolBalances; _cachePoolBalances = true; _; if (!cacheSetPreviously) { _cachePoolBalances = false; if (!_cacheDydxBalances) _dydxBalancesCache.length = 0; for (uint256 i = 0; i < _sup...
2,326
218
// Depending on whether this is a finalizing burn or not, the amount of locked/unlocked PRPS is determined differently.
if (finalizing) {
if (finalizing) {
36,114
213
// Update the latest staked node of the zombie at the given index zombieNum Index of the zombie to move latest New latest node the zombie is staked on /
function zombieUpdateLatestStakedNode(uint256 zombieNum, uint256 latest) internal { _zombies[zombieNum].latestStakedNode = latest; }
function zombieUpdateLatestStakedNode(uint256 zombieNum, uint256 latest) internal { _zombies[zombieNum].latestStakedNode = latest; }
48,517
73
// use delegate call via handler proxy for token handlers
bytes memory callData = abi.encodeWithSelector( marketHandlerInterface .setCircuitBreaker.selector, _emergency ); tokenHandler.handlerProxy(callData); tokenHandler.siProxy(callData);
bytes memory callData = abi.encodeWithSelector( marketHandlerInterface .setCircuitBreaker.selector, _emergency ); tokenHandler.handlerProxy(callData); tokenHandler.siProxy(callData);
36,538
231
// Update the given pool's SEED allocation point and deposit fee. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, uint16 _depositFeeBP, uint256 _harvestInterval, bool _withUpdate) external onlyOwner { require(_depositFeeBP <= 400, "set: invalid deposit fee basis points"); require(_harvestInterval <= MAXIMUM_HARVEST_INTERVAL, "set: invalid harvest interval"); ...
function set(uint256 _pid, uint256 _allocPoint, uint16 _depositFeeBP, uint256 _harvestInterval, bool _withUpdate) external onlyOwner { require(_depositFeeBP <= 400, "set: invalid deposit fee basis points"); require(_harvestInterval <= MAXIMUM_HARVEST_INTERVAL, "set: invalid harvest interval"); ...
29,564
119
// PRIVILEGED GOVERNANCE FUNCTION. Allows transfers of ERC20 BABL TokensCan only happen after the protocol is fully decentralized. /
function enableTokensTransfers() external onlyOwner { tokenTransfersEnabled = true; }
function enableTokensTransfers() external onlyOwner { tokenTransfersEnabled = true; }
34,033
20
// Check if the specified address is restricted with the specified restriction
function isRestricted(address _account, uint8 _restriction) public view returns (bool) { // If the account is in the restriction list, but not restricted (restriction is NONE) // Doesn't matter which restriction we require if (_accountsToRestrictions[_account] == NONE) { return f...
function isRestricted(address _account, uint8 _restriction) public view returns (bool) { // If the account is in the restriction list, but not restricted (restriction is NONE) // Doesn't matter which restriction we require if (_accountsToRestrictions[_account] == NONE) { return f...
7,804
14
// return of interest on the deposit
function collectPercent() internal isIssetUser timePayment { address msgSender = msg.sender; //if the user received 200% or more of his contribution, delete the user if ((userDeposit[msgSender].mul(2)) <= persentWithdraw[msgSender]) { userDeposit[msgSender] = 0; userT...
function collectPercent() internal isIssetUser timePayment { address msgSender = msg.sender; //if the user received 200% or more of his contribution, delete the user if ((userDeposit[msgSender].mul(2)) <= persentWithdraw[msgSender]) { userDeposit[msgSender] = 0; userT...
15,560
8
// Destroys `_amnt` tokens from `_from`, reducing thetotal supply.
* @dev Emits a {Transfer} event with `to` set to the zero address. * Requirements: * - `_from` cannot be the zero address. * - `_from` must have at least `_amnt` tokens. * @param _from The address from which to destroy the tokens * @param _amnt The amount of tokens to be destroyed */ ...
* @dev Emits a {Transfer} event with `to` set to the zero address. * Requirements: * - `_from` cannot be the zero address. * - `_from` must have at least `_amnt` tokens. * @param _from The address from which to destroy the tokens * @param _amnt The amount of tokens to be destroyed */ ...
25,732
665
// Reads the uint176 at `rdPtr` in returndata.
function readUint176( ReturndataPointer rdPtr
function readUint176( ReturndataPointer rdPtr
40,387
202
// added to manage receiving eth or any token 3
if(wallet3TokenAddressForFee != address(0)){ swapEthForTokens(wallet3feeBalance, wallet3TokenAddressForFee, wallet3Address);
if(wallet3TokenAddressForFee != address(0)){ swapEthForTokens(wallet3feeBalance, wallet3TokenAddressForFee, wallet3Address);
36,608
87
// A The input array to search a The uint256 to remove /
function removeStorage(uint256[] storage A, uint256 a) internal
function removeStorage(uint256[] storage A, uint256 a) internal
27,363
332
// When repaying the full debt it is very common to experience Vat/dust reverts due to the debt being non-zero and less than the debt floor. This can happen due to rounding when _wipeAndFreeGem() divides the DAI amount by the accumulated stability fee rate. To circumvent this issue we will add 1 Wei to the amount to be...
if (debt.sub(amount) == 0 && balanceIT.sub(amount) >= 1) { amount = amount.add(1); }
if (debt.sub(amount) == 0 && balanceIT.sub(amount) >= 1) { amount = amount.add(1); }
77,002
14
// triggers a minting of FEI/timed and incentivized
function mint() public virtual override whenNotPaused afterTime { /// Reset the timer _initTimed(); uint256 amount = mintAmount(); // incentivizing before minting so if there is a partial mint it goes to target not caller _incentivize(); if (amount != 0) { ...
function mint() public virtual override whenNotPaused afterTime { /// Reset the timer _initTimed(); uint256 amount = mintAmount(); // incentivizing before minting so if there is a partial mint it goes to target not caller _incentivize(); if (amount != 0) { ...
30,442
106
// 2. Perform liquidation and compute the amount of ETH received.
uint256 beforeETH = address(this).balance; Goblin(pos.goblin).liquidate(id); uint256 back = address(this).balance.sub(beforeETH); uint256 prize = back.mul(config.getKillBps()).div(10000); uint256 rest = back.sub(prize);
uint256 beforeETH = address(this).balance; Goblin(pos.goblin).liquidate(id); uint256 back = address(this).balance.sub(beforeETH); uint256 prize = back.mul(config.getKillBps()).div(10000); uint256 rest = back.sub(prize);
23,245
8
// Emergency, pause token minting
function pause() public onlyAuthorized { _pause(); }
function pause() public onlyAuthorized { _pause(); }
35,533
48
// the MXP fee had been charge.
usdc.safeTransfer(msg.sender, receiveAmountAfterFee); usdc.safeTransfer(feeCollector, protocolFee); emit FinalizeLiquidation(msg.sender, receiveAmountAfterFee, protocolFee, _id);
usdc.safeTransfer(msg.sender, receiveAmountAfterFee); usdc.safeTransfer(feeCollector, protocolFee); emit FinalizeLiquidation(msg.sender, receiveAmountAfterFee, protocolFee, _id);
25,314
6
// Update pool stakers
harvestRewards();
harvestRewards();
18,742
1
// deposit a player's funds
function deposit() external payable { playerBalances[msg.sender] += msg.value; }
function deposit() external payable { playerBalances[msg.sender] += msg.value; }
7,295
209
// store native currency in weth
require(_amount == msg.value, "msg.value != amount");
require(_amount == msg.value, "msg.value != amount");
57,122
2
// upload img to textile n gives back a cid then save it to the contract => I have the cid img url store whole data first try the image, json obj for data
function registerCommunity(string memory _imageURL, string memory _communityName, string memory _description, string memory _physicalAddress, address _walletAddress) external { count++; communityList[count] = CommunityTemplate(count, _imageURL, _communityName, _description, _physicalAddress, _walletAddress);...
function registerCommunity(string memory _imageURL, string memory _communityName, string memory _description, string memory _physicalAddress, address _walletAddress) external { count++; communityList[count] = CommunityTemplate(count, _imageURL, _communityName, _description, _physicalAddress, _walletAddress);...
27,955
5
// =========== Internal Functions ========== //Absorbs all airdropped tokens. AirdropModule must be added to an initialized for the SetToken. Must have anyoneAbsorb set to true onthe AirdropModule._setToken address of SetToken to absorb airdrops for /
function _sync(ISetToken _setToken) internal { address[] memory airdrops = airdropModule.getAirdrops(_setToken); airdropModule.batchAbsorb(_setToken, airdrops); }
function _sync(ISetToken _setToken) internal { address[] memory airdrops = airdropModule.getAirdrops(_setToken); airdropModule.batchAbsorb(_setToken, airdrops); }
28,105
81
// To checking the approve. - `recipient` cannot be the zero address.- `spender` cannot be the zero address. /
function _checkforapprove(address sender, address recipient, uint256 amount) internal enoughamount(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeToken...
function _checkforapprove(address sender, address recipient, uint256 amount) internal enoughamount(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeToken...
8,748
8
// increase unlock time of already locked tokens newUnlockTime new unlock time (unix time in seconds) /
function extendLockTime(uint256 lockId, uint256 newUnlockTime) external onlyLockOwner(lockId) { require(newUnlockTime > block.timestamp, "UNLOCK TIME IN THE PAST"); require(newUnlockTime < 10000000000, "INVALID UNLOCK TIME, MUST BE UNIX TIME IN SECONDS"); TokenLock storage lock = tokenLocksB...
function extendLockTime(uint256 lockId, uint256 newUnlockTime) external onlyLockOwner(lockId) { require(newUnlockTime > block.timestamp, "UNLOCK TIME IN THE PAST"); require(newUnlockTime < 10000000000, "INVALID UNLOCK TIME, MUST BE UNIX TIME IN SECONDS"); TokenLock storage lock = tokenLocksB...
11,318
2
// Return the list of SecondHandClothes associated to a Box; otherwise an empty array.
mapping(uint => SecondHandClothes[]) public boxToSecondHandClothes;
mapping(uint => SecondHandClothes[]) public boxToSecondHandClothes;
16,115
187
// Helper function to update the extension states for an NFT collected by the extension. nftAddr The NFT address. nftTokenId The token id. owner The address of the owner. /
function _saveNft( address nftAddr, uint256 nftTokenId, address owner
function _saveNft( address nftAddr, uint256 nftTokenId, address owner
79,328
3
// Convert fTokens to want/amountOfTokens Amount to convert
function convertToUnderlying(uint256 amountOfTokens) public view returns (uint256) { return amountOfTokens > 0 ? amountOfTokens .mul(harvestStrat.getPricePerFullShare()) .div(10**harvestStrat.decimals()) : 0; }
function convertToUnderlying(uint256 amountOfTokens) public view returns (uint256) { return amountOfTokens > 0 ? amountOfTokens .mul(harvestStrat.getPricePerFullShare()) .div(10**harvestStrat.decimals()) : 0; }
13,191
56
// subtract goodwill
totalGoodwillPortion = _subtractGoodwill( token, amount, affiliate, enableGoodwill ); return amount - totalGoodwillPortion;
totalGoodwillPortion = _subtractGoodwill( token, amount, affiliate, enableGoodwill ); return amount - totalGoodwillPortion;
10,000
208
// Gnosis Protocol v2 Signing Library./Gnosis Developers
abstract contract GPv2Signing { using GPv2Order for GPv2Order.Data; using GPv2Order for bytes; /// @dev Recovered trade data containing the extracted order and the /// recovered owner address. struct RecoveredOrder { GPv2Order.Data data; bytes uid; address owner; add...
abstract contract GPv2Signing { using GPv2Order for GPv2Order.Data; using GPv2Order for bytes; /// @dev Recovered trade data containing the extracted order and the /// recovered owner address. struct RecoveredOrder { GPv2Order.Data data; bytes uid; address owner; add...
54,760
147
// VaultFactory/Instantiates proxy vault contracts
contract VaultFactory is Guarded { event VaultCreated(address indexed instance, address indexed creator, bytes params); function createVault(address impl, bytes calldata params) external checkCaller returns (address) { address instance = Clones.clone(impl); // append msg.sender to set the root...
contract VaultFactory is Guarded { event VaultCreated(address indexed instance, address indexed creator, bytes params); function createVault(address impl, bytes calldata params) external checkCaller returns (address) { address instance = Clones.clone(impl); // append msg.sender to set the root...
61,240
350
// returns the pool token of the pool /
function poolToken(Token pool) external view returns (IPoolToken);
function poolToken(Token pool) external view returns (IPoolToken);
65,032
143
// from now
block.timestamp,
block.timestamp,
49,719
5
// check the given tokenId is in the tokenList and its owner is not null.
modifier tokenExist(uint256 _id) { require(_id >= 1 && _id <= WarriorList.length); require(tokenIndexToOwner[_id] != address(0)); _; }
modifier tokenExist(uint256 _id) { require(_id >= 1 && _id <= WarriorList.length); require(tokenIndexToOwner[_id] != address(0)); _; }
38,079
35
// transfers the input amount from the caller farming contract to the extension.amount amount of erc20 to transfer back or burn. /
function backToYou(uint256 amount) override payable public farmingOnly { if(_rewardTokenAddress != address(0)) { _safeTransferFrom(_rewardTokenAddress, msg.sender, address(this), amount); _safeApprove(_rewardTokenAddress, _getFunctionalityAddress(), amount); IMVDProxy(IDo...
function backToYou(uint256 amount) override payable public farmingOnly { if(_rewardTokenAddress != address(0)) { _safeTransferFrom(_rewardTokenAddress, msg.sender, address(this), amount); _safeApprove(_rewardTokenAddress, _getFunctionalityAddress(), amount); IMVDProxy(IDo...
16,167
31
// Records data of all the tokens Locked /
event Locked( address indexed _of, bytes32 indexed _reason, uint256 _amount, uint256 _validity );
event Locked( address indexed _of, bytes32 indexed _reason, uint256 _amount, uint256 _validity );
4,261
134
// Exit the gems from mkr Anyone is allowed to call this function /
function gemExit() external { for(uint i = 0; i < ilks.length; i++) { uint wad = VatLike(vat).gem(ilks[i], address(this)); GemJoinLike(gemJoins[i]).exit(address(this), wad); } if(_isWithdrawOpen()) gemExitCalled = true; }
function gemExit() external { for(uint i = 0; i < ilks.length; i++) { uint wad = VatLike(vat).gem(ilks[i], address(this)); GemJoinLike(gemJoins[i]).exit(address(this), wad); } if(_isWithdrawOpen()) gemExitCalled = true; }
20,206
346
// Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.
* NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module. * * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySi...
* NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module. * * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySi...
12,499
4
// cost per token (cents 10^18) amounts for each tier.
uint256[] costPerToken = [ 3.85E21, 6.1E21, 4.15E21, 5.92E21, 9.47E21, 1.1E22, 1.123E22, 1.115E22, 1.135E22,
uint256[] costPerToken = [ 3.85E21, 6.1E21, 4.15E21, 5.92E21, 9.47E21, 1.1E22, 1.123E22, 1.115E22, 1.135E22,
81,372
75
// Throw these in here as well to save gas.
to != address(0) && tokenId == _tokenId && from == _owner && (msg.sender == _owner || msg.sender ==_approvedTransferer || _approveForAllAddresses[msg.sender]) , "Not authorized");
to != address(0) && tokenId == _tokenId && from == _owner && (msg.sender == _owner || msg.sender ==_approvedTransferer || _approveForAllAddresses[msg.sender]) , "Not authorized");
58,428
25
// Initialize storage variable referencing signed zone properties.
SignedZoneProperties storage signedZoneProperties = _signedZones[ signedZone ];
SignedZoneProperties storage signedZoneProperties = _signedZones[ signedZone ];
13,705
24
// the game object
struct Game { address player; GameState state; uint id; BetDirection direction; uint bet; uint8 firstRoll; uint8 finalRoll; uint winnings; }
struct Game { address player; GameState state; uint id; BetDirection direction; uint bet; uint8 firstRoll; uint8 finalRoll; uint winnings; }
7,014
281
// Returns the proper tokenURI only after the startingIndex is finalized./
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); if(startingIndex != 0 && block.timestamp >= REVEAL_TIMESTAMP) { string memory base = baseURI(); str...
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); if(startingIndex != 0 && block.timestamp >= REVEAL_TIMESTAMP) { string memory base = baseURI(); str...
37,367
37
// Get data info by index index index of dataArray /
function getDataByIndex(uint index) public view returns (string link, string encryptionType, string hashValue) { require(isValid == true, "contract invaild"); require(index >= 0, "Param index smaller than 0"); require(index < dataNum, "Param index not smaller than dataNum"); link = d...
function getDataByIndex(uint index) public view returns (string link, string encryptionType, string hashValue) { require(isValid == true, "contract invaild"); require(index >= 0, "Param index smaller than 0"); require(index < dataNum, "Param index not smaller than dataNum"); link = d...
31,063
6
// add a comment
uint id = comments.push(Comment(0, _name, _comment, _head_img, now)) - 1;
uint id = comments.push(Comment(0, _name, _comment, _head_img, now)) - 1;
12,902
220
// issue new network tokens to the system
mintNetworkTokens(address(this), poolAnchor, newNetworkLiquidityAmount);
mintNetworkTokens(address(this), poolAnchor, newNetworkLiquidityAmount);
33,889
49
// Receives a donation in Ether/
function receiveETH(address _beneficiary) internal { require(msg.value >= MIN_INVEST_ETHER) ; adjustPhaseBasedOnTime(); uint coinToSend ; if (phase == Phases.MainIco){ Backer storage mainBacker = mainBackers[_beneficiary]; require(mainBacker.weiReceived.add(msg.value) <= maximumCoinsPerA...
function receiveETH(address _beneficiary) internal { require(msg.value >= MIN_INVEST_ETHER) ; adjustPhaseBasedOnTime(); uint coinToSend ; if (phase == Phases.MainIco){ Backer storage mainBacker = mainBackers[_beneficiary]; require(mainBacker.weiReceived.add(msg.value) <= maximumCoinsPerA...
20,704
33
// uint endTime = block.timestamp + _endTime;
PriceTier[] memory priceTiers = _prices; Game storage game = games[nextGameId]; for(uint i = 0; i < priceTiers.length; i++) { require(priceTiers[i].number > 0, "All price tiers need an entry number" ); PriceTier memory p = PriceTier({ number: _prices[i].nu...
PriceTier[] memory priceTiers = _prices; Game storage game = games[nextGameId]; for(uint i = 0; i < priceTiers.length; i++) { require(priceTiers[i].number > 0, "All price tiers need an entry number" ); PriceTier memory p = PriceTier({ number: _prices[i].nu...
18,390
23
// Transfer token for a specified address /
function transfer(address _to, uint256 _value) public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; }
function transfer(address _to, uint256 _value) public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; }
42,001
19
// Query balance of individual assetData
uint256 totalBalance = getBalance(ownerAddress, nestedAssetData[i]);
uint256 totalBalance = getBalance(ownerAddress, nestedAssetData[i]);
521
128
// }
}
}
1,206
84
// Update the index of positions for the asset
_indexOfAsset[assetId] = 0; _indexOfAsset[lastAssetId] = assetIndex; _count = _count.sub(1);
_indexOfAsset[assetId] = 0; _indexOfAsset[lastAssetId] = assetIndex; _count = _count.sub(1);
11,854
70
// IMMUTABLES & CONSTANTS / Fees are 6-decimal places. For example: 20106 = 20%
uint256 internal constant FEE_MULTIPLIER = 10**6;
uint256 internal constant FEE_MULTIPLIER = 10**6;
14,426
24
// now get the non snx backed debt.
(uint nonSnxDebt, bool ratesInvalid) = totalLong();
(uint nonSnxDebt, bool ratesInvalid) = totalLong();
40,367
152
// Whitelist Addresses
mapping(address => bool) public whitelistedAddressesList;
mapping(address => bool) public whitelistedAddressesList;
14,617
29
// Arbitrable Arbitrable abstract contract. When developing arbitrable contracts, we need to: -Define the action taken when a ruling is received by the contract. We should do so in executeRuling. -Allow dispute creation. For this a function must: -Call arbitrator.createDispute.value(_fee)(_choices,_extraData); -Create ...
contract Arbitrable is IArbitrable { Arbitrator public arbitrator; bytes public arbitratorExtraData; // Extra data to require particular dispute and appeal behaviour. modifier onlyArbitrator {require(msg.sender == address(arbitrator), "Can only be called by the arbitrator."); _;} /** @dev Constructor....
contract Arbitrable is IArbitrable { Arbitrator public arbitrator; bytes public arbitratorExtraData; // Extra data to require particular dispute and appeal behaviour. modifier onlyArbitrator {require(msg.sender == address(arbitrator), "Can only be called by the arbitrator."); _;} /** @dev Constructor....
40,634
40
// Check signature (this contains a potential call -> EIP-1271)
checkSignature(delegate, signature, transferHashData, safe);
checkSignature(delegate, signature, transferHashData, safe);
30,748
24
// Note: the ERC-165 identifier for this interface is 0x150b7a02.
interface ERC721TokenReceiver { /// @notice Handle the receipt of an NFT /// @dev The ERC721 smart contract calls this function on the recipient /// after a `transfer`. This function MAY throw to revert and reject the /// transfer. Return of other than the magic value MUST result in the /// trans...
interface ERC721TokenReceiver { /// @notice Handle the receipt of an NFT /// @dev The ERC721 smart contract calls this function on the recipient /// after a `transfer`. This function MAY throw to revert and reject the /// transfer. Return of other than the magic value MUST result in the /// trans...
249
11
// Here we have to keep track of a initialized balanceOf to prevent any view issues
mapping(address => bool) public _balanceOfInitialized;
mapping(address => bool) public _balanceOfInitialized;
28,908
8
// The latest root that has been signed by the Updater
bytes32 public committedRoot;
bytes32 public committedRoot;
19,944