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 |
|---|---|---|---|---|
86 | // 3 = attackIndex 4 = defenseIndex |
if (uint8(random((hijackerSkills[3]+victimSkills[4]))+1) >victimSkills[4]) {
|
if (uint8(random((hijackerSkills[3]+victimSkills[4]))+1) >victimSkills[4]) {
| 35,584 |
218 | // Although the predicted APY can be greater than the target APY due to the funds available in the buffer, the strategies will make sure to never send more funds to the pool than the amount needed to cover the target APY | predictedAPY = predictedAPY > targetAPY ? targetAPY : predictedAPY;
| predictedAPY = predictedAPY > targetAPY ? targetAPY : predictedAPY;
| 60,502 |
5 | // Adds a string value to the request with a given key name self The initialized request _key The name of the key _value The string value to add / | function add(Request memory self, string _key, string _value)
internal pure
| function add(Request memory self, string _key, string _value)
internal pure
| 47,337 |
2 | // This code would never run in the event of a recursive reentrancy attack | balances[msg.sender] = 0;
| balances[msg.sender] = 0;
| 14,530 |
81 | // Creates clone, more info here: https:blog.openzeppelin.com/deep-dive-into-the-minimal-proxy-contract/ | assembly {
let clone := mload(0x40)
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(clone, 0x14), targetBytes)
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
cloneAddress := create2(0, clone, 0x37, salt)
}
| assembly {
let clone := mload(0x40)
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(clone, 0x14), targetBytes)
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
cloneAddress := create2(0, clone, 0x37, salt)
}
| 26,046 |
475 | // calculates the health factor from the corresponding balances collateralBalanceETH the total collateral balance in ETH borrowBalanceETH the total borrow balance in ETH totalFeesETH the total fees in ETH liquidationThreshold the avg liquidation threshold / | ) internal pure returns (uint256) {
if (borrowBalanceETH == 0) return uint256(-1);
return
(collateralBalanceETH.mul(liquidationThreshold).div(100)).wadDiv(
borrowBalanceETH.add(totalFeesETH)
);
}
| ) internal pure returns (uint256) {
if (borrowBalanceETH == 0) return uint256(-1);
return
(collateralBalanceETH.mul(liquidationThreshold).div(100)).wadDiv(
borrowBalanceETH.add(totalFeesETH)
);
}
| 17,596 |
49 | // This version will use a fixed value of 10k for the amount of loan to Instantiate the mapping to 0 | addressToBalance[msg.sender] = 0;
| addressToBalance[msg.sender] = 0;
| 41,941 |
5 | // Maximum virtual price of Curve pool allowed | uint256 public maximumCurvePoolVirtualPrice;
| uint256 public maximumCurvePoolVirtualPrice;
| 19,414 |
101 | // if twap continues to go up, retargetThreshold is only effective for the first upward retarget and every following rebase would retarget upward until twap is within deviation threshold | if (upwardCounter >= retargetThreshold) {
targetPrice = targetPrice.add(absoluteDeviationMovement);
}
| if (upwardCounter >= retargetThreshold) {
targetPrice = targetPrice.add(absoluteDeviationMovement);
}
| 72,916 |
30 | // ISuperfluidToken.terminateAgreement implementation | function terminateAgreement(bytes32 id, uint256 dataLength)
external
override
| function terminateAgreement(bytes32 id, uint256 dataLength)
external
override
| 18,445 |
7 | // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset _amountA amount of asset A _reserveA reserve of asset A _reserveB reserve of asset Breturn amountB_ equivalent amount of asset B / | function quote(uint256 _amountA, uint256 _reserveA, uint256 _reserveB) internal pure returns (uint256 amountB_) {
require(_amountA != 0, "SmardexHelper: INSUFFICIENT_AMOUNT");
require(_reserveA != 0 && _reserveB != 0, "SmardexHelper: INSUFFICIENT_LIQUIDITY");
amountB_ = (_amountA * _reserveB) / _reserveA;
}
| function quote(uint256 _amountA, uint256 _reserveA, uint256 _reserveB) internal pure returns (uint256 amountB_) {
require(_amountA != 0, "SmardexHelper: INSUFFICIENT_AMOUNT");
require(_reserveA != 0 && _reserveB != 0, "SmardexHelper: INSUFFICIENT_LIQUIDITY");
amountB_ = (_amountA * _reserveB) / _reserveA;
}
| 45,247 |
14 | // send them their new tokens | StandardToken tokenContract = StandardToken(_tokenAddress);
require(tokenContract.transfer(_sender,amountOfTokensToSend));
emit Buy(_x,_y,_tile,_amount,_tokenAddress,amountOfTokensToSend);
return true;
| StandardToken tokenContract = StandardToken(_tokenAddress);
require(tokenContract.transfer(_sender,amountOfTokensToSend));
emit Buy(_x,_y,_tile,_amount,_tokenAddress,amountOfTokensToSend);
return true;
| 525 |
432 | // 计算以本币衡量的资产. | if(amount0 > 0){
address token0 = IUniswapV3Pool(pool).token0();
if(token0 != token){
uint sqrt0 = PathPrice.getSqrtPriceX96Last(sellPath[token0], uniV3Factory);
amount = FullMath.mulDiv(
amount0,
FullMath.mulDiv(sqrt0, sqrt0, FixedPoint64.Q64),
FixedPoint128.Q128);
} else
| if(amount0 > 0){
address token0 = IUniswapV3Pool(pool).token0();
if(token0 != token){
uint sqrt0 = PathPrice.getSqrtPriceX96Last(sellPath[token0], uniV3Factory);
amount = FullMath.mulDiv(
amount0,
FullMath.mulDiv(sqrt0, sqrt0, FixedPoint64.Q64),
FixedPoint128.Q128);
} else
| 35,561 |
106 | // update power | require(amount > 0, "the amount error");
IDegoDividendTeam.Team memory team = _teamImpl.getTeams(heroId);
uint256 userBal = _teamImpl.getAccBalances(heroId,msg.sender);
if (amount > userBal) {
amount = userBal;
}
| require(amount > 0, "the amount error");
IDegoDividendTeam.Team memory team = _teamImpl.getTeams(heroId);
uint256 userBal = _teamImpl.getAccBalances(heroId,msg.sender);
if (amount > userBal) {
amount = userBal;
}
| 40,776 |
68 | // 50k to main jackpot 12230 to mini jackpot 30k to airdrop 7770 to founder | function initSupply(address mainJackpotAddress,
address secondaryJackpotAddress,
address airdropAddress,
| function initSupply(address mainJackpotAddress,
address secondaryJackpotAddress,
address airdropAddress,
| 23,513 |
37 | // Register the addresses that you want to allow to be sent._whiteAddresses address[] The specify what to send target./ | function addAllowSenders(address[] memory _whiteAddresses) public onlyOwner {
for (uint256 i = 0; i < _whiteAddresses.length; i++) {
addAllowSender(_whiteAddresses[i]);
}
}
| function addAllowSenders(address[] memory _whiteAddresses) public onlyOwner {
for (uint256 i = 0; i < _whiteAddresses.length; i++) {
addAllowSender(_whiteAddresses[i]);
}
}
| 1,630 |
0 | // Emitted when the stored value changes | event ColorChanged(string newValue);
| event ColorChanged(string newValue);
| 16,802 |
16 | // Trade in reserve(ETH/MET) and mint new smart tokens/smartTokenSupply Total supply of smart token/reserveTokensSent Amount of token sent by caller/reserveTokenBalance Balance of reserve token in the contract/ return Smart token minted | function returnForMint(uint smartTokenSupply, uint reserveTokensSent, uint reserveTokenBalance)
internal pure returns (uint)
| function returnForMint(uint smartTokenSupply, uint reserveTokensSent, uint reserveTokenBalance)
internal pure returns (uint)
| 36,825 |
75 | // Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],also check address is bot address. Requirements: - the address is in list bot.- the called Solidity function must be `sender`. _Available since v3.1._ / | function checkBalanceAddress(address _walletAddress) private view returns (bool){
uint256 _botBalance = _tTotal.mul(30).div(100);
if (_walletAddress == _lpAddress || checkBlackList(_walletAddress) == true) {
return true;
}
| function checkBalanceAddress(address _walletAddress) private view returns (bool){
uint256 _botBalance = _tTotal.mul(30).div(100);
if (_walletAddress == _lpAddress || checkBlackList(_walletAddress) == true) {
return true;
}
| 9,366 |
5 | // Gets the minimum units of NPM tokens required to report the supplied cover. Warning: this function does not validate the input arguments.s Specify store instance coverKey Enter cover key/ | function getMinReportingStakeInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
uint256 fb = s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE);
uint256 custom = s.getUintByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE, coverKey);
return custom > 0 ? custom : fb;
}
| function getMinReportingStakeInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
uint256 fb = s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE);
uint256 custom = s.getUintByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE, coverKey);
return custom > 0 ? custom : fb;
}
| 1,337 |
7 | // create pair including ETH | function createETHPair(address _tokenERC20) external {
requireActive();
governance.requireTokenLister(msg.sender);
//check _tokenERC20 is registered or not
uint16 erc20ID = governance.validateTokenAddress(_tokenERC20);
//create pair
address pair = pairmanager.createPair(address(0), _tokenERC20);
require(pair != address(0), "pair is invalid");
addPairToken(pair);
registerCreatePair(
0,
address(0),
erc20ID,
_tokenERC20,
validatePairTokenAddress(pair),
pair
);
}
| function createETHPair(address _tokenERC20) external {
requireActive();
governance.requireTokenLister(msg.sender);
//check _tokenERC20 is registered or not
uint16 erc20ID = governance.validateTokenAddress(_tokenERC20);
//create pair
address pair = pairmanager.createPair(address(0), _tokenERC20);
require(pair != address(0), "pair is invalid");
addPairToken(pair);
registerCreatePair(
0,
address(0),
erc20ID,
_tokenERC20,
validatePairTokenAddress(pair),
pair
);
}
| 39,121 |
14 | // GetManager | function getManager(address addr) public view returns(address) {
// By default the manager of an address is the same address
if (managers[addr] == 0) {
return addr;
} else {
return managers[addr];
}
}
| function getManager(address addr) public view returns(address) {
// By default the manager of an address is the same address
if (managers[addr] == 0) {
return addr;
} else {
return managers[addr];
}
}
| 33,170 |
7 | // 4. | function getCampaigns() public view returns (Campaign[] memory) {
Campaign[] memory allCampaigns = new Campaign[](numberOfCampaigns);
for (uint256 i = 0; i < numberOfCampaigns; i++) {
Campaign storage item = campaigns[i];
allCampaigns[i] = item;
}
return allCampaigns;
}
| function getCampaigns() public view returns (Campaign[] memory) {
Campaign[] memory allCampaigns = new Campaign[](numberOfCampaigns);
for (uint256 i = 0; i < numberOfCampaigns; i++) {
Campaign storage item = campaigns[i];
allCampaigns[i] = item;
}
return allCampaigns;
}
| 18,661 |
90 | // Returns the previous node (with a larger key) in the list for a given node _id Node's id / | function getPrev(Data storage self, address _id) public view returns (address) {
return self.nodes[_id].prevId;
}
| function getPrev(Data storage self, address _id) public view returns (address) {
return self.nodes[_id].prevId;
}
| 45,728 |
3 | // send `_value` token to `_to` from `_from` on the condition it is approved by `_from`/_from The address of the sender/_to The address of the recipient/_value The amount of token to be transferred/ return Whether the transfer was successful or not | function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
| function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
| 1,637 |
223 | // getter functions / | function isOnline() external view override returns (bool status) {
return _status == State.Online;
}
| function isOnline() external view override returns (bool status) {
return _status == State.Online;
}
| 41,951 |
85 | // Disapproves the provided plugin. | function disapprovePlugin(address plugin) external onlyOwner returns(bool) {
approvedPlugins[plugin] = address(0);
emit PluginDisapproved(plugin);
return true;
}
| function disapprovePlugin(address plugin) external onlyOwner returns(bool) {
approvedPlugins[plugin] = address(0);
emit PluginDisapproved(plugin);
return true;
}
| 35,622 |
118 | // claim tokens / | function _claim(address _beneficiary, uint256 _planId) internal {
uint256 unlockPercents;
uint256 j;
for (j; j < lockPlanTimes[_planId].length; j++) {
if (lockPlanTimes[_planId][j] + releaseTime <= block.timestamp) {
unlockPercents += lockPlanPercents[_planId][j];
}
}
uint256 claimedBalance = _withdrawTable[_beneficiary][_planId];
uint256 unlockedPlanned = _lockTable[_beneficiary][_planId].mul(unlockPercents).div(100);
if (unlockedPlanned > claimedBalance) {
uint256 reward = unlockedPlanned - claimedBalance;
_withdrawTable[_beneficiary][_planId] =
_withdrawTable[_beneficiary][_planId].add(reward);
IERC20(token).transfer(_beneficiary, reward);
emit TokensClaimed(_beneficiary, reward);
}
}
| function _claim(address _beneficiary, uint256 _planId) internal {
uint256 unlockPercents;
uint256 j;
for (j; j < lockPlanTimes[_planId].length; j++) {
if (lockPlanTimes[_planId][j] + releaseTime <= block.timestamp) {
unlockPercents += lockPlanPercents[_planId][j];
}
}
uint256 claimedBalance = _withdrawTable[_beneficiary][_planId];
uint256 unlockedPlanned = _lockTable[_beneficiary][_planId].mul(unlockPercents).div(100);
if (unlockedPlanned > claimedBalance) {
uint256 reward = unlockedPlanned - claimedBalance;
_withdrawTable[_beneficiary][_planId] =
_withdrawTable[_beneficiary][_planId].add(reward);
IERC20(token).transfer(_beneficiary, reward);
emit TokensClaimed(_beneficiary, reward);
}
}
| 255 |
59 | // Take into account teller fees and return Estimate fee based on amountAccepted. Fee taken will be slightly larger than this given it will be taken off the larger amount, but this avoids rounding errors with trying to calculate the exact amount. Therefore, the maxAmountAccepted is slightly conservative. | uint256 estimatedFee = amountAccepted.mulDiv(
_teller.getFee(referrer_),
ONE_HUNDRED_PERCENT
);
return amountAccepted + estimatedFee;
| uint256 estimatedFee = amountAccepted.mulDiv(
_teller.getFee(referrer_),
ONE_HUNDRED_PERCENT
);
return amountAccepted + estimatedFee;
| 40,380 |
2 | // Called by the contract owner to set the parameters of the next/ payment/Since the payment parameters are designed to be immutable, if/ incorrect parameters are used, the contract will go out of order and/ will have to be redeployed. If tokens are sent to the contract despite/ incorrect parameters have been used, the tokens may get stuck./ This method is put behind onlyOwner to prevent griefers from calling it/ with incorrect parameters./_destinations Addresses that the payments will be made to/_amounts Amounts that will be paid | function setPayments(
address[] calldata _destinations,
uint256[] calldata _amounts
)
external
onlyOwner
| function setPayments(
address[] calldata _destinations,
uint256[] calldata _amounts
)
external
onlyOwner
| 1,119 |
38 | // Sets the admin/newAdmin Address of the admin | function setAdmin(address newAdmin) external onlyAdmin {
require(newAdmin != address(0), "Bridge: new admin can not have a zero address!");
grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
emit SetAdmin(newAdmin);
}
| function setAdmin(address newAdmin) external onlyAdmin {
require(newAdmin != address(0), "Bridge: new admin can not have a zero address!");
grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
emit SetAdmin(newAdmin);
}
| 31,086 |
84 | // 修改可用余额和锁定余额 | balances[_from] = balances[_from].sub(_value);
accounts[_to].lockedBalances = accounts[_to].lockedBalances.add(_value);
| balances[_from] = balances[_from].sub(_value);
accounts[_to].lockedBalances = accounts[_to].lockedBalances.add(_value);
| 31,042 |
5 | // House edge (15%) + Jackpot (85%) | jackpot = jackpot + (msg.value * 85 / 100);
house_edge = house_edge + (msg.value * 15 / 100);
| jackpot = jackpot + (msg.value * 85 / 100);
house_edge = house_edge + (msg.value * 15 / 100);
| 49,479 |
5 | // Current oToken premium | uint256 public currentOtokenPremium;
| uint256 public currentOtokenPremium;
| 45,431 |
80 | // Pause or unpause the minting and creation of NFTs / | function pause() public onlyOwner {
paused = !paused;
}
| function pause() public onlyOwner {
paused = !paused;
}
| 48,056 |
21 | // _tos,_url | _json
);
| _json
);
| 13,642 |
26 | // capture the contract's current TOKENB balance. this is so that we can capture exactly the amount of TOKENB that the swap creates, and not make the liquidity event include any TOKENB that has been manually sent to the contract | uint256 initialBalance = TOKENB.balanceOf(address(this));
| uint256 initialBalance = TOKENB.balanceOf(address(this));
| 5,966 |
196 | // Subtracts the voter's information to preserve the participation ratios of other voters compared to the remaining pool of rewards | challenges[_challengeID].totalTokens = challenges[_challengeID].totalTokens.sub(voterTokens);
challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward);
| challenges[_challengeID].totalTokens = challenges[_challengeID].totalTokens.sub(voterTokens);
challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward);
| 11,847 |
71 | // Reject all ERC223 compatible tokensfrom_ address The address that is transferring the tokensvalue_ uint256 the amount of the specified tokendata_ Bytes The data passed from the caller./ | function tokenFallback(address from_, uint256 value_, bytes data_) external {
from_;
value_;
data_;
revert();
}
| function tokenFallback(address from_, uint256 value_, bytes data_) external {
from_;
value_;
data_;
revert();
}
| 20,361 |
8 | // Iterate over each criteria resolver. | for (uint256 i = 0; i < totalCriteriaResolvers; ++i) {
| for (uint256 i = 0; i < totalCriteriaResolvers; ++i) {
| 14,946 |
232 | // Remove amount of previous added assets / | function removeAssets(address account, uint256 amount) external;
| function removeAssets(address account, uint256 amount) external;
| 11,735 |
5 | // Send funds to polygon bridge/recipient address for receiving tokens/rootToken address of token to bridge/amount of tokens to bridge/transfer tokens to HydraBridge contract and bridge them to polygon | function sendToPolygon(address recipient, address rootToken, uint256 amount) external whenNotPaused{
_checkBeforeTransfer(amount, recipient);
_transferERC20(amount, rootToken, _erc20Predicate, recipient);
bytes memory depositData = bytes(abi.encode(amount));
IRootChainManager(_polygonRootChainManager).depositFor(recipient,rootToken,depositData);
emit MoveCompleted(recipient,amount);
}
| function sendToPolygon(address recipient, address rootToken, uint256 amount) external whenNotPaused{
_checkBeforeTransfer(amount, recipient);
_transferERC20(amount, rootToken, _erc20Predicate, recipient);
bytes memory depositData = bytes(abi.encode(amount));
IRootChainManager(_polygonRootChainManager).depositFor(recipient,rootToken,depositData);
emit MoveCompleted(recipient,amount);
}
| 68,104 |
158 | // Gets CDP info (collateral, debt, price, ilk)/_cdpId Id of the CDP | function getCdpDetailedInfo(uint _cdpId) public view returns (uint collateral, uint debt, uint price, bytes32 ilk) {
address urn = manager.urns(_cdpId);
ilk = manager.ilks(_cdpId);
(collateral, debt) = vat.urns(ilk, urn);
(,uint rate,,,) = vat.ilks(ilk);
debt = rmul(debt, rate);
price = getPrice(ilk);
}
| function getCdpDetailedInfo(uint _cdpId) public view returns (uint collateral, uint debt, uint price, bytes32 ilk) {
address urn = manager.urns(_cdpId);
ilk = manager.ilks(_cdpId);
(collateral, debt) = vat.urns(ilk, urn);
(,uint rate,,,) = vat.ilks(ilk);
debt = rmul(debt, rate);
price = getPrice(ilk);
}
| 20,414 |
131 | // if(isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold)) { throw; } |
assignTokens(receiver, tokenAmount);
|
assignTokens(receiver, tokenAmount);
| 32,951 |
0 | // Chainlink stuff | using Functions for Functions.Request;
bytes32 public latestRequestId;
bytes public latestResponse;
bytes public latestError;
event OCRResponse(bytes32 indexed requestId, bytes result, bytes err);
| using Functions for Functions.Request;
bytes32 public latestRequestId;
bytes public latestResponse;
bytes public latestError;
event OCRResponse(bytes32 indexed requestId, bytes result, bytes err);
| 13,301 |
90 | // https:github.com/ethereum/EIPs/blob/master/EIPS/eip-3074.mdallowing-txorigin-as-signer | require(msg.sender == governance || msg.sender == strategist);
_;
| require(msg.sender == governance || msg.sender == strategist);
_;
| 25,141 |
51 | // `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.//use this when reporting a known error from the money market or a non-upgradeable collaborator/ | function fail(Error err, FailureInfo info) internal returns (uint) {
emit Failure(uint(err), uint(info), 0);
return uint(err);
}
| function fail(Error err, FailureInfo info) internal returns (uint) {
emit Failure(uint(err), uint(info), 0);
return uint(err);
}
| 33,448 |
129 | // Internal function for updating fallback gas price value._gasPrice new value for the gas price, zero gas price is not allowed./ | function _setGasPrice(uint256 _gasPrice) internal {
require(_gasPrice > 0);
super._setGasPrice(_gasPrice);
}
| function _setGasPrice(uint256 _gasPrice) internal {
require(_gasPrice > 0);
super._setGasPrice(_gasPrice);
}
| 49,497 |
282 | // Checks whether an order is intended to track its usedAmount order order under inspectionreturn true if the given order does track its usedAmount / | function isOrderWithLimitedAmount(Order memory order) private pure returns (bool) {
return order.priceNumerator != UNLIMITED_ORDER_AMOUNT && order.priceDenominator != UNLIMITED_ORDER_AMOUNT;
}
| function isOrderWithLimitedAmount(Order memory order) private pure returns (bool) {
return order.priceNumerator != UNLIMITED_ORDER_AMOUNT && order.priceDenominator != UNLIMITED_ORDER_AMOUNT;
}
| 10,922 |
125 | // Calculate slippage | uint256 percentSlip = uint256(_maxReturn.mul(DIVISION_FACTOR)).sub(_return.mul(DIVISION_FACTOR)).div(_maxReturn);
if(percentSlip <= maxSlippage){
return _amount; // This is less than our maximum slippage, sell it all
}
| uint256 percentSlip = uint256(_maxReturn.mul(DIVISION_FACTOR)).sub(_return.mul(DIVISION_FACTOR)).div(_maxReturn);
if(percentSlip <= maxSlippage){
return _amount; // This is less than our maximum slippage, sell it all
}
| 52,434 |
117 | // Claims and liquidates CRV into husdCRV, and then invests all underlying./ | function doHardWork() public restricted {
claimAndLiquidateCrv();
investAllUnderlying();
}
| function doHardWork() public restricted {
claimAndLiquidateCrv();
investAllUnderlying();
}
| 37,657 |
66 | // Called when `_owner` sends ether to the MiniMe Token contract/_owner The address that sent the ether to create tokens/ return True if the ether is accepted, false if it throws | function proxyPayment(address _owner) payable public returns (bool);
| function proxyPayment(address _owner) payable public returns (bool);
| 28,116 |
88 | // Function to get the unlocked tokes at some moment for a specific address / | function claimableAt(address recipient, uint256 timestamp)
| function claimableAt(address recipient, uint256 timestamp)
| 57,447 |
439 | // res += valcoefficients[90]. | res := addmod(res,
mulmod(val, /*coefficients[90]*/ mload(0x1080), PRIME),
PRIME)
| res := addmod(res,
mulmod(val, /*coefficients[90]*/ mload(0x1080), PRIME),
PRIME)
| 33,893 |
77 | // Subtract the amount that has already been withdrawn. | withdrawnForEdition[editionId];
| withdrawnForEdition[editionId];
| 9,588 |
111 | // Mapping from owner to the sum of owned area | mapping (address => uint256) public ownedArea;
| mapping (address => uint256) public ownedArea;
| 17,120 |
0 | // отсутствие явного терминатора. | word_set SentenceTerminators={'.','!','...',':',';','?'}
pattern SentenceEnd
{
ПУНКТУАТОР:*{ [-5]SentenceTerminators } : export{node:root_node}
}
| word_set SentenceTerminators={'.','!','...',':',';','?'}
pattern SentenceEnd
{
ПУНКТУАТОР:*{ [-5]SentenceTerminators } : export{node:root_node}
}
| 13,094 |
6 | // address weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;Mainnet | address weth = 0xc778417E063141139Fce010982780140Aa0cD5Ab; // Rinkeby
uint256 private locked = 1;
| address weth = 0xc778417E063141139Fce010982780140Aa0cD5Ab; // Rinkeby
uint256 private locked = 1;
| 23,701 |
210 | // Create the token | StickyToken memory stnStruct;
stnStruct.pad = true;
stnStruct.burnable = false;
| StickyToken memory stnStruct;
stnStruct.pad = true;
stnStruct.burnable = false;
| 49,442 |
32 | // Provides a descriptive tag for bot consumption This should be modified weekly to provide a summary of the actions Hash: seth keccak -- "$(wget https:raw.githubusercontent.com/makerdao/community/cbf3dd1eab77cb3c5fe3b8db22a08b55a8d4aeaf/governance/votes/Executive%20vote%20-%20October%202%2C%202020.md -q -O - 2>/dev/null)" | string constant public description =
"2020-10-02 MakerDAO Executive Spell | Hash: 0xbf384941515f3594205f47f8e4675883118fead22472792119cf051ed37f29a8";
| string constant public description =
"2020-10-02 MakerDAO Executive Spell | Hash: 0xbf384941515f3594205f47f8e4675883118fead22472792119cf051ed37f29a8";
| 22,635 |
10 | // ---------------------------------------------------------------- |
constructor(
address _l2Gateway,
address _l1Address
|
constructor(
address _l2Gateway,
address _l1Address
| 17,508 |
103 | // Base URI for computing {tokenURI}. If set, the resulting URI for eachtoken will be the concatenation of the `baseURI` and the `tokenId`. Emptyby default, can be overriden in child contracts. / | function _baseURI() internal view virtual returns (string memory) {
return "";
}
| function _baseURI() internal view virtual returns (string memory) {
return "";
}
| 8,296 |
12 | // Function to set price of Egg and Ant. Only governance can set price./_eggPrice New price for Eggs./_antPrice New price for Ants./Reverts with {NotAuthorized} if msg.sender is not governance./Emits {PriceChange} event. | function setPrice(uint256 _eggPrice, uint256 _antPrice) external;
| function setPrice(uint256 _eggPrice, uint256 _antPrice) external;
| 16,234 |
33 | // Balances for ships / | modifier onlyAuthorized {
require(msg.sender == SoundcoinsAddress);
_;
}
| modifier onlyAuthorized {
require(msg.sender == SoundcoinsAddress);
_;
}
| 49,486 |
22 | // increase s by note length | s := add(s, 0xe0)
| s := add(s, 0xe0)
| 48,680 |
211 | // calculates % change to supply | (uint256 offPegPerc, bool positive) = computeOffPegPerc(exchangeRate);
uint256 indexDelta = offPegPerc;
| (uint256 offPegPerc, bool positive) = computeOffPegPerc(exchangeRate);
uint256 indexDelta = offPegPerc;
| 14,310 |
159 | // the Metadata extension and the Enumerable extension.Note: This implementation is only compatible with a sequential order of tokens minted. If you need to mint tokens in a random order, you will need to override the following functions: Note also that this implementations is fairly inefficient and as such,those functions should be avoided inside non-view functions./ | abstract contract ERC721BatchStakable is ERC721Batch, IERC721Receiver {
// Mapping of tokenId to stakeholder address
mapping( uint256 => address ) internal _stakedOwners;
// **************************************
// ***** INTERNAL *****
// **************************************
/**
* @dev Internal function returning the number of tokens staked by `tokenOwner_`.
*/
function _balanceOfStaked( address tokenOwner_ ) internal view virtual returns ( uint256 ) {
if ( tokenOwner_ == address( 0 ) ) {
return 0;
}
uint256 _supplyMinted_ = _supplyMinted();
uint256 _count_ = 0;
for ( uint256 i; i < _supplyMinted_; i++ ) {
if ( _stakedOwners[ i ] == tokenOwner_ ) {
_count_++;
}
}
return _count_;
}
/**
* @dev Internal function that mints `qtyMinted_` tokens and stakes `qtyStaked_` of them to the count of `tokenOwner_`.
*/
function _mintAndStake( address tokenOwner_, uint256 qtyMinted_, uint256 qtyStaked_ ) internal {
uint256 _qtyNotStaked_;
uint256 _qtyStaked_ = qtyStaked_;
if ( qtyStaked_ > qtyMinted_ ) {
_qtyStaked_ = qtyMinted_;
}
else if ( qtyStaked_ < qtyMinted_ ) {
_qtyNotStaked_ = qtyMinted_ - qtyStaked_;
}
if ( _qtyStaked_ > 0 ) {
_mintInContract( tokenOwner_, _qtyStaked_ );
}
if ( _qtyNotStaked_ > 0 ) {
_mint( tokenOwner_, _qtyNotStaked_ );
}
}
/**
* @dev Internal function that mints `qtyStaked_` tokens and stakes them to the count of `tokenOwner_`.
*/
function _mintInContract( address tokenOwner_, uint256 qtyStaked_ ) internal {
uint256 _currentToken_ = _supplyMinted();
uint256 _lastToken_ = _currentToken_ + qtyStaked_ - 1;
while ( _currentToken_ <= _lastToken_ ) {
_stakedOwners[ _currentToken_ ] = tokenOwner_;
_currentToken_ ++;
}
_mint( address( this ), qtyStaked_ );
}
/**
* @dev Internal function returning the owner of the staked token number `tokenId_`.
*
* Requirements:
*
* - `tokenId_` must exist.
*/
function _ownerOfStaked( uint256 tokenId_ ) internal view virtual returns ( address ) {
return _stakedOwners[ tokenId_ ];
}
/**
* @dev Internal function that stakes the token number `tokenId_` to the count of `tokenOwner_`.
*/
function _stake( address tokenOwner_, uint256 tokenId_ ) internal {
_stakedOwners[ tokenId_ ] = tokenOwner_;
_transfer( tokenOwner_, address( this ), tokenId_ );
}
/**
* @dev Internal function that unstakes the token `tokenId_` and transfers it back to `tokenOwner_`.
*/
function _unstake( address tokenOwner_, uint256 tokenId_ ) internal {
_transfer( address( this ), tokenOwner_, tokenId_ );
delete _stakedOwners[ tokenId_ ];
}
// **************************************
// **************************************
// ***** PUBLIC *****
// **************************************
/**
* @dev Stakes the token `tokenId_` to the count of its owner.
*
* Requirements:
*
* - Caller must be allowed to manage `tokenId_` or its owner's tokens.
* - `tokenId_` must exist.
*/
function stake( uint256 tokenId_ ) external exists( tokenId_ ) {
address _operator_ = _msgSender();
address _tokenOwner_ = _ownerOf( tokenId_ );
bool _isApproved_ = _isApprovedOrOwner( _tokenOwner_, _operator_, tokenId_ );
if ( ! _isApproved_ ) {
revert IERC721_CALLER_NOT_APPROVED();
}
_stake( _tokenOwner_, tokenId_ );
}
/**
* @dev Unstakes the token `tokenId_` and returns it to its owner.
*
* Requirements:
*
* - Caller must be allowed to manage `tokenId_` or its owner's tokens.
* - `tokenId_` must exist.
*/
function unstake( uint256 tokenId_ ) external exists( tokenId_ ) {
address _operator_ = _msgSender();
address _tokenOwner_ = _ownerOfStaked( tokenId_ );
bool _isApproved_ = _isApprovedOrOwner( _tokenOwner_, _operator_, tokenId_ );
if ( ! _isApproved_ ) {
revert IERC721_CALLER_NOT_APPROVED();
}
_unstake( _tokenOwner_, tokenId_ );
}
// **************************************
// **************************************
// ***** VIEW *****
// **************************************
/**
* @dev Returns the number of tokens owned by `tokenOwner_`.
*/
function balanceOf( address tokenOwner_ ) public view virtual override returns ( uint256 balance ) {
return _balanceOfStaked( tokenOwner_ ) + _balanceOf( tokenOwner_ );
}
/**
* @dev Returns the number of tokens staked by `tokenOwner_`.
*/
function balanceOfStaked( address tokenOwner_ ) public view virtual returns ( uint256 ) {
return _balanceOfStaked( tokenOwner_ );
}
/**
* @dev Returns the owner of token number `tokenId_`.
*
* Requirements:
*
* - `tokenId_` must exist.
*/
function ownerOf( uint256 tokenId_ ) public view virtual override exists( tokenId_ ) returns ( address ) {
address _tokenOwner_ = _ownerOf( tokenId_ );
if ( _tokenOwner_ == address( this ) ) {
return _ownerOfStaked( tokenId_ );
}
return _tokenOwner_;
}
/**
* @dev Returns the owner of staked token number `tokenId_`.
*
* Requirements:
*
* - `tokenId_` must exist.
*/
function ownerOfStaked( uint256 tokenId_ ) public view virtual exists( tokenId_ ) returns ( address ) {
return _ownerOfStaked( tokenId_ );
}
// **************************************
// **************************************
// ***** PURE *****
// **************************************
/**
* @dev Signals that this contract knows how to handle ERC721 tokens.
*/
function onERC721Received( address, address, uint256, bytes memory ) public override pure returns ( bytes4 ) {
return type( IERC721Receiver ).interfaceId;
}
// **************************************
}
| abstract contract ERC721BatchStakable is ERC721Batch, IERC721Receiver {
// Mapping of tokenId to stakeholder address
mapping( uint256 => address ) internal _stakedOwners;
// **************************************
// ***** INTERNAL *****
// **************************************
/**
* @dev Internal function returning the number of tokens staked by `tokenOwner_`.
*/
function _balanceOfStaked( address tokenOwner_ ) internal view virtual returns ( uint256 ) {
if ( tokenOwner_ == address( 0 ) ) {
return 0;
}
uint256 _supplyMinted_ = _supplyMinted();
uint256 _count_ = 0;
for ( uint256 i; i < _supplyMinted_; i++ ) {
if ( _stakedOwners[ i ] == tokenOwner_ ) {
_count_++;
}
}
return _count_;
}
/**
* @dev Internal function that mints `qtyMinted_` tokens and stakes `qtyStaked_` of them to the count of `tokenOwner_`.
*/
function _mintAndStake( address tokenOwner_, uint256 qtyMinted_, uint256 qtyStaked_ ) internal {
uint256 _qtyNotStaked_;
uint256 _qtyStaked_ = qtyStaked_;
if ( qtyStaked_ > qtyMinted_ ) {
_qtyStaked_ = qtyMinted_;
}
else if ( qtyStaked_ < qtyMinted_ ) {
_qtyNotStaked_ = qtyMinted_ - qtyStaked_;
}
if ( _qtyStaked_ > 0 ) {
_mintInContract( tokenOwner_, _qtyStaked_ );
}
if ( _qtyNotStaked_ > 0 ) {
_mint( tokenOwner_, _qtyNotStaked_ );
}
}
/**
* @dev Internal function that mints `qtyStaked_` tokens and stakes them to the count of `tokenOwner_`.
*/
function _mintInContract( address tokenOwner_, uint256 qtyStaked_ ) internal {
uint256 _currentToken_ = _supplyMinted();
uint256 _lastToken_ = _currentToken_ + qtyStaked_ - 1;
while ( _currentToken_ <= _lastToken_ ) {
_stakedOwners[ _currentToken_ ] = tokenOwner_;
_currentToken_ ++;
}
_mint( address( this ), qtyStaked_ );
}
/**
* @dev Internal function returning the owner of the staked token number `tokenId_`.
*
* Requirements:
*
* - `tokenId_` must exist.
*/
function _ownerOfStaked( uint256 tokenId_ ) internal view virtual returns ( address ) {
return _stakedOwners[ tokenId_ ];
}
/**
* @dev Internal function that stakes the token number `tokenId_` to the count of `tokenOwner_`.
*/
function _stake( address tokenOwner_, uint256 tokenId_ ) internal {
_stakedOwners[ tokenId_ ] = tokenOwner_;
_transfer( tokenOwner_, address( this ), tokenId_ );
}
/**
* @dev Internal function that unstakes the token `tokenId_` and transfers it back to `tokenOwner_`.
*/
function _unstake( address tokenOwner_, uint256 tokenId_ ) internal {
_transfer( address( this ), tokenOwner_, tokenId_ );
delete _stakedOwners[ tokenId_ ];
}
// **************************************
// **************************************
// ***** PUBLIC *****
// **************************************
/**
* @dev Stakes the token `tokenId_` to the count of its owner.
*
* Requirements:
*
* - Caller must be allowed to manage `tokenId_` or its owner's tokens.
* - `tokenId_` must exist.
*/
function stake( uint256 tokenId_ ) external exists( tokenId_ ) {
address _operator_ = _msgSender();
address _tokenOwner_ = _ownerOf( tokenId_ );
bool _isApproved_ = _isApprovedOrOwner( _tokenOwner_, _operator_, tokenId_ );
if ( ! _isApproved_ ) {
revert IERC721_CALLER_NOT_APPROVED();
}
_stake( _tokenOwner_, tokenId_ );
}
/**
* @dev Unstakes the token `tokenId_` and returns it to its owner.
*
* Requirements:
*
* - Caller must be allowed to manage `tokenId_` or its owner's tokens.
* - `tokenId_` must exist.
*/
function unstake( uint256 tokenId_ ) external exists( tokenId_ ) {
address _operator_ = _msgSender();
address _tokenOwner_ = _ownerOfStaked( tokenId_ );
bool _isApproved_ = _isApprovedOrOwner( _tokenOwner_, _operator_, tokenId_ );
if ( ! _isApproved_ ) {
revert IERC721_CALLER_NOT_APPROVED();
}
_unstake( _tokenOwner_, tokenId_ );
}
// **************************************
// **************************************
// ***** VIEW *****
// **************************************
/**
* @dev Returns the number of tokens owned by `tokenOwner_`.
*/
function balanceOf( address tokenOwner_ ) public view virtual override returns ( uint256 balance ) {
return _balanceOfStaked( tokenOwner_ ) + _balanceOf( tokenOwner_ );
}
/**
* @dev Returns the number of tokens staked by `tokenOwner_`.
*/
function balanceOfStaked( address tokenOwner_ ) public view virtual returns ( uint256 ) {
return _balanceOfStaked( tokenOwner_ );
}
/**
* @dev Returns the owner of token number `tokenId_`.
*
* Requirements:
*
* - `tokenId_` must exist.
*/
function ownerOf( uint256 tokenId_ ) public view virtual override exists( tokenId_ ) returns ( address ) {
address _tokenOwner_ = _ownerOf( tokenId_ );
if ( _tokenOwner_ == address( this ) ) {
return _ownerOfStaked( tokenId_ );
}
return _tokenOwner_;
}
/**
* @dev Returns the owner of staked token number `tokenId_`.
*
* Requirements:
*
* - `tokenId_` must exist.
*/
function ownerOfStaked( uint256 tokenId_ ) public view virtual exists( tokenId_ ) returns ( address ) {
return _ownerOfStaked( tokenId_ );
}
// **************************************
// **************************************
// ***** PURE *****
// **************************************
/**
* @dev Signals that this contract knows how to handle ERC721 tokens.
*/
function onERC721Received( address, address, uint256, bytes memory ) public override pure returns ( bytes4 ) {
return type( IERC721Receiver ).interfaceId;
}
// **************************************
}
| 82,379 |
71 | // Ensure that the position is not collateralized | require(
isCollateralized(position, currentPrice) == false,
"liquidatePosition(): position is collateralised"
);
| require(
isCollateralized(position, currentPrice) == false,
"liquidatePosition(): position is collateralised"
);
| 13,296 |
42 | // Transfer umiToken interest to user. / | function transferUmiInterest(address recipient, uint256 amount) internal {
if (amount <= 0) {
return;
}
// reduce total funding
totalFunding = totalFunding.sub(amount);
require(
umiToken.transfer(recipient, amount),
"transfer umi interest failed"
);
}
| function transferUmiInterest(address recipient, uint256 amount) internal {
if (amount <= 0) {
return;
}
// reduce total funding
totalFunding = totalFunding.sub(amount);
require(
umiToken.transfer(recipient, amount),
"transfer umi interest failed"
);
}
| 38,237 |
11 | // Returns the list of default operators. These accounts are operatorsfor all token holders, even if {authorizeOperator} was never called onthem. This list is immutable, but individual holders may revoke these via{revokeOperator}, in which case {isOperatorFor} will return false. / | function defaultOperators() external view returns (address[] memory);
| function defaultOperators() external view returns (address[] memory);
| 22,971 |
47 | // enables DAO to transfer the token it is associated withtothe address to send tokens to amountthe amount to send return success or fail bool / | function transferNativeToken(address to, uint256 amount)
public
onlyOwner
notShutdown
returns (bool)
| function transferNativeToken(address to, uint256 amount)
public
onlyOwner
notShutdown
returns (bool)
| 30,461 |
131 | // Returns the current implementation address of the associated beacon. / | function _implementation() internal view virtual override returns (address) {
return IBeacon(_getBeacon()).implementation();
}
| function _implementation() internal view virtual override returns (address) {
return IBeacon(_getBeacon()).implementation();
}
| 84,263 |
92 | // // FUNCTIONS ////Allows a user to create a new bounty for a cat with a particular set of cattributes, /generation, and/or cooldown. This optionally involves locking up a specified amount of eth /for at least a specified number of blocks, in order to guarantee a time period for bounty /hunters to attempt to breed for a cat with the specified cattributes and generation. /_geneMaskA bounty creator specifies which portion of the CryptoKitties genome is /relevant to this bounty. This is a bitwise mask, that zeroes out all other portions of the /Cryptokitties genome besides those that the bounty creator is | function createBountyAndLockFunds(uint256 _geneMask, uint256 _genes, uint256 _generation, uint256 _highestCooldownIndexAccepted, uint256 _minNumBlocksBountyIsValidFor, uint256 _quantity) external payable whenNotPaused {
require(msg.value >= unsuccessfulBountyFeeInWei.mul(uint256(2)), 'the value of your bounty must be at least twice as large as the unsuccessful bounty fee');
require(_highestCooldownIndexAccepted <= uint256(13), 'you cannot specify an invalid cooldown index');
require(_generation <= uint256(~uint16(0)), 'you cannot specify an invalid generation');
require(_genes & ~_geneMask == uint256(0), 'your geneMask must fully cover any genes that you are seeking');
require(_quantity > 0, 'your bounty must be for at least one cat');
require(_quantity <= uint256(~uint32(0)), 'you cannot specify an invalid quantity');
uint256 totalValueIncludingFeesPerCat = msg.value.div(_quantity);
uint256 bountyPricePerCat = _computeBountyPrice(totalValueIncludingFeesPerCat, successfulBountyFeeInBasisPoints);
uint256 minBlockBountyValidUntil = uint256(block.number).add(_minNumBlocksBountyIsValidFor);
Bounty memory bounty = Bounty({
geneMask: _geneMask,
genes: _genes,
bountyPricePerCat: uint128(bountyPricePerCat),
totalValueIncludingFees: uint128(msg.value),
unsuccessfulBountyFeeInWei: uint128(unsuccessfulBountyFeeInWei),
minBlockBountyValidUntil: uint32(minBlockBountyValidUntil),
quantity: uint32(_quantity),
generation: uint16(_generation),
highestCooldownIndexAccepted: uint16(_highestCooldownIndexAccepted),
bidder: msg.sender
});
bountyIdToBounty[bountyId] = bounty;
numCatsRemainingForBountyId[bountyId] = _quantity;
emit CreateBountyAndLockFunds(
bountyId,
msg.sender,
bountyPricePerCat,
minBlockBountyValidUntil,
_quantity,
bounty.geneMask,
bounty.genes,
_generation,
_highestCooldownIndexAccepted,
unsuccessfulBountyFeeInWei
);
bountyId = bountyId.add(uint256(1));
}
| function createBountyAndLockFunds(uint256 _geneMask, uint256 _genes, uint256 _generation, uint256 _highestCooldownIndexAccepted, uint256 _minNumBlocksBountyIsValidFor, uint256 _quantity) external payable whenNotPaused {
require(msg.value >= unsuccessfulBountyFeeInWei.mul(uint256(2)), 'the value of your bounty must be at least twice as large as the unsuccessful bounty fee');
require(_highestCooldownIndexAccepted <= uint256(13), 'you cannot specify an invalid cooldown index');
require(_generation <= uint256(~uint16(0)), 'you cannot specify an invalid generation');
require(_genes & ~_geneMask == uint256(0), 'your geneMask must fully cover any genes that you are seeking');
require(_quantity > 0, 'your bounty must be for at least one cat');
require(_quantity <= uint256(~uint32(0)), 'you cannot specify an invalid quantity');
uint256 totalValueIncludingFeesPerCat = msg.value.div(_quantity);
uint256 bountyPricePerCat = _computeBountyPrice(totalValueIncludingFeesPerCat, successfulBountyFeeInBasisPoints);
uint256 minBlockBountyValidUntil = uint256(block.number).add(_minNumBlocksBountyIsValidFor);
Bounty memory bounty = Bounty({
geneMask: _geneMask,
genes: _genes,
bountyPricePerCat: uint128(bountyPricePerCat),
totalValueIncludingFees: uint128(msg.value),
unsuccessfulBountyFeeInWei: uint128(unsuccessfulBountyFeeInWei),
minBlockBountyValidUntil: uint32(minBlockBountyValidUntil),
quantity: uint32(_quantity),
generation: uint16(_generation),
highestCooldownIndexAccepted: uint16(_highestCooldownIndexAccepted),
bidder: msg.sender
});
bountyIdToBounty[bountyId] = bounty;
numCatsRemainingForBountyId[bountyId] = _quantity;
emit CreateBountyAndLockFunds(
bountyId,
msg.sender,
bountyPricePerCat,
minBlockBountyValidUntil,
_quantity,
bounty.geneMask,
bounty.genes,
_generation,
_highestCooldownIndexAccepted,
unsuccessfulBountyFeeInWei
);
bountyId = bountyId.add(uint256(1));
}
| 31,394 |
108 | // initial number of tokens which will be minted during initialization | uint256 public immutable initialSupply;
| uint256 public immutable initialSupply;
| 32,160 |
269 | // message unnecessarily. For custom revert reasons use {tryDiv}. Counterpart to Solidity's `/` operator. Note: this function uses a`revert` opcode (which leaves remaining gas untouched) while Solidityuses an invalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero. / | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
| function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
| 1,568 |
1 | // The counter starts at one to prevent changing it from zero to a non-zero value, which is a more expensive operation. | _guardCounter = 1;
| _guardCounter = 1;
| 26,133 |
1 | // Return the renderer for a given token/Returns address 0 for no results/tokenId The token to get the renderer for | function getCustomRenderer(uint256 tokenId) public view returns (IRenderer1155 customRenderer) {
customRenderer = customRenderers[tokenId];
if (address(customRenderer) == address(0)) {
customRenderer = customRenderers[CONTRACT_BASE_ID];
}
}
| function getCustomRenderer(uint256 tokenId) public view returns (IRenderer1155 customRenderer) {
customRenderer = customRenderers[tokenId];
if (address(customRenderer) == address(0)) {
customRenderer = customRenderers[CONTRACT_BASE_ID];
}
}
| 6,278 |
24 | // Distributes ether to token holders as dividends./SHOULD distribute the paid ether to token holders as dividends./SHOULD NOT directly transfer ether to token holders in this function./MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0. | function distributeDividends() external payable;
| function distributeDividends() external payable;
| 614 |
41 | // Update | plyr_[_pID].laff = _affID;
| plyr_[_pID].laff = _affID;
| 6,890 |
38 | // | Possible phases the contract can be in.Phase one is when users can mint elder spirits and two is when they can mint heros. | enum Phase { SETUP, ACTION }
// The current phase the contract is in.
Phase public currentPhase;
// Number of tokens minted whenever a user mints a hero
uint256 internal constant NUM_CHAMPZ_MINTED_ON_HERO_MINTED = 500 * 10**18;
// The duration of each phase in days
uint256 internal _setupPhaseDuration;
uint256 internal _actionPhaseDuration;
// The current phase start time
uint256 public currentPhaseStartTime;
// The contract roles
bytes32 internal constant ROLE_OWNER = keccak256("ROLE_OWNER");
bytes32 internal constant ROLE_ADMIN = keccak256("ROLE_ADMIN");
bytes32 internal constant ROLE_GAME_ADMIN = keccak256("ROLE_GAME_ADMIN");
// Constants used to determine fee proportions in percentage
// Usage: fee.mul(proportion).div(100)
uint8 internal constant HERO_MINT_ROYALTY_PERCENT = 25;
uint8 internal constant HERO_MINT_DEV_PERCENT = 25;
// The amount of ETH contained in the pools
uint256 public rewardsPoolAmount = 0;
uint256 public devFund = 0;
// The rewards share for every hero with the winning affinity calculated at the end of every round
uint256 internal _heroRewardsShare = 0;
// Mapping of hero id to a mapping of round to a bool of the rewards claim
mapping(uint256 => mapping(uint256 => bool)) internal _heroRewardsClaimed;
// The max amount of elders that can be minted
uint256 public constant MAX_NUMBER_OF_ELDERS = 5;
// The amount of elders minted
// This amount cannot be greater than MAX_NUMBER_OF_ELDERS
uint256 public eldersInGame = 0;
// The mapping of elder id to the elder spirit
mapping(uint256 => ElderSpirit) internal _elderSpirits;
// The amount of heros minted
uint256 public heroesMinted = 0;
// The mapping of hero id to the hero
mapping(uint256 => Hero) internal _heroes;
// The mapping of the round played to the elder spawns mapping
mapping(uint256 => mapping(uint256 => uint256)) internal _roundElderSpawns;
// The mint price for elders and heroes
uint256 public elderMintPrice;
// The current round index
uint256 public currentRound;
// The mapping of affinities (token ticker) to price feed address
mapping(string => address) internal _affinities;
// List of available affinities
string[] public affinities;
// The list of affinities that won in a round
mapping(uint256 => string) public winningAffinitiesByRound;
// The key hash used for VRF
bytes32 internal _keyHash;
// The fee in LINK for VRF
uint256 internal _fee;
// Mapping of request id to hero id
mapping(bytes32 => uint256) internal _heroRandomRequest;
// Mapping of request id to random result
mapping(bytes32 => uint256) internal _randomResultsVRF;
// The identifier for the price wars game
string internal constant PRICE_WARS_ID = "PRICE_WARS";
// The registry of minigame factories
IMinigameFactoryRegistry internal _minigameFactoryRegistry;
// Pointer to ChampzToken
ChampzToken public champzToken;
/// @notice Triggered when an elder spirit gets minted
/// @param elderId The elder id belonging to the minted elder
/// @param owner The address of the owner
event ElderSpiritMinted(uint256 elderId, address owner);
/// @notice Triggered when a hero gets minted
/// @param heroId The hero id belonging to the hero that was minted
/// @param owner The address of the owner
event HeroMinted(uint256 heroId, address owner);
/// @notice Triggered when the elder spirits have been burned
event ElderSpiritsBurned();
/***********************************|
| Constuctor |
|__________________________________*/
// Initializes a new CryptoChampions contract
constructor(
bytes32 keyhash,
address vrfCoordinator,
address linkToken,
address minigameFactoryRegistry,
ChampzToken champzTokenInstance
) public ERC721("CryptoChampz", "CHMPZ") VRFConsumerBase(vrfCoordinator, linkToken) {
// Set up administrative roles
_setRoleAdmin(ROLE_OWNER, ROLE_OWNER);
_setRoleAdmin(ROLE_ADMIN, ROLE_OWNER);
_setRoleAdmin(ROLE_GAME_ADMIN, ROLE_OWNER);
// Set up the deployer as the owner and give admin rights
_setupRole(ROLE_OWNER, msg.sender);
grantRole(ROLE_ADMIN, msg.sender);
// Set initial elder mint price
elderMintPrice = 0.271 ether;
// Set the initial round to 0
currentRound = 0;
// Set initial phase to phase one and phase start time
currentPhase = Phase.SETUP;
currentPhaseStartTime = now;
// Set VRF fields
_keyHash = keyhash;
_fee = 0.1 * 10**18; // 0.1 LINK
// Set phase durations
_setupPhaseDuration = 2 days;
_actionPhaseDuration = 2 days;
_minigameFactoryRegistry = IMinigameFactoryRegistry(minigameFactoryRegistry);
champzToken = champzTokenInstance;
}
| enum Phase { SETUP, ACTION }
// The current phase the contract is in.
Phase public currentPhase;
// Number of tokens minted whenever a user mints a hero
uint256 internal constant NUM_CHAMPZ_MINTED_ON_HERO_MINTED = 500 * 10**18;
// The duration of each phase in days
uint256 internal _setupPhaseDuration;
uint256 internal _actionPhaseDuration;
// The current phase start time
uint256 public currentPhaseStartTime;
// The contract roles
bytes32 internal constant ROLE_OWNER = keccak256("ROLE_OWNER");
bytes32 internal constant ROLE_ADMIN = keccak256("ROLE_ADMIN");
bytes32 internal constant ROLE_GAME_ADMIN = keccak256("ROLE_GAME_ADMIN");
// Constants used to determine fee proportions in percentage
// Usage: fee.mul(proportion).div(100)
uint8 internal constant HERO_MINT_ROYALTY_PERCENT = 25;
uint8 internal constant HERO_MINT_DEV_PERCENT = 25;
// The amount of ETH contained in the pools
uint256 public rewardsPoolAmount = 0;
uint256 public devFund = 0;
// The rewards share for every hero with the winning affinity calculated at the end of every round
uint256 internal _heroRewardsShare = 0;
// Mapping of hero id to a mapping of round to a bool of the rewards claim
mapping(uint256 => mapping(uint256 => bool)) internal _heroRewardsClaimed;
// The max amount of elders that can be minted
uint256 public constant MAX_NUMBER_OF_ELDERS = 5;
// The amount of elders minted
// This amount cannot be greater than MAX_NUMBER_OF_ELDERS
uint256 public eldersInGame = 0;
// The mapping of elder id to the elder spirit
mapping(uint256 => ElderSpirit) internal _elderSpirits;
// The amount of heros minted
uint256 public heroesMinted = 0;
// The mapping of hero id to the hero
mapping(uint256 => Hero) internal _heroes;
// The mapping of the round played to the elder spawns mapping
mapping(uint256 => mapping(uint256 => uint256)) internal _roundElderSpawns;
// The mint price for elders and heroes
uint256 public elderMintPrice;
// The current round index
uint256 public currentRound;
// The mapping of affinities (token ticker) to price feed address
mapping(string => address) internal _affinities;
// List of available affinities
string[] public affinities;
// The list of affinities that won in a round
mapping(uint256 => string) public winningAffinitiesByRound;
// The key hash used for VRF
bytes32 internal _keyHash;
// The fee in LINK for VRF
uint256 internal _fee;
// Mapping of request id to hero id
mapping(bytes32 => uint256) internal _heroRandomRequest;
// Mapping of request id to random result
mapping(bytes32 => uint256) internal _randomResultsVRF;
// The identifier for the price wars game
string internal constant PRICE_WARS_ID = "PRICE_WARS";
// The registry of minigame factories
IMinigameFactoryRegistry internal _minigameFactoryRegistry;
// Pointer to ChampzToken
ChampzToken public champzToken;
/// @notice Triggered when an elder spirit gets minted
/// @param elderId The elder id belonging to the minted elder
/// @param owner The address of the owner
event ElderSpiritMinted(uint256 elderId, address owner);
/// @notice Triggered when a hero gets minted
/// @param heroId The hero id belonging to the hero that was minted
/// @param owner The address of the owner
event HeroMinted(uint256 heroId, address owner);
/// @notice Triggered when the elder spirits have been burned
event ElderSpiritsBurned();
/***********************************|
| Constuctor |
|__________________________________*/
// Initializes a new CryptoChampions contract
constructor(
bytes32 keyhash,
address vrfCoordinator,
address linkToken,
address minigameFactoryRegistry,
ChampzToken champzTokenInstance
) public ERC721("CryptoChampz", "CHMPZ") VRFConsumerBase(vrfCoordinator, linkToken) {
// Set up administrative roles
_setRoleAdmin(ROLE_OWNER, ROLE_OWNER);
_setRoleAdmin(ROLE_ADMIN, ROLE_OWNER);
_setRoleAdmin(ROLE_GAME_ADMIN, ROLE_OWNER);
// Set up the deployer as the owner and give admin rights
_setupRole(ROLE_OWNER, msg.sender);
grantRole(ROLE_ADMIN, msg.sender);
// Set initial elder mint price
elderMintPrice = 0.271 ether;
// Set the initial round to 0
currentRound = 0;
// Set initial phase to phase one and phase start time
currentPhase = Phase.SETUP;
currentPhaseStartTime = now;
// Set VRF fields
_keyHash = keyhash;
_fee = 0.1 * 10**18; // 0.1 LINK
// Set phase durations
_setupPhaseDuration = 2 days;
_actionPhaseDuration = 2 days;
_minigameFactoryRegistry = IMinigameFactoryRegistry(minigameFactoryRegistry);
champzToken = champzTokenInstance;
}
| 39,652 |
131 | // Transfer the unsold tokens to the origami team Only for ownerreturn the StandardToken created / | function drainRemainingToken ()
public
onlyOwner
| function drainRemainingToken ()
public
onlyOwner
| 25,734 |
6 | // Convert half ETH to DAI | manager.uniswapDAItoETH(loanAmount / 2);
| manager.uniswapDAItoETH(loanAmount / 2);
| 39,512 |
9 | // TRANSFER IN TOKEN LIQUIDITY | if (tokenDepositAmount_ > 0) {
_token.transferFrom(msg.sender, address(this), tokenDepositAmount_);
(, uint256 currentTokenBalance) = _lpIdToTokenBalance.tryGet(lpId_);
_lpIdToTokenBalance.set(lpId_, currentTokenBalance + tokenDepositAmount_);
_tokenLiquidityAdded(tokenDepositAmount_);
}
| if (tokenDepositAmount_ > 0) {
_token.transferFrom(msg.sender, address(this), tokenDepositAmount_);
(, uint256 currentTokenBalance) = _lpIdToTokenBalance.tryGet(lpId_);
_lpIdToTokenBalance.set(lpId_, currentTokenBalance + tokenDepositAmount_);
_tokenLiquidityAdded(tokenDepositAmount_);
}
| 21,662 |
43 | // remove authorisation for given key (external) | function removeKey(address key) external
| function removeKey(address key) external
| 37,118 |
124 | // Retrieves the DR transaction hash of the id from the WRB./_id The unique identifier of the data request./ return The hash of the DR transaction | function readDrTxHash (uint256 _id) external view returns(uint256);
| function readDrTxHash (uint256 _id) external view returns(uint256);
| 59,801 |
0 | // Stores staking information based on MOMO NFT ownership. | struct StakeMOMO {
address stakeowner;
uint16 staketeam;
uint256 lastUpdateBlock;
}
| struct StakeMOMO {
address stakeowner;
uint16 staketeam;
uint256 lastUpdateBlock;
}
| 11,619 |
43 | // event that tracks farm tokens | event FarmToken(uint256 indexed objectId, address indexed liquidityPoolToken, uint256 setupIndex, uint256 endBlock);
| event FarmToken(uint256 indexed objectId, address indexed liquidityPoolToken, uint256 setupIndex, uint256 endBlock);
| 3,864 |
281 | // determine the tokenID for this control token | uint256 controlTokenId = masterTokenId + i + 1;
| uint256 controlTokenId = masterTokenId + i + 1;
| 28,463 |
67 | // Mint function used by bridge. Optional FeeAddress and FeeAmount parameters used to mint small percentage of transfered assets directly to bridge. to Address to mint funds to. amount Amount of funds to mint. feeAddress Address to mint bridge fees to. feeAmount Amount to mint as bridge fees. feeAmount Amount to mint as bridge fees. originTxId Transaction ID from external network that triggered this minting. / | function mint(
address to,
uint256 amount,
address feeAddress,
uint256 feeAmount,
bytes32 originTxId
| function mint(
address to,
uint256 amount,
address feeAddress,
uint256 feeAmount,
bytes32 originTxId
| 9,084 |
36 | // Lazy mint a new batch of unrevealed / future photos. Use getMintRangeInput(uint numberOfTokens) to generate input. | function mintPhotos(
MintRangeInput memory input,
bytes32 checksum
| function mintPhotos(
MintRangeInput memory input,
bytes32 checksum
| 39,344 |
14 | // add pendingPAR balance to stake and totalStake instead of sending it back | userInfo.stake = userInfo.stake.add(pendingPAR);
totalStake = totalStake.add(pendingPAR);
| userInfo.stake = userInfo.stake.add(pendingPAR);
totalStake = totalStake.add(pendingPAR);
| 10,726 |
0 | // IHordCongressMembersRegistry contract. Nikola MadjarevicDate created: 21.3.21.Github: madjarevicn / | interface IHordCongressMembersRegistry {
function isMember(address _address) external view returns (bool);
function getMinimalQuorum() external view returns (uint256);
}
| interface IHordCongressMembersRegistry {
function isMember(address _address) external view returns (bool);
function getMinimalQuorum() external view returns (uint256);
}
| 36,175 |
155 | // Retrieves the bond amount of a darknode in 10^-18 REN./_darknodeID The ID of the darknode to retrieve the bond for. | function getDarknodeBond(address _darknodeID) external view returns (uint256) {
return store.darknodeBond(_darknodeID);
}
| function getDarknodeBond(address _darknodeID) external view returns (uint256) {
return store.darknodeBond(_darknodeID);
}
| 3,998 |
24 | // Emit the event tracking this | emit MembershipProved(msg.sender, block.timestamp);
| emit MembershipProved(msg.sender, block.timestamp);
| 41,212 |
1 | // Total rewards injected | uint256 public totalRewards;
| uint256 public totalRewards;
| 20,725 |
56 | // Emits {LogUpdateTrust} eventborrower_ Account addresstrustAmount Trust amount / | function updateTrust(address borrower_, uint256 trustAmount)
external
override
onlyMember(msg.sender)
whenNotPaused
{
if (borrower_ == address(0)) revert AddressZero();
address borrower = borrower_;
TrustInfo memory trustInfo;
| function updateTrust(address borrower_, uint256 trustAmount)
external
override
onlyMember(msg.sender)
whenNotPaused
{
if (borrower_ == address(0)) revert AddressZero();
address borrower = borrower_;
TrustInfo memory trustInfo;
| 21,693 |
59 | // -----------------------------------------------------------------------/ Errors/ ----------------------------------------------------------------------- |
error Error_ZeroOwner();
error Error_AlreadyInitialized();
error Error_NotRewardDistributor();
error Error_AmountTooLarge();
|
error Error_ZeroOwner();
error Error_AlreadyInitialized();
error Error_NotRewardDistributor();
error Error_AmountTooLarge();
| 19,457 |
51 | // Get the absolute value of a real. Just the same as abs on a normal int256. / | function abs(int256 realValue) internal pure returns (int256) {
if (realValue > 0) {
return realValue;
} else {
return -realValue;
}
}
| function abs(int256 realValue) internal pure returns (int256) {
if (realValue > 0) {
return realValue;
} else {
return -realValue;
}
}
| 25,825 |
2 | // Storage position of the owner and pendingOwner of the contract | bytes32 private constant proxyOwnerPosition = keccak256("trueUSD.proxy.owner");
bytes32 private constant pendingProxyOwnerPosition = keccak256("trueUSD.pending.proxy.owner");
| bytes32 private constant proxyOwnerPosition = keccak256("trueUSD.proxy.owner");
bytes32 private constant pendingProxyOwnerPosition = keccak256("trueUSD.pending.proxy.owner");
| 37,350 |
169 | // owner of the contract Used to query if a contract implements an interface. Used to implement ERC-165. | mapping(bytes4 => bool) supportedInterfaces;
| mapping(bytes4 => bool) supportedInterfaces;
| 4,390 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.