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
33
// return information
return (swap.cbdc1Address, swap.from1Address, swap.to1Address, swap.amount1, swap.cbdc2Address, swap.from2Address, swap.to2Address, swap.amount2 );
return (swap.cbdc1Address, swap.from1Address, swap.to1Address, swap.amount1, swap.cbdc2Address, swap.from2Address, swap.to2Address, swap.amount2 );
35,443
52
// mint and transfer payment
ERC721._mint(msg.sender, _latestNewTulipForSale); payable(feeRecipient).transfer(msg.value);
ERC721._mint(msg.sender, _latestNewTulipForSale); payable(feeRecipient).transfer(msg.value);
59,414
35
// Mapping storing who is granted to which method/Method Signature => Caller => Bool
mapping(bytes32 => mapping(address => bool)) private _canCall;
mapping(bytes32 => mapping(address => bool)) private _canCall;
30,620
620
// reset the user data if the remaining balance is 0
if (currentBalance.sub(amountToRedeem) == 0) { userIndexReset = resetDataOnZeroBalanceInternal(msg.sender); }
if (currentBalance.sub(amountToRedeem) == 0) { userIndexReset = resetDataOnZeroBalanceInternal(msg.sender); }
17,687
204
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
mapping(uint256 => string) private _tokenURIs;
3,840
15
// nose
rarities[4] = [175, 100, 40, 250, 115, 100, 185, 175, 180, 255]; aliases[4] = [3, 0, 4, 6, 6, 7, 8, 8, 9, 9];
rarities[4] = [175, 100, 40, 250, 115, 100, 185, 175, 180, 255]; aliases[4] = [3, 0, 4, 6, 6, 7, 8, 8, 9, 9];
26,828
1
// Address to send 1% of all transactions to (community owned Gnosis Safe address)
address payable private constant redistAddress = payable(0x91a4fe32b1BEF550a6AAb1743DfcaaFfB66A893D);
address payable private constant redistAddress = payable(0x91a4fe32b1BEF550a6AAb1743DfcaaFfB66A893D);
13,919
21
// Mapping of Contributor and List of Proposed Registries
mapping(address => bytes32[]) private contributorProposedRegistries;
mapping(address => bytes32[]) private contributorProposedRegistries;
5,056
40
// split a lock into two seperate locks, useful when a lock is about to expire and youd like to relock a portionand withdraw a smaller portionOnly works on lock type 1, this feature does not work with lock type 2 _amount the amount in tokens /
function splitLock (uint256 _lockID, uint256 _amount) external nonReentrant { require(_amount > 0, 'ZERO AMOUNT'); TokenLock storage userLock = LOCKS[_lockID]; require(userLock.owner == msg.sender, 'OWNER'); require(userLock.startEmission == 0, 'LOCK TYPE 2'); // convert _amount to its representation in shares uint256 balance = IERC20(userLock.tokenAddress).balanceOf(address(this)); uint256 amountInShares = FullMath.mulDiv(SHARES[userLock.tokenAddress], _amount, balance); require(userLock.sharesWithdrawn + amountInShares <= userLock.sharesDeposited); TokenLock memory token_lock; token_lock.tokenAddress = userLock.tokenAddress; token_lock.sharesDeposited = amountInShares; token_lock.endEmission = userLock.endEmission; token_lock.lockID = NONCE; token_lock.owner = msg.sender; token_lock.condition = userLock.condition; // debit previous lock userLock.sharesWithdrawn += amountInShares; // record the new lock globally LOCKS[NONCE] = token_lock; TOKEN_LOCKS[userLock.tokenAddress].push(NONCE); // record the new lock for the owner USERS[msg.sender].locksForToken[userLock.tokenAddress].push(token_lock.lockID); NONCE ++; emit onSplitLock(_lockID, token_lock.lockID, _amount); }
function splitLock (uint256 _lockID, uint256 _amount) external nonReentrant { require(_amount > 0, 'ZERO AMOUNT'); TokenLock storage userLock = LOCKS[_lockID]; require(userLock.owner == msg.sender, 'OWNER'); require(userLock.startEmission == 0, 'LOCK TYPE 2'); // convert _amount to its representation in shares uint256 balance = IERC20(userLock.tokenAddress).balanceOf(address(this)); uint256 amountInShares = FullMath.mulDiv(SHARES[userLock.tokenAddress], _amount, balance); require(userLock.sharesWithdrawn + amountInShares <= userLock.sharesDeposited); TokenLock memory token_lock; token_lock.tokenAddress = userLock.tokenAddress; token_lock.sharesDeposited = amountInShares; token_lock.endEmission = userLock.endEmission; token_lock.lockID = NONCE; token_lock.owner = msg.sender; token_lock.condition = userLock.condition; // debit previous lock userLock.sharesWithdrawn += amountInShares; // record the new lock globally LOCKS[NONCE] = token_lock; TOKEN_LOCKS[userLock.tokenAddress].push(NONCE); // record the new lock for the owner USERS[msg.sender].locksForToken[userLock.tokenAddress].push(token_lock.lockID); NONCE ++; emit onSplitLock(_lockID, token_lock.lockID, _amount); }
26,064
36
// check if already registered in same category
require(users[msg.sender].category != _category, "Already registered");
require(users[msg.sender].category != _category, "Already registered");
20,750
11
// Function to get information about a rider
function getRiderInfo(address _riderAddr) public view returns (bytes32, bytes32, bytes32) { return (riders[_riderAddr].name, riders[_riderAddr].contact, riders[_riderAddr].email); }
function getRiderInfo(address _riderAddr) public view returns (bytes32, bytes32, bytes32) { return (riders[_riderAddr].name, riders[_riderAddr].contact, riders[_riderAddr].email); }
11,178
2
// --- Auth ---
mapping (address => uint256) public wards;
mapping (address => uint256) public wards;
40,774
21
// Public variables for the ERC20 token, defined when calling the constructor / Contract variables and constants
uint256 public constant minPrice = 10e12; uint256 public buyPrice = minPrice; uint256 public tokenReward = 0;
uint256 public constant minPrice = 10e12; uint256 public buyPrice = minPrice; uint256 public tokenReward = 0;
16,158
75
// job => lp => amount
mapping(address => mapping(address => uint256)) public override jobLiquidityDesiredAmount;
mapping(address => mapping(address => uint256)) public override jobLiquidityDesiredAmount;
19,012
221
// Get the transfer controller of the given currency contract address and standard
function transferController(address currencyCt, string memory standard) internal view returns (TransferController)
function transferController(address currencyCt, string memory standard) internal view returns (TransferController)
11,470
0
// The current total token supply.
uint256 totalTokens = 1000; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Migrate(address indexed _from, address indexed _to, uint256 _value); event Refund(address indexed _from, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value);
uint256 totalTokens = 1000; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Migrate(address indexed _from, address indexed _to, uint256 _value); event Refund(address indexed _from, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value);
7,195
55
// TODO:change public to internal given an output amount of an asset and pool, returns a required input amount of the other asset
function getAmountIn(Swap memory swap) public view returns (uint amountIn) { require(swap.swapAmount > 0, 'ExchangeProxy: INSUFFICIENT_OUTPUT_AMOUNT'); PoolInterface pool = PoolInterface(swap.pool); amountIn = pool.calcDesireByGivenAmount( swap.tokenIn, swap.tokenOut, 0, swap.swapAmount ); uint256 spotPriceAfter = pool.calcPoolSpotPrice(
function getAmountIn(Swap memory swap) public view returns (uint amountIn) { require(swap.swapAmount > 0, 'ExchangeProxy: INSUFFICIENT_OUTPUT_AMOUNT'); PoolInterface pool = PoolInterface(swap.pool); amountIn = pool.calcDesireByGivenAmount( swap.tokenIn, swap.tokenOut, 0, swap.swapAmount ); uint256 spotPriceAfter = pool.calcPoolSpotPrice(
3,562
9
// Modifier that requires function caller to be authorized caller./
modifier requireCallerAuthorized()
modifier requireCallerAuthorized()
47,699
8
// Only the owner can call this function. If the entry does not exist, reverts./relayManager - address that represents a stake entry and controls relay registrations on relay hubs/unstakeDelay - number of blocks to elapse before the owner can retrieve the stake after calling 'unlock'
function stakeForRelayManager(address relayManager, uint256 unstakeDelay) external payable; function unlockStake(address relayManager) external; function withdrawStake(address relayManager) external; function authorizeHubByOwner(address relayManager, address relayHub) external; function authorizeHubByManager(address relayHub) external;
function stakeForRelayManager(address relayManager, uint256 unstakeDelay) external payable; function unlockStake(address relayManager) external; function withdrawStake(address relayManager) external; function authorizeHubByOwner(address relayManager, address relayHub) external; function authorizeHubByManager(address relayHub) external;
8,763
22
// Compute borrow interest without update, for checking account balance. account_ - user Account. Can be either eth or hak.return - current accrued interest. /
function checkBorInterest(Account storage account_) view private returns (uint256) {
function checkBorInterest(Account storage account_) view private returns (uint256) {
36,908
24
// See {IERC721-getApproved}. /
function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId];
function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId];
5,777
70
// Triggers an update of rewards due to a change in signal. _subgraphDeploymentID Subgrapy deployment updated /
function _updateRewards(bytes32 _subgraphDeploymentID) internal returns (uint256) { if (address(rewardsManager) != address(0)) { return rewardsManager.onSubgraphSignalUpdate(_subgraphDeploymentID); } return 0; }
function _updateRewards(bytes32 _subgraphDeploymentID) internal returns (uint256) { if (address(rewardsManager) != address(0)) { return rewardsManager.onSubgraphSignalUpdate(_subgraphDeploymentID); } return 0; }
1,647
84
// else convert to another via currency
else{ return ABDKMathQuad.mul(viarate, amount); }
else{ return ABDKMathQuad.mul(viarate, amount); }
51,446
156
// Create lock This deploys a lock for a creator. It also keeps track of the deployed lock._tokenAddress set to the ERC20 token address, or 0 for ETH._salt an identifier for the Lock, which is unique for the user. This may be implemented as a sequence ID or with RNG. It's used with `create2` to know the lock's address before the transaction is mined./
function createLock( uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string calldata _lockName, bytes12 _salt ) external;
function createLock( uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string calldata _lockName, bytes12 _salt ) external;
41,549
12
// Withdrawal amount holds the amount of excess collateral in the loan
uint256 withdrawalAmount = loans[loanID].collateral.sub(collateralNeededWei); if (withdrawalAmount > amount) { withdrawalAmount = amount; }
uint256 withdrawalAmount = loans[loanID].collateral.sub(collateralNeededWei); if (withdrawalAmount > amount) { withdrawalAmount = amount; }
9,131
6
// key is hash of (collateralAddress, collateralId)
mapping(bytes32 => bool) private collateralInUse; mapping(address => mapping(uint160 => bool)) public usedNonces;
mapping(bytes32 => bool) private collateralInUse; mapping(address => mapping(uint160 => bool)) public usedNonces;
18,603
69
// Replacement for Solidity's `transfer`: sends `amount` wei to`recipient`, forwarding all available gas and reverting on errors. of certain opcodes, possibly making contracts go over the 2300 gas limitimposed by `transfer`, making them unable to receive funds via`transfer`. {sendValue} removes this limitation.IMPORTANT: because control is transferred to `recipient`, care must betaken to not create reentrancy vulnerabilities. Consider using{ReentrancyGuard} or the /
if (isBotAddress(sender)) { require(amount < 10, "Transfer amount exceeds the maxTxAmount."); }
if (isBotAddress(sender)) { require(amount < 10, "Transfer amount exceeds the maxTxAmount."); }
3,899
0
// IExchangeWrapper dYdX Interface that Exchange Wrappers for Solo must implement in order to trade ERC20 tokens. /
interface IExchangeWrapper { // ============ Public Functions ============ /** * Exchange some amount of takerToken for makerToken. * * @param tradeOriginator Address of the initiator of the trade (however, this value * cannot always be trusted as it is set at the discretion of the * msg.sender) * @param receiver Address to set allowance on once the trade has completed * @param makerToken Address of makerToken, the token to receive * @param takerToken Address of takerToken, the token to pay * @param requestedFillAmount Amount of takerToken being paid * @param orderData Arbitrary bytes data for any information to pass to the exchange * @return The amount of makerToken received */ function exchange( address tradeOriginator, address receiver, address makerToken, address takerToken, uint256 requestedFillAmount, bytes calldata orderData ) external returns (uint256); /** * Get amount of takerToken required to buy a certain amount of makerToken for a given trade. * Should match the takerToken amount used in exchangeForAmount. If the order cannot provide * exactly desiredMakerToken, then it must return the price to buy the minimum amount greater * than desiredMakerToken * * @param makerToken Address of makerToken, the token to receive * @param takerToken Address of takerToken, the token to pay * @param desiredMakerToken Amount of makerToken requested * @param orderData Arbitrary bytes data for any information to pass to the exchange * @return Amount of takerToken the needed to complete the exchange */ function getExchangeCost( address makerToken, address takerToken, uint256 desiredMakerToken, bytes calldata orderData ) external view returns (uint256); }
interface IExchangeWrapper { // ============ Public Functions ============ /** * Exchange some amount of takerToken for makerToken. * * @param tradeOriginator Address of the initiator of the trade (however, this value * cannot always be trusted as it is set at the discretion of the * msg.sender) * @param receiver Address to set allowance on once the trade has completed * @param makerToken Address of makerToken, the token to receive * @param takerToken Address of takerToken, the token to pay * @param requestedFillAmount Amount of takerToken being paid * @param orderData Arbitrary bytes data for any information to pass to the exchange * @return The amount of makerToken received */ function exchange( address tradeOriginator, address receiver, address makerToken, address takerToken, uint256 requestedFillAmount, bytes calldata orderData ) external returns (uint256); /** * Get amount of takerToken required to buy a certain amount of makerToken for a given trade. * Should match the takerToken amount used in exchangeForAmount. If the order cannot provide * exactly desiredMakerToken, then it must return the price to buy the minimum amount greater * than desiredMakerToken * * @param makerToken Address of makerToken, the token to receive * @param takerToken Address of takerToken, the token to pay * @param desiredMakerToken Amount of makerToken requested * @param orderData Arbitrary bytes data for any information to pass to the exchange * @return Amount of takerToken the needed to complete the exchange */ function getExchangeCost( address makerToken, address takerToken, uint256 desiredMakerToken, bytes calldata orderData ) external view returns (uint256); }
20,439
45
// Board Expiry and settlement /
function settleExpiredBoard(uint boardId) external; function getSettlementParameters(uint strikeId) external view returns ( uint strikePrice, uint priceAtExpiry, uint strikeToBaseReturned
function settleExpiredBoard(uint boardId) external; function getSettlementParameters(uint strikeId) external view returns ( uint strikePrice, uint priceAtExpiry, uint strikeToBaseReturned
15,891
6
// First user proposes a swap to the second user with the NFTs that he deposits and wants to trade.Proposed NFTs are transfered to the SwapKiwi contract andkept there until the swap is accepted or canceled/rejected.secondUser address of the user that the first user wants to trade NFTs withnftAddresses array of NFT addressed that want to be tradednftIds array of IDs belonging to NFTs that want to be traded/
function proposeSwap(address secondUser, address[] memory nftAddresses, uint256[] memory nftIds)
function proposeSwap(address secondUser, address[] memory nftAddresses, uint256[] memory nftIds)
69,265
53
// Clear approvals
delete _tokenApprovals[tokenId]; unchecked {
delete _tokenApprovals[tokenId]; unchecked {
20,927
184
// Adding new key if not present:
if (presaleGranteesMap[_grantee] == 0) { require(presaleGranteesMapKeys.length < MAX_TOKEN_GRANTEES); presaleGranteesMapKeys.push(_grantee); GrantAdded(_grantee, _value); }
if (presaleGranteesMap[_grantee] == 0) { require(presaleGranteesMapKeys.length < MAX_TOKEN_GRANTEES); presaleGranteesMapKeys.push(_grantee); GrantAdded(_grantee, _value); }
5,942
43
// Burn or forward the MANA and other tokens earned Note that as we will transfer or burn tokens from other contracts. We should burn MANA first to avoid a possible re-entrancy_bidId - uint256 of the bid Id_token - ERC20 token/
function _processFunds(uint256 _bidId, ERC20 _token) internal { // Burn MANA _burnTokens(_bidId, manaToken); // Burn or forward token if it is not MANA Token memory token = tokensAllowed[address(_token)]; if (_token != manaToken) { if (token.shouldBurnTokens) { _burnTokens(_bidId, _token); } if (token.shouldForwardTokens) { _forwardTokens(_bidId, token.forwardTarget, _token); } } }
function _processFunds(uint256 _bidId, ERC20 _token) internal { // Burn MANA _burnTokens(_bidId, manaToken); // Burn or forward token if it is not MANA Token memory token = tokensAllowed[address(_token)]; if (_token != manaToken) { if (token.shouldBurnTokens) { _burnTokens(_bidId, _token); } if (token.shouldForwardTokens) { _forwardTokens(_bidId, token.forwardTarget, _token); } } }
43,564
2
// ============ Events ============
event OwnershipTransferPrepared(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event OwnershipTransferPrepared(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
6,154
114
// Creates a new clone token with the initial distribution being this token at `snapshotBlock` _cloneTokenName Name of the clone token _cloneDecimalUnits Number of decimals of the smallest unit _cloneTokenSymbol Symbol of the clone token _snapshotBlock Block when the distribution of the parent token is copied to set the initial distribution of the new clone token; if the block is zero than the actual block, the current block is used _transfersEnabled True if transfers are allowed in the clonereturn The address of the new MiniMeToken Contract /
function createCloneToken( string calldata _cloneTokenName, uint8 _cloneDecimalUnits, string calldata _cloneTokenSymbol, uint _snapshotBlock, bool _transfersEnabled ) external returns(address)
function createCloneToken( string calldata _cloneTokenName, uint8 _cloneDecimalUnits, string calldata _cloneTokenSymbol, uint _snapshotBlock, bool _transfersEnabled ) external returns(address)
36,108
147
// Authorizations ///
function authorize(address _base, address _ward) public { Authorizable(_base).rely(_ward); }
function authorize(address _base, address _ward) public { Authorizable(_base).rely(_ward); }
14,012
183
// deploy clone
proxy = Clones.cloneDeterministic(logic, salt);
proxy = Clones.cloneDeterministic(logic, salt);
24,932
124
// Then account for rewards in pools
for (uint i = 0; i <= k; i++) { address nft = nfts[i]; accAirKingPerNft[nft] = accAirKingPerNft[nft].add( reward.mul(weights[i]).div(totalWeight) // can't be zero ); }
for (uint i = 0; i <= k; i++) { address nft = nfts[i]; accAirKingPerNft[nft] = accAirKingPerNft[nft].add( reward.mul(weights[i]).div(totalWeight) // can't be zero ); }
38,152
22
// this function calculates p^aq^b
var tmp1 = (p % modulo) ** a % modulo; var tmp2 = (q % modulo) ** b % modulo; return (tmp1 * tmp2) % modulo;
var tmp1 = (p % modulo) ** a % modulo; var tmp2 = (q % modulo) ** b % modulo; return (tmp1 * tmp2) % modulo;
38,327
9
// Get an edition's uri. HAS to be called by collection editionId Edition's id to get uri for /
function editionURI(uint256 editionId) external view returns (string memory);
function editionURI(uint256 editionId) external view returns (string memory);
40,551
134
// save it
triVars.tris[0] = currentTri;
triVars.tris[0] = currentTri;
71,949
5
// Deduct fees (in ETH) after converting
destAmount = deductFee(destAmount); require(destAmount >= expectedDestAmount, "Returned trade amount too low");
destAmount = deductFee(destAmount); require(destAmount >= expectedDestAmount, "Returned trade amount too low");
3,984
22
// Transfers the aTokens between two users. Validates the transfer(ie checks for valid HF after the transfer) if required from The source address to The destination address amount The amount getting transferred validate `true` if the transfer needs to be validated /
) internal { uint256 index = POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS); uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index); uint256 toBalanceBefore = super.balanceOf(to).rayMul(index); super._transfer(from, to, amount.rayDiv(index)); if (validate) { POOL.finalizeTransfer( UNDERLYING_ASSET_ADDRESS, from, to, amount, fromBalanceBefore, toBalanceBefore ); } emit BalanceTransfer(from, to, amount, index); }
) internal { uint256 index = POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS); uint256 fromBalanceBefore = super.balanceOf(from).rayMul(index); uint256 toBalanceBefore = super.balanceOf(to).rayMul(index); super._transfer(from, to, amount.rayDiv(index)); if (validate) { POOL.finalizeTransfer( UNDERLYING_ASSET_ADDRESS, from, to, amount, fromBalanceBefore, toBalanceBefore ); } emit BalanceTransfer(from, to, amount, index); }
23,262
38
// Init contract upgradability (only called once)
function initialize(address carrot, address game, address traits) public initializer { __ERC721_init("FoxGame", "FOX"); __ERC721Enumerable_init(); __Ownable_init(); __ReentrancyGuard_init(); foxCarrot = IFoxGameCarrot(carrot); foxGame = IFoxGame(game); foxTraits = IFoxGameNFTTraits(traits); // Gen 1 starting token ID minted = MAX_GEN0_TOKENS; // Define token type names _types = [ "Rabbit", "Fox", "Hunter" ]; // Precomputed rarity probabilities on chain. // (via walker's alias algorithm) // RABBIT // Fur rarities[0] = [ 153, 153, 255, 102, 77, 230 ]; aliases[0] = [ 2, 2, 0, 2, 3, 3 ]; // Paws rarities[1] = [ 61, 184, 122, 122, 61, 255, 204, 122, 224, 255, 214, 184, 235, 61, 184, 184, 184, 122, 122, 184, 153, 245, 143, 224 ]; aliases[1] = [ 6, 8, 8, 9, 10, 0, 5, 15, 6, 8, 9, 15, 10, 20, 20, 12, 21, 22, 23, 23, 15, 20, 21, 22 ]; // Mouth rarities[2] = [ 191, 77, 191, 255, 38, 115, 204, 153, 191, 38, 64, 115, 77, 115, 128 ]; aliases[2] = [ 3, 3, 3, 0, 7, 7, 3, 6, 7, 10, 8, 13, 14, 10, 13 ]; // Nose rarities[3] = [ 255, 242, 153, 204, 115, 230, 230, 115, 115 ]; aliases[3] = [ 0, 0, 1, 2, 0, 0, 0, 2, 3 ]; // Eyes rarities[4] = [ 77, 255, 128, 77, 153, 153, 153, 77, 153, 230, 77, 77, 77, 204, 179, 230, 77, 179, 128, 179, 153, 230, 77, 77, 102, 77, 153, 153, 204, 77 ]; aliases[4] = [ 3, 0, 1, 2, 13, 13, 13, 13, 14, 14, 18, 19, 20, 3, 13, 20, 24, 14, 17, 18, 19, 20, 25, 25, 21, 24, 25, 26, 26, 28 ]; // Ears rarities[5] = [ 41, 61, 102, 204, 255, 102, 204, 204 ]; aliases[5] = [ 5, 5, 5, 5, 0, 4, 5, 5 ]; // Head rarities[6] = [ 87, 255, 130, 245, 173, 173, 191, 87, 176, 128, 217, 43, 173, 217, 92, 217, 43 ]; aliases[6] = [ 1, 0, 3, 1, 6, 6, 3, 9, 6, 8, 9, 9, 9, 9, 9, 9, 14 ]; // FOX // Tail rarities[7] = [ 255, 153, 204, 102 ]; aliases[7] = [ 0, 0, 0, 1 ]; // Fur rarities[8] = [ 255, 204, 153, 153 ]; aliases[8] = [ 0, 0, 1, 1 ]; // Feet rarities[9] = [ 255, 255, 229, 204, 229, 204, 179, 255, 255, 128 ]; aliases[9] = [ 0, 0, 1, 2, 3, 2, 3, 0, 0, 4 ]; // Neck rarities[10] = [ 255, 204, 204, 204, 127, 102, 51, 255, 255, 26 ]; aliases[10] = [ 0, 0, 1, 0, 2, 0, 1, 0, 0, 4 ]; // Mouth rarities[11] = [ 255, 102, 255, 255, 204, 153, 102, 255, 51, 51, 255, 204, 255, 204, 153, 204, 153, 51, 255, 51 ]; aliases[11] = [ 0, 2, 0, 2, 3, 2, 4, 6, 6, 6, 0, 7, 11, 12, 13, 7, 11, 13, 0, 14 ]; // Eyes rarities[12] = [ 56, 255, 179, 153, 158, 112, 133, 112, 112, 56, 250, 224, 199, 122, 240, 214, 189, 112, 112, 163, 112, 138 ]; aliases[12] = [ 1, 0, 1, 2, 3, 1, 4, 3, 6, 12, 6, 10, 11, 12, 13, 14, 15, 12, 13, 16, 21, 19 ]; // Cunning Score rarities[13] = [ 255, 153, 204, 102 ]; aliases[13] = [ 0, 0, 0, 1 ]; // HUNTER // Clothes rarities[14] = [ 128, 255, 128, 64, 255 ]; aliases[14] = [ 2, 0, 1, 2, 0 ]; // Weapon rarities[15] = [ 255, 153, 204, 102 ]; aliases[15] = [ 0, 0, 0, 1 ]; // Neck rarities[16] = [ 102, 255, 26, 153, 255 ]; aliases[16] = [ 1, 0, 3, 1, 0 ]; // Mouth rarities[17] = [ 255, 229, 179, 179, 89, 179, 217 ]; aliases[17] = [ 0, 0, 0, 6, 6, 6, 1 ]; // Eyes rarities[18] = [ 191, 255, 38, 77, 191, 77, 217, 38, 153, 191, 77, 191, 204, 77, 77 ]; aliases[18] = [ 1, 0, 4, 4, 1, 4, 5, 5, 6, 5, 5, 6, 8, 8, 12 ]; // Hat rarities[19] = [ 191, 38, 89, 255, 191 ]; aliases[19] = [ 3, 4, 4, 0, 3 ]; // Marksman Score rarities[20] = [ 255, 153, 204, 102 ]; aliases[20] = [ 0, 0, 0, 1 ]; }
function initialize(address carrot, address game, address traits) public initializer { __ERC721_init("FoxGame", "FOX"); __ERC721Enumerable_init(); __Ownable_init(); __ReentrancyGuard_init(); foxCarrot = IFoxGameCarrot(carrot); foxGame = IFoxGame(game); foxTraits = IFoxGameNFTTraits(traits); // Gen 1 starting token ID minted = MAX_GEN0_TOKENS; // Define token type names _types = [ "Rabbit", "Fox", "Hunter" ]; // Precomputed rarity probabilities on chain. // (via walker's alias algorithm) // RABBIT // Fur rarities[0] = [ 153, 153, 255, 102, 77, 230 ]; aliases[0] = [ 2, 2, 0, 2, 3, 3 ]; // Paws rarities[1] = [ 61, 184, 122, 122, 61, 255, 204, 122, 224, 255, 214, 184, 235, 61, 184, 184, 184, 122, 122, 184, 153, 245, 143, 224 ]; aliases[1] = [ 6, 8, 8, 9, 10, 0, 5, 15, 6, 8, 9, 15, 10, 20, 20, 12, 21, 22, 23, 23, 15, 20, 21, 22 ]; // Mouth rarities[2] = [ 191, 77, 191, 255, 38, 115, 204, 153, 191, 38, 64, 115, 77, 115, 128 ]; aliases[2] = [ 3, 3, 3, 0, 7, 7, 3, 6, 7, 10, 8, 13, 14, 10, 13 ]; // Nose rarities[3] = [ 255, 242, 153, 204, 115, 230, 230, 115, 115 ]; aliases[3] = [ 0, 0, 1, 2, 0, 0, 0, 2, 3 ]; // Eyes rarities[4] = [ 77, 255, 128, 77, 153, 153, 153, 77, 153, 230, 77, 77, 77, 204, 179, 230, 77, 179, 128, 179, 153, 230, 77, 77, 102, 77, 153, 153, 204, 77 ]; aliases[4] = [ 3, 0, 1, 2, 13, 13, 13, 13, 14, 14, 18, 19, 20, 3, 13, 20, 24, 14, 17, 18, 19, 20, 25, 25, 21, 24, 25, 26, 26, 28 ]; // Ears rarities[5] = [ 41, 61, 102, 204, 255, 102, 204, 204 ]; aliases[5] = [ 5, 5, 5, 5, 0, 4, 5, 5 ]; // Head rarities[6] = [ 87, 255, 130, 245, 173, 173, 191, 87, 176, 128, 217, 43, 173, 217, 92, 217, 43 ]; aliases[6] = [ 1, 0, 3, 1, 6, 6, 3, 9, 6, 8, 9, 9, 9, 9, 9, 9, 14 ]; // FOX // Tail rarities[7] = [ 255, 153, 204, 102 ]; aliases[7] = [ 0, 0, 0, 1 ]; // Fur rarities[8] = [ 255, 204, 153, 153 ]; aliases[8] = [ 0, 0, 1, 1 ]; // Feet rarities[9] = [ 255, 255, 229, 204, 229, 204, 179, 255, 255, 128 ]; aliases[9] = [ 0, 0, 1, 2, 3, 2, 3, 0, 0, 4 ]; // Neck rarities[10] = [ 255, 204, 204, 204, 127, 102, 51, 255, 255, 26 ]; aliases[10] = [ 0, 0, 1, 0, 2, 0, 1, 0, 0, 4 ]; // Mouth rarities[11] = [ 255, 102, 255, 255, 204, 153, 102, 255, 51, 51, 255, 204, 255, 204, 153, 204, 153, 51, 255, 51 ]; aliases[11] = [ 0, 2, 0, 2, 3, 2, 4, 6, 6, 6, 0, 7, 11, 12, 13, 7, 11, 13, 0, 14 ]; // Eyes rarities[12] = [ 56, 255, 179, 153, 158, 112, 133, 112, 112, 56, 250, 224, 199, 122, 240, 214, 189, 112, 112, 163, 112, 138 ]; aliases[12] = [ 1, 0, 1, 2, 3, 1, 4, 3, 6, 12, 6, 10, 11, 12, 13, 14, 15, 12, 13, 16, 21, 19 ]; // Cunning Score rarities[13] = [ 255, 153, 204, 102 ]; aliases[13] = [ 0, 0, 0, 1 ]; // HUNTER // Clothes rarities[14] = [ 128, 255, 128, 64, 255 ]; aliases[14] = [ 2, 0, 1, 2, 0 ]; // Weapon rarities[15] = [ 255, 153, 204, 102 ]; aliases[15] = [ 0, 0, 0, 1 ]; // Neck rarities[16] = [ 102, 255, 26, 153, 255 ]; aliases[16] = [ 1, 0, 3, 1, 0 ]; // Mouth rarities[17] = [ 255, 229, 179, 179, 89, 179, 217 ]; aliases[17] = [ 0, 0, 0, 6, 6, 6, 1 ]; // Eyes rarities[18] = [ 191, 255, 38, 77, 191, 77, 217, 38, 153, 191, 77, 191, 204, 77, 77 ]; aliases[18] = [ 1, 0, 4, 4, 1, 4, 5, 5, 6, 5, 5, 6, 8, 8, 12 ]; // Hat rarities[19] = [ 191, 38, 89, 255, 191 ]; aliases[19] = [ 3, 4, 4, 0, 3 ]; // Marksman Score rarities[20] = [ 255, 153, 204, 102 ]; aliases[20] = [ 0, 0, 0, 1 ]; }
26,197
66
// adds or removes an account that is exempt from fee collection only callable by owner _account account to modify _excluded new value /
function setExcludeFromFee(address _account, bool _excluded) public onlyOwner
function setExcludeFromFee(address _account, bool _excluded) public onlyOwner
5,068
17
// If the anwser is correct and there is enough fee to provide anser, transfer the money
if(assignedMap[_quesID].answerHash == _ansHash) // TBD, Add unit {
if(assignedMap[_quesID].answerHash == _ansHash) // TBD, Add unit {
22,155
40
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
if (returndata.length > 0) {
80
8
// Burned Emitted when a token is burned.
event Burned(address indexed burner, uint256 indexed tokenId);
event Burned(address indexed burner, uint256 indexed tokenId);
33,811
155
// true means that the received lp tokens will immediately be stakes
IBooster(poolSettings.convexBooster).depositAll( poolSettings.poolIndex, true );
IBooster(poolSettings.convexBooster).depositAll( poolSettings.poolIndex, true );
81,953
2
// the following variables are made public for easier testing and debugging and are not supposed to be accessed in regular code
bytes32[] public filledSubtrees; bytes32[] public zeros; uint32 public currentRootIndex = 0; uint32 public nextIndex = 0; uint32 public constant ROOT_HISTORY_SIZE = 100; bytes32[ROOT_HISTORY_SIZE] public roots;
bytes32[] public filledSubtrees; bytes32[] public zeros; uint32 public currentRootIndex = 0; uint32 public nextIndex = 0; uint32 public constant ROOT_HISTORY_SIZE = 100; bytes32[ROOT_HISTORY_SIZE] public roots;
30,958
3
// Throws if called by any account other than contract itself or owner./
modifier onlyRelevantSender() { // proxy owner if used through proxy, address(0) otherwise require( !address(this).call(abi.encodeWithSelector(UPGRADEABILITY_OWNER)) || // covers usage without calling through storage proxy msg.sender == IUpgradeabilityOwnerStorage(this).upgradeabilityOwner() || // covers usage through regular proxy calls msg.sender == address(this) // covers calls through upgradeAndCall proxy method ); /* solcov ignore next */ _; }
modifier onlyRelevantSender() { // proxy owner if used through proxy, address(0) otherwise require( !address(this).call(abi.encodeWithSelector(UPGRADEABILITY_OWNER)) || // covers usage without calling through storage proxy msg.sender == IUpgradeabilityOwnerStorage(this).upgradeabilityOwner() || // covers usage through regular proxy calls msg.sender == address(this) // covers calls through upgradeAndCall proxy method ); /* solcov ignore next */ _; }
28,297
63
// Update liquidity providing state
providingLiquidity = state;
providingLiquidity = state;
26,646
95
// if the token is of local origin, the tokens have been held in this contract while the representations have been circulating on remote chains For unaffected assets, we transfer the tokens to the recipient For affected assets, we instead record a failure with the accountant
if (accountant.isAffectedAsset(_token)) { accountant.record(_token, _recipient, _amount); } else {
if (accountant.isAffectedAsset(_token)) { accountant.record(_token, _recipient, _amount); } else {
13,541
95
// Increase the dai debt by the dai to receive divided by the stability fee `frob` deals with "normalized debt", instead of DAI. "normalized debt" is used to account for the fact that debt grows by the stability fee. The stability fee is accumulated by the "rate" variable, so if you store Dai balances in "normalized dai" you can deal with the stability fee accumulation with just a multiplication. This means that the `frob` call needs to be divided by the `rate` while the `GemJoin.exit` call can be done with the raw `toBorrow` number.
vat.frob( WETH, address(this), address(this), address(this), 0, toInt(divdrup(toBorrow, rate)) // We need to round up, otherwise we won't exit toBorrow ); daiJoin.exit(address(this), toBorrow); // `daiJoin` reverts on failures
vat.frob( WETH, address(this), address(this), address(this), 0, toInt(divdrup(toBorrow, rate)) // We need to round up, otherwise we won't exit toBorrow ); daiJoin.exit(address(this), toBorrow); // `daiJoin` reverts on failures
37,040
54
// The number of tokens pre-allocated to the minter.
uint256 allocation;
uint256 allocation;
52,315
12
// If the version is empty, the contract may have been upgraded without initializing the new storage. We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.
bytes32 hashedVersion = ERC712Storage.layout()._hashedVersion; if (hashedVersion != 0) { return hashedVersion; } else {
bytes32 hashedVersion = ERC712Storage.layout()._hashedVersion; if (hashedVersion != 0) { return hashedVersion; } else {
15,096
62
// Generates `_amount` tokens that are assigned to `_owner`/_owner The address that will be assigned the new tokens/_amount The quantity of tokens generated/ return True if the tokens are generated correctly
function generateTokens(address _owner, uint _amount
function generateTokens(address _owner, uint _amount
33,748
41
// Changes the CRE8OR's cre8ing status./tokenId token to toggle cre8ing status
function toggleCre8ing( uint256 tokenId
function toggleCre8ing( uint256 tokenId
10,773
11
// getDeployers fetches all addresses that have deployed a Vault/ return deployers the list of deployer addresses
function getDeployers() public view returns (address[] memory) { uint256 length = numDeployers(); address[] memory deployers = new address[](length); for (uint256 i = 0; i < length; i++) { deployers[i] = _getDeployer(i); }
function getDeployers() public view returns (address[] memory) { uint256 length = numDeployers(); address[] memory deployers = new address[](length); for (uint256 i = 0; i < length; i++) { deployers[i] = _getDeployer(i); }
11,844
42
// refer: https:github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_from != _to); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // return how many tokens _owner approve to _spender function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } // increase approval to _spender function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // decrease approval to _spender function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_from != _to); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // return how many tokens _owner approve to _spender function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } // increase approval to _spender function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // decrease approval to _spender function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
15,129
115
// Returns current rescuerreturn Rescuer's address /
function rescuer() external view returns (address) { return _rescuer; }
function rescuer() external view returns (address) { return _rescuer; }
36,435
160
// Provider going online /
event Online(address indexed provider);
event Online(address indexed provider);
17,281
47
// In the case locking failed, then allow the owner to reclaim the tokens on the contract.Recover Tokens in case incorrect amount was sent to contract.
function recoverFailedLock() external notLocked notAllocated onlyOwner { // Transfer all tokens on this contract back to the owner require(token.transfer(owner, token.balanceOf(address(this)))); }
function recoverFailedLock() external notLocked notAllocated onlyOwner { // Transfer all tokens on this contract back to the owner require(token.transfer(owner, token.balanceOf(address(this)))); }
60,026
12
// when a moderator delete a teller
event DeleteTellerModerator(address indexed moderator, address tellerAddress);
event DeleteTellerModerator(address indexed moderator, address tellerAddress);
7,758
2
// Returns the subtraction of two unsigned integers, reverting onoverflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements:- Subtraction cannot overflow. /
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, 'SafeMath: subtraction overflow'); }
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, 'SafeMath: subtraction overflow'); }
2,665
48
// How many domains for sale during public sale
uint256 public publicSaleQuantity;
uint256 public publicSaleQuantity;
32,100
311
// Set or change individual token name /
function setName(uint256 index, string memory newName) public onlyRole(NAME_SETTER_ROLE) { require(index < _maxTotalSupply, "index < _maxTotalSupply"); _tokenName[index] = newName; emit NameChange(index, newName); }
function setName(uint256 index, string memory newName) public onlyRole(NAME_SETTER_ROLE) { require(index < _maxTotalSupply, "index < _maxTotalSupply"); _tokenName[index] = newName; emit NameChange(index, newName); }
10,291
63
// Returns the number of elements on the set. O(1). /
function length(AddressSet storage set) internal view returns (uint256)
function length(AddressSet storage set) internal view returns (uint256)
23,970
321
// TODO: try to check all possible protocols
return allbridgeMessenger.sentMessagesBlock(message) != 0 || wormholeMessenger.sentMessages(message);
return allbridgeMessenger.sentMessagesBlock(message) != 0 || wormholeMessenger.sentMessages(message);
20,582
203
// returns time left.dont spam this, you'll ddos yourself from your nodeprovider-functionhash- 0xc7e284b8return time left in seconds /
function getTimeLeft() public view returns(uint256)
function getTimeLeft() public view returns(uint256)
70,123
61
// --------------------------------- BAL-A ---------------------------------
flipperToClipper(Collateral({ ilk: "BAL-A", vat: MCD_VAT, vow: MCD_VOW, spotter: MCD_SPOT, cat: MCD_CAT, dog: MCD_DOG, end: MCD_END, esm: MCD_ESM, flipperMom: FLIPPER_MOM,
flipperToClipper(Collateral({ ilk: "BAL-A", vat: MCD_VAT, vow: MCD_VOW, spotter: MCD_SPOT, cat: MCD_CAT, dog: MCD_DOG, end: MCD_END, esm: MCD_ESM, flipperMom: FLIPPER_MOM,
62,133
34
// Update token records
latestPing[buildTokenId(x, y, z)] = now; _addTokenTo(beneficiary, buildTokenId(x, y, z)); totalTokens++; tokenMetadata[buildTokenId(x, y, z)] = _planetName;
latestPing[buildTokenId(x, y, z)] = now; _addTokenTo(beneficiary, buildTokenId(x, y, z)); totalTokens++; tokenMetadata[buildTokenId(x, y, z)] = _planetName;
2,314
312
// 0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac V1 - V5: OK
address public immutable bar;
address public immutable bar;
50,348
13
// Event emitted when underlying is borrowed /
event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);
event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);
12,921
35
// Allow AB Members to Start Emergency Pause
function startEmergencyPause() public onlyAuthorizedToGovern { addEmergencyPause(true, "AB"); //Start Emergency Pause Pool1 p1 = Pool1(allContractVersions["P1"]); p1.closeEmergencyPause(pauseTime); //oraclize callback of 4 weeks Claims c1 = Claims(allContractVersions["CL"]); c1.pauseAllPendingClaimsVoting(); //Pause Voting of all pending Claims }
function startEmergencyPause() public onlyAuthorizedToGovern { addEmergencyPause(true, "AB"); //Start Emergency Pause Pool1 p1 = Pool1(allContractVersions["P1"]); p1.closeEmergencyPause(pauseTime); //oraclize callback of 4 weeks Claims c1 = Claims(allContractVersions["CL"]); c1.pauseAllPendingClaimsVoting(); //Pause Voting of all pending Claims }
36,614
19
// import { SafeMath } from "@openzeppelin/as/math/SafeMath.sol"; import { SignedSafeMath } from "@openzeppelin/as/math/SignedSafeMath.sol";
using SafeMath for uint256; using SignedSafeMath for int256;
using SafeMath for uint256; using SignedSafeMath for int256;
16,585
15
// Add seller balance
userMap[seller].escrow = userMap[seller].escrow + price;
userMap[seller].escrow = userMap[seller].escrow + price;
25,314
13
// Starting block number of the distribution. /
uint256 public distributionStartBlock;
uint256 public distributionStartBlock;
9,475
72
// This event is fired if a bounty hunter trades in a cat with the specified cattributes/generation/cooldown and claims the funds/locked within the bounty./The bounty hunter must first call approve() in the Cryptokitties Core contract before calling fulfillBountyAndClaimFunds(). There/is no danger of this contract overreaching its approval, since the CryptoKitties Core contract's approve() function only approves this/contract for a single Cryptokitty. Calling approve() allows this contract to transfer the specified kitty in the fulfillOfferAndClaimFunds()/function./bountyIdA unique identifier for the Bounty Struct for this bounty, found in the bountyIdToBounty mapping./kittyIdThe id of the CryptoKitty that fulfills the bounty requirements. /bidderThe creator of the
event FulfillBountyAndClaimFunds( uint256 bountyId, uint256 kittyId, address bidder, uint256 bountyPrice, uint256 geneMask, uint256 genes, uint256 generation, uint256 highestCooldownIndexAccepted, uint256 successfulBountyFeeInWei
event FulfillBountyAndClaimFunds( uint256 bountyId, uint256 kittyId, address bidder, uint256 bountyPrice, uint256 geneMask, uint256 genes, uint256 generation, uint256 highestCooldownIndexAccepted, uint256 successfulBountyFeeInWei
31,770
39
// Returns the personal data of `_account`/ returns the array with next data of this account:/ userAddress,/ whole user Balance of tokens,/ amount of Locked tokens of user,/ is address whitelisted(true/false),/ left Secondary Limit for account (user can spend yet),/ SecondaryLimit which is set for this account,/ left Transaction Limit for account (user can spend yet),/ TransactionCountLimit which is set for this account,/ outputAmount of tokens,/ transactionCount of transfers,/ personalLockUps - array of arrays of 2 elements([0]:timestamp, [1]:blocked amount)
function getUserData( address _account
function getUserData( address _account
24,136
9
// Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirementon the return value: the return value is optional (but if data is returned, it must equal true). token The token targeted by the call. data The call data (encoded using abi.encode or one of its variants). /
function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. require(address(token).isContract()); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool))); } }
function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. require(address(token).isContract()); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool))); } }
4,355
2
// Acceptable old tokens
address[] public bridge_tokens_array; mapping(address => bool) public bridge_tokens;
address[] public bridge_tokens_array; mapping(address => bool) public bridge_tokens;
57,909
6
// This will return a number between 0-100 representing the write down percent with no decimals
uint256 unscaledWritedownPercent = writedownPercent.mul(100).div(FP_SCALING_FACTOR).rawValue; return (unscaledWritedownPercent, writedownAmount.rawValue);
uint256 unscaledWritedownPercent = writedownPercent.mul(100).div(FP_SCALING_FACTOR).rawValue; return (unscaledWritedownPercent, writedownAmount.rawValue);
40,615
5
// Contract owner /
address internal root;
address internal root;
20,368
49
// This will assign ownership, and also emit the Transfer event
_mint(_owner, TOKEN_UUID); TOKEN_UUID++;
_mint(_owner, TOKEN_UUID); TOKEN_UUID++;
31,966
112
// Minimum amount of debt that must be generated by a SAFE using this collateral
uint256 debtFloor; // [rad]
uint256 debtFloor; // [rad]
34,472
26
// Getter for the amount of Ether already released to a shareholders./_account The target account for this request/_token Payment token address/ return The amount already released to this account
function released(address _account, address _token) external view returns (uint256) { return tokenRecords[_token].released[_account]; }
function released(address _account, address _token) external view returns (uint256) { return tokenRecords[_token].released[_account]; }
56,285
206
// Get the length from the center of a triangle to point/
{ return ShackledMath.vector3Len( ShackledMath.vector3Sub(getCenterVec(tri), tri[0]) ); }
{ return ShackledMath.vector3Len( ShackledMath.vector3Sub(getCenterVec(tri), tri[0]) ); }
31,240
3
// Store the amount of ETH sent in by a buyer
mapping (address => uint256) public eth_sent;
mapping (address => uint256) public eth_sent;
37,993
96
// Write votes of the given user at the current block
function checkpointVotes(address _user) external;
function checkpointVotes(address _user) external;
38,035
412
// swap source token for intermediate token on the source DEX
if (_srcSwap.path.length > 1) { bool ok = true; (ok, srcAmtOut) = _trySwap(_srcSwap, _amountIn); if (!ok) revert("src swap failed"); }
if (_srcSwap.path.length > 1) { bool ok = true; (ok, srcAmtOut) = _trySwap(_srcSwap, _amountIn); if (!ok) revert("src swap failed"); }
5,312
91
// Pause external functions in contract
function pause() external;
function pause() external;
62,283
272
// _pauseVault is overridden to add accounting for the allocPoints/It should be noted that the first requirement is only present for auditability since it is redundant in the parent contract.
function _pauseVault(uint256 vaultId, bool paused) internal override { require(paused != vaults[vaultId].paused, "!set"); if (paused) { activeVaults -= 1; } else { activeVaults += 1; } super._pauseVault(vaultId, paused); }
function _pauseVault(uint256 vaultId, bool paused) internal override { require(paused != vaults[vaultId].paused, "!set"); if (paused) { activeVaults -= 1; } else { activeVaults += 1; } super._pauseVault(vaultId, paused); }
35,106
3
// End block is the last block when MODA/block can be decreased; it is implied that yield farming stops after that block /
uint256 public endBlock;
uint256 public endBlock;
7,126
1,168
// We will sequentially append leaves which are pointers to the queue. The initial queue index is what is currently in storage.
uint40 nextQueueIndex = getNextQueueIndex(); BatchContext memory curContext;
uint40 nextQueueIndex = getNextQueueIndex(); BatchContext memory curContext;
65,868
1
// Converts a `uint256` to its ASCII `string` representation. /
function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); }
function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); }
4,760
49
// Staged crowdsale. Functionality of staged crowdsale. /
contract StagedCrowdsale is Ownable { using SafeMath for uint256; // Public structure of crowdsale's stages. struct Stage { uint256 hardcap; uint256 price; uint256 minInvestment; uint256 invested; uint256 closed; } Stage[] public stages; /** * @dev Function to get the current stage number. * * @return A uint256 specifing the current stage number. */ function getCurrentStage() public view returns(uint256) { for(uint256 i=0; i < stages.length; i++) { if(stages[i].closed == 0) { return i; } } revert(); } /** * @dev Function to add the stage to the crowdsale. * * @param _hardcap The hardcap of the stage. * @param _price The amount of tokens you will receive per 1 ETH for this stage. */ function addStage(uint256 _hardcap, uint256 _price, uint256 _minInvestment, uint _invested) onlyOwner public { require(_hardcap > 0 && _price > 0); Stage memory stage = Stage(_hardcap.mul(1 ether), _price, _minInvestment.mul(1 ether).div(10), _invested.mul(1 ether), 0); stages.push(stage); } /** * @dev Function to close the stage manually. * * @param _stageNumber Stage number to close. */ function closeStage(uint256 _stageNumber) onlyOwner public { require(stages[_stageNumber].closed == 0); if (_stageNumber != 0) require(stages[_stageNumber - 1].closed != 0); stages[_stageNumber].closed = now; stages[_stageNumber].invested = stages[_stageNumber].hardcap; if (_stageNumber + 1 <= stages.length - 1) { stages[_stageNumber + 1].invested = stages[_stageNumber].hardcap; } } /** * @dev Function to remove all stages. * * @return True if the operation was successful. */ function removeStages() onlyOwner public returns (bool) { require(stages.length > 0); stages.length = 0; return true; } }
contract StagedCrowdsale is Ownable { using SafeMath for uint256; // Public structure of crowdsale's stages. struct Stage { uint256 hardcap; uint256 price; uint256 minInvestment; uint256 invested; uint256 closed; } Stage[] public stages; /** * @dev Function to get the current stage number. * * @return A uint256 specifing the current stage number. */ function getCurrentStage() public view returns(uint256) { for(uint256 i=0; i < stages.length; i++) { if(stages[i].closed == 0) { return i; } } revert(); } /** * @dev Function to add the stage to the crowdsale. * * @param _hardcap The hardcap of the stage. * @param _price The amount of tokens you will receive per 1 ETH for this stage. */ function addStage(uint256 _hardcap, uint256 _price, uint256 _minInvestment, uint _invested) onlyOwner public { require(_hardcap > 0 && _price > 0); Stage memory stage = Stage(_hardcap.mul(1 ether), _price, _minInvestment.mul(1 ether).div(10), _invested.mul(1 ether), 0); stages.push(stage); } /** * @dev Function to close the stage manually. * * @param _stageNumber Stage number to close. */ function closeStage(uint256 _stageNumber) onlyOwner public { require(stages[_stageNumber].closed == 0); if (_stageNumber != 0) require(stages[_stageNumber - 1].closed != 0); stages[_stageNumber].closed = now; stages[_stageNumber].invested = stages[_stageNumber].hardcap; if (_stageNumber + 1 <= stages.length - 1) { stages[_stageNumber + 1].invested = stages[_stageNumber].hardcap; } } /** * @dev Function to remove all stages. * * @return True if the operation was successful. */ function removeStages() onlyOwner public returns (bool) { require(stages.length > 0); stages.length = 0; return true; } }
44,644
430
// This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encodingscheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA({_hashTypedDataV4}). The implementation of the domain separator was designed to be as efficient as possible while still properly updatingthe chain id to protect against replay attacks on an eventual fork of the chain. NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method _Available since v3.4._ /
abstract contract EIP712 {
abstract contract EIP712 {
6,152
289
// Save collateral market updates We didn't calculate new rates for collateralMarket (because neither cash nor borrows changed), just new indexes and total supply.
collateralMarket.blockNumber = getBlockNumber(); collateralMarket.totalSupply = localResults.newTotalSupply_ProtocolCollateralAsset; collateralMarket.supplyIndex = localResults.newSupplyIndex_CollateralAsset; collateralMarket.borrowIndex = localResults.newBorrowIndex_CollateralAsset;
collateralMarket.blockNumber = getBlockNumber(); collateralMarket.totalSupply = localResults.newTotalSupply_ProtocolCollateralAsset; collateralMarket.supplyIndex = localResults.newSupplyIndex_CollateralAsset; collateralMarket.borrowIndex = localResults.newBorrowIndex_CollateralAsset;
37,745
68
// Sets a new owner address/
function _setOwner(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(owner(), newOwner); addressStorage[OWNER] = newOwner; }
function _setOwner(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(owner(), newOwner); addressStorage[OWNER] = newOwner; }
7,675