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 |
|---|---|---|---|---|
12 | // Whitelist mint fee | uint256 public whitelistMintFee = 0.2 ether;
| uint256 public whitelistMintFee = 0.2 ether;
| 8,364 |
15 | // Construct Varen token and allocate all tokens to treasury | constructor() {
_balances[TREASURY] = totalSupply;
}
| constructor() {
_balances[TREASURY] = totalSupply;
}
| 49,271 |
117 | // Ensure that the new timelock expiration will not cause an overflow error. | require(
newTimelockExpiration < _A_TRILLION_YEARS,
"Supplied default timelock expiration is too large."
);
| require(
newTimelockExpiration < _A_TRILLION_YEARS,
"Supplied default timelock expiration is too large."
);
| 5,837 |
186 | // The block number when GrowDeFi mining starts. | uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
GrowDeFiToken _growdefi,
address _devaddr,
uint256 _growdefiPerBlock,
| uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
GrowDeFiToken _growdefi,
address _devaddr,
uint256 _growdefiPerBlock,
| 41,236 |
2 | // keep track of address allowed for barter | mapping(address => bool) private _barterables;
| mapping(address => bool) private _barterables;
| 12,401 |
85 | // Owner address is excluded from reward system. | address private excluded;
| address private excluded;
| 10,101 |
179 | // Check if the targeted balance is enough | require (primordialBalanceOf[_from] >= _value);
| require (primordialBalanceOf[_from] >= _value);
| 52,994 |
58 | // Make sure we can deposit | if (baseDelta > 0 || usdcDelta > 0) {
dd.curBaseAmount = _roundDown(dd.curBaseAmount.sub(baseDelta));
dd.curQuoteAmount = _roundDown(dd.curQuoteAmount.sub(usdcDelta));
return _calcDepositAmount(_curve, _base, dd);
}
| if (baseDelta > 0 || usdcDelta > 0) {
dd.curBaseAmount = _roundDown(dd.curBaseAmount.sub(baseDelta));
dd.curQuoteAmount = _roundDown(dd.curQuoteAmount.sub(usdcDelta));
return _calcDepositAmount(_curve, _base, dd);
}
| 47,791 |
9 | // Emitted when setting a new liquidation incentive that is below the lower bound. | error Fintroller__LiquidationIncentiveUnderflow(uint256 newLiquidationIncentive);
| error Fintroller__LiquidationIncentiveUnderflow(uint256 newLiquidationIncentive);
| 51,599 |
5 | // Signals support for a given interface/interfaceId 4bytes signature of the interface | function supportsInterface(bytes4 interfaceId)
public
view
override(ERC1155, AccessControlEnumerable)
returns (bool)
| function supportsInterface(bytes4 interfaceId)
public
view
override(ERC1155, AccessControlEnumerable)
returns (bool)
| 22,774 |
188 | // array with last balance recorded for each gov tokens | mapping (address => uint256) public govTokensLastBalances;
| mapping (address => uint256) public govTokensLastBalances;
| 39,705 |
7 | // @inheritdoc IL1StandardBridge / | function depositETH(uint32 _l2Gas, bytes calldata _data) external payable onlyEOA {
_initiateETHDeposit(msg.sender, msg.sender, _l2Gas, _data);
}
| function depositETH(uint32 _l2Gas, bytes calldata _data) external payable onlyEOA {
_initiateETHDeposit(msg.sender, msg.sender, _l2Gas, _data);
}
| 3,665 |
202 | // CUSTOM URI | uint day = diffDays(startTime, block.timestamp);
if(isDaoNFT){
customMintedUri[nounId] = nextDaoUri;
} else {
| uint day = diffDays(startTime, block.timestamp);
if(isDaoNFT){
customMintedUri[nounId] = nextDaoUri;
} else {
| 37,159 |
14 | // Multiplies x and y, assuming they are both fixed point with 27 digits. | function muld(uint256 x, uint256 y) internal pure returns (uint256) {
return x.mul(y).div(UNIT);
}
| function muld(uint256 x, uint256 y) internal pure returns (uint256) {
return x.mul(y).div(UNIT);
}
| 33,808 |
42 | // If in countdown mode, then set countdown count | countdown = uint8((value >> 3) & 255);
randomThreshold = 0;
| countdown = uint8((value >> 3) & 255);
randomThreshold = 0;
| 28,144 |
165 | // exclude from paying fees or having max transaction amount | excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
devFeeAddress = msg.sender;
| excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
devFeeAddress = msg.sender;
| 3,247 |
13 | // Verify product with bar code | function verifyProduct(string memory barCode)
public
view
returns (productDetails memory)
| function verifyProduct(string memory barCode)
public
view
returns (productDetails memory)
| 8,924 |
205 | // Trade for the quoted token amount on Uniswap and send to recipient. | amounts = _UNISWAP_ROUTER.swapTokensForExactTokens(
quotedTokenReceivedAmount, tokenProvidedAmount, path, recipient, deadline
);
totalTokensSold = amounts[0];
retainedAmount = tokenProvidedAmount.sub(totalTokensSold);
| amounts = _UNISWAP_ROUTER.swapTokensForExactTokens(
quotedTokenReceivedAmount, tokenProvidedAmount, path, recipient, deadline
);
totalTokensSold = amounts[0];
retainedAmount = tokenProvidedAmount.sub(totalTokensSold);
| 6,844 |
248 | // xref:ROOT:erc1155.adocbatch-operations[Batched] version of {_mint}. Requirements: - `ids` and `amounts` must have the same length.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return theacceptance magic value. / | function _mintBatch(
| function _mintBatch(
| 17,600 |
145 | // List of users who take part in staking | EnumerableSet.AddressSet private holders;
| EnumerableSet.AddressSet private holders;
| 15,010 |
9 | // Are you still able to vote? | require(block.number < _surveyEndBlock, "Survey ended!");
| require(block.number < _surveyEndBlock, "Survey ended!");
| 34,533 |
57 | // users need to send their token back to owner to download | if (beneficiary.send(amountRaised)) {
emit FundTransfer(beneficiary, amountRaised, false);
}
| if (beneficiary.send(amountRaised)) {
emit FundTransfer(beneficiary, amountRaised, false);
}
| 53,630 |
54 | // Reward token | ERC20 private rewardToken;
| ERC20 private rewardToken;
| 11,715 |
19 | // Withdraw user's portion of pool's assets | for (uint i = assetCount; i > 0; i--)
{
uint portionOfAssetBalance = _withdrawProcessing(_positionKeys[i], portion);
if (portionOfAssetBalance > 0)
{
IERC20(_positionKeys[i]).transfer(msg.sender, portionOfAssetBalance.mul(10000 - managerFee).div(10000));
IERC20(_positionKeys[i]).transfer(manager, portionOfAssetBalance.mul(managerFee).div(10000));
amountsWithdrawn[i.sub(1)] = portionOfAssetBalance.mul(10000 - managerFee).div(10000);
| for (uint i = assetCount; i > 0; i--)
{
uint portionOfAssetBalance = _withdrawProcessing(_positionKeys[i], portion);
if (portionOfAssetBalance > 0)
{
IERC20(_positionKeys[i]).transfer(msg.sender, portionOfAssetBalance.mul(10000 - managerFee).div(10000));
IERC20(_positionKeys[i]).transfer(manager, portionOfAssetBalance.mul(managerFee).div(10000));
amountsWithdrawn[i.sub(1)] = portionOfAssetBalance.mul(10000 - managerFee).div(10000);
| 25,839 |
7 | // Emit event {SetVerifier} / | function setVerifier(address _account) external onlyAdmin {
require(
_account != address(0) && !_account.isContract(),
"Ownable: Invalid address"
);
address oldVerifier = verifier;
verifier = _account;
emit SetVerifier(oldVerifier, verifier);
}
| function setVerifier(address _account) external onlyAdmin {
require(
_account != address(0) && !_account.isContract(),
"Ownable: Invalid address"
);
address oldVerifier = verifier;
verifier = _account;
emit SetVerifier(oldVerifier, verifier);
}
| 9,779 |
256 | // Hook function after iToken `seize()`Will `revert()` if any operation fails _iTokenCollateral The collateral iToken to be seized _iTokenBorrowed The iToken was borrowed _liquidator The account which has repaid and seized _borrower The account which has borrowed _seizedAmountThe amount of collateral being seized / | function afterSeize(
address _iTokenCollateral,
address _iTokenBorrowed,
address _liquidator,
address _borrower,
uint256 _seizedAmount
| function afterSeize(
address _iTokenCollateral,
address _iTokenBorrowed,
address _liquidator,
address _borrower,
uint256 _seizedAmount
| 40,567 |
112 | // 0.3% fee of all transfers are sent to this dev fund (reward for devs). | devRewardAddress = 0x29807F6f06ec2a7AD56ed1a6dB3C3648D4d88634;
| devRewardAddress = 0x29807F6f06ec2a7AD56ed1a6dB3C3648D4d88634;
| 1,612 |
259 | // The Exchanger contract informs us when fees are paid. amount susd amount in fees being paid. / | function recordFeePaid(uint amount) external onlyInternalContracts {
// Keep track off fees in sUSD in the open fee pool period.
_recentFeePeriodsStorage(0).feesToDistribute = _recentFeePeriodsStorage(0).feesToDistribute.add(amount);
}
| function recordFeePaid(uint amount) external onlyInternalContracts {
// Keep track off fees in sUSD in the open fee pool period.
_recentFeePeriodsStorage(0).feesToDistribute = _recentFeePeriodsStorage(0).feesToDistribute.add(amount);
}
| 10,150 |
21 | // --------------------------modifiers and constructor ------------------------------------/ | constructor(IERC20 t,string memory _roundName,uint _claimPercentage ,uint _totalSupplyInWei,uint _unlockTime,uint _releasePeriod){
require(_unlockTime > block.timestamp,"unlock time must be greater than now");
require(_releasePeriod > 0,"release periods should be gereater than zero");
require(0 < _claimPercentage && _claimPercentage <10000,"claim percentage must be within 0 to 10000");
token = t;
name = _roundName;
claimPercentage = _claimPercentage;
totalSupplyInWei = _totalSupplyInWei;
unlockTime = _unlockTime;
releasePeriod = _releasePeriod;
}
| constructor(IERC20 t,string memory _roundName,uint _claimPercentage ,uint _totalSupplyInWei,uint _unlockTime,uint _releasePeriod){
require(_unlockTime > block.timestamp,"unlock time must be greater than now");
require(_releasePeriod > 0,"release periods should be gereater than zero");
require(0 < _claimPercentage && _claimPercentage <10000,"claim percentage must be within 0 to 10000");
token = t;
name = _roundName;
claimPercentage = _claimPercentage;
totalSupplyInWei = _totalSupplyInWei;
unlockTime = _unlockTime;
releasePeriod = _releasePeriod;
}
| 5,946 |
21 | // Make the xDomain call NOTICE: We approximate the max submission cost of sending a retryable tx with specific calldata length. | uint256 maxSubmissionCost = _approximateMaxSubmissionCost(message.length);
uint256 maxGas = 120_000; // static `maxGas` for L2 -> L1 transfer
uint256 gasPriceBid = s_gasConfig.gasPriceBid;
uint256 l1PaymentValue = s_paymentStrategy == PaymentStrategy.L1
? _maxRetryableTicketCost(maxSubmissionCost, maxGas, gasPriceBid)
: 0;
| uint256 maxSubmissionCost = _approximateMaxSubmissionCost(message.length);
uint256 maxGas = 120_000; // static `maxGas` for L2 -> L1 transfer
uint256 gasPriceBid = s_gasConfig.gasPriceBid;
uint256 l1PaymentValue = s_paymentStrategy == PaymentStrategy.L1
? _maxRetryableTicketCost(maxSubmissionCost, maxGas, gasPriceBid)
: 0;
| 56,049 |
15 | // Returns number of instantiations by creator. creator Contract creator.return Returns number of instantiations by creator. / | function getInstantiationCount(address creator)
public
view
returns (uint256)
| function getInstantiationCount(address creator)
public
view
returns (uint256)
| 42,458 |
166 | // this method is responsible for taking all fee, if takeFee is true | function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) internal {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
| function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) internal {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
| 6,646 |
148 | // Mints PYTs and NYTs to the recipient given the amount of underlying deposited. | function _enter(
address nytRecipient,
address pytRecipient,
address vault,
IxPYT xPYT,
uint256 underlyingAmount,
uint256 updatedPricePerVaultShare
| function _enter(
address nytRecipient,
address pytRecipient,
address vault,
IxPYT xPYT,
uint256 underlyingAmount,
uint256 updatedPricePerVaultShare
| 4,049 |
44 | // returns the amount of Kata tokens withdrawn as rewards / | function getTotalRewardsClaimed() public view returns (uint256) {
return _totalKataRewardsClaimed;
}
| function getTotalRewardsClaimed() public view returns (uint256) {
return _totalKataRewardsClaimed;
}
| 19,258 |
117 | // user's balance and boostedSupply will be changed in this function | applyBoost(msg.sender, newBoostBalance);
_getReward(msg.sender);
boostToken.safeTransferFrom(msg.sender, address(this), boosterAmount);
IERC20Burnable burnableBoostToken = IERC20Burnable(address(boostToken));
| applyBoost(msg.sender, newBoostBalance);
_getReward(msg.sender);
boostToken.safeTransferFrom(msg.sender, address(this), boosterAmount);
IERC20Burnable burnableBoostToken = IERC20Burnable(address(boostToken));
| 14,387 |
31 | // Multiplies two int256 variables and fails on overflow. / | function mul(int256 a, int256 b)
internal
pure
returns (int256)
| function mul(int256 a, int256 b)
internal
pure
returns (int256)
| 45,295 |
661 | // month |
uint value;
|
uint value;
| 146 |
3 | // The current version of this library. | bytes32 public constant CURRENT_VERSION = V1_VERSION_STRING;
| bytes32 public constant CURRENT_VERSION = V1_VERSION_STRING;
| 6,662 |
77 | // ------------------------------------------------------------------------ Query to get the staking period you staked at ------------------------------------------------------------------------ | function YourStakingPeriod(address _user) external view returns(uint256 _stakingPeriod){
return users[_user][SYFP].period;
}
| function YourStakingPeriod(address _user) external view returns(uint256 _stakingPeriod){
return users[_user][SYFP].period;
}
| 47,643 |
80 | // Emit the `Transfer` event. Similar to above. | log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
| log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
| 10,876 |
44 | // See {IERC20-allowance}. / | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| 632 |
88 | // Mint 500 iHope (18 Decimals) | _mint(msg.sender, 500000000000000000000);
| _mint(msg.sender, 500000000000000000000);
| 59,735 |
206 | // CONSTRUCTOR | constructor() {
_addOwner(msg.sender);
_paused = false;
}
| constructor() {
_addOwner(msg.sender);
_paused = false;
}
| 4,646 |
27 | // Moves `amount` tokens from the caller's account to `recipient`. Returns a boolean value indicating whether the operation succeeded. | * Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| * Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 22,531 |
115 | // Given an input asset amount, returns the maximum output amount of the other asset and the prices amountIn Amount of reserveIn reserveIn Address of the asset to be swap from reserveOut Address of the asset to be swap toreturn uint256 Amount out of the reserveOutreturn uint256 The price of out amount denominated in the reserveIn currency (18 decimals)return uint256 In amount of reserveIn value denominated in USD (8 decimals)return uint256 Out amount of reserveOut value denominated in USD (8 decimals)return address[] The exchange path / | function getAmountsOut(
uint256 amountIn,
address reserveIn,
address reserveOut
)
external
view
returns (
uint256,
uint256,
| function getAmountsOut(
uint256 amountIn,
address reserveIn,
address reserveOut
)
external
view
returns (
uint256,
uint256,
| 39,427 |
98 | // crossing max cap can always happen | maxCapExceeded = isCapExceeded(state() == ETOState.Whitelist, equityTokenInt, fixedSlotsEquityTokenInt, newInvestorContributionEurUlps);
| maxCapExceeded = isCapExceeded(state() == ETOState.Whitelist, equityTokenInt, fixedSlotsEquityTokenInt, newInvestorContributionEurUlps);
| 33,940 |
0 | // Register a handler with a bytes32 information. registration Handler address. info Info string. Dapps that triggers callback function should also be registered.In this case, registration is the Dapp address and the leading 20 bytesof info is the handler address. / | function register(address registration, bytes32 info) external onlyOwner {
require(registration != address(0), "zero address");
require(infos[registration] != DEPRECATED, "unregistered");
infos[registration] = info;
}
| function register(address registration, bytes32 info) external onlyOwner {
require(registration != address(0), "zero address");
require(infos[registration] != DEPRECATED, "unregistered");
infos[registration] = info;
}
| 47,428 |
4 | // called once by the smartcontract_address at time of deployment | function initialize(address _token0, address _token1, address _bankx_contract_address, address _pid_address, address _collateral_pool_address) public initializer {
require(msg.sender == smartcontract_owner, 'XSD/WETH: FORBIDDEN'); // sufficient check
require((_token0 != address(0))
&&(_token1 != address(0))
&&(_bankx_contract_address != address(0))
&&(_pid_address != address(0))
&&(_collateral_pool_address != address(0)), "Zero address detected");
XSDaddress = _token0;
XSD = XSDStablecoin(XSDaddress);
BankX = BankXToken(_bankx_contract_address);
WETHaddress = _token1;
pid_controller = IPIDController(_pid_address);
}
| function initialize(address _token0, address _token1, address _bankx_contract_address, address _pid_address, address _collateral_pool_address) public initializer {
require(msg.sender == smartcontract_owner, 'XSD/WETH: FORBIDDEN'); // sufficient check
require((_token0 != address(0))
&&(_token1 != address(0))
&&(_bankx_contract_address != address(0))
&&(_pid_address != address(0))
&&(_collateral_pool_address != address(0)), "Zero address detected");
XSDaddress = _token0;
XSD = XSDStablecoin(XSDaddress);
BankX = BankXToken(_bankx_contract_address);
WETHaddress = _token1;
pid_controller = IPIDController(_pid_address);
}
| 34,491 |
26 | // A helper function to check if an operator approval is allowed. / | modifier onlyOwner() {
require(msg.sender == _owner, "Ownable: caller is not the owner");
_;
}
| modifier onlyOwner() {
require(msg.sender == _owner, "Ownable: caller is not the owner");
_;
}
| 33 |
48 | // solium-disable-next-line security/no-block-members | require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
| require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
| 13,809 |
40 | // Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` inparticular (ignoring whether it is owned by `owner`). WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify thisassumption. / | function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
return
spender != address(0) &&
(owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
}
| function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
return
spender != address(0) &&
(owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
}
| 38,390 |
9 | // _maximumGasPrice highest gas price for which transmitter will be compensated _reasonableGasPrice transmitter will receive reward for gas prices under this value _microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units _linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units _linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units _link address of the LINK contract _minAnswer lowest answer the median of a report is allowed to be _maxAnswer highest answer the median of a report is allowed to be _billingAccessController access controller for billing admin functions _requesterAccessController access controller for requesting | constructor(
uint32 _maximumGasPrice,
uint32 _reasonableGasPrice,
uint32 _microLinkPerEth,
uint32 _linkGweiPerObservation,
uint32 _linkGweiPerTransmission,
LinkTokenInterface _link,
int192 _minAnswer,
| constructor(
uint32 _maximumGasPrice,
uint32 _reasonableGasPrice,
uint32 _microLinkPerEth,
uint32 _linkGweiPerObservation,
uint32 _linkGweiPerTransmission,
LinkTokenInterface _link,
int192 _minAnswer,
| 28,248 |
126 | // 卡牌积分增益系数和变更 | ownerPointCoefficients[_to] = ownerPointCoefficients[_to].add(cardPointCoefficient[_ids[i]]);
ownerPointCoefficients[_from] = ownerPointCoefficients[_from].sub(cardPointCoefficient[_ids[i]]);
| ownerPointCoefficients[_to] = ownerPointCoefficients[_to].add(cardPointCoefficient[_ids[i]]);
ownerPointCoefficients[_from] = ownerPointCoefficients[_from].sub(cardPointCoefficient[_ids[i]]);
| 4,047 |
15 | // return extra payment | if (msg.value > _price)
payable(msg.sender).transfer(msg.value - _price);
| if (msg.value > _price)
payable(msg.sender).transfer(msg.value - _price);
| 6,040 |
70 | // helper function for processing multiple purchases | function processMultiPurchase(uint32 _pixelId,uint8 _colourR,uint8 _colourG,uint8 _colourB,string _text, // solium-disable-line
| function processMultiPurchase(uint32 _pixelId,uint8 _colourR,uint8 _colourG,uint8 _colourB,string _text, // solium-disable-line
| 29,684 |
217 | // We get the current exchange rate and calculate the number of WarpWrapperToken to be minted:mintTokens = _amount / exchangeRate | (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(
_amount,
| (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(
_amount,
| 24,050 |
161 | // Total revenue | totalRevenue = totalRevenue.add(_amount);
| totalRevenue = totalRevenue.add(_amount);
| 61,118 |
90 | // Magic value to be returned upon successful reception of ERC1363 tokens Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`, which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector` / | bytes4 internal constant _INTERFACE_ID_ERC1363_RECEIVER = 0x88a7ca5c;
| bytes4 internal constant _INTERFACE_ID_ERC1363_RECEIVER = 0x88a7ca5c;
| 34,305 |
4 | // calculate the square of Coefficient of Variation (CV)/ https:en.wikipedia.org/wiki/Coefficient_of_variation | function cvsquare(
uint[] arr,
uint scale
)
internal
pure
returns (uint)
| function cvsquare(
uint[] arr,
uint scale
)
internal
pure
returns (uint)
| 46,243 |
59 | // sipId starts from 0. first sip of user will have id 0, then 1 and so on. | uint256 _sipId = sips[msg.sender].length - 1;
| uint256 _sipId = sips[msg.sender].length - 1;
| 24,119 |
11 | // Returns the state of the current auction.return AuctionState The state of the current auction. / | function getAuction() external view returns (AuctionState memory) {
return
AuctionState(
tokenId,
startTime,
endTime,
currentBid,
bidder,
getCurrentMinBid(),
bool(block.timestamp > endTime)
);
}
| function getAuction() external view returns (AuctionState memory) {
return
AuctionState(
tokenId,
startTime,
endTime,
currentBid,
bidder,
getCurrentMinBid(),
bool(block.timestamp > endTime)
);
}
| 23,201 |
19 | // first delete all characters at the end of the array | while (nchars > 0
&& characters[ids[nchars - 1]].owner == msg.sender
&& characters[ids[nchars - 1]].purchaseTimestamp + 1 days < now
&& characters[ids[nchars - 1]].characterType < 2*numDragonTypes) {
nchars--;
lastId = ids[nchars];
numCharactersXType[characters[lastId].characterType]--;
playerBalance += characters[lastId].value;
removed[count] = lastId;
count++;
| while (nchars > 0
&& characters[ids[nchars - 1]].owner == msg.sender
&& characters[ids[nchars - 1]].purchaseTimestamp + 1 days < now
&& characters[ids[nchars - 1]].characterType < 2*numDragonTypes) {
nchars--;
lastId = ids[nchars];
numCharactersXType[characters[lastId].characterType]--;
playerBalance += characters[lastId].value;
removed[count] = lastId;
count++;
| 3,255 |
237 | // isNFTHolder(_genNumber) | {
uint256[] memory _amount = new uint256[](_tokenIds.length);
bytes memory _data = "";
if (collections[_genNumber].nftType == E1155) {
for (uint256 i = 0; i < _tokenIds.length; i++) _amount[i] = 1;
collections[_genNumber].erc1155.safeBatchTransferFrom(
msg.sender,
address(this),
_tokenIds,
_amount,
_data
);
} else if (collections[_genNumber].nftType == E721) {
for (uint256 i = 0; i < _tokenIds.length; i++)
collections[_genNumber].erc721.safeTransferFrom(
msg.sender,
address(this),
_tokenIds[i]
);
}
updateBalance(msg.sender, _tokenIds, _genNumber);
}
| {
uint256[] memory _amount = new uint256[](_tokenIds.length);
bytes memory _data = "";
if (collections[_genNumber].nftType == E1155) {
for (uint256 i = 0; i < _tokenIds.length; i++) _amount[i] = 1;
collections[_genNumber].erc1155.safeBatchTransferFrom(
msg.sender,
address(this),
_tokenIds,
_amount,
_data
);
} else if (collections[_genNumber].nftType == E721) {
for (uint256 i = 0; i < _tokenIds.length; i++)
collections[_genNumber].erc721.safeTransferFrom(
msg.sender,
address(this),
_tokenIds[i]
);
}
updateBalance(msg.sender, _tokenIds, _genNumber);
}
| 24,790 |
29 | // Mapping from diamond ID to metadata | mapping(string => Diamond) internal diamondIdToMetadata;
| mapping(string => Diamond) internal diamondIdToMetadata;
| 14,757 |
1 | // bool | bool public sale_active = false;
| bool public sale_active = false;
| 48,671 |
42 | // Total amount of ghost shares caused by IOUs. Ghost shares can be/ removed upon IOU removal, and thus should be ignored while considering/ how much collateral the pool can provide. | uint256 public totalGhostShares = 1;
| uint256 public totalGhostShares = 1;
| 17,240 |
289 | // Value is too low | uint256 internal constant VALUE_TOO_LOW = 25;
| uint256 internal constant VALUE_TOO_LOW = 25;
| 34,108 |
83 | // Emit the Approval event | emit Approval(msg.sender, _tokenspender, _value);
return true;
| emit Approval(msg.sender, _tokenspender, _value);
return true;
| 13,754 |
31 | // Decrease the amount of tokens that an owner has allowed to a spender.spender The address which will spend the funds. subtractedValue The amount of tokens to decrease the allowance by. / | function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
require(!isBlacklisted[msg.sender], "owner blacklisted");
require(!isBlacklisted[spender], "spender blacklisted");
require(spender != address(0x0), "invalid address");
uint256 oldValue = _allowedTokens[msg.sender][spender];
if (subtractedValue >= oldValue) {
_allowedTokens[msg.sender][spender] = 0;
} else {
_allowedTokens[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit Approval(msg.sender, spender, _allowedTokens[msg.sender][spender]);
return true;
}
| function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
require(!isBlacklisted[msg.sender], "owner blacklisted");
require(!isBlacklisted[spender], "spender blacklisted");
require(spender != address(0x0), "invalid address");
uint256 oldValue = _allowedTokens[msg.sender][spender];
if (subtractedValue >= oldValue) {
_allowedTokens[msg.sender][spender] = 0;
} else {
_allowedTokens[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit Approval(msg.sender, spender, _allowedTokens[msg.sender][spender]);
return true;
}
| 12,948 |
12 | // generates an array composed of all the individual traits and values tokenId the ID of the token to compose the metadata forreturn a JSON array of all of the attributes for given token ID / | function compileAttributes(uint256 tokenId) public view returns (string memory) {
IDiamondHeist.LlamaDog memory s = diamondheist.getTokenTraits(tokenId);
string memory traits;
if (s.isLlama) {
traits = string(abi.encodePacked(
attributeForTypeAndValue(_traitTypes[0], traitData[0][s.body].name),",",
attributeForTypeAndValue(_traitTypes[1], traitData[1][s.hat].name),",",
attributeForTypeAndValue(_traitTypes[2], traitData[2][s.eye].name),",",
attributeForTypeAndValue(_traitTypes[3], traitData[3][s.mouth].name),",",
attributeForTypeAndValue(_traitTypes[4], traitData[4][s.clothes].name),",",
attributeForTypeAndValue(_traitTypes[5], traitData[5][s.tail].name),","
// traitData 6 = alpha score, but not visible
));
} else {
traits = string(abi.encodePacked(
attributeForTypeAndValue(_traitTypes[0], traitData[7][s.body].name),",",
attributeForTypeAndValue(_traitTypes[1], traitData[8][s.hat].name),",",
attributeForTypeAndValue(_traitTypes[2], traitData[9][s.eye].name),",",
attributeForTypeAndValue(_traitTypes[3], traitData[10][s.mouth].name),",",
attributeForTypeAndValue(_traitTypes[4], traitData[11][s.clothes].name),",",
attributeForTypeAndValue(_traitTypes[5], traitData[12][s.tail].name),",",
attributeForTypeAndValueNumber("Sneaky Score", _alphas[s.alphaIndex]),","
));
}
return string(abi.encodePacked(
'[',
traits,
'{"trait_type":"Generation","value":"',
getGen(tokenId),
'"},{"trait_type":"Type","value":',
s.isLlama ? '"Llama"' : '"Dog"',
'}]'
));
}
| function compileAttributes(uint256 tokenId) public view returns (string memory) {
IDiamondHeist.LlamaDog memory s = diamondheist.getTokenTraits(tokenId);
string memory traits;
if (s.isLlama) {
traits = string(abi.encodePacked(
attributeForTypeAndValue(_traitTypes[0], traitData[0][s.body].name),",",
attributeForTypeAndValue(_traitTypes[1], traitData[1][s.hat].name),",",
attributeForTypeAndValue(_traitTypes[2], traitData[2][s.eye].name),",",
attributeForTypeAndValue(_traitTypes[3], traitData[3][s.mouth].name),",",
attributeForTypeAndValue(_traitTypes[4], traitData[4][s.clothes].name),",",
attributeForTypeAndValue(_traitTypes[5], traitData[5][s.tail].name),","
// traitData 6 = alpha score, but not visible
));
} else {
traits = string(abi.encodePacked(
attributeForTypeAndValue(_traitTypes[0], traitData[7][s.body].name),",",
attributeForTypeAndValue(_traitTypes[1], traitData[8][s.hat].name),",",
attributeForTypeAndValue(_traitTypes[2], traitData[9][s.eye].name),",",
attributeForTypeAndValue(_traitTypes[3], traitData[10][s.mouth].name),",",
attributeForTypeAndValue(_traitTypes[4], traitData[11][s.clothes].name),",",
attributeForTypeAndValue(_traitTypes[5], traitData[12][s.tail].name),",",
attributeForTypeAndValueNumber("Sneaky Score", _alphas[s.alphaIndex]),","
));
}
return string(abi.encodePacked(
'[',
traits,
'{"trait_type":"Generation","value":"',
getGen(tokenId),
'"},{"trait_type":"Type","value":',
s.isLlama ? '"Llama"' : '"Dog"',
'}]'
));
}
| 7,762 |
4 | // anyone can call to claim rewards for multiple epochsall eth will be sent back to rewardRecipient/ | function claimRewards(
uint256 cycle,
uint256 index,
IERC20Ext[] calldata tokens,
uint256[] calldata cumulativeAmounts,
bytes32[] calldata merkleProof
)
external
returns (uint256[] memory claimAmounts)
| function claimRewards(
uint256 cycle,
uint256 index,
IERC20Ext[] calldata tokens,
uint256[] calldata cumulativeAmounts,
bytes32[] calldata merkleProof
)
external
returns (uint256[] memory claimAmounts)
| 67,147 |
56 | // Called by a owner to unpause, returns to normal state. / | function unpause() public onlyOwner whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
| function unpause() public onlyOwner whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
| 50,450 |
17 | // This would return the winning address and winning bid. | giveUpOwnershipOfContract(onlyOwner);
| giveUpOwnershipOfContract(onlyOwner);
| 45,454 |
24 | // There is minimum and maximum bets. | uint constant MIN_BET = 0.01 ether;
uint constant MAX_AMOUNT = 10 ether;
| uint constant MIN_BET = 0.01 ether;
uint constant MAX_AMOUNT = 10 ether;
| 49,327 |
14 | // read first 12 bits | uint256 layerNum = uint256(picSid & bitMask);
if (layerNum == 0) {
| uint256 layerNum = uint256(picSid & bitMask);
if (layerNum == 0) {
| 20,469 |
13 | // admins info | address[] public admins;
mapping (address => uint256) public adminId;
| address[] public admins;
mapping (address => uint256) public adminId;
| 27,966 |
53 | // Log the event | emit Swap(msg.sender, ETH_TOKEN_ADDRESS, ercToken);
return amount;
| emit Swap(msg.sender, ETH_TOKEN_ADDRESS, ercToken);
return amount;
| 30,290 |
20 | // default is 0, if mode == CoreLibrary.InterestRateMode.NONE | if (mode == CoreLibrary.InterestRateMode.STABLE) {
borrowRate = core.getUserCurrentStableBorrowRate(_reserve, _user);
} else if (mode == CoreLibrary.InterestRateMode.VARIABLE) {
| if (mode == CoreLibrary.InterestRateMode.STABLE) {
borrowRate = core.getUserCurrentStableBorrowRate(_reserve, _user);
} else if (mode == CoreLibrary.InterestRateMode.VARIABLE) {
| 31,516 |
97 | // Emit the event that a new master was deployed | emit MasterCreated(address(proxyMaster));
| emit MasterCreated(address(proxyMaster));
| 44,435 |
129 | // View function to see pending ALDs on frontend. | function pendingALD(address _token, address _user) onlyValidPool(_token) external view returns (uint256) {
uint pid = tokenToPid[_token];
PoolInfo storage pool = poolInfo[pid - 1];
UserInfo storage user = userInfo[pid][_user];
uint256 accALDPerShare = pool.accALDPerShare;
uint256 lpSupply = IERC20(pool.token).balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 aldReward = aldPerBlock.mul(block.number.sub(pool.lastRewardBlock))
.mul(pool.allocPoint)
.div(totalAllocPoint);
uint256 distributorReward = aldReward.mul(tokenDistributorAllocNume).div(tokenDistributorAllocDenom);
uint256 poolReward = aldReward.sub(distributorReward);
accALDPerShare = accALDPerShare.add(poolReward.mul(1e18).div(lpSupply));
}
return user.amount.mul(accALDPerShare).div(1e18).sub(user.rewardDebt);
}
| function pendingALD(address _token, address _user) onlyValidPool(_token) external view returns (uint256) {
uint pid = tokenToPid[_token];
PoolInfo storage pool = poolInfo[pid - 1];
UserInfo storage user = userInfo[pid][_user];
uint256 accALDPerShare = pool.accALDPerShare;
uint256 lpSupply = IERC20(pool.token).balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 aldReward = aldPerBlock.mul(block.number.sub(pool.lastRewardBlock))
.mul(pool.allocPoint)
.div(totalAllocPoint);
uint256 distributorReward = aldReward.mul(tokenDistributorAllocNume).div(tokenDistributorAllocDenom);
uint256 poolReward = aldReward.sub(distributorReward);
accALDPerShare = accALDPerShare.add(poolReward.mul(1e18).div(lpSupply));
}
return user.amount.mul(accALDPerShare).div(1e18).sub(user.rewardDebt);
}
| 38,539 |
1 | // --- ERC20 Data --- | uint8 public constant decimals = 18;
string public name;
string public symbol;
string public constant version = "1";
uint256 public totalSupply;
bytes32 public DOMAIN_SEPARATOR;
| uint8 public constant decimals = 18;
string public name;
string public symbol;
string public constant version = "1";
uint256 public totalSupply;
bytes32 public DOMAIN_SEPARATOR;
| 17,784 |
104 | // Add new Convex pool./_convexPid - The Convex pool id./_rewardTokens - The list of addresses of reward tokens./_withdrawFeePercentage - The withdraw fee percentage of the pool./_platformFeePercentage - The platform fee percentage of the pool./_harvestBountyPercentage - The harvest bounty percentage of the pool. | function addPool(
uint256 _convexPid,
address[] memory _rewardTokens,
uint256 _withdrawFeePercentage,
uint256 _platformFeePercentage,
uint256 _harvestBountyPercentage
| function addPool(
uint256 _convexPid,
address[] memory _rewardTokens,
uint256 _withdrawFeePercentage,
uint256 _platformFeePercentage,
uint256 _harvestBountyPercentage
| 29,113 |
43 | // This read function is O({totalSupply}). If calling from a separate contract, be sure to test gas first./ It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case./owner Address to query./ return ids An array of the ID's owned by `owner`. | function _idsOfOwner(address owner) internal view virtual returns (uint256[] memory ids) {
uint256 bal = uint256(_addressData[owner].balance);
if (bal == 0) return ids;
ids = new uint256[](bal);
uint256 minted = currentIndex;
address currOwner;
uint256 index;
| function _idsOfOwner(address owner) internal view virtual returns (uint256[] memory ids) {
uint256 bal = uint256(_addressData[owner].balance);
if (bal == 0) return ids;
ids = new uint256[](bal);
uint256 minted = currentIndex;
address currOwner;
uint256 index;
| 9,009 |
177 | // ERC721MetadataMintable ERC721 minting logic with metadata. / | contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole {
/**
* @dev Function to mint tokens.
* @param to The address that will receive the minted tokens.
* @param tokenId The token id to mint.
* @param tokenURI The token URI of the minted token.
* @return A boolean that indicates if the operation was successful.
*/
function mintWithTokenURI(address to, uint256 tokenId, string memory tokenURI) public onlyMinter returns (bool) {
_mint(to, tokenId);
_setTokenURI(tokenId, tokenURI);
return true;
}
}
| contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole {
/**
* @dev Function to mint tokens.
* @param to The address that will receive the minted tokens.
* @param tokenId The token id to mint.
* @param tokenURI The token URI of the minted token.
* @return A boolean that indicates if the operation was successful.
*/
function mintWithTokenURI(address to, uint256 tokenId, string memory tokenURI) public onlyMinter returns (bool) {
_mint(to, tokenId);
_setTokenURI(tokenId, tokenURI);
return true;
}
}
| 8,389 |
31 | // require(tx.origin == msg.sender, "!EOA."); | uint256 totalEth = address(this).balance;
address[] memory path = new address[](2);
path[0] = wETHaddress;
path[1] = address(token);
uniswapRouter.swapExactETHForTokens.value(totalEth)(minAmountOut, path, defReceiver, now);
| uint256 totalEth = address(this).balance;
address[] memory path = new address[](2);
path[0] = wETHaddress;
path[1] = address(token);
uniswapRouter.swapExactETHForTokens.value(totalEth)(minAmountOut, path, defReceiver, now);
| 24,149 |
171 | // Withdraw everything from pool for yourself | function withdrawAll(uint256 _pid) external {
_withdraw(_pid, uint256(-1), msg.sender);
}
| function withdrawAll(uint256 _pid) external {
_withdraw(_pid, uint256(-1), msg.sender);
}
| 5,766 |
3 | // verify signature | bytes32 structHash = genOrderHash(loan);
bytes32 hashTypedData = _hashTypedDataV4(structHash);
address lender = verifySignature(hashTypedData, signature);
require(lender == loan.lender, "Loan: Signature Incorrect");
loanContract.transferFrom(loan.lender, msg.sender, loan.loanAmount);
token.safeTransferFrom(msg.sender, address(this), loan.tokenId);
loans[loan.nftAddress][loan.tokenId] = loan;
| bytes32 structHash = genOrderHash(loan);
bytes32 hashTypedData = _hashTypedDataV4(structHash);
address lender = verifySignature(hashTypedData, signature);
require(lender == loan.lender, "Loan: Signature Incorrect");
loanContract.transferFrom(loan.lender, msg.sender, loan.loanAmount);
token.safeTransferFrom(msg.sender, address(this), loan.tokenId);
loans[loan.nftAddress][loan.tokenId] = loan;
| 28,251 |
18 | // mint an NFT through the market place_to the address that will receive the freshly minted NFT_tokenId uint token ID (painting number)/ | function mintThroughPurchase(address _to, uint _tokenId) external payable {
require(price[_tokenId] > 0, PRICE_NOT_SET);
require(msg.value >= price[_tokenId],NOT_EHOUGH_ETHER);
require(_msgSender() != address(0) && _msgSender() != address(this));
//avoid reentrancy. Also mintLocked before launch time.
require(!mintLock,MINTING_LOCKED);
mintLock=true;
//we extract the royalty address from the mapping
address royaltyRecipient = royaltyAddress[_tokenId];
//this is hardcoded 6.0% for all NFTs
uint royaltyValue = 600;
contractBalance += msg.value;
TokenContract.mint(_to, _tokenId, royaltyRecipient, royaltyValue);
mintLock=false;
}
| function mintThroughPurchase(address _to, uint _tokenId) external payable {
require(price[_tokenId] > 0, PRICE_NOT_SET);
require(msg.value >= price[_tokenId],NOT_EHOUGH_ETHER);
require(_msgSender() != address(0) && _msgSender() != address(this));
//avoid reentrancy. Also mintLocked before launch time.
require(!mintLock,MINTING_LOCKED);
mintLock=true;
//we extract the royalty address from the mapping
address royaltyRecipient = royaltyAddress[_tokenId];
//this is hardcoded 6.0% for all NFTs
uint royaltyValue = 600;
contractBalance += msg.value;
TokenContract.mint(_to, _tokenId, royaltyRecipient, royaltyValue);
mintLock=false;
}
| 20,090 |
4 | // uint型可変配列の長さを取り出す | function getLength() public view returns (uint256) {
// Pythonでいう`len`
return uintArray.length;
}
| function getLength() public view returns (uint256) {
// Pythonでいう`len`
return uintArray.length;
}
| 21,503 |
74 | // Validation of an executed purchase. Observe state and use revert statements to undo rollback when validconditions are not met. beneficiary Address performing the token purchase weiAmount Value in wei involved in the purchase / | function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
// solhint-disable-previous-line no-empty-blocks
}
| function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
// solhint-disable-previous-line no-empty-blocks
}
| 7,101 |
13 | // Functions with this modifier can only be executed by the owner | modifier onlyOwner() {
if (msg.sender != owner) {
revert();
}
_;
}
| modifier onlyOwner() {
if (msg.sender != owner) {
revert();
}
_;
}
| 62,610 |
10 | // Data required to assign/revoke a permission to/from a role. | struct RolePermissionData {
uint8 role; // ID of the role to set (uint8 ensures onchain enumerability when burning policies).
PermissionData permissionData; // The `(target, selector, strategy)` tuple that will be keccak256 hashed to
// generate the permission ID to assign or unassign to the role
bool hasPermission; // Whether to assign the permission or remove the permission.
}
| struct RolePermissionData {
uint8 role; // ID of the role to set (uint8 ensures onchain enumerability when burning policies).
PermissionData permissionData; // The `(target, selector, strategy)` tuple that will be keccak256 hashed to
// generate the permission ID to assign or unassign to the role
bool hasPermission; // Whether to assign the permission or remove the permission.
}
| 33,929 |
21 | // Getting underlying token of aave aToken | mapping (address => address) public underlyingToken;
| mapping (address => address) public underlyingToken;
| 1,319 |
7 | // Pays out the contract balance to the winner of the current round. / | function payoutAndRestart() public {
// Get the contract balance
uint256 pot = address(this).balance;
// Revert if the contract balance is less than 1000
require(pot >= 1000, "pot has to be >= 1000");
// Revert if the current block number is not greater than the ending block number
require(block.number > endingBlock(), "round not over yet");
// Revert if the round has already been paid out
require(!paid(), "already paid out");
// Pay out the contract balance to the winner of the current round
_payout(pot);
_start();
}
| function payoutAndRestart() public {
// Get the contract balance
uint256 pot = address(this).balance;
// Revert if the contract balance is less than 1000
require(pot >= 1000, "pot has to be >= 1000");
// Revert if the current block number is not greater than the ending block number
require(block.number > endingBlock(), "round not over yet");
// Revert if the round has already been paid out
require(!paid(), "already paid out");
// Pay out the contract balance to the winner of the current round
_payout(pot);
_start();
}
| 19,847 |
413 | // Length of existing buffer data | let buflen := mload(bufptr)
| let buflen := mload(bufptr)
| 16,175 |
75 | // ============================================================================== __|_ ___|_ _._\ | | |_|(_ | _\.============================================================================== | library Mildatasets {
// between `DRAWN' and `ASSIGNED', someone need to claim winners.
enum RoundState {
UNKNOWN, // aim to differ from normal states
STARTED, // start current round
STOPPED, // stop current round
DRAWN, // draw code
ASSIGNED // assign to foundation, winners, and migrate the rest to the next round
}
// MilFold Transaction Action.
enum TxAction {
UNKNOWN, // default
BUY, // buy or reload tickets and so on
DRAW, // draw code of game
ASSIGN, // assign to winners
ENDROUND // end game and start new round
}
// RewardType
enum RewardType {
UNKNOWN, // default
DRAW, // draw code
ASSIGN, // assign winner
END, // end game
CLIAM // winner cliam
}
struct Player {
uint256 playerID; // Player id(use to affiliate other player)
uint256 eth; // player eth balance
uint256 mask; // player mask
uint256 genTotal; // general total vault
uint256 affTotal; // affiliate total vault
uint256 laff; // last affiliate id used
}
struct Round {
uint256 roundDeadline; // deadline to end round
uint256 claimDeadline; // deadline to claim winners
uint256 pot; // pot
uint256 blockNumber; // draw block number(last one)
RoundState state; // round state
uint256 drawCode; // draw code
uint256 totalNum; // total number
mapping (address => uint256) winnerNum; // winners' number
address[] winners; // winners
}
}
| library Mildatasets {
// between `DRAWN' and `ASSIGNED', someone need to claim winners.
enum RoundState {
UNKNOWN, // aim to differ from normal states
STARTED, // start current round
STOPPED, // stop current round
DRAWN, // draw code
ASSIGNED // assign to foundation, winners, and migrate the rest to the next round
}
// MilFold Transaction Action.
enum TxAction {
UNKNOWN, // default
BUY, // buy or reload tickets and so on
DRAW, // draw code of game
ASSIGN, // assign to winners
ENDROUND // end game and start new round
}
// RewardType
enum RewardType {
UNKNOWN, // default
DRAW, // draw code
ASSIGN, // assign winner
END, // end game
CLIAM // winner cliam
}
struct Player {
uint256 playerID; // Player id(use to affiliate other player)
uint256 eth; // player eth balance
uint256 mask; // player mask
uint256 genTotal; // general total vault
uint256 affTotal; // affiliate total vault
uint256 laff; // last affiliate id used
}
struct Round {
uint256 roundDeadline; // deadline to end round
uint256 claimDeadline; // deadline to claim winners
uint256 pot; // pot
uint256 blockNumber; // draw block number(last one)
RoundState state; // round state
uint256 drawCode; // draw code
uint256 totalNum; // total number
mapping (address => uint256) winnerNum; // winners' number
address[] winners; // winners
}
}
| 16,845 |
79 | // set platform fees percent for borrowed entry | uint256 _feesPercent = 5;
lentERC721List[tokenAddress][tokenId].platformFeesPercent = _feesPercent;
| uint256 _feesPercent = 5;
lentERC721List[tokenAddress][tokenId].platformFeesPercent = _feesPercent;
| 7,551 |
39 | // check the signature | bytes32 hash = sha256(abi.encodePacked("Eidoo icoengine authorization", this, buyerAddress, buyerId, maxAmount));
address signer = ecrecover(hash, v, r, s);
if (!isKycSigner[signer]) {
revert();
} else {
| bytes32 hash = sha256(abi.encodePacked("Eidoo icoengine authorization", this, buyerAddress, buyerId, maxAmount));
address signer = ecrecover(hash, v, r, s);
if (!isKycSigner[signer]) {
revert();
} else {
| 9,603 |
10 | // Mints a new knockout liquidity position, or adds to a previous position, and updates the curve and debit flows accordingly.curve The current state of the liquidity curve. priceTick The 24-bit tick of the pool's current price loc The location of where to mint the knockout liquidity liquidity The total amount of XY=K liquidity to mint. poolHash The hash of the pool the curve applies to knockoutBits The bitwise knockout parameters currently set on the pool. return The incrmental base and quote debit flows from this action. / | internal returns (int128 baseFlow, int128 quoteFlow) {
addKnockoutLiq(poolHash, knockoutBits, priceTick, curve.concGrowth_, loc,
liquidity.liquidityToLots());
(uint128 base, uint128 quote) = liquidityReceivable
(curve, liquidity, loc.lowerTick_, loc.upperTick_);
(baseFlow, quoteFlow) = signMintFlow(base, quote);
}
| internal returns (int128 baseFlow, int128 quoteFlow) {
addKnockoutLiq(poolHash, knockoutBits, priceTick, curve.concGrowth_, loc,
liquidity.liquidityToLots());
(uint128 base, uint128 quote) = liquidityReceivable
(curve, liquidity, loc.lowerTick_, loc.upperTick_);
(baseFlow, quoteFlow) = signMintFlow(base, quote);
}
| 9,233 |
17 | // Проверка адресов | require(from != address(0), "Err. Sender's address can't be equal to 0");
require(to != address(0), "Err. Recipient's address can't be equal to 0");
| require(from != address(0), "Err. Sender's address can't be equal to 0");
require(to != address(0), "Err. Recipient's address can't be equal to 0");
| 18,764 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.