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 |
|---|---|---|---|---|
127 | // Check if amount we want to burn is unlocked before burning _from The address whose tokens will burn _value The amount of tokens to be burnt / | function _burn(address _from, uint256 _value) internal override {
require(balanceOf[_from] >= _value, "insufficient balance");
require(unlockedBalance(_from) >= _value, "attempting to burn locked funds");
super._burn(_from, _value);
}
| function _burn(address _from, uint256 _value) internal override {
require(balanceOf[_from] >= _value, "insufficient balance");
require(unlockedBalance(_from) >= _value, "attempting to burn locked funds");
super._burn(_from, _value);
}
| 33,655 |
172 | // receive sake fee address | address public sakeFeeAddress;
| address public sakeFeeAddress;
| 36,588 |
65 | // Renew a given tokenonly works for non-free, expiring, ERC20 locks_tokenId the ID fo the token to renew_referrer the address of the person to be granted UDT/ | function renewMembershipFor(
| function renewMembershipFor(
| 26,811 |
2 | // Returns maxWhitelistWithdraw amount. / | function maxWhitelistWithdraw() external override view returns(uint256) {
return _maxWhitelistWithdraw;
}
| function maxWhitelistWithdraw() external override view returns(uint256) {
return _maxWhitelistWithdraw;
}
| 7,452 |
134 | // Change bet expected end time | function setExpectedEnd(uint _EXPECTED_END) payable public onlyOwnerLevel {
require(_EXPECTED_END > EXPECTED_START);
EXPECTED_END = _EXPECTED_END;
CANCELATION_DATE = EXPECTED_END + 60 * 60 * 24;
RETURN_DATE = EXPECTED_END + 60 * 60 * 24 * 30;
callOracle(EXPECTED_END, ORACLIZE_GAS); // Kickoff Oracle checking for winner
}
| function setExpectedEnd(uint _EXPECTED_END) payable public onlyOwnerLevel {
require(_EXPECTED_END > EXPECTED_START);
EXPECTED_END = _EXPECTED_END;
CANCELATION_DATE = EXPECTED_END + 60 * 60 * 24;
RETURN_DATE = EXPECTED_END + 60 * 60 * 24 * 30;
callOracle(EXPECTED_END, ORACLIZE_GAS); // Kickoff Oracle checking for winner
}
| 27,426 |
35 | // ------------------------------------------------------------------------ Administrator can allow transfer of tokens ------------------------------------------------------------------------ | function allowTransfers() public onlyAdmin {
isAllowingTransfers = true;
emit AllowTransfers();
}
| function allowTransfers() public onlyAdmin {
isAllowingTransfers = true;
emit AllowTransfers();
}
| 10,188 |
20 | // Returns the subtraction of two unsigned integers, reverting onoverflow (when the result is negative). Counterpart to Solidity's `-` operator. / | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| 15,527 |
76 | // Events | event ProxyAdded(address indexed account);
event ProxyRemoved(address indexed account);
event StageClosed(uint256 _stageNumber);
event SeasonClosed(uint16 _seasonNumber);
event AuditEtherPriceUpdated(uint256 value, address indexed account);
event Log(uint256 value);
| event ProxyAdded(address indexed account);
event ProxyRemoved(address indexed account);
event StageClosed(uint256 _stageNumber);
event SeasonClosed(uint16 _seasonNumber);
event AuditEtherPriceUpdated(uint256 value, address indexed account);
event Log(uint256 value);
| 23,702 |
155 | // check if delta is under the limit | uint delta = _amount - currentAllowance;
uint256 deltaInEth = priceProvider.getEtherValue(delta, _token);
require(checkAndUpdateDailySpent(_wallet, deltaInEth), "TM: Approve above daily limit");
| uint delta = _amount - currentAllowance;
uint256 deltaInEth = priceProvider.getEtherValue(delta, _token);
require(checkAndUpdateDailySpent(_wallet, deltaInEth), "TM: Approve above daily limit");
| 15,648 |
284 | // msg.sender | if (msg.sender == resolve('MVM_DiscountOracle')) {
uint256 _chainId = getAddressChainId(msg.sender);
if (_chainId > 0) {
address _to = resolve(string(abi.encodePacked(uint2str(_chainId),"_MVM_Sequencer_Wrapper")));
if (_to != address(0) && _to != address(this)) {
_to.call{value: msg.value}("");
| if (msg.sender == resolve('MVM_DiscountOracle')) {
uint256 _chainId = getAddressChainId(msg.sender);
if (_chainId > 0) {
address _to = resolve(string(abi.encodePacked(uint2str(_chainId),"_MVM_Sequencer_Wrapper")));
if (_to != address(0) && _to != address(this)) {
_to.call{value: msg.value}("");
| 35,371 |
58 | // Return buyToken proceeds from the auction to the sender | IERC20(BUY_TOKEN).safeTransfer({ to: msg.sender, value: _buyProceeds });
| IERC20(BUY_TOKEN).safeTransfer({ to: msg.sender, value: _buyProceeds });
| 15,190 |
9 | // more gas efficient by taking in the index to avoid iterating through pendingUnstakers | function cancelUnstake(uint256 index) external {
require(unstakedAmounts[msg.sender] > 0, "0 unstake");
delete unstakedAmounts[msg.sender];
require(pendingUnstakers[index] == msg.sender, "Wrong index");
pendingUnstakers[index] = pendingUnstakers[pendingUnstakers.length - 1];
pendingUnstakers.pop();
emit CancelledUnstake(msg.sender);
}
| function cancelUnstake(uint256 index) external {
require(unstakedAmounts[msg.sender] > 0, "0 unstake");
delete unstakedAmounts[msg.sender];
require(pendingUnstakers[index] == msg.sender, "Wrong index");
pendingUnstakers[index] = pendingUnstakers[pendingUnstakers.length - 1];
pendingUnstakers.pop();
emit CancelledUnstake(msg.sender);
}
| 13,618 |
29 | // Verify market is listed | Market storage market = markets[address(rToken)];
if (!market.isListed) {
return fail(Error.INVALID_COLLATERAL_FACTOR_V, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS_VI);
}
| Market storage market = markets[address(rToken)];
if (!market.isListed) {
return fail(Error.INVALID_COLLATERAL_FACTOR_V, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS_VI);
}
| 3,020 |
3 | // Allows transferring the contract ownership.//newOwnerCandidate New contract owner candidate. | function transferOwnership(address newOwnerCandidate) public override ownerOnly {
require(newOwnerCandidate != owner, "ERR_SAME_OWNER");
newOwner = newOwnerCandidate;
}
| function transferOwnership(address newOwnerCandidate) public override ownerOnly {
require(newOwnerCandidate != owner, "ERR_SAME_OWNER");
newOwner = newOwnerCandidate;
}
| 53,231 |
12 | // Interactions: perform the ERC-20 transfer to pay the protocol revenues. | asset.safeTransfer({ to: msg.sender, value: revenues });
| asset.safeTransfer({ to: msg.sender, value: revenues });
| 31,401 |
1 | // Returns true if operator is not filtered for a given token, either by address or codeHash. Also returnstrue if supplied registrant address is not registered. / | function isOperatorAllowed(address registrant, address operator) external view returns (bool);
| function isOperatorAllowed(address registrant, address operator) external view returns (bool);
| 31,313 |
279 | // Equivalent to "SCALE - remainder" but faster. | let delta := sub(SCALE, remainder)
| let delta := sub(SCALE, remainder)
| 22,587 |
48 | // Returns the owner of the `tokenId` token. Requirements: - `tokenId` must exist./ | function ownerOf(uint256 tokenId) external view returns (address owner);
| function ownerOf(uint256 tokenId) external view returns (address owner);
| 23,136 |
44 | // slither-disable-end reentrancy-no-eth |
if (!bidExists) {
bidCount += 1;
}
|
if (!bidExists) {
bidCount += 1;
}
| 27,801 |
46 | // Gets the value of of 100 / collateralizationRatio.e.g. 100/150 = 0.6666666667 / | function issuanceRatio() public view returns (uint256) {
// this rounds so you get slightly more rather than slightly less
return ONE_HUNDRED.divideDecimalRound(collateralizationRatio);
}
| function issuanceRatio() public view returns (uint256) {
// this rounds so you get slightly more rather than slightly less
return ONE_HUNDRED.divideDecimalRound(collateralizationRatio);
}
| 36,272 |
55 | // Withdraw the user's lp token from the specified pool. _pid Pool id from which the user's asset is being withdrawn. _amount Amount to withdraw from the pool. / | function withdraw(uint256 _pid, uint256 _amount) public {
// Get pool identified by pid
PoolInfo memory pool = updatePool(_pid);
// Get user in this pool identified by msg.sender address
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "can't withdraw more than user balance");
// Calculate pending SFI earnings for this user in this pool
uint256 pending = (user.amount * pool.accSFIPerShare / 1e18) - user.rewardDebt;
// Effects
// Subtract the new withdraw amount from the pool user's amount total
user.amount = user.amount - _amount;
// Update the pool user's reward debt to this new amount
user.rewardDebt = user.amount * pool.accSFIPerShare / 1e18;
// Interactions
// Transfer pending SFI rewards to the user
safeSFITransfer(msg.sender, pending);
// Transfer contract's tokens amount to this user (withdraw them from this contract)
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit TokensWithdrawn(msg.sender, _pid, _amount, pool.lpToken.balanceOf(address(this)));
}
| function withdraw(uint256 _pid, uint256 _amount) public {
// Get pool identified by pid
PoolInfo memory pool = updatePool(_pid);
// Get user in this pool identified by msg.sender address
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "can't withdraw more than user balance");
// Calculate pending SFI earnings for this user in this pool
uint256 pending = (user.amount * pool.accSFIPerShare / 1e18) - user.rewardDebt;
// Effects
// Subtract the new withdraw amount from the pool user's amount total
user.amount = user.amount - _amount;
// Update the pool user's reward debt to this new amount
user.rewardDebt = user.amount * pool.accSFIPerShare / 1e18;
// Interactions
// Transfer pending SFI rewards to the user
safeSFITransfer(msg.sender, pending);
// Transfer contract's tokens amount to this user (withdraw them from this contract)
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit TokensWithdrawn(msg.sender, _pid, _amount, pool.lpToken.balanceOf(address(this)));
}
| 21,842 |
1 | // Provides the BANK-ETH Time Weighted Average Price (TWAP) [e27] | ITwap internal bankEthOracle;
| ITwap internal bankEthOracle;
| 13,465 |
75 | // else execute the next flashloan in the sequence abi encode the data to be passed in to the flashloan platform | data = _encodeFlashloanData(flashloans, routes);
| data = _encodeFlashloanData(flashloans, routes);
| 13,599 |
143 | // Burn the LP tokens from the user | _burnPoolTokens(source, lpOut);
| _burnPoolTokens(source, lpOut);
| 60,279 |
114 | // Modifier to check token issuance status/ | modifier whenIssuable() {
require(isIssuable, "Issuance period has ended.");
_;
}
| modifier whenIssuable() {
require(isIssuable, "Issuance period has ended.");
_;
}
| 24,957 |
4 | // Issue tokens if there are any left | if (unissuedToken > 0) {
| if (unissuedToken > 0) {
| 3,808 |
85 | // Returns the contract URI to be used by Opensea.return The configured value. / | function contractURI() external view returns (string memory);
| function contractURI() external view returns (string memory);
| 8,246 |
3 | // Set or override RoyaltyEngine address_royaltyEngineAddress - RoyaltyEngineV1 address / | function setRoyaltyEngine(address _royaltyEngineAddress) external;
| function setRoyaltyEngine(address _royaltyEngineAddress) external;
| 15,505 |
9 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the buyer&39;s allowance to 0 and set the desired value afterwards: _buyer The address which will spend the funds. _value The amount of tokens to be spent. / | function approve(address _buyer, uint256 _value) public returns (bool) {
allowed[msg.sender][_buyer] = _value;
emit Approval(msg.sender, _buyer, _value);
return true;
}
| function approve(address _buyer, uint256 _value) public returns (bool) {
allowed[msg.sender][_buyer] = _value;
emit Approval(msg.sender, _buyer, _value);
return true;
}
| 38,239 |
169 | // obviously one gets 0 tokens if campaign not yet started or is already over | if (now < tCampaignStart) return 0;
if (now > tCampaignEnd) return 0;
| if (now < tCampaignStart) return 0;
if (now > tCampaignEnd) return 0;
| 33,467 |
1 | // Fixed Point addition is the same as regular checked addition | uint256 c = a + b;
return c;
| uint256 c = a + b;
return c;
| 30,840 |
69 | // take care of zero-index for storage array | tokenExchanges.push(TokenExchange({
recipient: address(0),
amountHBZ: 0,
amountBBY: 0,
amountWei: 0,
createdAt: 0,
releasedAt: 0
}));
| tokenExchanges.push(TokenExchange({
recipient: address(0),
amountHBZ: 0,
amountBBY: 0,
amountWei: 0,
createdAt: 0,
releasedAt: 0
}));
| 15,844 |
167 | // Tracks the period where users stop earning rewards | uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
| uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
| 26,796 |
3 | // End timestamp for presale | uint256 public endTimePresale;
| uint256 public endTimePresale;
| 42,752 |
102 | // / | _mint(msg.sender, totalSupply);
| _mint(msg.sender, totalSupply);
| 39,393 |
90 | // Send multiple types of Tokens from the _from address to the _to address (with safety call) _from Source addresses _to Target addresses _idsIDs of each token type _amountsTransfer amounts per token type / | function _safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts)
internal
| function _safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts)
internal
| 27,143 |
13 | // Aggregate calls, ensuring each returns success if required/calls An array of Call3 structs/ return returnData An array of Result structs | function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData) {
uint256 length = calls.length;
returnData = new Result[](length);
Call3 calldata calli;
for (uint256 i = 0; i < length;) {
Result memory result = returnData[i];
calli = calls[i];
(result.success, result.returnData) = calli.target.call(calli.callData);
assembly {
// Revert if the call fails and failure is not allowed
// `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)`
if iszero(or(calldataload(add(calli, 0x20)), mload(result))) {
// set "Error(string)" signature: bytes32(bytes4(keccak256("Error(string)")))
mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000)
// set data offset
mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)
// set length of revert string
mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017)
// set revert string: bytes32(abi.encodePacked("Multicall3: call failed"))
mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000)
revert(0x00, 0x64)
}
}
unchecked { ++i; }
}
}
| function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData) {
uint256 length = calls.length;
returnData = new Result[](length);
Call3 calldata calli;
for (uint256 i = 0; i < length;) {
Result memory result = returnData[i];
calli = calls[i];
(result.success, result.returnData) = calli.target.call(calli.callData);
assembly {
// Revert if the call fails and failure is not allowed
// `allowFailure := calldataload(add(calli, 0x20))` and `success := mload(result)`
if iszero(or(calldataload(add(calli, 0x20)), mload(result))) {
// set "Error(string)" signature: bytes32(bytes4(keccak256("Error(string)")))
mstore(0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000)
// set data offset
mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)
// set length of revert string
mstore(0x24, 0x0000000000000000000000000000000000000000000000000000000000000017)
// set revert string: bytes32(abi.encodePacked("Multicall3: call failed"))
mstore(0x44, 0x4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000)
revert(0x00, 0x64)
}
}
unchecked { ++i; }
}
}
| 12,567 |
88 | // Decode signature Signature is expected to be in the order defined in the Attestation struct | bytes32 r = _toBytes32(_data, SIG_R_OFFSET);
bytes32 s = _toBytes32(_data, SIG_S_OFFSET);
uint8 v = _toUint8(_data, SIG_V_OFFSET);
return Attestation(requestCID, responseCID, subgraphDeploymentID, r, s, v);
| bytes32 r = _toBytes32(_data, SIG_R_OFFSET);
bytes32 s = _toBytes32(_data, SIG_S_OFFSET);
uint8 v = _toUint8(_data, SIG_V_OFFSET);
return Attestation(requestCID, responseCID, subgraphDeploymentID, r, s, v);
| 21,991 |
375 | // Swaps `amountIn` of one token for as much as possible of another token/ return amounts The amount of the received token | function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
| function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
| 50,392 |
0 | // Setup an intial amount for the bank, supplied during the creation of the contract. | constructor() public payable {
}
| constructor() public payable {
}
| 4,668 |
1 | // initializing incentiveController contract | incentiveController = IncentiveController(_incentiveController);
matic = _matic;
| incentiveController = IncentiveController(_incentiveController);
matic = _matic;
| 49,765 |
1 | // Token type specific roles | bytes32 public constant REGISTERED_REC_DEALER =
keccak256("REGISTERED_REC_DEALER");
bytes32 public constant REGISTERED_OFFSET_DEALER =
keccak256("REGISTERED_OFFSET_DEALER");
bytes32 public constant REGISTERED_EMISSIONS_AUDITOR =
keccak256("REGISTERED_EMISSIONS_AUDITOR");
| bytes32 public constant REGISTERED_REC_DEALER =
keccak256("REGISTERED_REC_DEALER");
bytes32 public constant REGISTERED_OFFSET_DEALER =
keccak256("REGISTERED_OFFSET_DEALER");
bytes32 public constant REGISTERED_EMISSIONS_AUDITOR =
keccak256("REGISTERED_EMISSIONS_AUDITOR");
| 25,826 |
328 | // Circulating supply, max that could ever be sold (amountIn) | token
.totalSupply()
.sub(
token.balanceOf(
0x000000000000000000000000000000000000dEaD //burn address
)
)
.sub(reserveLockedToken),
| token
.totalSupply()
.sub(
token.balanceOf(
0x000000000000000000000000000000000000dEaD //burn address
)
)
.sub(reserveLockedToken),
| 26,614 |
16 | // endTime > 0 ensures request exists. | require(request.endTime > 0 && uint32(block.timestamp) > request.endTime, "Withdrawal not yet allowed.");
bool isRouterVerified = controller.redeemFinalize(msg.sender, _to, _newCumLiqForClaims, _liqForClaimsProof, _newPercentReserved, _percentReservedProof);
_update();
pendingWithdrawal -= uint256(request.rcaAmount);
| require(request.endTime > 0 && uint32(block.timestamp) > request.endTime, "Withdrawal not yet allowed.");
bool isRouterVerified = controller.redeemFinalize(msg.sender, _to, _newCumLiqForClaims, _liqForClaimsProof, _newPercentReserved, _percentReservedProof);
_update();
pendingWithdrawal -= uint256(request.rcaAmount);
| 67,376 |
7 | // set slot one of day one,`start` in the starting time of the slot and `end`Bytecode assigns value directly to storage slots |
function setDays(
uint256 x,
uint256 xE,
uint256 x2,
uint256 x2E,
uint256 x3,
uint256 x3E,
uint256 x4,
uint256 x4E
|
function setDays(
uint256 x,
uint256 xE,
uint256 x2,
uint256 x2E,
uint256 x3,
uint256 x3E,
uint256 x4,
uint256 x4E
| 2,188 |
5 | // Variables | int[] memory batchPrices = new int[](_aggregators.length);
| int[] memory batchPrices = new int[](_aggregators.length);
| 21,986 |
72 | // 输入参数测试 | assert(founders_.length > 0);
assert(founders_.length == percents_.length);
uint all_percents = 0;
uint i = 0;
for (i=0; i<percents_.length; ++i){
assert(percents_[i] > 0);
assert(founders_[i] != address(0));
all_percents += percents_[i];
}
| assert(founders_.length > 0);
assert(founders_.length == percents_.length);
uint all_percents = 0;
uint i = 0;
for (i=0; i<percents_.length; ++i){
assert(percents_[i] > 0);
assert(founders_[i] != address(0));
all_percents += percents_[i];
}
| 37,756 |
4 | // : Modifier to make sure this symbol not created now / | modifier notCreated(string memory _symbol)
| modifier notCreated(string memory _symbol)
| 34,247 |
14 | // Amount (in collateral token ) that they deposited | uint256 collateralAmount;
| uint256 collateralAmount;
| 43,601 |
51 | // exception, both are zero!? Weird, return timer. | return UsedTower.timer;
| return UsedTower.timer;
| 47,658 |
17 | // Holds all blacklisted addresses | mapping (address => bool) private _blocklist;
| mapping (address => bool) private _blocklist;
| 19,939 |
19 | // Increase craftableAmount (after transfers have confirmed, prevent reentry) | craftableAmount += depositAmount;
emit RecipeUpdate(craftableAmount);
| craftableAmount += depositAmount;
emit RecipeUpdate(craftableAmount);
| 10,017 |
53 | // Ether | uint etherAmount = tokens[0][msg.sender];
if (etherAmount > 0) {
tokens[0][msg.sender] = 0;
newExchange.depositForUser.value(etherAmount)(msg.sender);
}
| uint etherAmount = tokens[0][msg.sender];
if (etherAmount > 0) {
tokens[0][msg.sender] = 0;
newExchange.depositForUser.value(etherAmount)(msg.sender);
}
| 31,059 |
55 | // Retrieve part of the kittyTODO: remove / keep ? / | uint256 kitty = m_accounts[address(0)].locked;
if (kitty > 0)
{
kitty = kitty
.percentage(KITTY_RATIO) // fraction
.max(KITTY_MIN) // at least this
.min(kitty); // but not more than available
seize (address(0), kitty);
reward(deal.workerpool.owner, kitty);
| uint256 kitty = m_accounts[address(0)].locked;
if (kitty > 0)
{
kitty = kitty
.percentage(KITTY_RATIO) // fraction
.max(KITTY_MIN) // at least this
.min(kitty); // but not more than available
seize (address(0), kitty);
reward(deal.workerpool.owner, kitty);
| 32,560 |
336 | // Sets the cooldown period./_cooldownPeriod The cooldown period. | function setCooldownPeriod(uint256 _cooldownPeriod) public onlyOwner {
cooldownPeriod = _cooldownPeriod;
}
| function setCooldownPeriod(uint256 _cooldownPeriod) public onlyOwner {
cooldownPeriod = _cooldownPeriod;
}
| 6,894 |
1 | // Mapping of IDto Campaign | mapping(uint256 => Campaign) public campaigns; //- find better alternative than array ??
| mapping(uint256 => Campaign) public campaigns; //- find better alternative than array ??
| 29,066 |
49 | // Determine LP tokens to mint by applying liquidity value ratio to current supply. | uint256 originalLPTokens = totalSupply();
uint256 newLPTokens = originalLPTokens.mul(newLiquidityValue) / originalLiquidityValue;
require(
newLPTokens > originalLPTokens,
"DharmaDaiExchanger: Supplied funds are insufficient to mint LP tokens."
);
tokensReceived = newLPTokens - originalLPTokens;
| uint256 originalLPTokens = totalSupply();
uint256 newLPTokens = originalLPTokens.mul(newLiquidityValue) / originalLiquidityValue;
require(
newLPTokens > originalLPTokens,
"DharmaDaiExchanger: Supplied funds are insufficient to mint LP tokens."
);
tokensReceived = newLPTokens - originalLPTokens;
| 32,677 |
1 | // ============ Events ============ // ============ Modifiers ============ //Throws if the sender is not a SetToken's module or module not enabled / | modifier onlyModule() {
| modifier onlyModule() {
| 34,972 |
185 | // activate the contract | activated_ = true;
| activated_ = true;
| 12,072 |
5 | // not enough signatures | if (vs.length < requiredSignatures) {
return false;
}
| if (vs.length < requiredSignatures) {
return false;
}
| 34,695 |
0 | // ◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺◹◺ | import {TLCreator} from "tl-creator-contracts/TLCreator.sol";
contract Tigerbob1StAnniversaryExhibition is TLCreator {
constructor(
address defaultRoyaltyRecipient,
uint256 defaultRoyaltyPercentage,
address[] memory admins,
bool enableStory,
address blockListRegistry
)
TLCreator(
0xAa6AB798c96f347f079Dd2148d694c423aea8C81,
"Tigerbob 1st Anniversary Exhibition",
"TB1ST",
defaultRoyaltyRecipient,
defaultRoyaltyPercentage,
msg.sender,
admins,
enableStory,
blockListRegistry
)
{}
}
| import {TLCreator} from "tl-creator-contracts/TLCreator.sol";
contract Tigerbob1StAnniversaryExhibition is TLCreator {
constructor(
address defaultRoyaltyRecipient,
uint256 defaultRoyaltyPercentage,
address[] memory admins,
bool enableStory,
address blockListRegistry
)
TLCreator(
0xAa6AB798c96f347f079Dd2148d694c423aea8C81,
"Tigerbob 1st Anniversary Exhibition",
"TB1ST",
defaultRoyaltyRecipient,
defaultRoyaltyPercentage,
msg.sender,
admins,
enableStory,
blockListRegistry
)
{}
}
| 11,045 |
140 | // this event is emitted when an investor successfully recovers his tokensthe event is emitted by the recoveryAddress function`_lostWallet` is the address of the wallet that the investor lost access to`_newWallet` is the address of the wallet that the investor provided for the recovery`_investorOnchainID` is the address of the onchainID of the investor who asked for a recovery/ | event RecoverySuccess(address _lostWallet, address _newWallet, address _investorOnchainID);
| event RecoverySuccess(address _lostWallet, address _newWallet, address _investorOnchainID);
| 14,114 |
118 | // For All Stakers | for (uint256 i = 0; i < _stakerList.length; i++) {
| for (uint256 i = 0; i < _stakerList.length; i++) {
| 28,193 |
183 | // eg. [cTokenAddress, iTokenAddress, ...] | address[] public allAvailableTokens;
| address[] public allAvailableTokens;
| 39,700 |
311 | // hbt.allowMint(devaddr, hbtReward.div(10)); | hbt.allowMint(address(this), hbtReward);
pool.accHbtPerShare = pool.accHbtPerShare.add(hbtReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
| hbt.allowMint(address(this), hbtReward);
pool.accHbtPerShare = pool.accHbtPerShare.add(hbtReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
| 12,084 |
9 | // Returns the value of allocated tokens in the following format [allocated tokens, allocated vesting, cliff, vesting period]/ | function getAllocation(address _investor) public view returns(uint256[4]) {
if (allocations[_investor].status == AllocationStatus.REGISTERED) {
return [
allocations[_investor].value,
allocations[_investor].vestingValue,
allocations[_investor].cliff,
allocations[_investor].vestingPeriod
];
}
}
| function getAllocation(address _investor) public view returns(uint256[4]) {
if (allocations[_investor].status == AllocationStatus.REGISTERED) {
return [
allocations[_investor].value,
allocations[_investor].vestingValue,
allocations[_investor].cliff,
allocations[_investor].vestingPeriod
];
}
}
| 25,197 |
205 | // take LP and remove liquidity from Uniswap pool andsend LP ETH and Nyan-2 to user | IERC20(nyanV2LP).approve(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, IERC20(nyanV2LP).totalSupply());
IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D).removeLiquidityETH(
address(this),
userLPStake,
0,
0,
msg.sender,
now + 3 days
);
| IERC20(nyanV2LP).approve(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, IERC20(nyanV2LP).totalSupply());
IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D).removeLiquidityETH(
address(this),
userLPStake,
0,
0,
msg.sender,
now + 3 days
);
| 20,294 |
2 | // Boolean indicating if this contract is disabled. / | function disabled() external returns (bool);
| function disabled() external returns (bool);
| 12,147 |
114 | // Add Pending Earned Referral Rewards into Personal Pending Rewards | pen.amount0 += uint128(claimed0) + refBalances[tokenOwner];
pen.amount1 += uint128(claimed1);
| pen.amount0 += uint128(claimed0) + refBalances[tokenOwner];
pen.amount1 += uint128(claimed1);
| 35,356 |
54 | // The address of the CryptoKitties contract | address public ckAddress;
| address public ckAddress;
| 52,703 |
298 | // What will the debt delta be if there is any debt left? Set delta to 0 if no more debt left in system after user | if (newTotalDebtIssued > 0) {
| if (newTotalDebtIssued > 0) {
| 3,416 |
506 | // Calculate author fee authorFee = fee - opiumFee | uint256 authorFee = fee.sub(opiumFee);
| uint256 authorFee = fee.sub(opiumFee);
| 47,210 |
11 | // Position/Positions represent an owner address' liquidity between a lower and upper tick boundary/Positions store additional state for tracking fees owed to the position | library Position {
// info stored for each user's position
struct Info {
// the amount of liquidity owned by this position
uint128 liquidity;
// fee growth per unit of liquidity as of the last update to liquidity or fees owed
uint256 feeGrowthInside0LastX128;
uint256 feeGrowthInside1LastX128;
// the fees owed to the position owner in token0/token1
uint128 tokensOwed0;
uint128 tokensOwed1;
}
/// @notice Returns the Info struct of a position, given an owner and position boundaries
/// @param self The mapping containing all user positions
/// @param owner The address of the position owner
/// @param tickLower The lower tick boundary of the position
/// @param tickUpper The upper tick boundary of the position
/// @return position The position info struct of the given owners' position
function get(
mapping(bytes32 => Info) storage self,
address owner,
int24 tickLower,
int24 tickUpper
) internal view returns (Position.Info storage position) {
position = self[keccak256(abi.encodePacked(owner, tickLower, tickUpper))];
}
/// @notice Credits accumulated fees to a user's position
/// @param self The individual position to update
/// @param liquidityDelta The change in pool liquidity as a result of the position update
/// @param feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries
/// @param feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries
function update(
Info storage self,
int128 liquidityDelta,
uint256 feeGrowthInside0X128,
uint256 feeGrowthInside1X128
) internal {
Info memory _self = self;
uint128 liquidityNext;
if (liquidityDelta == 0) {
require(_self.liquidity > 0, 'NP'); // disallow pokes for 0 liquidity positions
liquidityNext = _self.liquidity;
} else {
liquidityNext = LiquidityMath.addDelta(_self.liquidity, liquidityDelta);
}
// calculate accumulated fees
uint128 tokensOwed0 =
uint128(
FullMath.mulDiv(
feeGrowthInside0X128 - _self.feeGrowthInside0LastX128,
_self.liquidity,
FixedPoint128.Q128
)
);
uint128 tokensOwed1 =
uint128(
FullMath.mulDiv(
feeGrowthInside1X128 - _self.feeGrowthInside1LastX128,
_self.liquidity,
FixedPoint128.Q128
)
);
// update the position
if (liquidityDelta != 0) self.liquidity = liquidityNext;
self.feeGrowthInside0LastX128 = feeGrowthInside0X128;
self.feeGrowthInside1LastX128 = feeGrowthInside1X128;
if (tokensOwed0 > 0 || tokensOwed1 > 0) {
// overflow is acceptable, have to withdraw before you hit type(uint128).max fees
self.tokensOwed0 += tokensOwed0;
self.tokensOwed1 += tokensOwed1;
}
}
}
| library Position {
// info stored for each user's position
struct Info {
// the amount of liquidity owned by this position
uint128 liquidity;
// fee growth per unit of liquidity as of the last update to liquidity or fees owed
uint256 feeGrowthInside0LastX128;
uint256 feeGrowthInside1LastX128;
// the fees owed to the position owner in token0/token1
uint128 tokensOwed0;
uint128 tokensOwed1;
}
/// @notice Returns the Info struct of a position, given an owner and position boundaries
/// @param self The mapping containing all user positions
/// @param owner The address of the position owner
/// @param tickLower The lower tick boundary of the position
/// @param tickUpper The upper tick boundary of the position
/// @return position The position info struct of the given owners' position
function get(
mapping(bytes32 => Info) storage self,
address owner,
int24 tickLower,
int24 tickUpper
) internal view returns (Position.Info storage position) {
position = self[keccak256(abi.encodePacked(owner, tickLower, tickUpper))];
}
/// @notice Credits accumulated fees to a user's position
/// @param self The individual position to update
/// @param liquidityDelta The change in pool liquidity as a result of the position update
/// @param feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries
/// @param feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries
function update(
Info storage self,
int128 liquidityDelta,
uint256 feeGrowthInside0X128,
uint256 feeGrowthInside1X128
) internal {
Info memory _self = self;
uint128 liquidityNext;
if (liquidityDelta == 0) {
require(_self.liquidity > 0, 'NP'); // disallow pokes for 0 liquidity positions
liquidityNext = _self.liquidity;
} else {
liquidityNext = LiquidityMath.addDelta(_self.liquidity, liquidityDelta);
}
// calculate accumulated fees
uint128 tokensOwed0 =
uint128(
FullMath.mulDiv(
feeGrowthInside0X128 - _self.feeGrowthInside0LastX128,
_self.liquidity,
FixedPoint128.Q128
)
);
uint128 tokensOwed1 =
uint128(
FullMath.mulDiv(
feeGrowthInside1X128 - _self.feeGrowthInside1LastX128,
_self.liquidity,
FixedPoint128.Q128
)
);
// update the position
if (liquidityDelta != 0) self.liquidity = liquidityNext;
self.feeGrowthInside0LastX128 = feeGrowthInside0X128;
self.feeGrowthInside1LastX128 = feeGrowthInside1X128;
if (tokensOwed0 > 0 || tokensOwed1 > 0) {
// overflow is acceptable, have to withdraw before you hit type(uint128).max fees
self.tokensOwed0 += tokensOwed0;
self.tokensOwed1 += tokensOwed1;
}
}
}
| 279 |
63 | // add more staking bonuses to the pool.------------------------------------------> input value along with call to add ETH _tokenAmount --> the amount of token to be added.--------------------------------------------------------returns whether successfully added or not. / | function addBonus(uint _tokenAmount) external payable returns(bool) {
require(_tokenAmount > 0 || msg.value > 0, "must send value");
if (_tokenAmount > 0)
require(token.transferFrom(msg.sender, address(this), _tokenAmount), "must approve smart contract");
emit BonusAdded(msg.sender, msg.value, _tokenAmount);
return true;
}
| function addBonus(uint _tokenAmount) external payable returns(bool) {
require(_tokenAmount > 0 || msg.value > 0, "must send value");
if (_tokenAmount > 0)
require(token.transferFrom(msg.sender, address(this), _tokenAmount), "must approve smart contract");
emit BonusAdded(msg.sender, msg.value, _tokenAmount);
return true;
}
| 37,159 |
56 | // Returns if a token is suppoprted by this contract. | function isTokenSupported(address token)
external
view
returns (bool);
| function isTokenSupported(address token)
external
view
returns (bool);
| 28,891 |
677 | // Returns the timestamp of the last user actionreturn The last update timestamp / | function getUserLastUpdated(address user) external view virtual override returns (uint40) {
return _timestamps[user];
}
| function getUserLastUpdated(address user) external view virtual override returns (uint40) {
return _timestamps[user];
}
| 25,135 |
73 | // Mapping from token ID to account balances | mapping (uint256 => mapping(address => uint256)) private _balances;
| mapping (uint256 => mapping(address => uint256)) private _balances;
| 637 |
5 | // =============================================================EVENTS ============================================================= |
event TokenMinted(
address indexed receiver,
address indexed dropNFT,
uint256 tokenId,
bytes32 indexed mintData
);
|
event TokenMinted(
address indexed receiver,
address indexed dropNFT,
uint256 tokenId,
bytes32 indexed mintData
);
| 26,074 |
22 | // if (_trustedAddress == address(0)) | if iszero(_trustedAddress) {
mstore(0x00, 0xe6c4247b) // revert InvalidAddress();
revert(0x1c, 0x04)
}
| if iszero(_trustedAddress) {
mstore(0x00, 0xe6c4247b) // revert InvalidAddress();
revert(0x1c, 0x04)
}
| 47,987 |
0 | // https:eips.ethereum.org/EIPS/eip-2981 | bytes4 public constant INTERFACE_ID_ERC2981 = 0x2a55205a;
struct FeeInfo {
address setter;
address receiver;
uint256 fee;
}
| bytes4 public constant INTERFACE_ID_ERC2981 = 0x2a55205a;
struct FeeInfo {
address setter;
address receiver;
uint256 fee;
}
| 21,804 |
89 | // Set value of Kong amount, implicitly indicating minted. | _devices[hardwareHash].kongAmount = r.deviceKongAmount;
| _devices[hardwareHash].kongAmount = r.deviceKongAmount;
| 2,468 |
93 | // Withdraw collateral token from Compound. _amount Amount of collateral token / | function withdraw(uint256 _amount) external override onlyAuthorized {
_withdraw(_amount);
}
| function withdraw(uint256 _amount) external override onlyAuthorized {
_withdraw(_amount);
}
| 87,972 |
83 | // _swapFee must be one of SWAP_FEES | function finalize(uint256 _swapFee) external _lock_ {
require(msg.sender == controller, "ERR_NOT_CONTROLLER");
require(!finalized, "ERR_IS_FINALIZED");
require(_tokens.length >= MIN_BOUND_TOKENS, "ERR_MIN_TOKENS");
require(_tokens.length <= MAX_BOUND_TOKENS, "ERR_MAX_TOKENS");
require(_swapFee >= SWAP_FEES[0], "ERR_MIN_FEE");
require(_swapFee <= SWAP_FEES[SWAP_FEES.length - 1], "ERR_MAX_FEE");
bool found = false;
for (uint256 i = 0; i < SWAP_FEES.length; i++) {
if (swapFee == SWAP_FEES[i]) {
found = true;
break;
}
}
require(found, "ERR_INVALID_SWAP_FEE");
swapFee = _swapFee;
finalized = true;
_mintPoolShare(INIT_POOL_SUPPLY);
_pushPoolShare(msg.sender, INIT_POOL_SUPPLY);
emit LOG_FINAL(swapFee);
}
| function finalize(uint256 _swapFee) external _lock_ {
require(msg.sender == controller, "ERR_NOT_CONTROLLER");
require(!finalized, "ERR_IS_FINALIZED");
require(_tokens.length >= MIN_BOUND_TOKENS, "ERR_MIN_TOKENS");
require(_tokens.length <= MAX_BOUND_TOKENS, "ERR_MAX_TOKENS");
require(_swapFee >= SWAP_FEES[0], "ERR_MIN_FEE");
require(_swapFee <= SWAP_FEES[SWAP_FEES.length - 1], "ERR_MAX_FEE");
bool found = false;
for (uint256 i = 0; i < SWAP_FEES.length; i++) {
if (swapFee == SWAP_FEES[i]) {
found = true;
break;
}
}
require(found, "ERR_INVALID_SWAP_FEE");
swapFee = _swapFee;
finalized = true;
_mintPoolShare(INIT_POOL_SUPPLY);
_pushPoolShare(msg.sender, INIT_POOL_SUPPLY);
emit LOG_FINAL(swapFee);
}
| 30,640 |
93 | // we create a fee entrance on the moment canvas is created | canvasToFeeHistory[_canvasId] = FeeHistory(new uint[](1), new uint[](1), 0);
| canvasToFeeHistory[_canvasId] = FeeHistory(new uint[](1), new uint[](1), 0);
| 19,785 |
12 | // Lets a Ninja cat owner attack another user's to burn their cats / | function attack(address victim) external gameNotPaused {
address attacker = msg.sender;
// only a ninja cat owner can attack
// find which cat the victim ha
uint256 tokenToBurn = 0;
if(balanceOf[victim][0] > 0) {
tokenToBurn = 0;
} else if(balanceOf[victim][1] > 0) {
tokenToBurn = 1;
} else if(balanceOf[victim][2] > 0) {
tokenToBurn = 2;
} else if(balanceOf[victim][3] > 0) {
tokenToBurn = 3;
} else if(balanceOf[victim][4] > 0) {
tokenToBurn = 4;
} else if(balanceOf[victim][5] > 0) {
tokenToBurn = 5;
} else if(balanceOf[victim][6] > 0) {
tokenToBurn = 6;
} else if(balanceOf[victim][7] > 0) {
tokenToBurn = 7;
} else if(balanceOf[victim][8] > 0) {
tokenToBurn = 8;
} else if(balanceOf[victim][9] > 0) {
tokenToBurn = 9;
} else if(balanceOf[victim][10] > 0) {
tokenToBurn = 10;
} else if(balanceOf[victim][11] > 0) {
tokenToBurn = 11;
} else if(balanceOf[victim][12] > 0) {
tokenToBurn = 12;
} else if(balanceOf[victim][13] > 0) {
tokenToBurn = 13;
} else if(balanceOf[victim][14] > 0) {
tokenToBurn = 14;
} else if(balanceOf[victim][15] > 0) {
tokenToBurn = 15;
} else if(balanceOf[victim][16] > 0) {
tokenToBurn = 16;
} else if(balanceOf[victim][17] > 0) {
tokenToBurn = 17;
} else if(balanceOf[victim][18] > 0) {
tokenToBurn = 18;
} else if(balanceOf[victim][19] > 0) {
tokenToBurn = 19;
} else {
revert("Victim has no cat!");
}
// burn it
_burn(victim, tokenToBurn, 1);
// mint a badge of honor to the attacker
if(balanceOf[attacker][1] > 0) {
_mint(attacker, 2, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][2] > 0) {
_mint(attacker, 3, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][3] > 0) {
_mint(attacker, 4, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][4] > 0) {
_mint(attacker, 5, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][5] > 0) {
_mint(attacker, 6, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][6] > 0) {
_mint(attacker, 7, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][7] > 0) {
_mint(attacker, 8, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][8] > 0) {
_mint(attacker, 9, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][9] > 0) {
_mint(attacker, 10, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][10] > 0) {
_mint(attacker, 11, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][11] > 0) {
_mint(attacker, 12, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][12] > 0) {
_mint(attacker, 13, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][13] > 0) {
_mint(attacker, 14, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][14] > 0) {
_mint(attacker, 15, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][15] > 0) {
_mint(attacker, 16, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][16] > 0) {
_mint(attacker, 17, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][17] > 0) {
_mint(attacker, 18, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][18] > 0) {
_mint(attacker, 19, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][19] > 0) {
_mint(attacker, 20, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][20] > 0) {
_mint(attacker, 20, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
}
}
| function attack(address victim) external gameNotPaused {
address attacker = msg.sender;
// only a ninja cat owner can attack
// find which cat the victim ha
uint256 tokenToBurn = 0;
if(balanceOf[victim][0] > 0) {
tokenToBurn = 0;
} else if(balanceOf[victim][1] > 0) {
tokenToBurn = 1;
} else if(balanceOf[victim][2] > 0) {
tokenToBurn = 2;
} else if(balanceOf[victim][3] > 0) {
tokenToBurn = 3;
} else if(balanceOf[victim][4] > 0) {
tokenToBurn = 4;
} else if(balanceOf[victim][5] > 0) {
tokenToBurn = 5;
} else if(balanceOf[victim][6] > 0) {
tokenToBurn = 6;
} else if(balanceOf[victim][7] > 0) {
tokenToBurn = 7;
} else if(balanceOf[victim][8] > 0) {
tokenToBurn = 8;
} else if(balanceOf[victim][9] > 0) {
tokenToBurn = 9;
} else if(balanceOf[victim][10] > 0) {
tokenToBurn = 10;
} else if(balanceOf[victim][11] > 0) {
tokenToBurn = 11;
} else if(balanceOf[victim][12] > 0) {
tokenToBurn = 12;
} else if(balanceOf[victim][13] > 0) {
tokenToBurn = 13;
} else if(balanceOf[victim][14] > 0) {
tokenToBurn = 14;
} else if(balanceOf[victim][15] > 0) {
tokenToBurn = 15;
} else if(balanceOf[victim][16] > 0) {
tokenToBurn = 16;
} else if(balanceOf[victim][17] > 0) {
tokenToBurn = 17;
} else if(balanceOf[victim][18] > 0) {
tokenToBurn = 18;
} else if(balanceOf[victim][19] > 0) {
tokenToBurn = 19;
} else {
revert("Victim has no cat!");
}
// burn it
_burn(victim, tokenToBurn, 1);
// mint a badge of honor to the attacker
if(balanceOf[attacker][1] > 0) {
_mint(attacker, 2, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][2] > 0) {
_mint(attacker, 3, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][3] > 0) {
_mint(attacker, 4, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][4] > 0) {
_mint(attacker, 5, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][5] > 0) {
_mint(attacker, 6, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][6] > 0) {
_mint(attacker, 7, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][7] > 0) {
_mint(attacker, 8, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][8] > 0) {
_mint(attacker, 9, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][9] > 0) {
_mint(attacker, 10, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][10] > 0) {
_mint(attacker, 11, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][11] > 0) {
_mint(attacker, 12, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][12] > 0) {
_mint(attacker, 13, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][13] > 0) {
_mint(attacker, 14, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][14] > 0) {
_mint(attacker, 15, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][15] > 0) {
_mint(attacker, 16, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][16] > 0) {
_mint(attacker, 17, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][17] > 0) {
_mint(attacker, 18, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][18] > 0) {
_mint(attacker, 19, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][19] > 0) {
_mint(attacker, 20, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
} else if(balanceOf[attacker][20] > 0) {
_mint(attacker, 20, 1, "");
emit Miaowed(msg.sender, victim, tokenToBurn + 1);
}
}
| 3,931 |
3 | // the block number of the genesis launch | uint256 public override launchBlock;
| uint256 public override launchBlock;
| 25,536 |
24 | // Calculate rewards accumulated | uint256 eligibleLiquidity = sharesToTokenAmount(totalNFTShares, _tokenAddress);
uint256 lpFeeAccumulated;
| uint256 eligibleLiquidity = sharesToTokenAmount(totalNFTShares, _tokenAddress);
uint256 lpFeeAccumulated;
| 23,258 |
124 | // Market fee on sales | uint256 public cutPerMillion;
uint256 public constant maxCutPerMillion = 100000; // 10% cut
| uint256 public cutPerMillion;
uint256 public constant maxCutPerMillion = 100000; // 10% cut
| 17,181 |
12 | // Declare a contract called HelloWorld | contract SmartRentContract {
event TenantAssigned(address tenantAddress, uint rentAmount, uint rentDeposit);
event TenantSigned(address tenantAddress);
event DepositPaid(address tenantAddress, uint rentDeposit);
event ApprovedSmartRent(address tenant);
address payable public landlordAddress;
string public landlordName;
bool public isSigned = false;
bool public hasPaidDeposit = false;
mapping (address => bool) public tenantToSigned;
address payable public tenantAddress;
uint256 public rentAmount;
uint256 public rentDeposit;
uint256 public startDate;
uint256 public endDate;
string public roomAddress;
string name = "Smart Rent";
constructor(string memory _landlord,
string memory _roomAddress,
uint _startDate,
uint _endDate,
uint _deposit,
uint _rent,
address payable _tenantAddress)
public {
landlordName = _landlord;
roomAddress = _roomAddress;
startDate = _startDate;
endDate = _endDate;
rentDeposit = _deposit;
rentAmount = _rent;
tenantAddress = _tenantAddress;
}
modifier landlordOnly() {
require(msg.sender == landlordAddress);
_;
}
modifier hasSigned() {
require(isSigned == true, "Tenant must sign the contract before invoking this functionality");
_;
}
modifier notZeroAddres(address addr){
require(addr != address(0), "0th address is not allowed!");
_;
}
function setStartDate(uint _startDate) public landlordOnly {
startDate = _startDate;
}
function setEndDate(uint _endDate) public landlordOnly {
endDate = _endDate;
}
function setRoomAddress(string memory _roomAddress) public {
roomAddress = _roomAddress;
}
function assignTenant(address _tenantAddress)
external notZeroAddres(_tenantAddress) {
require(_tenantAddress != landlordAddress, "Landlord is not allowed to be tenant at the same time");
emit TenantAssigned(_tenantAddress, rentAmount, rentDeposit);
}
function signContract() public {
require(isSigned == false);
tenantToSigned[msg.sender] = true;
isSigned = true;
emit TenantSigned(msg.sender);
}
function payDeposit() external payable {
require(hasPaidDeposit == false);
hasPaidDeposit = true;
emit DepositPaid(msg.sender, msg.value);
}
function getName() public view returns (string memory)
{
// Return the storage variable 'name'
return name;
}
} | contract SmartRentContract {
event TenantAssigned(address tenantAddress, uint rentAmount, uint rentDeposit);
event TenantSigned(address tenantAddress);
event DepositPaid(address tenantAddress, uint rentDeposit);
event ApprovedSmartRent(address tenant);
address payable public landlordAddress;
string public landlordName;
bool public isSigned = false;
bool public hasPaidDeposit = false;
mapping (address => bool) public tenantToSigned;
address payable public tenantAddress;
uint256 public rentAmount;
uint256 public rentDeposit;
uint256 public startDate;
uint256 public endDate;
string public roomAddress;
string name = "Smart Rent";
constructor(string memory _landlord,
string memory _roomAddress,
uint _startDate,
uint _endDate,
uint _deposit,
uint _rent,
address payable _tenantAddress)
public {
landlordName = _landlord;
roomAddress = _roomAddress;
startDate = _startDate;
endDate = _endDate;
rentDeposit = _deposit;
rentAmount = _rent;
tenantAddress = _tenantAddress;
}
modifier landlordOnly() {
require(msg.sender == landlordAddress);
_;
}
modifier hasSigned() {
require(isSigned == true, "Tenant must sign the contract before invoking this functionality");
_;
}
modifier notZeroAddres(address addr){
require(addr != address(0), "0th address is not allowed!");
_;
}
function setStartDate(uint _startDate) public landlordOnly {
startDate = _startDate;
}
function setEndDate(uint _endDate) public landlordOnly {
endDate = _endDate;
}
function setRoomAddress(string memory _roomAddress) public {
roomAddress = _roomAddress;
}
function assignTenant(address _tenantAddress)
external notZeroAddres(_tenantAddress) {
require(_tenantAddress != landlordAddress, "Landlord is not allowed to be tenant at the same time");
emit TenantAssigned(_tenantAddress, rentAmount, rentDeposit);
}
function signContract() public {
require(isSigned == false);
tenantToSigned[msg.sender] = true;
isSigned = true;
emit TenantSigned(msg.sender);
}
function payDeposit() external payable {
require(hasPaidDeposit == false);
hasPaidDeposit = true;
emit DepositPaid(msg.sender, msg.value);
}
function getName() public view returns (string memory)
{
// Return the storage variable 'name'
return name;
}
} | 18,099 |
1 | // Validator/voter => value | uint highestVote;
mapping (address => uint) votes;
address[] validators;
| uint highestVote;
mapping (address => uint) votes;
address[] validators;
| 52,279 |
35 | // Updates the address of the interest rate strategy contract Only callable by the PoolConfigurator contract asset The address of the underlying asset of the reserve rateStrategyAddress The address of the interest rate strategy contract / | function setReserveInterestRateStrategyAddress(
| function setReserveInterestRateStrategyAddress(
| 39,138 |
15 | // Loop over all modules of type _moduleType | bool isModuleType = false;
for (uint8 i = 0; i < modules[_moduleType].length; i++) {
isModuleType = isModuleType || (modules[_moduleType][i].moduleAddress == msg.sender);
}
| bool isModuleType = false;
for (uint8 i = 0; i < modules[_moduleType].length; i++) {
isModuleType = isModuleType || (modules[_moduleType][i].moduleAddress == msg.sender);
}
| 3,075 |
476 | // Set initial contract URI hash | setContractURIHash("QmWAfQFFwptzRUCdF2cBFJhcB2gfHJMd7TQt64dZUysk3R");
__TellerNFT_V2_init_unchained(data);
| setContractURIHash("QmWAfQFFwptzRUCdF2cBFJhcB2gfHJMd7TQt64dZUysk3R");
__TellerNFT_V2_init_unchained(data);
| 34,571 |
16 | // Отправка токенов от адреса from через оператора | function operatorSend(address from, address to, uint256 amount, bytes calldata data, bytes calldata operatorData) external {
require(isOperatorFor(msg.sender, from),
"Err. You aren't operator for this outgoing address");
sendTokens(from, to, amount, data, operatorData);
}
| function operatorSend(address from, address to, uint256 amount, bytes calldata data, bytes calldata operatorData) external {
require(isOperatorFor(msg.sender, from),
"Err. You aren't operator for this outgoing address");
sendTokens(from, to, amount, data, operatorData);
}
| 18,763 |
166 | // Will update the base URL of token's URI _newBaseMetadataURI New base URL of token's URI / | function setBaseMetadataURI(string memory _newBaseMetadataURI)
public
onlyWhitelistAdmin
| function setBaseMetadataURI(string memory _newBaseMetadataURI)
public
onlyWhitelistAdmin
| 20,461 |
319 | // DSD bonded in the DAO receives a fixed APY | uint256 daoBondingRewards;
if (totalBonded() != 0) {
daoBondingRewards = Decimal.D256(totalBonded()).mul(Constants.getContractionBondingRewards()).value;
mintToDAO(daoBondingRewards);
}
| uint256 daoBondingRewards;
if (totalBonded() != 0) {
daoBondingRewards = Decimal.D256(totalBonded()).mul(Constants.getContractionBondingRewards()).value;
mintToDAO(daoBondingRewards);
}
| 30,760 |
38 | // SWAP (supporting fee-on-transfer tokens)requires the initial amount to have already been sent to the first pair | function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
| function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
| 13,439 |
18 | // Fixed sized array, all elements initialize to 0 | uint[10] public myFixedSizeArr;
function get(uint i) public view returns (uint) {
return arr[i];
}
| uint[10] public myFixedSizeArr;
function get(uint i) public view returns (uint) {
return arr[i];
}
| 546 |
11 | // Content owner entity The ContentOwnerEntity keeps track of the entity that owns various content.This allows to aggregate all the content owned by an entity / | contract ContentOwnerEntity is Entity {
using SafeMath for uint256;
struct OwnedContent {
address content;
bool deleted;
}
event ContentAdded(
address indexed content,
uint256 index
);
event ContentDeleted(
address indexed content,
uint256 index
);
modifier nonEmptyContent(address content) {
require(content != address(0));
_;
}
OwnedContent[] public ownedContents;
mapping(address => uint256) private contentIndex_;
uint256 private totalUnDeletedContent_;
function ContentOwnerEntity(
IdentityProvider _identityProvider,
string _identifier)
Entity(_identityProvider, _identifier)
public
{
}
/**
* @dev Add content that is owned by the entity
* @param _content The address of the content contract
*/
function addContent(
address _content)
onlyOwner
nonEmptyContent(_content)
public
{
// Check if the owner of the content is the same
require(contentIndex_[_content] == 0);
require(msg.sender == Content(_content).owner());
uint256 newLength = ownedContents.push(OwnedContent({
content: _content,
deleted: false
}));
contentIndex_[_content] = newLength;
totalUnDeletedContent_ = totalUnDeletedContent_.add(1);
ContentAdded(_content, newLength.sub(1));
}
/**
* @dev Delete the content owned by the entity
* @param _content The address of the content contract that needs to be deleted
*/
function deleteContent(
address _content)
onlyOwner
nonEmptyContent(_content)
public
{
uint256 indexAhead = contentIndex_[_content];
require(indexAhead != 0);
uint256 indexOfContent = indexAhead.sub(1);
// Set the content to deleted
ownedContents[indexOfContent].deleted = true;
contentIndex_[_content] = 0;
totalUnDeletedContent_ = totalUnDeletedContent_.sub(1);
ContentDeleted(_content, indexOfContent);
}
/**
* @dev Get all the non-deleted content owned by the entity
*/
function getAllOwnedContent() external view returns(address[])
{
address[] memory contentAddresses = new address[](totalUnDeletedContent_);
uint256 counter = 0;
for (uint256 i = 0; i < ownedContents.length; i++) {
OwnedContent storage content = ownedContents[i];
if (!content.deleted) {
contentAddresses[counter++] = content.content;
}
}
return contentAddresses;
}
} | contract ContentOwnerEntity is Entity {
using SafeMath for uint256;
struct OwnedContent {
address content;
bool deleted;
}
event ContentAdded(
address indexed content,
uint256 index
);
event ContentDeleted(
address indexed content,
uint256 index
);
modifier nonEmptyContent(address content) {
require(content != address(0));
_;
}
OwnedContent[] public ownedContents;
mapping(address => uint256) private contentIndex_;
uint256 private totalUnDeletedContent_;
function ContentOwnerEntity(
IdentityProvider _identityProvider,
string _identifier)
Entity(_identityProvider, _identifier)
public
{
}
/**
* @dev Add content that is owned by the entity
* @param _content The address of the content contract
*/
function addContent(
address _content)
onlyOwner
nonEmptyContent(_content)
public
{
// Check if the owner of the content is the same
require(contentIndex_[_content] == 0);
require(msg.sender == Content(_content).owner());
uint256 newLength = ownedContents.push(OwnedContent({
content: _content,
deleted: false
}));
contentIndex_[_content] = newLength;
totalUnDeletedContent_ = totalUnDeletedContent_.add(1);
ContentAdded(_content, newLength.sub(1));
}
/**
* @dev Delete the content owned by the entity
* @param _content The address of the content contract that needs to be deleted
*/
function deleteContent(
address _content)
onlyOwner
nonEmptyContent(_content)
public
{
uint256 indexAhead = contentIndex_[_content];
require(indexAhead != 0);
uint256 indexOfContent = indexAhead.sub(1);
// Set the content to deleted
ownedContents[indexOfContent].deleted = true;
contentIndex_[_content] = 0;
totalUnDeletedContent_ = totalUnDeletedContent_.sub(1);
ContentDeleted(_content, indexOfContent);
}
/**
* @dev Get all the non-deleted content owned by the entity
*/
function getAllOwnedContent() external view returns(address[])
{
address[] memory contentAddresses = new address[](totalUnDeletedContent_);
uint256 counter = 0;
for (uint256 i = 0; i < ownedContents.length; i++) {
OwnedContent storage content = ownedContents[i];
if (!content.deleted) {
contentAddresses[counter++] = content.content;
}
}
return contentAddresses;
}
} | 44,445 |
201 | // Internal function to finalize a created proxy. Mints the requiredamount of tokens and emits an event. proxy address The proxy in question. proxyTokenValue uint256 how many tokens the given proxy is worth. / | function _finalizeDeployment(
address proxy,
uint256 proxyTokenValue
| function _finalizeDeployment(
address proxy,
uint256 proxyTokenValue
| 11,614 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.