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
2
// initate asset of client's accont
function InitAccount (address newaccount) public returns(bool)
function InitAccount (address newaccount) public returns(bool)
1,162
7
// Tier mapping for the token
mapping(uint256 => uint8) public tokenTier;
mapping(uint256 => uint8) public tokenTier;
73,862
169
// we just keep all money in want if we dont have any lenders
if(lenders.length == 0){ return; }
if(lenders.length == 0){ return; }
11,526
579
// Allows the owner to update the protocolFeeCollector address./updatedProtocolFeeCollector The updated protocolFeeCollector contract address.
function setProtocolFeeCollectorAddress(address updatedProtocolFeeCollector) external;
function setProtocolFeeCollectorAddress(address updatedProtocolFeeCollector) external;
54,976
79
// Allow the owner to transfer out any accidentally sent ERC20 tokens. _tokenAddress The address of the ERC20 contract. _amount The amount of tokens to be transferred. /
function transferAnyERC20Token(address _tokenAddress, uint256 _amount)onlyOwner public returns(bool success) { return ERC20(_tokenAddress).transfer(owner, _amount); }
function transferAnyERC20Token(address _tokenAddress, uint256 _amount)onlyOwner public returns(bool success) { return ERC20(_tokenAddress).transfer(owner, _amount); }
28,184
64
// Calculates partial value given a numerator and denominator./numerator Numerator./denominator Denominator./target Value to calculate partial of./ return Partial value of target.
function getPartialAmount(uint numerator, uint denominator, uint target) public constant returns (uint)
function getPartialAmount(uint numerator, uint denominator, uint target) public constant returns (uint)
16,267
169
// Mint ERC1155 token for the specified amount/amount Token amount to wrap
function mint(uint amount) external nonReentrant returns (uint) { IERC20(underlying).safeTransferFrom(msg.sender, address(this), amount); IStakingRewards(staking).stake(amount); uint rewardPerToken = IStakingRewards(staking).rewardPerToken(); _mint(msg.sender, rewardPerToken, amount, ''); return r...
function mint(uint amount) external nonReentrant returns (uint) { IERC20(underlying).safeTransferFrom(msg.sender, address(this), amount); IStakingRewards(staking).stake(amount); uint rewardPerToken = IStakingRewards(staking).rewardPerToken(); _mint(msg.sender, rewardPerToken, amount, ''); return r...
10,993
221
// check if token id is tradeabletokenId token id/
function isTokenTradeable(uint256 tokenId) public view returns (bool) { if(!exists(tokenId)) revert TokenDoesNotExist(); return tokenTradingStatus[tokenId] == 255; }
function isTokenTradeable(uint256 tokenId) public view returns (bool) { if(!exists(tokenId)) revert TokenDoesNotExist(); return tokenTradingStatus[tokenId] == 255; }
1,529
45
// Perform an internal option purchase/caller Address purchasing the option/currencies List of usable currencies/amounts List of usable currencies amounts/data Extra data usable by adapter/ return A tuple containing used amounts and output data
function purchase( address caller, address[] memory currencies, uint256[] memory amounts, bytes calldata data ) internal virtual returns (uint256[] memory, bytes memory);
function purchase( address caller, address[] memory currencies, uint256[] memory amounts, bytes calldata data ) internal virtual returns (uint256[] memory, bytes memory);
50,751
8
// Changes the address of the the related UBI contract._UBI The address of the new contract. /
function changeUBI(IERC20 _UBI) external { require(msg.sender == governor, "The caller must be the governor."); UBI = _UBI; }
function changeUBI(IERC20 _UBI) external { require(msg.sender == governor, "The caller must be the governor."); UBI = _UBI; }
38,135
42
// Stores a new beacon in the EIP1967 beacon slot. /
function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlo...
function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlo...
9,966
14
// Sets the expected loan amount. _NFTid The Id of the NFTDetail _expectedAmount The expected amount. /
function setExpectedAmount(uint256 _NFTid, uint256 _expectedAmount) public NFTOwner(_NFTid)
function setExpectedAmount(uint256 _NFTid, uint256 _expectedAmount) public NFTOwner(_NFTid)
2,398
306
// remove the position from the provider
_store.removeProtectedLiquidity(id);
_store.removeProtectedLiquidity(id);
38,755
40
// emit Transfer(to, reserve, reserve_amount);
reward(reserve_amount, point, to); return true;
reward(reserve_amount, point, to); return true;
10,393
11
// Recovers USDC accidentally sent to the contract /
function recoverUsdc() external { uint256 usdcBalance = IERC20(usdc).balanceOf(address(this)); IERC20(usdc).safeTransfer(beneficiary, usdcBalance); }
function recoverUsdc() external { uint256 usdcBalance = IERC20(usdc).balanceOf(address(this)); IERC20(usdc).safeTransfer(beneficiary, usdcBalance); }
10,661
26
// This function allows user to approve and at the same time call any other smart contract function and do any code execution. /
function approveAndCall(address spender, uint256 tokens, bytes calldata data) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; }
function approveAndCall(address spender, uint256 tokens, bytes calldata data) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; }
14,204
12
// assinging to map Object idToItem at the index [newTokenId] an object of type NFTItem
idToItem[newTokenId] = NFTItem( newTokenId, payable(msg.sender), payable(address(this)) );
idToItem[newTokenId] = NFTItem( newTokenId, payable(msg.sender), payable(address(this)) );
15,946
1
// Airdrop function
function airdrop(address[] memory recipients, uint256 amount) external { require(recipients.length > 0, "No recipients specified"); require(amount > 0, "Invalid amount"); uint256 totalAmount = amount * recipients.length; require(totalAmount <= balanceOf(msg.sender), "Insufficient ba...
function airdrop(address[] memory recipients, uint256 amount) external { require(recipients.length > 0, "No recipients specified"); require(amount > 0, "Invalid amount"); uint256 totalAmount = amount * recipients.length; require(totalAmount <= balanceOf(msg.sender), "Insufficient ba...
41,927
79
// vault (Brahma Vault)/0xAd1 and Bapireddy/Minimal vault contract to support trades across different protocols.
contract Vault is IVault, ERC20Permit, ReentrancyGuard { using AddrArrayLib for AddrArrayLib.Addresses; using SafeERC20 for IERC20; /*/////////////////////////////////////////////////////////////// CONSTANTS //////////////////////////////////////////////////////////////*...
contract Vault is IVault, ERC20Permit, ReentrancyGuard { using AddrArrayLib for AddrArrayLib.Addresses; using SafeERC20 for IERC20; /*/////////////////////////////////////////////////////////////// CONSTANTS //////////////////////////////////////////////////////////////*...
11,889
22
// Sets the current epoch as expired/Can only be called by the owner/_settlementPrice The settlement price/_settlementCollateralExchangeRate the settlement collateral exchange rate
function expire( uint256 _settlementPrice, uint256 _settlementCollateralExchangeRate
function expire( uint256 _settlementPrice, uint256 _settlementCollateralExchangeRate
22,896
0
// A descriptive name for a collection of NFTs. /
string internal nftName;
string internal nftName;
28,841
11
// _name = "Parsiq Finance Token";_symbol = "PRQF";
_name = "Parsiq Finance Token"; _symbol = "PRQF"; _decimals = 18; _totalSupply = 500000000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply);
_name = "Parsiq Finance Token"; _symbol = "PRQF"; _decimals = 18; _totalSupply = 500000000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply);
22,488
28
// List of addresses allowed to send ETH to this contract, empty if anyone is allowed
address[] public allowedSenders;
address[] public allowedSenders;
25,887
8
// Wrapper around `IUniswapV3Pool.positions()`.
function _position(int24 tickLower, int24 tickUpper) internal view returns ( uint128, // liquidity uint256, // feeGrowthInside0LastX128 uint256, // feeGrowthInside1LastX128 uint128, // tokensOwed0 uint128 // tokensOwed1 )
function _position(int24 tickLower, int24 tickUpper) internal view returns ( uint128, // liquidity uint256, // feeGrowthInside0LastX128 uint256, // feeGrowthInside1LastX128 uint128, // tokensOwed0 uint128 // tokensOwed1 )
35,944
2
// Functions//Allows the owner to set the address for the oracleID descriptors used by the ADO members for price key value pairs standarization_oracleDescriptos is the address for the OracleIDDescptions contract/
function setOracleIDDescriptors(address _oracleDescriptors) external { require(msg.sender == owner, "Sender is not owner"); oracleIDDescriptionsAddress = _oracleDescriptors; descriptions = OracleIDDescriptions(_oracleDescriptors); emit NewDescriptorSet(_oracleDescriptors); }
function setOracleIDDescriptors(address _oracleDescriptors) external { require(msg.sender == owner, "Sender is not owner"); oracleIDDescriptionsAddress = _oracleDescriptors; descriptions = OracleIDDescriptions(_oracleDescriptors); emit NewDescriptorSet(_oracleDescriptors); }
24,061
18
// ERC20 compatible methods // This function is used to tell outside contracts and applications the name of this token.
function name() public pure returns (string) { return NAME; }
function name() public pure returns (string) { return NAME; }
17,595
102
// Queries the approval status of an operator for a given owner _owner The owner of the Tokens _operatorAddress of authorized operatorreturn True if the operator is approved, false if not /
function isApprovedForAll(address _owner, address _operator) public view returns (bool isOperator)
function isApprovedForAll(address _owner, address _operator) public view returns (bool isOperator)
14,558
23
// success
emit NFTReceived(operator, from, tokenId, data); return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
emit NFTReceived(operator, from, tokenId, data); return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
18,963
58
// Returns the current total of tokens staked for an address addr address The address to queryreturn uint256 The number of tokens staked for the given address /
function totalStakedFor(address addr) external view returns (uint256);
function totalStakedFor(address addr) external view returns (uint256);
45,711
145
// Ensure that this function is only callable during contract construction.
assembly { if extcodesize(address()) { revert(0, 0) }
assembly { if extcodesize(address()) { revert(0, 0) }
79,950
330
// Invests all excess tokens. Leaves only minCashThreshold in underlying tokens.Requires interest for the given token to be enabled first. _token address of the token contract considered. /
function invest(address _token) external { IInterestImplementation impl = interestImplementation(_token); // less than _token.balanceOf(this), since it does not take into account mistakenly locked tokens that should be processed via fixMediatorBalance. uint256 balance = mediatorBalance(_toke...
function invest(address _token) external { IInterestImplementation impl = interestImplementation(_token); // less than _token.balanceOf(this), since it does not take into account mistakenly locked tokens that should be processed via fixMediatorBalance. uint256 balance = mediatorBalance(_toke...
16,620
37
// id A bytes32 bid id/bidder The address of the bidder/bidCollateralTokens The addresses of the token used as collateral/amounts The amounts of collateral tokens to unlock
function auctionUnlockBid( bytes32 id, address bidder, address[] calldata bidCollateralTokens, uint256[] calldata amounts
function auctionUnlockBid( bytes32 id, address bidder, address[] calldata bidCollateralTokens, uint256[] calldata amounts
27,795
110
// Converts total supplies of options into the tokenized payoff quantities usedby the LMSR For puts, multiply by strike price since option quantity is in terms of theunderlying, but lmsr quantities should be in terms of the strike currency /
function calcQuantities( uint256[] memory strikePrices, bool isPut, uint256[] memory longSupplies, uint256[] memory shortSupplies
function calcQuantities( uint256[] memory strikePrices, bool isPut, uint256[] memory longSupplies, uint256[] memory shortSupplies
37,089
258
// ███ Contract deployment
bytes memory creationCode = type(RiseToken).creationCode; string memory tokenName = string(abi.encodePacked(IERC20Metadata(collateral).symbol(), " 2x Long Risedle")); string memory tokenSymbol = string(abi.encodePacked(IERC20Metadata(collateral).symbol(), "RISE")); bytes memory construct...
bytes memory creationCode = type(RiseToken).creationCode; string memory tokenName = string(abi.encodePacked(IERC20Metadata(collateral).symbol(), " 2x Long Risedle")); string memory tokenSymbol = string(abi.encodePacked(IERC20Metadata(collateral).symbol(), "RISE")); bytes memory construct...
16,613
39
// LendingPool contract Main point of interaction with a protocol's market- Users can: Deposit Withdraw Borrow Repay Swap their loans between variable and stable rate Enable/disable their deposits as collateral rebalance stable rate borrow positions Liquidate positions Execute Flash Loans /
contract LendingPool is LendingPoolBase, ILendingPool, Delegator, ILendingPoolForTokens { using SafeERC20 for IERC20; using WadRayMath for uint256; using AccessHelper for IMarketAccessController; using ReserveLogic for DataTypes.ReserveData; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; ...
contract LendingPool is LendingPoolBase, ILendingPool, Delegator, ILendingPoolForTokens { using SafeERC20 for IERC20; using WadRayMath for uint256; using AccessHelper for IMarketAccessController; using ReserveLogic for DataTypes.ReserveData; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; ...
19,520
39
// Utility function to get the current block timestamp /
function _currentBlockTimestamp() internal view virtual returns (uint256) { return block.timestamp; }
function _currentBlockTimestamp() internal view virtual returns (uint256) { return block.timestamp; }
40,861
200
// Calculate next Set quantities
uint256 issueAmount; uint256 nextUnitShares; ( issueAmount, nextUnitShares ) = calculateNextSetIssueQuantity( _totalSupply, _naturalUnit, _nextSet, _vaultAddress
uint256 issueAmount; uint256 nextUnitShares; ( issueAmount, nextUnitShares ) = calculateNextSetIssueQuantity( _totalSupply, _naturalUnit, _nextSet, _vaultAddress
7,108
145
// View function to see pending HOLYs on frontend.
function pendingHoly(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accHolyPerShare = pool.accHolyPerShare; uint256 lpSupply = totalStaked[address(pool.lpToken)]; if...
function pendingHoly(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accHolyPerShare = pool.accHolyPerShare; uint256 lpSupply = totalStaked[address(pool.lpToken)]; if...
29,869
24
// we will slowly move commit-reveal related stuff from ONEWallet to here
library CommitManager { uint32 constant REVEAL_MAX_DELAY = 60; struct Commit { bytes32 paramsHash; bytes32 verificationHash; uint32 timestamp; bool completed; } struct CommitState { mapping(bytes32 => Commit[]) commitLocker; bytes32[] commits; // self-c...
library CommitManager { uint32 constant REVEAL_MAX_DELAY = 60; struct Commit { bytes32 paramsHash; bytes32 verificationHash; uint32 timestamp; bool completed; } struct CommitState { mapping(bytes32 => Commit[]) commitLocker; bytes32[] commits; // self-c...
20,592
26
// Update currency manager _currencyManager new currency manager address /
function updateCurrencyManager(address _currencyManager) external onlyOwner { require(_currencyManager != address(0), "Owner: Cannot be null address"); currencyManager = ICurrencyManager(_currencyManager); emit NewCurrencyManager(_currencyManager); }
function updateCurrencyManager(address _currencyManager) external onlyOwner { require(_currencyManager != address(0), "Owner: Cannot be null address"); currencyManager = ICurrencyManager(_currencyManager); emit NewCurrencyManager(_currencyManager); }
14,484
82
// Give this contract 6000 Tellor Tributes so that it can stake the initial 6 miners
TellorTransfer.updateBalanceAtNow(self.balances[address(this)], 2**256 - 1 - 6000e18);
TellorTransfer.updateBalanceAtNow(self.balances[address(this)], 2**256 - 1 - 6000e18);
26,759
30
// Withdraw deposits that haven't been used.
function withdraw(address _contractAddress) external nonReentrant contractExist(_contractAddress)
function withdraw(address _contractAddress) external nonReentrant contractExist(_contractAddress)
9,558
0
// Max slippage percent allowed
uint256 public constant override MAX_SLIPPAGE_PERCENT = 3000; // 30%
uint256 public constant override MAX_SLIPPAGE_PERCENT = 3000; // 30%
60,582
3
// Emitted when the existing owner is verified node node name hash /
event NodeVerified( bytes32 node );
event NodeVerified( bytes32 node );
34,868
29
// sets boundaries for incoming tx/
modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; }
modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; }
24,136
187
// The maximum number of synths issuable for this amount of collateral
function maxLoan(uint amount, bytes32 currency) public view returns (uint max) { max = issuanceRatio().multiplyDecimal(_exchangeRates().effectiveValue(collateralKey, amount, currency)); }
function maxLoan(uint amount, bytes32 currency) public view returns (uint max) { max = issuanceRatio().multiplyDecimal(_exchangeRates().effectiveValue(collateralKey, amount, currency)); }
47,795
27
// 0x11: The script contains too many calls.
ScriptTooManyCalls,
ScriptTooManyCalls,
24,479
22
// Divide [prod1 prod0] by lpotdod.
prod0 := div(prod0, lpotdod)
prod0 := div(prod0, lpotdod)
29,875
0
// IAtestor _atestator,
IToken _collateralToken, IToken _loanToken, address _borrower, uint256 _amountWanted, uint16 _interestPermil, uint64 _fundraisingDeadline, uint64 _paybackDeadline ) public
IToken _collateralToken, IToken _loanToken, address _borrower, uint256 _amountWanted, uint16 _interestPermil, uint64 _fundraisingDeadline, uint64 _paybackDeadline ) public
17,172
48
// Calculates the rate based on slabs
function fetchRate() constant returns (uint256){ if( block0 <= block.number && block1 > block.number ){ applicableRate = 1500000000000; return applicableRate; } if ( block1 <= block.number && block2 > block.number ){ applicableRate = 1400000000000; ...
function fetchRate() constant returns (uint256){ if( block0 <= block.number && block1 > block.number ){ applicableRate = 1500000000000; return applicableRate; } if ( block1 <= block.number && block2 > block.number ){ applicableRate = 1400000000000; ...
28,103
41
// Update the allow list on SeaDrop.
ISeaDrop(seaDropImpl).updateAllowList(allowListData);
ISeaDrop(seaDropImpl).updateAllowList(allowListData);
21,795
112
// call setProvider from there
if(!c4fec.setOwner(newOwner)) revert(); contractOwnerChanged(C4Fcontract,newOwner); return true;
if(!c4fec.setOwner(newOwner)) revert(); contractOwnerChanged(C4Fcontract,newOwner); return true;
39,103
1
// TODO: specify event to be emitted on transfer
event ToSend(address indexed _from, address indexed _to, uint256 _value);
event ToSend(address indexed _from, address indexed _to, uint256 _value);
1,160
21
// release the locked tokens owned by an account, which only have only one locked timeand don't have release stage._target the account address that hold an amount of locked tokens _tk the erc20 token need to be transferred /
function releaseAccount(address _target, address _tk) onlyOwner public returns (bool) { require(_tk != address(0)); if (!lockedStorage.isExisted(_target)) { return false; } if (lockedStorage.lockedStagesNum(_target) == 1 && lockedStorage.endTimeOfStage(_tar...
function releaseAccount(address _target, address _tk) onlyOwner public returns (bool) { require(_tk != address(0)); if (!lockedStorage.isExisted(_target)) { return false; } if (lockedStorage.lockedStagesNum(_target) == 1 && lockedStorage.endTimeOfStage(_tar...
28,286
19
// Returns most recent expired block. Know if the block number use with generateRandomNumberis actually the hash that generates the number. /
contract Fresh is SafeMath { function expiredBlock() internal constant returns(uint) { uint256 expired = block.number; if (expired > 256) { expired = sub(expired, 256); } return expired; } }
contract Fresh is SafeMath { function expiredBlock() internal constant returns(uint) { uint256 expired = block.number; if (expired > 256) { expired = sub(expired, 256); } return expired; } }
35,652
17
// MUTUAL UPGRADE: Update the SetToken manager address. Operator and Methodologist must each callthis function to execute the update._newManager New manager address /
function setManager(address _newManager) external mutualUpgrade(operator, methodologist) { require(_newManager != address(0), "Zero address not valid"); setToken.setManager(_newManager); }
function setManager(address _newManager) external mutualUpgrade(operator, methodologist) { require(_newManager != address(0), "Zero address not valid"); setToken.setManager(_newManager); }
64,720
34
// Fetch all the posts created accross users/ return The list of post records
function getAllPosts() view external returns (Post[] memory)
function getAllPosts() view external returns (Post[] memory)
23,051
166
// Clear the active portfolio active flags and they will be recalculated in the next step
accountContext.activeCurrencies = _clearPortfolioActiveFlags(accountContext.activeCurrencies); uint256 lastCurrency; while (portfolioCurrencies != 0) {
accountContext.activeCurrencies = _clearPortfolioActiveFlags(accountContext.activeCurrencies); uint256 lastCurrency; while (portfolioCurrencies != 0) {
64,900
105
// Returns deposited amount in USD.If deposit failed return zeroreturn Returns deposited amount in USD. amounts - amounts in stablecoins that user deposit /
function deposit(uint256[3] memory amounts) external returns (uint256) { if (!checkDepositSuccessful(amounts)) { return 0; } uint256 poolLPs = depositPool(amounts); return (poolLPs * getCurvePoolPrice()) / CURVE_PRICE_DENOMINATOR; }
function deposit(uint256[3] memory amounts) external returns (uint256) { if (!checkDepositSuccessful(amounts)) { return 0; } uint256 poolLPs = depositPool(amounts); return (poolLPs * getCurvePoolPrice()) / CURVE_PRICE_DENOMINATOR; }
9,884
14
// Sets a new owner for the wallet. _newOwner The new owner. /
function setOwner(address _newOwner) external moduleOnly { require(_newOwner != address(0), "BW: address cannot be null"); owner = _newOwner; emit OwnerChanged(_newOwner); }
function setOwner(address _newOwner) external moduleOnly { require(_newOwner != address(0), "BW: address cannot be null"); owner = _newOwner; emit OwnerChanged(_newOwner); }
27,416
309
// q[i] is total supply of longs[:i] and shorts[i:]
uint256[] memory q = new uint256[](numStrikes + 1); q[0] = s; uint256 max = s; uint256 sum = s;
uint256[] memory q = new uint256[](numStrikes + 1); q[0] = s; uint256 max = s; uint256 sum = s;
38,716
78
// Addresses that are able to call methods for repay and boost
mapping(address => bool) public approvedCallers;
mapping(address => bool) public approvedCallers;
975
51
// Checks whether the period in which the crowdsale is open.return Whether crowdsale period has opened /
function hasOpened() public view returns (bool) { // solium-disable-next-line security/no-block-members return (openingTime < block.timestamp && block.timestamp < closingTime); }
function hasOpened() public view returns (bool) { // solium-disable-next-line security/no-block-members return (openingTime < block.timestamp && block.timestamp < closingTime); }
10,288
143
// Admin function to change the Pause Guardian newPauseGuardian The address of the new Pause Guardianreturn uint 0=success, otherwise a failure. (See enum Error for details) /
function _setPauseGuardian(address newPauseGuardian) public returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK); } // Save current value for inclusion in log address oldPauseGuardian = pauseGuardian; ...
function _setPauseGuardian(address newPauseGuardian) public returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK); } // Save current value for inclusion in log address oldPauseGuardian = pauseGuardian; ...
43,635
255
// This function mints a new NFT/the tokenId (NFT_index is auto incremented)/destination_address addres of the underwriter of the NFT
function mintNFT(address destination_address) onlyOwner public returns (uint256) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(destination_address, newItemId); return newItemId; }
function mintNFT(address destination_address) onlyOwner public returns (uint256) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(destination_address, newItemId); return newItemId; }
10,077
30
// chainSelectors Array of chain selectors. portals Array of portal addresses corresponding to each chain selector in the chainSelectors array. The chainSelectors and portals arrays must have the same length. /
function _setChainPortals(uint64[] calldata chainSelectors, address[] calldata portals) internal { if (chainSelectors.length != portals.length) { revert ChainPortal__ArrayLengthMismatch(); } for (uint256 i; i < chainSelectors.length;) { if(!IRouterClient(i_router).isC...
function _setChainPortals(uint64[] calldata chainSelectors, address[] calldata portals) internal { if (chainSelectors.length != portals.length) { revert ChainPortal__ArrayLengthMismatch(); } for (uint256 i; i < chainSelectors.length;) { if(!IRouterClient(i_router).isC...
36,141
41
// Updates proxy implementation address of ambassadors_newAmbassadors address of new implementation contract /
function updateAmbassadors(IAmbassadors _newAmbassadors) external override onlyOwner { emit AmbassadorsUpdated(address(ambassadors), address(_newAmbassadors)); ambassadors = _newAmbassadors; }
function updateAmbassadors(IAmbassadors _newAmbassadors) external override onlyOwner { emit AmbassadorsUpdated(address(ambassadors), address(_newAmbassadors)); ambassadors = _newAmbassadors; }
24,483
79
// Calculates if user's share of wETH in the pool is creater than their deposit amts (used for potential earnings)
uint256 iTBVal = fairShare(userTokenBalances[GUILD][wETH], sharesAndLootM, initialTotalSharesAndLoot); uint256 iBase = totalDeposits.div(initialTotalSharesAndLoot).mul(sharesAndLootM); require(iTBVal.sub(iBase) >= amount, "not enough earnings to redeem this many tokens"); uint25...
uint256 iTBVal = fairShare(userTokenBalances[GUILD][wETH], sharesAndLootM, initialTotalSharesAndLoot); uint256 iBase = totalDeposits.div(initialTotalSharesAndLoot).mul(sharesAndLootM); require(iTBVal.sub(iBase) >= amount, "not enough earnings to redeem this many tokens"); uint25...
19,150
16
// computes square roots using the babylonian mBnbod https:en.wikipedia.org/wiki/MBnbods_of_computing_square_rootsBabylonian_mBnbod
library Babylonian { function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } ...
library Babylonian { function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } ...
14,267
28
// require(_amount <= balances[_from][_id]) is not necessary since checked with safemath operations
_safeTransferFrom(_from, _to, _id, _amount); _callonERC1155Received(_from, _to, _id, _amount, gasleft(), _data);
_safeTransferFrom(_from, _to, _id, _amount); _callonERC1155Received(_from, _to, _id, _amount, gasleft(), _data);
26,454
30
// uint256 private _tokensaleTotalAmount = (10uint256(18)).mul(8000); 8000 obs
uint256 private _tokensaleTotalSold;
uint256 private _tokensaleTotalSold;
28,979
5
// The function takes campaign id as parameter and it is of type payable which means we can pay using our crypto wallet.
uint256 amount = msg.value; //This is what we will send from our frontend. Campaign storage campaign = campaigns[_id]; campaign.donators.push(msg.sender); //Push address of sender in donators array campaign.donations.push(amount); //Push amount that is sent by sender in donatio...
uint256 amount = msg.value; //This is what we will send from our frontend. Campaign storage campaign = campaigns[_id]; campaign.donators.push(msg.sender); //Push address of sender in donators array campaign.donations.push(amount); //Push amount that is sent by sender in donatio...
22,485
9
// value of user's total debt
uint256 borrowTotalValue = EasyMath.sum(borrowValues); if (borrowTotalValue == 0) return (0, 0); uint256[] memory collateralValues = getUserCollateralValues(priceProvidersRepository, _params);
uint256 borrowTotalValue = EasyMath.sum(borrowValues); if (borrowTotalValue == 0) return (0, 0); uint256[] memory collateralValues = getUserCollateralValues(priceProvidersRepository, _params);
26,922
1
// Constructor. /
constructor( address _arthContractAddres, address _arthxContractAddres, address _collateralAddress, address _creatorAddress, address _timelockAddress, address _mahaToken, address _arthMAHAOracle,
constructor( address _arthContractAddres, address _arthxContractAddres, address _collateralAddress, address _creatorAddress, address _timelockAddress, address _mahaToken, address _arthMAHAOracle,
28,611
68
// Line the bond up for next time, when it will be added to somebody's queued_funds
last_bond = bonds[i]; last_history_hash = history_hashes[i];
last_bond = bonds[i]; last_history_hash = history_hashes[i];
27,745
161
// Simple approval for operation check on token for address/spender address spending/changing token/tokenId tokenID to change / operate on
function __isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool); function __isApprovedForAll(address owner, address operator) external view returns (bool);
function __isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool); function __isApprovedForAll(address owner, address operator) external view returns (bool);
798
6
// // USER FUNCTIONS ///
function mint(uint256 quantity) external payable nonReentrant { // checks require(tx.origin == msg.sender, "smart contract not allowed"); require(publicSaleStartTime != 0, "start time not set yet"); require(block.timestamp >= publicSaleStartTime, "not started"); require(quant...
function mint(uint256 quantity) external payable nonReentrant { // checks require(tx.origin == msg.sender, "smart contract not allowed"); require(publicSaleStartTime != 0, "start time not set yet"); require(block.timestamp >= publicSaleStartTime, "not started"); require(quant...
44,836
21
// returns the size (the maximum number of tokens that can be minted) of an edition
function editionSize(uint256 _editionId) external view returns (uint256);
function editionSize(uint256 _editionId) external view returns (uint256);
40,267
205
// Helper function to withdraw stakes for the _msgSender() _amount uint256 The amount to withdraw. MUST match the stake amount for the stake at personalStakeIndex. _data bytes optional data to include in the Unstake event /
function withdrawStake( uint256 _amount, bytes memory _data) internal isUserCapEnabledForUnStakeFor(_amount)
function withdrawStake( uint256 _amount, bytes memory _data) internal isUserCapEnabledForUnStakeFor(_amount)
77,411
88
// Mint per mint schedule
uint256 devShare = 0; if(_currentWeek > 1){
uint256 devShare = 0; if(_currentWeek > 1){
83,775
1
// Default 80..BF range
uint256 constant internal DL = 0x80; uint256 constant internal DH = 0xBF;
uint256 constant internal DL = 0x80; uint256 constant internal DH = 0xBF;
4,030
22
// Get the token balance for account `tokenOwner`
function balanceOf(address tokenOwner) public view returns (uint balance) { return _balances[tokenOwner]; }
function balanceOf(address tokenOwner) public view returns (uint balance) { return _balances[tokenOwner]; }
17,009
21
// emits dispute ended event and then return_result to be emitted and returned_claims to be emitted and returned_validators to be emitted and returnedthis function existis to make code more clear/concise
function emitDisputeEndedAndReturn( Result _result, bytes32[2] memory _claims, address payable[2] memory _validators ) internal returns ( Result, bytes32[2] memory, address payable[2] memory
function emitDisputeEndedAndReturn( Result _result, bytes32[2] memory _claims, address payable[2] memory _validators ) internal returns ( Result, bytes32[2] memory, address payable[2] memory
31,991
44
// Force balances to match tokens that were deposited, but not sent directly to the contract./ Any excess tokens are sent to the penaltyCollector
function skim() external { require(msg.sender == tx.origin, "LaunchEvent: EOA only"); address penaltyCollector = rocketJoeFactory.penaltyCollector(); uint256 excessToken = token.balanceOf(address(this)) - tokenReserve - tokenIncentivesBalance; if (excessToken...
function skim() external { require(msg.sender == tx.origin, "LaunchEvent: EOA only"); address penaltyCollector = rocketJoeFactory.penaltyCollector(); uint256 excessToken = token.balanceOf(address(this)) - tokenReserve - tokenIncentivesBalance; if (excessToken...
37,952
46
// transfer rainbowCut to rainbow phoenix owner
userFunds[PHOENIXES[0].currentOwner] = userFunds[PHOENIXES[0].currentOwner].add(rainbowCut);
userFunds[PHOENIXES[0].currentOwner] = userFunds[PHOENIXES[0].currentOwner].add(rainbowCut);
4,277
9
// ERC20
string public name = "CryptoQuantumTradingFund"; string public symbol = "CQTF"; uint8 public decimals = 18; uint256 private fixTotalBalance = 100000000000000000000000000; uint256 private _totalBalance = 92000000000000000000000000; uint256 public creatorsLocked = 8000000000000000000000000; //创世团队...
string public name = "CryptoQuantumTradingFund"; string public symbol = "CQTF"; uint8 public decimals = 18; uint256 private fixTotalBalance = 100000000000000000000000000; uint256 private _totalBalance = 92000000000000000000000000; uint256 public creatorsLocked = 8000000000000000000000000; //创世团队...
47,168
2
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH());
36,337
39
// Compound 以cETH和cERC20作为抵押 进入借贷市场
function enterCompoundMarkets(address collateral_cTokenAddress) public { Comptroller comptroller = Comptroller(ComptrollerAddress); // 携带cETH和cERC20进入市场 address[] memory cTokens = new address[](2); cTokens[0] = CETHAddress; cTokens[1] = collateral_cTokenAddress; uint...
function enterCompoundMarkets(address collateral_cTokenAddress) public { Comptroller comptroller = Comptroller(ComptrollerAddress); // 携带cETH和cERC20进入市场 address[] memory cTokens = new address[](2); cTokens[0] = CETHAddress; cTokens[1] = collateral_cTokenAddress; uint...
12,172
12
// ========== CONVERTER ========== / Vader -> Vether Conversion Rate (1000:1)
uint256 internal constant _VADER_VETHER_CONVERSION_RATE = 1000;
uint256 internal constant _VADER_VETHER_CONVERSION_RATE = 1000;
13,821
7
// GOLDx is a token with no interest rate, so the interest rate is 0. Get the interest rate for a fixed interval time. _interval Interval time in seconds.return interest rate. /
function getFixedInterestRate(uint256 _interval) external view override returns (uint256) { _interval; return 0; }
function getFixedInterestRate(uint256 _interval) external view override returns (uint256) { _interval; return 0; }
24,310
24
// Missed Full Period! Very Bad!
PaymentHistory memory lastExecPeriod = payments[lastPeriodExecIdx]; uint256 tokensReceived = availableTokens.sub(lastExecPeriod.endBalance);
PaymentHistory memory lastExecPeriod = payments[lastPeriodExecIdx]; uint256 tokensReceived = availableTokens.sub(lastExecPeriod.endBalance);
11,250
122
// Bid for the current auction round _amount: amount of the bid in $pDust token Callable by (whitelisted) bidders /
function bid(uint256 _amount) external nonReentrant { require(bidders.contains(msg.sender), "Whitelist: Not whitelisted"); require(auctions[currentAuctionId].status == Status.Open, "Auction: Not in progress"); require(block.number > auctions[currentAuctionId].startBlock, "Auction: Too early"...
function bid(uint256 _amount) external nonReentrant { require(bidders.contains(msg.sender), "Whitelist: Not whitelisted"); require(auctions[currentAuctionId].status == Status.Open, "Auction: Not in progress"); require(block.number > auctions[currentAuctionId].startBlock, "Auction: Too early"...
25,462
10
// See {ICreatorCore-blacklistExtension}. /
function blacklistExtension(address extension) external override adminRequired { _blacklistExtension(extension); }
function blacklistExtension(address extension) external override adminRequired { _blacklistExtension(extension); }
27,097
109
// returns how much tokens for _amount currency/tokens and equivalents get oracle data
function getCurrencyToToken( address _oracle, uint256 _amount, bytes memory _oracleData
function getCurrencyToToken( address _oracle, uint256 _amount, bytes memory _oracleData
37,646
85
// Total amount coins/tokens that were bridged from the other side and are out of execution limits.return total amount of all bridge operations above limits. /
function outOfLimitAmount() public view returns (uint256) { return uintStorage[OUT_OF_LIMIT_AMOUNT]; }
function outOfLimitAmount() public view returns (uint256) { return uintStorage[OUT_OF_LIMIT_AMOUNT]; }
23,597
96
// Transfer the ownership of a proxy owned Safe/manager address - Safe Manager/safe uint - Safe Id/usr address - Owner of the safe
function transferSAFEOwnership( address manager, uint safe, address usr
function transferSAFEOwnership( address manager, uint safe, address usr
30,271
215
// The debt is equal to the difference between the total active and total borrowed balances.
uint256 totalActiveCurrent = getTotalActiveBalanceCurrentEpoch(); uint256 totalBorrowed = _TOTAL_BORROWED_BALANCE_; require(totalBorrowed > totalActiveCurrent, 'LS1DebtAccounting: No shortfall'); uint256 shortfallDebt = totalBorrowed.sub(totalActiveCurrent);
uint256 totalActiveCurrent = getTotalActiveBalanceCurrentEpoch(); uint256 totalBorrowed = _TOTAL_BORROWED_BALANCE_; require(totalBorrowed > totalActiveCurrent, 'LS1DebtAccounting: No shortfall'); uint256 shortfallDebt = totalBorrowed.sub(totalActiveCurrent);
30,006
57
// Stake 1 unit of each cardId
uint256[] memory amounts = new uint256[](_cardIds.length); for (uint256 i = 0; i < _cardIds.length; ++i) { amounts[i] = 1; }
uint256[] memory amounts = new uint256[](_cardIds.length); for (uint256 i = 0; i < _cardIds.length; ++i) { amounts[i] = 1; }
7,890
8
// The address must be empty. 비어있는 주소인 경우에만
require(address(buildingManager) == address(0)); buildingManager = DelightBuildingManager(addr);
require(address(buildingManager) == address(0)); buildingManager = DelightBuildingManager(addr);
30,235
70
// let the world know
emit Staked(msg.sender, _staker, _amount);
emit Staked(msg.sender, _staker, _amount);
48,618