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
36
// Returns the total amount of tokens minted in the contract. /
function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return _currentIndex - _startTokenId(); } }
function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return _currentIndex - _startTokenId(); } }
1,157
2
// Constant values used in ramping A calculations
uint256 private constant A_PRECISION = 100;
uint256 private constant A_PRECISION = 100;
624
46
// Fires on every unfreeze of tokens_owner address The owner address of unfrozen tokens.amount uint256 The amount of tokens unfrozen /
event TokenUnfreezeEvent(address indexed _owner, uint256 amount); event TokensBurned(address indexed _owner, uint256 _tokens); mapping(address => uint256) internal frozenTokenBalances;
event TokenUnfreezeEvent(address indexed _owner, uint256 amount); event TokensBurned(address indexed _owner, uint256 _tokens); mapping(address => uint256) internal frozenTokenBalances;
51,317
0
// At the core virtualgold is just a data record that is linked to each holders wallet address which stores the amount amount of virtualgold held by each of one them. The value of your virtualgold is always backed by ethereum in this smart contract.
virtualGoldTeam=0xd98F9E1191Ac53B1Af3E7A09Af53E08755B3DE9a; //This is the wallet address of the virtualgold team virtualGoldPrice = 0.000000001 ether; //This is the starting price of virtualgold per microgram. This value keeps increasing after every investment/virtualgold purchase. This value can never depr...
virtualGoldTeam=0xd98F9E1191Ac53B1Af3E7A09Af53E08755B3DE9a; //This is the wallet address of the virtualgold team virtualGoldPrice = 0.000000001 ether; //This is the starting price of virtualgold per microgram. This value keeps increasing after every investment/virtualgold purchase. This value can never depr...
41,278
35
// blocking the reception of a standard coin of network
receive() external payable { require(false, "The contract does not accept the base coin of network."); }
receive() external payable { require(false, "The contract does not accept the base coin of network."); }
10,947
108
// external token transfer_externalToken the token contract_to the destination address_value the amount of tokens to transfer return bool which represents success/
function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value) public onlyOwner returns(bool)
function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value) public onlyOwner returns(bool)
6,530
15
// Objects balances
mapping (address => mapping(uint256 => uint256)) internal balances;
mapping (address => mapping(uint256 => uint256)) internal balances;
50,947
528
// If using the last_order_id_twamm and it is expired, clear the pending order indicator
if (is_expired && (order_id_override == 0)) pending_twamm_order = false;
if (is_expired && (order_id_override == 0)) pending_twamm_order = false;
37,381
63
// calculate your rewards
function calculateReward(address userAddress) public view returns (uint256 _reward, uint256 _tax) { uint256 cycleStartTime = government.getCycleStartTime(); uint256 amount = 0; uint256 ris3Amount = getUserBalance(userAddress); uint256 percnt = ris3Amount.mul(100000000); // to get per...
function calculateReward(address userAddress) public view returns (uint256 _reward, uint256 _tax) { uint256 cycleStartTime = government.getCycleStartTime(); uint256 amount = 0; uint256 ris3Amount = getUserBalance(userAddress); uint256 percnt = ris3Amount.mul(100000000); // to get per...
1,466
11
// rebaseFeeRate must be a number between 1 and 99 (in 18 decimal)
require(newRebaseFeeRate < (100 ether) && newRebaseFeeRate > (0 ether), "New rebase fee rate out of range"); emit ParameterChange("rebaseFeeRate", newRebaseFeeRate, _rebaseFeeRate); _rebaseFeeRate = newRebaseFeeRate;
require(newRebaseFeeRate < (100 ether) && newRebaseFeeRate > (0 ether), "New rebase fee rate out of range"); emit ParameterChange("rebaseFeeRate", newRebaseFeeRate, _rebaseFeeRate); _rebaseFeeRate = newRebaseFeeRate;
23,293
33
// This value is only used as the check below which currently never reverts uint16 versionMinor = UnsafeBytesLib.toUint16(encoded, index);
index += 2;
index += 2;
25,471
29
// Calculate the square root of the perfect square of a power of two that is the closest to x.
uint xAux = uint(x); result = 1; if (xAux >= 0x100000000000000000000000000000000) { xAux >>= 128; result <<= 64; }
uint xAux = uint(x); result = 1; if (xAux >= 0x100000000000000000000000000000000) { xAux >>= 128; result <<= 64; }
15,942
382
// discountedBorrowDenominatedCollateral = [supplyCurrent / (1 + liquidationDiscount)](Oracle price for the collateral / Oracle price for the borrow)return Return values are expressed in 1e18 scale /
function calculateDiscountedBorrowDenominatedCollateral( Exp memory underwaterAssetPrice, Exp memory collateralPrice, uint256 supplyCurrent_TargetCollateralAsset
function calculateDiscountedBorrowDenominatedCollateral( Exp memory underwaterAssetPrice, Exp memory collateralPrice, uint256 supplyCurrent_TargetCollateralAsset
17,568
31
// Owner can allow transfers for a particular address. Use for crowdsale contract.
function setTransferAdmin(address _addr, bool _canTransfer) onlyOwner public { transferAdmins[_addr] = _canTransfer; }
function setTransferAdmin(address _addr, bool _canTransfer) onlyOwner public { transferAdmins[_addr] = _canTransfer; }
45,093
277
// Allows users to deposit tokens and burn them in order to protect them from debasing. amount The amount of tokens to deposit and burn. The deposited tokens are burned, reducing the total supply of tokens in circulation. The user's deposit amount is recorded, and the tokens are locked for a period of time, after which...
* @dev Emits a {Deposit} event with the user's address and deposit amount. */ function deposit(uint amount) external { require(amount > 0, "zero amount"); require(!isExcludedFromDebase[msg.sender], "excluded from debase"); Depositor storage depositor = depositors[msg.sender]; ...
* @dev Emits a {Deposit} event with the user's address and deposit amount. */ function deposit(uint amount) external { require(amount > 0, "zero amount"); require(!isExcludedFromDebase[msg.sender], "excluded from debase"); Depositor storage depositor = depositors[msg.sender]; ...
36,136
1
// key : auth, value : duration (blocks)
mapping(address => uint256) internal _authorized_duration;
mapping(address => uint256) internal _authorized_duration;
9,963
52
// Provides information about the current execution context, including thesender of the transaction and its data. While these are generally availablevia msg.sender and msg.data, they should not be accessed in such a directmanner, since when dealing with meta-transactions the account sending andpaying for execution may ...
abstract contract Context { function _msgSender() internal view virtual returns(address) { return msg.sender; } function _msgData() internal view virtual returns(bytes calldata) { return msg.data; } }
abstract contract Context { function _msgSender() internal view virtual returns(address) { return msg.sender; } function _msgData() internal view virtual returns(bytes calldata) { return msg.data; } }
26,144
1
// Calculates and returns 'self - other' The function will throw if the operation would result in an underflow.
function exactSub(uint self, uint other) internal pure returns (uint diff) { require(other <= self); diff = self - other; }
function exactSub(uint self, uint other) internal pure returns (uint diff) { require(other <= self); diff = self - other; }
22,876
501
// close on this chain
_closeSecondary(snxBackedDebt, debtSharesSupply);
_closeSecondary(snxBackedDebt, debtSharesSupply);
34,233
149
// Root updaters can update the root
function _onlyRootUpdater() internal view { require(hasRole(ROOT_UPDATER_ROLE, msg.sender), "onlyRootUpdater"); }
function _onlyRootUpdater() internal view { require(hasRole(ROOT_UPDATER_ROLE, msg.sender), "onlyRootUpdater"); }
1,855
19
// If over vesting duration, all tokens vested
if (elapsedYears >= tokenGrant.vestingDuration) { uint256 remainingGrant = tokenGrant.amount.sub(tokenGrant.totalClaimed); uint256 remainingYears = tokenGrant.vestingDuration.sub(tokenGrant.yearsClaimed); return (remainingYears, remainingGrant); } else {
if (elapsedYears >= tokenGrant.vestingDuration) { uint256 remainingGrant = tokenGrant.amount.sub(tokenGrant.totalClaimed); uint256 remainingYears = tokenGrant.vestingDuration.sub(tokenGrant.yearsClaimed); return (remainingYears, remainingGrant); } else {
372
41
// _niftyRegistryContract Points to the repository of authenticated/
constructor(address _niftyRegistryContract) { niftyRegistryContract = _niftyRegistryContract; }
constructor(address _niftyRegistryContract) { niftyRegistryContract = _niftyRegistryContract; }
15,955
189
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(base, tokenId.toString()));
return string(abi.encodePacked(base, tokenId.toString()));
47,391
72
// If applicable, set the last pause time.
if (paused) { lastPauseTime = now; }
if (paused) { lastPauseTime = now; }
133
33
// force reserves to match balances
function sync() external override nonReentrant { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); }
function sync() external override nonReentrant { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); }
45,440
7
// TokenStorage External storage for tokens.The storage is implemented in a separate contract to maintain statebetween token upgrades. /
contract TokenStorage is Claimable, CanReclaimToken, NoOwner { using TokenStorageLib for TokenStorageLib.TokenStorage; TokenStorageLib.TokenStorage internal tokenStorage; /** * @dev Increases balance of an address. * @param to Address to increase. * @param amount Number of units to add. ...
contract TokenStorage is Claimable, CanReclaimToken, NoOwner { using TokenStorageLib for TokenStorageLib.TokenStorage; TokenStorageLib.TokenStorage internal tokenStorage; /** * @dev Increases balance of an address. * @param to Address to increase. * @param amount Number of units to add. ...
13,665
4
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) { IUniswapV2Factory(factory).createPair(tokenA, tokenB); }
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) { IUniswapV2Factory(factory).createPair(tokenA, tokenB); }
26,929
169
// calculate the referrer amount
search.currentReferrerAmount = search.currentLevelDiff * search.levelDiffAmountPerLevel;
search.currentReferrerAmount = search.currentLevelDiff * search.levelDiffAmountPerLevel;
26,764
133
// index Index of transaction to remove. Transaction ordering may have changed since adding. /
function removeTransaction(uint index) external onlyOwner
function removeTransaction(uint index) external onlyOwner
21,427
92
// Credit auctionner balance
pendingWithdrawals[_auctioneer] += auctioneerCut; return true;
pendingWithdrawals[_auctioneer] += auctioneerCut; return true;
7,790
1
// exposing the safe mint functionality
function safeMint(address to, uint256 tokenId) public { require(msg.sender == owner, "NFTBase: Only owner can mint"); _safeMint(to, tokenId); }
function safeMint(address to, uint256 tokenId) public { require(msg.sender == owner, "NFTBase: Only owner can mint"); _safeMint(to, tokenId); }
11,226
76
// Mapping containing which addresses are whitelisted/
mapping (address => bool) public whitelist;
mapping (address => bool) public whitelist;
7,005
223
// Staking State View Functions /
{ require(tokenId <= tokenIdCounter, "not existent"); StakingInfo storage stakingInfo = stakingInfos[tokenId]; if (stakingInfo.unstakeTime > 0) { return 0; } StakingPlan storage stakingPlan = stakingPlans[stakingInfo.stakingPlan]; // calculate compound...
{ require(tokenId <= tokenIdCounter, "not existent"); StakingInfo storage stakingInfo = stakingInfos[tokenId]; if (stakingInfo.unstakeTime > 0) { return 0; } StakingPlan storage stakingPlan = stakingPlans[stakingInfo.stakingPlan]; // calculate compound...
55,790
11
// get the RLP item by index. save gas. /
function getItemByIndex(RLPItem memory item, uint idx) internal pure returns (RLPItem memory) { require(isList(item), "RLPDecoder iterator is not a list"); uint memPtr = item.memPtr + _payloadOffset(item.memPtr); uint dataLen; for (uint i = 0; i < idx; i++) { dataLen = _...
function getItemByIndex(RLPItem memory item, uint idx) internal pure returns (RLPItem memory) { require(isList(item), "RLPDecoder iterator is not a list"); uint memPtr = item.memPtr + _payloadOffset(item.memPtr); uint dataLen; for (uint i = 0; i < idx; i++) { dataLen = _...
22,280
444
// compound the cumulated interest to the borrow balance and then subtracting the payback amount
if (borrowRateMode == CoreLibrary.InterestRateMode.STABLE) { reserve.increaseTotalBorrowsStableAndUpdateAverageRate( _balanceIncrease, user.stableBorrowRate ); reserve.decreaseTotalBorrowsStableAndUpdateAverageRate( _paybackAmou...
if (borrowRateMode == CoreLibrary.InterestRateMode.STABLE) { reserve.increaseTotalBorrowsStableAndUpdateAverageRate( _balanceIncrease, user.stableBorrowRate ); reserve.decreaseTotalBorrowsStableAndUpdateAverageRate( _paybackAmou...
7,074
25
// replace selector with last selector
if (oldFacet.selectorPosition != selectorCount - 1) { bytes4 lastSelector = ds.selectors[selectorCount - 1]; ds.selectors[oldFacet.selectorPosition] = lastSelector; ds.facets[lastSelector].selectorPosition = oldFacet.selectorPosition; }
if (oldFacet.selectorPosition != selectorCount - 1) { bytes4 lastSelector = ds.selectors[selectorCount - 1]; ds.selectors[oldFacet.selectorPosition] = lastSelector; ds.facets[lastSelector].selectorPosition = oldFacet.selectorPosition; }
78,269
161
// add delegates to the minter
_moveDelegates(address(0), _delegates[to], amount); emit Mint(to, scaledAmount); emit Transfer(address(0), to, scaledAmount);
_moveDelegates(address(0), _delegates[to], amount); emit Mint(to, scaledAmount); emit Transfer(address(0), to, scaledAmount);
79,476
30
// Throws if called by any account other than the owner. /
modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; }
modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; }
505
138
// src// pragma solidity >=0.8.10; /
/* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */ /* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */ /* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */ /* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ /* import {ERC20} from "lib/openzeppeli...
/* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */ /* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */ /* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */ /* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ /* import {ERC20} from "lib/openzeppeli...
50,785
73
// Checks that amount desired can be purchased, then adds purchased amount to buyer and to total sold.
consumeBlaq(msg.sender, amount); _tokensSold += amount;
consumeBlaq(msg.sender, amount); _tokensSold += amount;
24,000
273
// Sets provenance once it's calculated
function setProvenanceHash(string memory provenanceHash) public onlyOwner { SUBSTANDARD_PROVENANCE = provenanceHash; }
function setProvenanceHash(string memory provenanceHash) public onlyOwner { SUBSTANDARD_PROVENANCE = provenanceHash; }
31,388
35
// computes "MAX_WEIGHTa / (a + b)" and "MAX_WEIGHTb / (a + b)", assuming that "a <= b". /
function accurateWeights(uint256 _a, uint256 _b) public pure returns (uint32, uint32)
function accurateWeights(uint256 _a, uint256 _b) public pure returns (uint32, uint32)
1,509
2
// Perform tasks (clubbed all functions into one to reduce external calls & SAVE GAS FEE) Breakdown of functions written below
manager.performTasks();
manager.performTasks();
20,720
6
// Check if strategy has tokens from panic
if (_wantAmt > wantAmt) { _vaultWithdraw(_wantAmt - wantAmt); wantAmt = IERC20(wantAddress).balanceOf(address(this)); }
if (_wantAmt > wantAmt) { _vaultWithdraw(_wantAmt - wantAmt); wantAmt = IERC20(wantAddress).balanceOf(address(this)); }
1,898
15
// Stores the parameters for a settlement after liquidation process
struct SettleParams { FixedPoint.Unsigned feeAttenuation; FixedPoint.Unsigned settlementPrice; FixedPoint.Unsigned tokenRedemptionValue; FixedPoint.Unsigned collateral; FixedPoint.Unsigned disputerDisputeReward; FixedPoint.Unsigned sponsorDisputeReward; FixedPoint.Unsigned disputeBondAmoun...
struct SettleParams { FixedPoint.Unsigned feeAttenuation; FixedPoint.Unsigned settlementPrice; FixedPoint.Unsigned tokenRedemptionValue; FixedPoint.Unsigned collateral; FixedPoint.Unsigned disputerDisputeReward; FixedPoint.Unsigned sponsorDisputeReward; FixedPoint.Unsigned disputeBondAmoun...
9,578
121
// True if epoch has been wound down already
mapping(uint256=>bool) public epoch_wound_down; uint256 public last_deploy; // Last run of Hourly Deploy uint256 public deploy_interval; // Hourly deploy interval
mapping(uint256=>bool) public epoch_wound_down; uint256 public last_deploy; // Last run of Hourly Deploy uint256 public deploy_interval; // Hourly deploy interval
5,609
32
// Returns the number of vesting schedules managed by this contract.return the number of vesting schedules /
function getVestingSchedulesCount() public view returns (uint256) { return vestingSchedulesIds.length; }
function getVestingSchedulesCount() public view returns (uint256) { return vestingSchedulesIds.length; }
15,901
11
// unlocks a slot on an avatar avatarId the avatar to upgrade slot 0-12 inclusive for the slot to unlockreturn the id of the new avatar (old one is burned) /
function unlock(uint256 avatarId, uint16 slot) external nonReentrant onlyUnlocked returns (uint256) { require(ownerOf(avatarId) == _msgSender(), "Invalid avatar"); require(slot < EthlingUtils.MAX_SLOTS(), "Invalid slot"); uint256 newAvatarId = EthlingUtils.addSlot(avatarId, slot); av...
function unlock(uint256 avatarId, uint16 slot) external nonReentrant onlyUnlocked returns (uint256) { require(ownerOf(avatarId) == _msgSender(), "Invalid avatar"); require(slot < EthlingUtils.MAX_SLOTS(), "Invalid slot"); uint256 newAvatarId = EthlingUtils.addSlot(avatarId, slot); av...
10,086
62
// allows to burn tokens from own balance only allows burning tokens until minimum supply is reached value amount of tokens to burn /
function burn(uint256 value) public { _burn(_msgSender(), value); require(totalSupply() >= minSupply, "total supply exceeds min supply"); }
function burn(uint256 value) public { _burn(_msgSender(), value); require(totalSupply() >= minSupply, "total supply exceeds min supply"); }
7,182
19
// Log account that triggered the election cycle as well as the block timestamp
emit ElectionCycleTriggered(msg.sender, block.timestamp);
emit ElectionCycleTriggered(msg.sender, block.timestamp);
21,450
107
// Value used as divisor with the VIX, commonly used for many financial indices
uint256 public divisor;
uint256 public divisor;
5,173
53
// Core pool will pull the `balance` of token from this contract into the pool. Core pool will also make a state change: update the `_records` mapping with a new record.
optionPool_.bind(token_, balance, denorm); emit PoolBoundTokenUpdate(msg.sender, token_, balance, denorm);
optionPool_.bind(token_, balance, denorm); emit PoolBoundTokenUpdate(msg.sender, token_, balance, denorm);
40,097
4
// Cross-chain Functions// Complete a deposit from L1 to L2, and credits funds to the recipient's balance of thisL2 token. This call will fail if it did not originate from a corresponding deposit inL1StandardTokenBridge. _l1Token Address for the l1 token this is called with _l2Token Address for the l2 token this is cal...
function finalizeDeposit(
function finalizeDeposit(
17,464
30
// after 1,270,500 tokens burnt, supply is expanded by 637,500 tokens
if(_tBurnCycle >= (1275000 * _DECIMALFACTOR)){ uint256 _tRebaseDelta = 637500 * _DECIMALFACTOR; _tBurnCycle = _tBurnCycle.sub((1275000 * _DECIMALFACTOR)); _tTradeCycle = 0; _setBurnFee(500); _rebase(_tRebaseDelta); }
if(_tBurnCycle >= (1275000 * _DECIMALFACTOR)){ uint256 _tRebaseDelta = 637500 * _DECIMALFACTOR; _tBurnCycle = _tBurnCycle.sub((1275000 * _DECIMALFACTOR)); _tTradeCycle = 0; _setBurnFee(500); _rebase(_tRebaseDelta); }
28,109
4
// approve the position manager up to the maximum token amounts
TransferHelper.safeApprove(params.token0, nonfungiblePositionManager, amount0V2ToMigrate); TransferHelper.safeApprove(params.token1, nonfungiblePositionManager, amount1V2ToMigrate);
TransferHelper.safeApprove(params.token0, nonfungiblePositionManager, amount0V2ToMigrate); TransferHelper.safeApprove(params.token1, nonfungiblePositionManager, amount1V2ToMigrate);
15,549
72
// getNumFulfillments() returns the number of fulfillments for a given milestone/_bountyId the index of the bounty/ return Returns the number of fulfillments
function getNumFulfillments(uint _bountyId) public constant validateBountyArrayIndex(_bountyId) returns (uint)
function getNumFulfillments(uint _bountyId) public constant validateBountyArrayIndex(_bountyId) returns (uint)
6,851
6
// check if exceeding current limit
if(amount > currentBalance()) { amount = currentBalance(); tranches = amount / oneTrancheAmount(); }
if(amount > currentBalance()) { amount = currentBalance(); tranches = amount / oneTrancheAmount(); }
4,659
19
// View function to see pending AMDX on frontend./_pid The index of the pool. See `poolInfo`./_user Address of user./ return pending AMDX reward for a given user.
function pendingAmdx(uint256 _pid, address _user) external view returns (uint256 pending) { PoolInfo memory pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accAmdxPerShare = pool.accAmdxPerShare; if (block.number > pool.lastRewardBlock && pool.totalLp !=...
function pendingAmdx(uint256 _pid, address _user) external view returns (uint256 pending) { PoolInfo memory pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accAmdxPerShare = pool.accAmdxPerShare; if (block.number > pool.lastRewardBlock && pool.totalLp !=...
13,136
3
// Lot object
struct Lot { address nft; address payable seller; uint256 tokenId; Types offerType; uint256 price; uint256 stopPrice; uint256 reservePrice; uint256 auctionStart; uint256 auctionEnd; bool isSold; bool isCanceled; }
struct Lot { address nft; address payable seller; uint256 tokenId; Types offerType; uint256 price; uint256 stopPrice; uint256 reservePrice; uint256 auctionStart; uint256 auctionEnd; bool isSold; bool isCanceled; }
57,781
166
// built by mice, for everyone/
contract Randomice is ERC721, Ownable, ReentrancyGuard { using Strings for uint256; string public baseURI; uint256 public cost = 0.025 ether; uint256 public minted; uint256 public maxSupply = 6969; //nice uint256 public maxMint = 10; bool public status = false; address miceAddr = 0xbad6186E92002E312078...
contract Randomice is ERC721, Ownable, ReentrancyGuard { using Strings for uint256; string public baseURI; uint256 public cost = 0.025 ether; uint256 public minted; uint256 public maxSupply = 6969; //nice uint256 public maxMint = 10; bool public status = false; address miceAddr = 0xbad6186E92002E312078...
77,035
504
// Give an account access to this role./
function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; }
function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; }
25,077
384
// Validate message format
_originalMsg._validateMessageFormat();
_originalMsg._validateMessageFormat();
16,979
219
// Switches to a new {IRelayHub} instance. This method is added for future-proofing: there's no reason to notuse the default instance. IMPORTANT: After upgrading, the {GSNRecipient} will no longer be able to receive relayed calls from the old{IRelayHub} instance. Additionally, all funds should be previously withdrawn v...
function _upgradeRelayHub(address newRelayHub) internal { address currentRelayHub = _relayHub; require(newRelayHub != address(0), "GSNRecipient: new RelayHub is the zero address"); require(newRelayHub != currentRelayHub, "GSNRecipient: new RelayHub is the current one"); emit RelayHu...
function _upgradeRelayHub(address newRelayHub) internal { address currentRelayHub = _relayHub; require(newRelayHub != address(0), "GSNRecipient: new RelayHub is the zero address"); require(newRelayHub != currentRelayHub, "GSNRecipient: new RelayHub is the current one"); emit RelayHu...
37,339
147
// Executes the Auto Redistribution event by isolating the bAsset from the Basket _basketStruct containing core basket info _bAssetPersonalBasset data storage array _bAssetAddress of the ERC20 token to isolate _belowPegBool to describe whether the bAsset deviated below peg (t)or above (f) /
function handlePegLoss( MassetStructs.BasketState storage _basket, MassetStructs.BassetPersonal[] storage _bAssetPersonal, mapping(address => uint8) storage _bAssetIndexes, address _bAsset, bool _belowPeg
function handlePegLoss( MassetStructs.BasketState storage _basket, MassetStructs.BassetPersonal[] storage _bAssetPersonal, mapping(address => uint8) storage _bAssetIndexes, address _bAsset, bool _belowPeg
15,784
2
// Voter[] vtr_list; /
constructor() ERC721("Real Estate Agent", "REA") { creater = msg.sender; prices = new uint256[](4); maxCounts = new uint256[](4); currentCounts = new uint256[](4); prices[1] = 0.1 ether; prices[2] = 0.05 ether; prices[3] = 0.01 ether; maxCoun...
constructor() ERC721("Real Estate Agent", "REA") { creater = msg.sender; prices = new uint256[](4); maxCounts = new uint256[](4); currentCounts = new uint256[](4); prices[1] = 0.1 ether; prices[2] = 0.05 ether; prices[3] = 0.01 ether; maxCoun...
21,356
5
// does the customer purchase exceed the max Founder quota?
(FounderAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= FounderMaxPurchase_ );
(FounderAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= FounderMaxPurchase_ );
48,194
1
// ============ Properties ============
mapping(address => bool) public isWatcher;
mapping(address => bool) public isWatcher;
26,631
2
// compute the return for the amount of tokens provided
(uint256 sourceToDestRate, uint256 sourceToDestPrecision) = IPriceFeeds(priceFeeds).queryRate(address(_path[0]), address(_path[1])); uint256 actualReturn = _amount.mul(sourceToDestRate).div(sourceToDestPrecision); require(actualReturn >= _minReturn, "insufficient source tokens provi...
(uint256 sourceToDestRate, uint256 sourceToDestPrecision) = IPriceFeeds(priceFeeds).queryRate(address(_path[0]), address(_path[1])); uint256 actualReturn = _amount.mul(sourceToDestRate).div(sourceToDestPrecision); require(actualReturn >= _minReturn, "insufficient source tokens provi...
27,792
97
// calculate fee:
(uint256 transferToAmount, uint256 transferToFeeDistributorAmount) = calculateAmountsAfterFee(sender, recipient, amount); uint256 timeNow = block.timestamp; if(timeNow < transData[sender] + 10 minutes){ revert("CAN ONLY TRADE 5 DUCK PER 10 MIN"); }
(uint256 transferToAmount, uint256 transferToFeeDistributorAmount) = calculateAmountsAfterFee(sender, recipient, amount); uint256 timeNow = block.timestamp; if(timeNow < transData[sender] + 10 minutes){ revert("CAN ONLY TRADE 5 DUCK PER 10 MIN"); }
14,307
37
// Set approved borrowers
for (uint256 i = 0; i < _approvedBorrowers.length; ++i) { approvedBorrowers[_approvedBorrowers[i]] = true; }
for (uint256 i = 0; i < _approvedBorrowers.length; ++i) { approvedBorrowers[_approvedBorrowers[i]] = true; }
48,549
39
// store subjects
mapping(address => uint128[]) public studentSubjects;
mapping(address => uint128[]) public studentSubjects;
24,582
525
// Check if the deposit has indeed exceeded the time limit of if the exchange is in withdrawal mode
require( block.timestamp >= deposit.timestamp + S.maxAgeDepositUntilWithdrawable || S.isInWithdrawalMode(), "DEPOSIT_NOT_WITHDRAWABLE_YET" ); uint amount = deposit.amount;
require( block.timestamp >= deposit.timestamp + S.maxAgeDepositUntilWithdrawable || S.isInWithdrawalMode(), "DEPOSIT_NOT_WITHDRAWABLE_YET" ); uint amount = deposit.amount;
9,390
77
// When more calls in the same block, only the first one takes effect, so for the following calls, nothing updates.
if (block.number != accrualBlockNumber) { InterestLocalVars memory _vars; _vars.currentCash = _getCurrentCash(); _vars.totalBorrows = totalBorrows; _vars.totalReserves = totalReserves;
if (block.number != accrualBlockNumber) { InterestLocalVars memory _vars; _vars.currentCash = _getCurrentCash(); _vars.totalBorrows = totalBorrows; _vars.totalReserves = totalReserves;
71,411
2
// bring everything back one index
for (uint i = self[0] + 1; i < self.length ; ++i) { self[i-1] = self[i]; }
for (uint i = self[0] + 1; i < self.length ; ++i) { self[i-1] = self[i]; }
17,741
10
// Publishes an instruction for the delivery provider at `deliveryProviderAddress`to relay a payload and VAAs specified by `vaaKeys` to the address `targetAddress` on chain `targetChain`with `msg.value` equal toreceiverValue + (arbitrary amount that is paid for by paymentForExtraReceiverValue of this chain's wei) in ta...
function send(
function send(
15,599
645
// The top byte of ret has already been cleared to make room for the new digit. Upshift by 31 bytes to put it in position, and OR it with ret to leave the other characters untouched.
ret |= utf8Digit << (31 * bitsPerByte);
ret |= utf8Digit << (31 * bitsPerByte);
12,186
8
// Enables a module that can add transactions to the queue/module Address of the module to be enabled/This can only be called by the owner
function enableModule(address module) public onlyOwner { require( module != address(0) && module != SENTINEL_MODULES, "Invalid module" ); require(modules[module] == address(0), "Module already enabled"); modules[module] = modules[SENTINEL_MODULES]; mod...
function enableModule(address module) public onlyOwner { require( module != address(0) && module != SENTINEL_MODULES, "Invalid module" ); require(modules[module] == address(0), "Module already enabled"); modules[module] = modules[SENTINEL_MODULES]; mod...
28,226
27
// Only `owner` can update the config if it didn't start yet. /
function updateConfig(Config memory config) public onlyOwner notCancelled beforeStarted { _updateConfig(config); }
function updateConfig(Config memory config) public onlyOwner notCancelled beforeStarted { _updateConfig(config); }
43,635
2
// a settings contract controlled by governance
address public immutable settings;
address public immutable settings;
63,011
15
// Check to see if the duration is too long and if it is set the duration.
(,, m.parentExpiry) = nameWrappers[nameWrapperVersion].getData(uint256(parentNode)); if (m.nodeExpiry + duration > m.parentExpiry) { duration = m.parentExpiry - m.nodeExpiry; }
(,, m.parentExpiry) = nameWrappers[nameWrapperVersion].getData(uint256(parentNode)); if (m.nodeExpiry + duration > m.parentExpiry) { duration = m.parentExpiry - m.nodeExpiry; }
13,914
23
// Returns the ExtensionManager storage.
function _extensionManagerStorage() internal pure returns (ExtensionManagerStorage.Data storage data) { data = ExtensionManagerStorage.data(); }
function _extensionManagerStorage() internal pure returns (ExtensionManagerStorage.Data storage data) { data = ExtensionManagerStorage.data(); }
31,057
3
// check current expiry
uint256 currentExpiryTime = s_localAccessList[user][data];
uint256 currentExpiryTime = s_localAccessList[user][data];
7,648
293
// contracts/Pool.sol/ pragma solidity 0.6.11; // import "lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol"; // import "./interfaces/IBPool.sol"; // import "./interfaces/IDebtLocker.sol"; // import "./interfaces/IMapleGlobals.sol"; // import "./interfaces/ILiquidityLocker.sol"; // import "./interfaces/ILi...
contract Pool is PoolFDT { using SafeMath for uint256; using SafeERC20 for IERC20; uint256 constant WAD = 10 ** 18; uint8 public constant DL_FACTORY = 1; // Factory type of `DebtLockerFactory`. IERC20 public immutable liquidityAsset; // The asset deposited by Lenders into the LiquidityLocker...
contract Pool is PoolFDT { using SafeMath for uint256; using SafeERC20 for IERC20; uint256 constant WAD = 10 ** 18; uint8 public constant DL_FACTORY = 1; // Factory type of `DebtLockerFactory`. IERC20 public immutable liquidityAsset; // The asset deposited by Lenders into the LiquidityLocker...
60,233
85
// We need to manually run the static call since the getter cannot be flagged as view bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b"); require(success); return abi.decode(returndata, (address));
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b"); require(success); return abi.decode(returndata, (address));
9,561
0
// FAWC max supply will be 10k NFTs. Upon launch, we will temporarily lower this to500 to hard-cap a limited presale. After that, we will bump it back to 10k. The setMaxSupply() function below can never allow more than 10k.
uint public maxSupply = 10000; uint public mintPrice = 0.2 ether; uint public promoPrice = 0.2 ether; bool public presaleIsLive = false; string public provenanceHash; uint public reservedNFTs; bool public saleIsLive = false; uint public transactionLimit = 10; // ETH-mint limit ...
uint public maxSupply = 10000; uint public mintPrice = 0.2 ether; uint public promoPrice = 0.2 ether; bool public presaleIsLive = false; string public provenanceHash; uint public reservedNFTs; bool public saleIsLive = false; uint public transactionLimit = 10; // ETH-mint limit ...
30,765
11
// STOP or JUMP or RETURN or INVALID (Note: REVERT is blacklisted, so not included here) We are now inside unreachable code until we hit a JUMPDEST!
do { _pc++; assembly { opNum := byte(0, mload(_pc)) }
do { _pc++; assembly { opNum := byte(0, mload(_pc)) }
24,669
346
// Emitted when a Safe is gibbed./user The user who gibbed the Safe./to The recipient of the impounded collateral./assetAmount The amount of underling tokens impounded.
event SafeGibbed(address indexed user, address indexed to, uint256 assetAmount);
event SafeGibbed(address indexed user, address indexed to, uint256 assetAmount);
80,778
177
// it is not allowed to pass messages while other messages are processed
require(messageId() == bytes32(0)); require(_gas >= getMinimumGasUsage(_data) && _gas <= maxGasPerTx()); bytes32 _messageId; bytes memory header = _packHeader(_contract, _gas, _dataType); _setNonce(_nonce() + 1); assembly { _messageId := mload(add(header, 3...
require(messageId() == bytes32(0)); require(_gas >= getMinimumGasUsage(_data) && _gas <= maxGasPerTx()); bytes32 _messageId; bytes memory header = _packHeader(_contract, _gas, _dataType); _setNonce(_nonce() + 1); assembly { _messageId := mload(add(header, 3...
7,734
2
// Redemption errors
error InvalidCampaignId(); error CampaignAlreadyExists(); error InvalidCaller(address caller); error NotActive(uint256 currentTimestamp, uint256 startTime, uint256 endTime); error MaxRedemptionsReached(uint256 total, uint256 max); error MaxCampaignRedemptionsReached(uint256 total, uint256 max); ...
error InvalidCampaignId(); error CampaignAlreadyExists(); error InvalidCaller(address caller); error NotActive(uint256 currentTimestamp, uint256 startTime, uint256 endTime); error MaxRedemptionsReached(uint256 total, uint256 max); error MaxCampaignRedemptionsReached(uint256 total, uint256 max); ...
9,995
69
// Settlement only happens when state == Disputed and will only happen once per liquidation. If this liquidation is not ready to be settled, this method should return immediately.
if (liquidation.state != Status.Disputed) { return; }
if (liquidation.state != Status.Disputed) { return; }
19,195
69
// iterate through future sequences until a price update is found sequence corresponding to current timestamp used as upper bound
uint256 currentPriceUpdateSequenceId = block.timestamp / (256 hours); while (sequence == 0 && sequenceId <= currentPriceUpdateSequenceId) { sequence = l.priceUpdateSequences[++sequenceId]; }
uint256 currentPriceUpdateSequenceId = block.timestamp / (256 hours); while (sequence == 0 && sequenceId <= currentPriceUpdateSequenceId) { sequence = l.priceUpdateSequences[++sequenceId]; }
51,299
52
// Returns whether `spender` is allowed to consume `tokenId`. Requirements: - `tokenId` must exist. /
function isConsumerOf(address spender, uint256 tokenId) internal view returns (bool)
function isConsumerOf(address spender, uint256 tokenId) internal view returns (bool)
17,119
25
// Load the rune into the MSBs of b
assembly { word:= mload(mload(add(self, 32))) }
assembly { word:= mload(mload(add(self, 32))) }
4,181
10
// The element is removed from the linked list, but the node retains/ information on which predecessor it had, so that a node in the chain/ can be reached by following the predecessor chain of deleted elements.
function removeKeepHistory(Data storage self, bytes32 elementToRemove) internal returns (bool)
function removeKeepHistory(Data storage self, bytes32 elementToRemove) internal returns (bool)
34,228
44
// mint OHM needed and store amount of rewards for distribution
send_ = value.sub( _profit ); IERC20Mintable( OHM ).mint( msg.sender, send_ ); totalReserves = totalReserves.add( value ); emit ReservesUpdated( totalReserves ); emit Deposit( _token, _amount, value );
send_ = value.sub( _profit ); IERC20Mintable( OHM ).mint( msg.sender, send_ ); totalReserves = totalReserves.add( value ); emit ReservesUpdated( totalReserves ); emit Deposit( _token, _amount, value );
15,304
1
// Transfers a given amount of currency.
function transferCurrency( address _currency, address _from, address _to, uint256 _amount ) internal { if (_amount == 0) { return; }
function transferCurrency( address _currency, address _from, address _to, uint256 _amount ) internal { if (_amount == 0) { return; }
2,833
12
// safe to cast because amount is positive
_mint(dst, uint104(wrapperPostPrinc - wrapperPrePrinc));
_mint(dst, uint104(wrapperPostPrinc - wrapperPrePrinc));
7,909
284
// create a bool to track if we have a non number character
bool _hasNonNumber;
bool _hasNonNumber;
33,428
105
// fallback function can be used to buy tokens /
receive() external payable { buyTokens(); }
receive() external payable { buyTokens(); }
4,578
54
// Sets the developer wallet. developerWallet The new developer wallet. /
function setDeveloperWallet( address developerWallet
function setDeveloperWallet( address developerWallet
30,895