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
17
// Sanity check in case the contract does not do this
require(balance > 0); require(erc20.transfer(msg.sender, balance)); return true;
require(balance > 0); require(erc20.transfer(msg.sender, balance)); return true;
48,195
519
// unsuccess:
success := 0
success := 0
18,527
80
// Last time the pool distribute rewards to all stakeholders
uint256 internal _lastRewardDistributionOn; uint256 public _poolRewardHalvingAt = 0;
uint256 internal _lastRewardDistributionOn; uint256 public _poolRewardHalvingAt = 0;
7,322
163
// MIP39c2-SP2: Adding Risk Core Unit Hash: seth keccak -- "$(wget https:raw.githubusercontent.com/makerdao/mips/5c981b8b24c966d110f133c792d27e7728cc77ab/MIP39/MIP39c2-Subproposals/MIP39c2-SP2.md -q -O - 2>/dev/null)"
string constant public MIP39c2SP2 = "0xd1989672d982ca42dccbaf6d2682e68fd0ecc8c0b9537f2c970665af25c593c3";
string constant public MIP39c2SP2 = "0xd1989672d982ca42dccbaf6d2682e68fd0ecc8c0b9537f2c970665af25c593c3";
54,987
3
// Reentrant evil erc20
contract ReentrantERC20 { address state_gravityAddress; constructor(address _gravityAddress) public { state_gravityAddress = _gravityAddress; } function transfer(address _recipient, uint256 _amount) public returns (bool) { // _currentValidators, _currentPowers, _currentValsetNonce, _v, _r, _s, _args);( addr...
contract ReentrantERC20 { address state_gravityAddress; constructor(address _gravityAddress) public { state_gravityAddress = _gravityAddress; } function transfer(address _recipient, uint256 _amount) public returns (bool) { // _currentValidators, _currentPowers, _currentValsetNonce, _v, _r, _s, _args);( addr...
2,143
38
// Deposit LP tokens to MasterChef for FUZZ allocation.
function deposit(uint256 _pid, uint256 _amount) public { require (_pid != 0, 'deposit FUZZ by staking'); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); uint256 stakingRewards = 0; if(stakingRewa...
function deposit(uint256 _pid, uint256 _amount) public { require (_pid != 0, 'deposit FUZZ by staking'); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); uint256 stakingRewards = 0; if(stakingRewa...
16,554
22
// A function used by withdrawLiquidation function from SelfMintingPerpetualLiquidatableMultiParty contractto withdraw any proceeds after a successfull liquidation on a token sponsor position liquidation The liquidation for which proceeds will be withdrawn fetched from storage liquidatableData Data for the liquidation ...
function withdrawLiquidation( SelfMintingPerpetualLiquidatableMultiParty.LiquidationData storage liquidation, SelfMintingPerpetualLiquidatableMultiParty.LiquidatableData storage liquidatableData, SelfMintingPerpetualPositionManagerMultiParty.PositionManagerData storage positionManagerDat...
function withdrawLiquidation( SelfMintingPerpetualLiquidatableMultiParty.LiquidationData storage liquidation, SelfMintingPerpetualLiquidatableMultiParty.LiquidatableData storage liquidatableData, SelfMintingPerpetualPositionManagerMultiParty.PositionManagerData storage positionManagerDat...
9,582
7
// Assigns a new address to act as the COO. Only available to the current CEO/_newCOO The address of the new COO
function setCOO(address _newCOO) public onlyCEO { require(_newCOO != address(0)); cooAddress = _newCOO; }
function setCOO(address _newCOO) public onlyCEO { require(_newCOO != address(0)); cooAddress = _newCOO; }
61,010
108
// sets affiliate fee with WEI_PERCENT_PRECISION/newValue affiliate fee percent
function setAffiliateFeePercent(uint256 newValue) external;
function setAffiliateFeePercent(uint256 newValue) external;
43,016
125
// (avgPriceoldBalance) + (currPricenewQty)) / totBalance
userAvgPrices[usr] = userAvgPrices[usr].mul(oldBalance).add(price.mul(newQty)).div(oldBalance.add(newQty));
userAvgPrices[usr] = userAvgPrices[usr].mul(oldBalance).add(price.mul(newQty)).div(oldBalance.add(newQty));
22,855
82
// this calls getPlayerId because it was almost a copy of it.
(bool out, ) = getPlayerId(_avatarId); return out;
(bool out, ) = getPlayerId(_avatarId); return out;
40,176
15
// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
uint immutable x = 1;
uint immutable x = 1;
37,780
194
// Changes the admin of the proxy.
* Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); }
* Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); }
17,995
107
// In case there are some issues discovered about the pool or underlying asset Governance can exit the pool properly The function is only used for emergency to exit the pool/
function emergencyExit() public onlyGovernance { rewardPool.exit(); pausedInvesting = true; }
function emergencyExit() public onlyGovernance { rewardPool.exit(); pausedInvesting = true; }
46,872
488
// Liquidate a loan if it is expired or under collateralized loanID The ID of the loan to be liquidated /
function liquidateLoan(uint256 loanID) external loanActive(loanID) isInitialized() whenNotPaused() whenLendingPoolNotPaused(address(lendingPool)) nonReentrant()
function liquidateLoan(uint256 loanID) external loanActive(loanID) isInitialized() whenNotPaused() whenLendingPoolNotPaused(address(lendingPool)) nonReentrant()
12,231
9
// Starts a proposal for fee /
function setProposal(Proposal memory VoteProposal) redeemRightToVot public { proposals.push( Proposal({ motivation: VoteProposal.motivation, value: VoteProposal.value, voteCount: 0 })); }
function setProposal(Proposal memory VoteProposal) redeemRightToVot public { proposals.push( Proposal({ motivation: VoteProposal.motivation, value: VoteProposal.value, voteCount: 0 })); }
37,700
48
// Mapping of actionIds to Actions. This data can be accessed through the `getAction` function.
mapping(uint256 actionId => Action) internal actions;
mapping(uint256 actionId => Action) internal actions;
33,712
3
// VaultCore.sol
function mint( address _asset, uint256 _amount, uint256 _minimumOusdAmount ) external; function mintMultiple( address[] calldata _assets, uint256[] calldata _amount, uint256 _minimumOusdAmount
function mint( address _asset, uint256 _amount, uint256 _minimumOusdAmount ) external; function mintMultiple( address[] calldata _assets, uint256[] calldata _amount, uint256 _minimumOusdAmount
33,898
111
// track amount allocated into pool
if ( amount < tokenInfo[ token ].deployed ) { tokenInfo[ token ].deployed = tokenInfo[ token ].deployed.sub( amount ); } else {
if ( amount < tokenInfo[ token ].deployed ) { tokenInfo[ token ].deployed = tokenInfo[ token ].deployed.sub( amount ); } else {
31,340
1
// Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to theaccount that deploys the contract. Token URIs will be autogenerated based on `baseURI` and their token IDs.See {ERC721-tokenURI}. /
constructor(string memory name, string memory symbol, string memory baseTokenURI, address royaltiesReceiver, uint96 royaltiesFeeNumerator, address eventContract) ERC721(name, symbol,eventContract) {
constructor(string memory name, string memory symbol, string memory baseTokenURI, address royaltiesReceiver, uint96 royaltiesFeeNumerator, address eventContract) ERC721(name, symbol,eventContract) {
21,163
99
// To display on website
function getGameInfo() external constant returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256[], bool[]){ uint256[] memory units = new uint256[](schema.currentNumberOfUnits()); bool[] memory upgrades = new bool[](schema.currentNumberOfUpgrades()); ...
function getGameInfo() external constant returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256[], bool[]){ uint256[] memory units = new uint256[](schema.currentNumberOfUnits()); bool[] memory upgrades = new bool[](schema.currentNumberOfUpgrades()); ...
62,020
2
// SHOPX Settings value percentage (using 2 decimals: 10000 = 100.00%, 0 = 0.00%) shopxFee value (between 0 and 10000)
address public shopxAddress; uint256 public shopxFee;
address public shopxAddress; uint256 public shopxFee;
20,195
166
// set locked amount
Staked[sender] = 0;
Staked[sender] = 0;
60,761
52
// Emitted when a previosly dead token is marked as alive tokenId Token ID /
event Resurrection(uint256 indexed tokenId);
event Resurrection(uint256 indexed tokenId);
80,005
16
// 从未上过架的上架 { preItemId: 上级授权的item id}
function uploadMarket( address nftContract, uint256 tokenId, uint256 preItemId, uint256 price ) public payable nonReentrant { require( price >= _marketFee, "Price must be larger than the mark fee of 0.0000001 ether" );
function uploadMarket( address nftContract, uint256 tokenId, uint256 preItemId, uint256 price ) public payable nonReentrant { require( price >= _marketFee, "Price must be larger than the mark fee of 0.0000001 ether" );
28,179
24
// ERC20 Token Info /
function name() external view override returns (string memory) { return _name; }
function name() external view override returns (string memory) { return _name; }
5,085
22
// 发行 Cat
function issueCat( string _genes
function issueCat( string _genes
43,778
15
// check if boost and boost allowed
if (_method == Method.Boost && !holder.boostEnabled) return (false, 0, "Boost not enabled");
if (_method == Method.Boost && !holder.boostEnabled) return (false, 0, "Boost not enabled");
12,744
61
// ensures instantiation only by sub-contracts/
constructor() internal {} // protects a function against reentrancy attacks modifier protected() { _protected(); locked = true; _; locked = false; }
constructor() internal {} // protects a function against reentrancy attacks modifier protected() { _protected(); locked = true; _; locked = false; }
1,549
24
// Lets an owner or approved operator burn NFTs of the given tokenIds. _ownerThe owner of the NFTs to burn._tokenIds The tokenIds of the NFTs to burn._amountsThe amounts of the NFTs to burn. /
function burnBatch( address _owner, uint256[] memory _tokenIds, uint256[] memory _amounts
function burnBatch( address _owner, uint256[] memory _tokenIds, uint256[] memory _amounts
26,397
19
// fill pot with c2d
if(info.roundNumber%bigPotFrequency == 0){
if(info.roundNumber%bigPotFrequency == 0){
43,099
221
// Pull aTokens from user
_pullAToken( collateralAsset, collateralReserveData.aTokenAddress, msg.sender, amounts[0], permitSignature );
_pullAToken( collateralAsset, collateralReserveData.aTokenAddress, msg.sender, amounts[0], permitSignature );
47,654
29
// -------------------------------------------------------------------------- Miner --------------------------------------------------------------------------
function getFreeMiner(address ref) public
function getFreeMiner(address ref) public
29,318
13
// Restore the zero slot.
mstore(0x60, 0)
mstore(0x60, 0)
21,265
44
// Call the contract, and revert if the call fails.
if iszero( call( gas(), // Gas remaining. c, // `contracts[i]`. 0, // `msg.value` of the call: 0 ETH. m, // Start of the copy of `bytes[i]` in memory. calldataload(...
if iszero( call( gas(), // Gas remaining. c, // `contracts[i]`. 0, // `msg.value` of the call: 0 ETH. m, // Start of the copy of `bytes[i]` in memory. calldataload(...
14,815
6
// FSA for the policy is a one step with a minimum approval count /
function challengeResponse(uint64 pendingActionId, uint64 challengeId, bool approval) external override { senderRequires(Role.ADMIN); validatePolicyInitialized(); validatePendingActionId(pendingActionId); validateChallengeId(challengeId); _actions.challengeResponse(pendingActionId, challengeId,...
function challengeResponse(uint64 pendingActionId, uint64 challengeId, bool approval) external override { senderRequires(Role.ADMIN); validatePolicyInitialized(); validatePendingActionId(pendingActionId); validateChallengeId(challengeId); _actions.challengeResponse(pendingActionId, challengeId,...
44,958
127
// SusafeToken with Governance.
contract SusafeToken is ERC20Capped("SusafeToken", "SUSAFE", 210000 ether), Ownable { address public dev = address(0); function setDev(address _dev) public onlyOwner { require(dev == address(0) && _dev != address(0), "DevFund contract can be set once only (to avoid of rug-pull)"); dev = _dev; ...
contract SusafeToken is ERC20Capped("SusafeToken", "SUSAFE", 210000 ether), Ownable { address public dev = address(0); function setDev(address _dev) public onlyOwner { require(dev == address(0) && _dev != address(0), "DevFund contract can be set once only (to avoid of rug-pull)"); dev = _dev; ...
66,085
31
// class => {armor | offhand | mainhand} => value => address
mapping(uint8 => mapping(uint8 => mapping(uint8 => mapping(uint8 => address)))) public traitSvgs; IDogewood public dogewood; string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
mapping(uint8 => mapping(uint8 => mapping(uint8 => mapping(uint8 => address)))) public traitSvgs; IDogewood public dogewood; string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
48,775
26
// Adjusting
error AdjustmentResultsInMinimumCollateralNotBeingMet(address thrower, OptionPosition position, uint spotPrice); error CannotClosePositionZero(address thrower); error CannotOpenZeroAmount(address thrower); error CannotAdjustInvalidPosition( address thrower, uint positionId, bool invalidPositionId, ...
error AdjustmentResultsInMinimumCollateralNotBeingMet(address thrower, OptionPosition position, uint spotPrice); error CannotClosePositionZero(address thrower); error CannotOpenZeroAmount(address thrower); error CannotAdjustInvalidPosition( address thrower, uint positionId, bool invalidPositionId, ...
15,731
67
// Redeem all Dharma Dai held by this account for Dai. /
function redeemAllDDai() external { _withdrawMaxFromDharmaToken(AssetType.DAI); }
function redeemAllDDai() external { _withdrawMaxFromDharmaToken(AssetType.DAI); }
43,503
353
// Ensure the Vault has not already been initialized.
require(!isInitialized, "ALREADY_INITIALIZED");
require(!isInitialized, "ALREADY_INITIALIZED");
40,367
15
// Twenty6Fifty2lileddie.eth / Enefte Studio/
contract Twenty6Fifty2 is ERC721A, EnefteOwnership { uint64 public MAX_SUPPLY = 2652; uint64 public TOKEN_PRICE = 0.01 ether; uint64 public SALE_OPENS = 0; uint64 public SALE_CLOSES = 999999999999; uint256 public EMISSIONS = 91000 ether; INinety1 NINETY_ONE; IFold FOLD; IFoldSta...
contract Twenty6Fifty2 is ERC721A, EnefteOwnership { uint64 public MAX_SUPPLY = 2652; uint64 public TOKEN_PRICE = 0.01 ether; uint64 public SALE_OPENS = 0; uint64 public SALE_CLOSES = 999999999999; uint256 public EMISSIONS = 91000 ether; INinety1 NINETY_ONE; IFold FOLD; IFoldSta...
747
15
// Prepare storage for first call.
if (_paidFees.firstContributionTime == 0) { _paidFees.firstContributionTime = now; _paidFees.ruling.push(0); _paidFees.stake.push(stake); _paidFees.totalValue.push(0); _paidFees.totalContributedPerSide.push([0, 0]); _paidFees.loserFullyFund...
if (_paidFees.firstContributionTime == 0) { _paidFees.firstContributionTime = now; _paidFees.ruling.push(0); _paidFees.stake.push(stake); _paidFees.totalValue.push(0); _paidFees.totalContributedPerSide.push([0, 0]); _paidFees.loserFullyFund...
1,482
316
// Per-market mapping of "accounts in this asset"
mapping(address => bool) accountMembership;
mapping(address => bool) accountMembership;
3,331
1
// Public functions //Creates a new ultimate Oracle contract/oracle Oracle address/collateralToken Collateral token address/spreadMultiplier Defines the spread as a multiple of the money bet on other outcomes/challengePeriod Time to challenge oracle outcome/challengeAmount Amount to challenge the outcome/frontRunnerPer...
function createUltimateOracle( Oracle oracle, Token collateralToken, uint8 spreadMultiplier, uint challengePeriod, uint challengeAmount, uint frontRunnerPeriod ) public returns (UltimateOracle ultimateOracle)
function createUltimateOracle( Oracle oracle, Token collateralToken, uint8 spreadMultiplier, uint challengePeriod, uint challengeAmount, uint frontRunnerPeriod ) public returns (UltimateOracle ultimateOracle)
13,131
36
// Function to Withdraw certain amountof funds in ETHER. This method is hereso the Owner can be able to withdraw fundsin case that there is a needof exchanging the amount of ETHER storedin this contract for some other Asset, Fiat or the Like. /
function withdrawSome(uint256 amount) external onlyOwner { require( address(this).balance >= amount, "MDST: No balance found for that amount" ); payable(msg.sender).transfer(amount); }
function withdrawSome(uint256 amount) external onlyOwner { require( address(this).balance >= amount, "MDST: No balance found for that amount" ); payable(msg.sender).transfer(amount); }
43,622
89
// amount sold from virtual trades
uint256 blockTimestampElapsed = blockTimestamp - longTermOrders.lastVirtualOrderTimestamp; uint256 token0SellAmount = orderPool0.currentSalesRate * blockTimestampElapsed / SELL_RATE_ADDITIONAL_PRECISION; uint256 token1SellAmount = orderPool1.currentSalesRate * blockTimestampElapsed /...
uint256 blockTimestampElapsed = blockTimestamp - longTermOrders.lastVirtualOrderTimestamp; uint256 token0SellAmount = orderPool0.currentSalesRate * blockTimestampElapsed / SELL_RATE_ADDITIONAL_PRECISION; uint256 token1SellAmount = orderPool1.currentSalesRate * blockTimestampElapsed /...
60,378
367
// Sets the quorum threshold. _domain The remote domain of the validator set. _threshold The new quorum threshold. /
function setThreshold(uint32 _domain, uint8 _threshold) public onlyOwner { require( _threshold > 0 && _threshold <= validatorCount(_domain), "!range" ); threshold[_domain] = _threshold; emit ThresholdSet(_domain, _threshold); _updateCommitment(_domain...
function setThreshold(uint32 _domain, uint8 _threshold) public onlyOwner { require( _threshold > 0 && _threshold <= validatorCount(_domain), "!range" ); threshold[_domain] = _threshold; emit ThresholdSet(_domain, _threshold); _updateCommitment(_domain...
19,167
107
// Once all allocations on queue have been claimed, reset user state
if (user.Amount == 0) {
if (user.Amount == 0) {
51,334
136
// Transfer enterToken even it's ETH or ERC20._to Offset to generate the random number _amount Random number to generate the other random number /
function _transferEnterToken(address _to, uint256 _amount) internal { if (_isEthPool()) { IWETH(controller.getWeth()).withdraw(_amount); (bool status, ) = payable(_to).call{value: _amount}(""); require(status, "ETH not transferred"); } else { enterToke...
function _transferEnterToken(address _to, uint256 _amount) internal { if (_isEthPool()) { IWETH(controller.getWeth()).withdraw(_amount); (bool status, ) = payable(_to).call{value: _amount}(""); require(status, "ETH not transferred"); } else { enterToke...
32,379
10
// Return the current second highest bid
function getSecondHighestBid() public view returns (uint256){ return runnerUpBid; }
function getSecondHighestBid() public view returns (uint256){ return runnerUpBid; }
7,846
13
// Checks if `str1` ends with `str2`/str1 Span to search within/str2 Span pointing to characters to look for/ return True if the span ends with the provided text, false otherwise
function endsWith(span memory str1, span memory str2) internal pure returns(bool) { if (str1.length < str2.length) { return false; } uint256 str1Ptr = str1.ptr; uint256 str2Ptr = str2.ptr; assembly { let len1 := mload(add(str1, 0x20)) let...
function endsWith(span memory str1, span memory str2) internal pure returns(bool) { if (str1.length < str2.length) { return false; } uint256 str1Ptr = str1.ptr; uint256 str2Ptr = str2.ptr; assembly { let len1 := mload(add(str1, 0x20)) let...
37,132
104
// Control and manage Cocos Use for owner setting operating income address, PayerInterface. /
contract WorldCupControl is WorldCupFactory { /// @dev Operating income address. address public cooAddress; function WorldCupControl() public { cooAddress = msg.sender; } /// @dev Assigns a new address to act as the COO. /// @param _newCOO The address of the new COO. function setCOO(addres...
contract WorldCupControl is WorldCupFactory { /// @dev Operating income address. address public cooAddress; function WorldCupControl() public { cooAddress = msg.sender; } /// @dev Assigns a new address to act as the COO. /// @param _newCOO The address of the new COO. function setCOO(addres...
46,572
77
// Claim ETH Overflow/Claim ETH Overflow from contract
function claimETHOverflow() external onlyOwner { require(address(this).balance > 0, "Ares Token: Cannot send more than contract balance"); uint256 amount = address(this).balance; (bool success,) = address(owner()).call{value : amount}(""); if (success){ emit ClaimETHOverflow(amount); } }
function claimETHOverflow() external onlyOwner { require(address(this).balance > 0, "Ares Token: Cannot send more than contract balance"); uint256 amount = address(this).balance; (bool success,) = address(owner()).call{value : amount}(""); if (success){ emit ClaimETHOverflow(amount); } }
10,851
24
// An event that's emitted when a new mint is accepted
event MintAccepted(uint256 indexed amount, address indexed recipient, uint256 oldSupply, uint256 newSupply);
event MintAccepted(uint256 indexed amount, address indexed recipient, uint256 oldSupply, uint256 newSupply);
9,075
77
// Wrappers over Solidity's arithmetic operations with added overflowchecks. Arithmetic operations in Solidity wrap on overflow. This can easily resultin bugs, because programmers usually assume that an overflow raises anerror, which is the standard behavior in high level programming languages.`SafeMath` restores this ...
library SafeMath64 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint64 a, uint64 b) internal pure returns (uint64) { uint64 c = a + ...
library SafeMath64 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint64 a, uint64 b) internal pure returns (uint64) { uint64 c = a + ...
1,484
193
// Returns the scaling factor for one of the Pool's tokens. Reverts if `token` is not a token registered by thePool. /
function _scalingFactor(bool token0) internal view returns (uint256) { return token0 ? _scalingFactor0 : _scalingFactor1; }
function _scalingFactor(bool token0) internal view returns (uint256) { return token0 ? _scalingFactor0 : _scalingFactor1; }
3,108
62
// If a vault is provided, it must be valid, otherwise throw rather than optimistically-minting with original `msg.sender`. Note, we do not check `checkDelegateForAll` as well, as it is known to be implicitly checked by calling `checkDelegateForContract`.
bool isValidDelegee = delegationRegistryContract .checkDelegateForContract( msg.sender, // delegate _vault, // vault genArt721CoreAddress // contract ); require(isValidDelegee, "Invalid delegate-vault pai...
bool isValidDelegee = delegationRegistryContract .checkDelegateForContract( msg.sender, // delegate _vault, // vault genArt721CoreAddress // contract ); require(isValidDelegee, "Invalid delegate-vault pai...
30,806
216
// Free up returns for Vault to pull
(profit, loss, debtPayment) = prepareReturn(vault.debtOutstanding());
(profit, loss, debtPayment) = prepareReturn(vault.debtOutstanding());
7,398
93
// recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved
state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96);
state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96);
39,969
15
// if layer has traits to pick and no trait been picked yet then pick a trait and roll it.
if (pool[i].length > 0 && picks[i] == 0x0) { j = _uniform(a, pool[i].length); // roll a dice to choose starting pos uint256 count = 0; while (true) { if (count==pool[i].length) { break; ...
if (pool[i].length > 0 && picks[i] == 0x0) { j = _uniform(a, pool[i].length); // roll a dice to choose starting pos uint256 count = 0; while (true) { if (count==pool[i].length) { break; ...
27,948
153
// contracts/math/SafeMathUint.sol/ pragma solidity 0.6.11; /
library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256 b) { b = int256(a); require(b >= 0, "SMU:OOB"); } }
library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256 b) { b = int256(a); require(b >= 0, "SMU:OOB"); } }
20,846
4
// 向owner发送ether
result = owner.send(number); sendEvent(owner, number, result);
result = owner.send(number); sendEvent(owner, number, result);
14,986
0
// MOBOX FarmContract/
address public moboxFarm;
address public moboxFarm;
7,737
17
// : logic overview Redeem `amount` of underlying at the given `couponEpoch` Reverts if balance of underlying at `couponEpoch` is less than `amount`
function redeemCoupons(uint256 couponEpoch, uint256 amount) external { require(epoch().sub(couponEpoch) >= 2, "Market: Too early to redeem"); require(amount != 0, "Market: Amount too low"); decrementBalanceOfCouponUnderlying(msg.sender, couponEpoch, amount, "Market: Insufficient coupon unde...
function redeemCoupons(uint256 couponEpoch, uint256 amount) external { require(epoch().sub(couponEpoch) >= 2, "Market: Too early to redeem"); require(amount != 0, "Market: Amount too low"); decrementBalanceOfCouponUnderlying(msg.sender, couponEpoch, amount, "Market: Insufficient coupon unde...
52,028
163
// Pausable transferFrom function from The address from which tokens are sent to The recipient address value The amount of token to be transferred.return If the transaction was successful in bool. /
function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); }
function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); }
38,109
31
// Transfers ownership of the contract to a new account (`newOwner`). /
function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
14,554
61
// 2^192 doesn't fit within the 192.64-bit format used internally in this function.
if (x >= 192e18) { revert PRBMathUD60x18__Exp2InputTooBig(x); }
if (x >= 192e18) { revert PRBMathUD60x18__Exp2InputTooBig(x); }
53,742
154
// |/ Burn _amount of tokens of a given token id _fromThe address to burn tokens from _idToken id to burn _amountThe amount to be burned /
function _burn(address _from, uint256 _id, uint256 _amount) internal
function _burn(address _from, uint256 _id, uint256 _amount) internal
8,324
41
// sorted lists of orders. one list for token to Eth, other for Eth to token. Each order is added in the correct position in the list to keep it sorted.
OrderListInterface public tokenToEthList; OrderListInterface public ethToTokenList;
OrderListInterface public tokenToEthList; OrderListInterface public ethToTokenList;
21,761
95
// Transfer tokens from other address Send `_value` tokens to `_to` in behalf of `_from`_from The address of the sender _to The address of the recipient _value the amount to send /
function transferFrom(address _from, address _to, uint256 _value) public onlyTranferable returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public onlyTranferable returns (bool success)
43,709
13
// Returns true if mainnet contracts and schain contracts are connected together for transferring messages. /
function hasSchain(string calldata schainName) external view override returns (bool connected) { uint length = _mainnetContracts.length(); connected = messageProxy.isConnectedChain(schainName); for (uint i = 0; connected && i < length; i++) { connected = connected && Twin(_mainne...
function hasSchain(string calldata schainName) external view override returns (bool connected) { uint length = _mainnetContracts.length(); connected = messageProxy.isConnectedChain(schainName); for (uint i = 0; connected && i < length; i++) { connected = connected && Twin(_mainne...
59,577
10
// Returns an array of all hashes./
{ return _allHashes.paginate(page, limit); }
{ return _allHashes.paginate(page, limit); }
1,922
3
// Template version
uint256 public constant VERSION = 1_01_00;
uint256 public constant VERSION = 1_01_00;
28,919
46
// Store the size
mstore(ptr, returndatasize())
mstore(ptr, returndatasize())
25,614
4
// ENG::Function that show SmarrtContract BalanceФункция которая отобразит Баланс СмартКонтракта
function getTotalBalance() public constant returns(uint) { return address(this).balance; }
function getTotalBalance() public constant returns(uint) { return address(this).balance; }
28,263
151
// Allow as many s as desired.
if (character >= 0x30 && character <= 0x39) {
if (character >= 0x30 && character <= 0x39) {
33,170
28
// https:docs.peri.finance/contracts/source/contracts/rewardsdistribution
contract RewardsDistribution is Owned, IRewardsDistribution { using SafeMath for uint; using SafeDecimalMath for uint; /** * @notice Authorised address able to call distributeRewards */ address public authority; /** * @notice Address of the PeriFinance ProxyERC20 */ address...
contract RewardsDistribution is Owned, IRewardsDistribution { using SafeMath for uint; using SafeDecimalMath for uint; /** * @notice Authorised address able to call distributeRewards */ address public authority; /** * @notice Address of the PeriFinance ProxyERC20 */ address...
18,313
59
// Add to balance so tokens don't get issued.
_terminal.addToBalanceOf{value: _payableValue}(_projectId, _amount, _token, _memo, _metadata);
_terminal.addToBalanceOf{value: _payableValue}(_projectId, _amount, _token, _memo, _metadata);
37,088
186
// Only used for local testing. payoutContractAddress = addresses[5];
_name = strings[0]; _symbol = strings[1]; _setSecondary(uints[0]); _setRoyalties(royaltiesAddrs, [uints[1], uints[2], uints[3], uints[4]]); if (uints[5] != 0) { timePerDecrement = uints[5]; }
_name = strings[0]; _symbol = strings[1]; _setSecondary(uints[0]); _setRoyalties(royaltiesAddrs, [uints[1], uints[2], uints[3], uints[4]]); if (uints[5] != 0) { timePerDecrement = uints[5]; }
33,583
72
// - `index` must be strictly less than {length}./
function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; }
function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; }
342
7
// ensure the msg.value is greather than the amount of ETH being sent
require(msg.value > amount, "Not enough ETH provided as msg.value");
require(msg.value > amount, "Not enough ETH provided as msg.value");
5,223
17
// Sets up the initial assets for the pool. Note: `tokenProvider` must have approved the pool to transfer thecorresponding `balances` of `tokens`.tokens Underlying tokens to initialize the pool with balances Initial balances to transfer denorms Initial denormalized weights for the tokens tokenProvider Address to transf...
function initialize( address[] calldata tokens, uint256[] calldata balances, uint96[] calldata denorms, address tokenProvider ) external override _control_
function initialize( address[] calldata tokens, uint256[] calldata balances, uint96[] calldata denorms, address tokenProvider ) external override _control_
7,542
256
// returns the staked balance of a given reserve token_reserveTokenreserve token address return staked balance/
function reserveStakedBalance(IERC20Token _reserveToken) public view validReserve(_reserveToken) returns (uint256)
function reserveStakedBalance(IERC20Token _reserveToken) public view validReserve(_reserveToken) returns (uint256)
10,093
35
// counter starts in 1 as 0 is reserved for empty objects
counter.increment();
counter.increment();
22,133
236
// When the level of the sheet is less than 4, both the nest and the scale of the offer are doubled
if (level < uint(config.maxBiteNestedLevel)) {
if (level < uint(config.maxBiteNestedLevel)) {
37,338
1
// Add new migration data to the contract oldPoolAddress pool address to migrate from mData MigrationData struct that contains information of the old and new pools overwrite should overwrite existing migration data /
function addMigrationData( address oldPoolAddress, MigrationData memory mData, bool overwrite ) external onlyOwner {
function addMigrationData( address oldPoolAddress, MigrationData memory mData, bool overwrite ) external onlyOwner {
23,505
0
// Creates `_amount` token to `_to`. Must only be called by the owner.
function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); }
function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); }
23,575
537
// Implements logic for repay credit accounts//borrower Borrower address/to Address to transfer assets from credit account
function _repayCreditAccountImpl(address borrower, address to) internal returns (uint256)
function _repayCreditAccountImpl(address borrower, address to) internal returns (uint256)
28,849
7
// Generates a data key of keyType Mapping by hashing a string and concatenating it with an address:<bytes10(keccak256(firstWord))>:<bytes2(0)>:<bytes20(addr)> firstWord Used to generate a hash and its first 10 bytesare used for the first part of the data key of keyType Mapping addr used for the last part of the data k...
function generateMappingKey(string memory firstWord, address addr) internal pure returns (bytes32)
function generateMappingKey(string memory firstWord, address addr) internal pure returns (bytes32)
16,602
4
// owner of the contract
address contractOwner;
address contractOwner;
20,330
145
// Verifies that the caller is the Savings Manager contract /
modifier onlyVault() { require(vaultAddress == msg.sender, "Caller is not the Vault"); _; }
modifier onlyVault() { require(vaultAddress == msg.sender, "Caller is not the Vault"); _; }
11,571
83
// Constructs the Basis Bond ERC-20 contract. /
constructor() public ERC20('BBOND', 'BBOND') {} /** * @notice Operator mints basis bonds to a recipient * @param recipient_ The address of recipient * @param amount_ The amount of basis bonds to mint to * @return whether the process has been done */ function mint(address recipient_...
constructor() public ERC20('BBOND', 'BBOND') {} /** * @notice Operator mints basis bonds to a recipient * @param recipient_ The address of recipient * @param amount_ The amount of basis bonds to mint to * @return whether the process has been done */ function mint(address recipient_...
15,565
12
// wallet section: erc721
function receiveNft(ERC721 _nft, uint id) external { require(msg.sender == _nft.ownerOf(id),"just real owner"); // _nft.setApprovalForAll(address(this), true); // this is by sender from contract address.1- handly, 2- signature _nft.approve(address(this), id); _nft.transferFrom(msg.se...
function receiveNft(ERC721 _nft, uint id) external { require(msg.sender == _nft.ownerOf(id),"just real owner"); // _nft.setApprovalForAll(address(this), true); // this is by sender from contract address.1- handly, 2- signature _nft.approve(address(this), id); _nft.transferFrom(msg.se...
45,830
65
// in case of hack, funds can be transfered out to another addresses and transferred to the stake holders from there
if (payoutBlocked) if(!secondaryPayoutAddress.send(address(this).balance)) revert();
if (payoutBlocked) if(!secondaryPayoutAddress.send(address(this).balance)) revert();
22,114
39
// Ensures that the msg.sender is a provider for the passed EIN./ein The EIN to check.
modifier _isProviderFor(uint ein) { require(isProviderFor(ein, msg.sender), "The identity has not set the passed provider."); _; }
modifier _isProviderFor(uint ein) { require(isProviderFor(ein, msg.sender), "The identity has not set the passed provider."); _; }
30,212
8
// _registrar The initial registrar for the manager/_feeToken The module fee token contract to mint from upon module registration
constructor(address _registrar, address _feeToken) { require(_registrar != address(0), "ZMM::must set registrar to non-zero address"); registrar = _registrar; moduleFeeToken = ZoraProtocolFeeSettings(_feeToken); }
constructor(address _registrar, address _feeToken) { require(_registrar != address(0), "ZMM::must set registrar to non-zero address"); registrar = _registrar; moduleFeeToken = ZoraProtocolFeeSettings(_feeToken); }
4,903
109
// Claim ALX allocation
function claimALX() public onlyEOA { require(claimTimestamp <= block.timestamp, "cannot claim yet"); require(!claimed[msg.sender], "already claimed"); if(invested[msg.sender] > 0) { ERC20(ALX).transfer(msg.sender, invested[msg.sender]); } claimed[msg.sender] = tru...
function claimALX() public onlyEOA { require(claimTimestamp <= block.timestamp, "cannot claim yet"); require(!claimed[msg.sender], "already claimed"); if(invested[msg.sender] > 0) { ERC20(ALX).transfer(msg.sender, invested[msg.sender]); } claimed[msg.sender] = tru...
17,839
136
// info stored for each initialized individual tick
struct Info { // the total position liquidity that references this tick uint128 liquidityGross; // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left), int128 liquidityNet; // fee growth per unit of liquidity on the _other_ side ...
struct Info { // the total position liquidity that references this tick uint128 liquidityGross; // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left), int128 liquidityNet; // fee growth per unit of liquidity on the _other_ side ...
50,970
6
// ipfs:QmcM2pbvjXfTYQShMUWihZxNYdyE8roHHNBVi5r8mTytfj/hidden.json ipfs:QmdTQDFiNGySULUFXdqWBYFZAjzh74JWsikxzV68CZBT5m/
contract ERC721Metadata is ERC721Enumerable, Ownable { using Strings for uint256; // Base URI string private baseURI; string public baseExtension = ".json"; bool public revealed = false; string public notRevealedUri; uint256 private _maxNftSupply; constructor( string memory na...
contract ERC721Metadata is ERC721Enumerable, Ownable { using Strings for uint256; // Base URI string private baseURI; string public baseExtension = ".json"; bool public revealed = false; string public notRevealedUri; uint256 private _maxNftSupply; constructor( string memory na...
30,059