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 | // WETH token. | address private constant WETH = 0xc778417E063141139Fce010982780140Aa0cD5Ab;
| address private constant WETH = 0xc778417E063141139Fce010982780140Aa0cD5Ab;
| 9,987 |
72 | // EIP712 scheme: https:github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md | bytes32 delegatedTransferHash = keccak256(abi.encodePacked(// solium-disable-line
EIP712_DELEGATED_TRANSFER_SCHEMA_HASH, bytes32(to), value, fee, seq, deadline
));
bytes32 hash = keccak256(abi.encodePacked(EIP191_HEADER, EIP712_DOMAIN_HASH, delegatedTransferHash));
address _from = ecrecover(hash, v, r, s);
require(_from != address(0), "error determining from address from signature");
require(to != address(0), "canno use address zero");
require(!frozen[to] && !frozen[_from] && !frozen[msg.sender], "address frozen");
require(value.add(fee) <= balances[_from], "insufficient fund");
| bytes32 delegatedTransferHash = keccak256(abi.encodePacked(// solium-disable-line
EIP712_DELEGATED_TRANSFER_SCHEMA_HASH, bytes32(to), value, fee, seq, deadline
));
bytes32 hash = keccak256(abi.encodePacked(EIP191_HEADER, EIP712_DOMAIN_HASH, delegatedTransferHash));
address _from = ecrecover(hash, v, r, s);
require(_from != address(0), "error determining from address from signature");
require(to != address(0), "canno use address zero");
require(!frozen[to] && !frozen[_from] && !frozen[msg.sender], "address frozen");
require(value.add(fee) <= balances[_from], "insufficient fund");
| 1,114 |
25 | // returns validator registration data./validator address address of the validator. | function getValidatorData(address validator)
external
view
returns (
string name,
bytes4 ipAddress,
string website,
bytes20 orbsAddress
);
| function getValidatorData(address validator)
external
view
returns (
string name,
bytes4 ipAddress,
string website,
bytes20 orbsAddress
);
| 32,173 |
117 | // Individual power of each equipment. DUPLICATE CODE with _getDungeonPower: Constant array variable is not yet implemented, so need to put it here in order to save gas. | uint16[32] memory EQUIPMENT_POWERS = [
1, 2, 4, 5, 16, 17, 32, 33, // [Holy] Normal Equipments
8, 16, 16, 32, 32, 48, 64, 96, // [Myth] Normal Equipments
4, 16, 32, 64, // [Holy] Rare Equipments
32, 48, 80, 128, // [Myth] Rare Equipments
32, 96, // [Holy] Epic Equipments
80, 192, // [Myth] Epic Equipments
| uint16[32] memory EQUIPMENT_POWERS = [
1, 2, 4, 5, 16, 17, 32, 33, // [Holy] Normal Equipments
8, 16, 16, 32, 32, 48, 64, 96, // [Myth] Normal Equipments
4, 16, 32, 64, // [Holy] Rare Equipments
32, 48, 80, 128, // [Myth] Rare Equipments
32, 96, // [Holy] Epic Equipments
80, 192, // [Myth] Epic Equipments
| 42,813 |
47 | // Get the delegation target contract | address _target = controller.lookup(controllerLookupName);
assembly {
| address _target = controller.lookup(controllerLookupName);
assembly {
| 32,017 |
13 | // uint256[] memory _luckAttrs = [0]; | TeaCake memory _teaCake = TeaCake({
name: _name,
placeOfOrigin: _placeOfOrigin,
kind: _kind,
varieties: _varieties,
teaTime: _teaTime,
teaTreeTime: _teaTreeTime,
image: _image,
basePrice: _basePrice,
luckAttrs:new uint256[](0),
| TeaCake memory _teaCake = TeaCake({
name: _name,
placeOfOrigin: _placeOfOrigin,
kind: _kind,
varieties: _varieties,
teaTime: _teaTime,
teaTreeTime: _teaTreeTime,
image: _image,
basePrice: _basePrice,
luckAttrs:new uint256[](0),
| 28,098 |
10 | // functionality to replace an old signer with a new signer_oldSigner signer addresss of the old signer_newSigner signer addresss of the new signerexpireTime the number of seconds since 1970 for which this transaction is validsequenceId the unique sequence id obtainable from getNextSequenceIdsignature see Data Formats/ | function transferSignership(
address _oldSigner,
address _newSigner,
uint256 _expireTime,
uint256 _sequenceId,
bytes _signature
| function transferSignership(
address _oldSigner,
address _newSigner,
uint256 _expireTime,
uint256 _sequenceId,
bytes _signature
| 10,736 |
28 | // An event to make the transfer easy to find on the blockchain | Transfer(_from, _to, _value);
return true;
| Transfer(_from, _to, _value);
return true;
| 8,425 |
240 | // globalConstraintsCount return the global constraint pre and post countreturn uint globalConstraintsPre count.return uint globalConstraintsPost count. / | function globalConstraintsCount(address _avatar) external view returns(uint,uint);
| function globalConstraintsCount(address _avatar) external view returns(uint,uint);
| 20,628 |
8 | // Authorizes the proxy to spend a new request currency (ERC20)._erc20Address Address of an ERC20 used as a request currency/ | function approvePaymentProxyToSpend(address _erc20Address) public {
IERC20 erc20 = IERC20(_erc20Address);
uint256 max = 2**256 - 1;
erc20.safeApprove(address(paymentProxy), max);
}
| function approvePaymentProxyToSpend(address _erc20Address) public {
IERC20 erc20 = IERC20(_erc20Address);
uint256 max = 2**256 - 1;
erc20.safeApprove(address(paymentProxy), max);
}
| 31,738 |
132 | // transfer the LP tokens to the liquidator | LPtoken.transfer(_liquidator, collateralizedLP[_account]);
| LPtoken.transfer(_liquidator, collateralizedLP[_account]);
| 6,968 |
44 | // Underlying asset for this CToken / | address public underlying;
| address public underlying;
| 13,550 |
123 | // Set the implementation of the TokenEscrowMarketplace contract by setting a new address Restricted to initializer _newTokenEscrowMarketplace Address of new SigningLogic implementation / | function setTokenEscrowMarketplace(TokenEscrowMarketplace _newTokenEscrowMarketplace) external onlyDuringInitialization {
address oldTokenEscrowMarketplace = tokenEscrowMarketplace;
tokenEscrowMarketplace = _newTokenEscrowMarketplace;
emit TokenEscrowMarketplaceChanged(oldTokenEscrowMarketplace, tokenEscrowMarketplace);
}
| function setTokenEscrowMarketplace(TokenEscrowMarketplace _newTokenEscrowMarketplace) external onlyDuringInitialization {
address oldTokenEscrowMarketplace = tokenEscrowMarketplace;
tokenEscrowMarketplace = _newTokenEscrowMarketplace;
emit TokenEscrowMarketplaceChanged(oldTokenEscrowMarketplace, tokenEscrowMarketplace);
}
| 1,010 |
43 | // This function gets the list of hashed ecosystem names. _start The array start index (inclusive). _end The array end index (exclusive).return An array of the hashed ecosystem names. / | function getEcosystems(uint256 _start, uint256 _end) external view override returns (bytes32[] memory) {
require(
_start < ecosystems.length && _end <= ecosystems.length && _end > _start,
"CollectionFactory: Array indices out of bounds"
);
bytes32[] memory _ecosystems = new bytes32[](_end - _start);
for (uint256 i = _start; i < _end; i++) {
_ecosystems[i] = ecosystems[i];
}
return _ecosystems;
}
| function getEcosystems(uint256 _start, uint256 _end) external view override returns (bytes32[] memory) {
require(
_start < ecosystems.length && _end <= ecosystems.length && _end > _start,
"CollectionFactory: Array indices out of bounds"
);
bytes32[] memory _ecosystems = new bytes32[](_end - _start);
for (uint256 i = _start; i < _end; i++) {
_ecosystems[i] = ecosystems[i];
}
return _ecosystems;
}
| 30,291 |
26 | // Allows an owner to execute a confirmed withdrawal _withdrawalId withdrawal ID / | function executeWithdrawal(uint _withdrawalId)
public
ownerExists(msg.sender)
confirmedWithdrawal(_withdrawalId, msg.sender)
notExecutedWithdrawal(_withdrawalId)
| function executeWithdrawal(uint _withdrawalId)
public
ownerExists(msg.sender)
confirmedWithdrawal(_withdrawalId, msg.sender)
notExecutedWithdrawal(_withdrawalId)
| 52,584 |
18 | // Returns the token addresses of the reserve asset The address of the underlying asset of the reservereturn aTokenAddress The AToken address of the reservereturn stableDebtTokenAddress The StableDebtToken address of the reservereturn variableDebtTokenAddress The VariableDebtToken address of the reserve / | function getReserveTokensAddresses(
| function getReserveTokensAddresses(
| 4,947 |
76 | // ------ 4: verify account and strategy inclusion | if (accountId > 0) {
_verifyProofInclusion(
_accountProof.stateRoot,
keccak256(_getAccountInfoBytes(_accountProof.value)),
_accountProof.index,
_accountProof.siblings
);
}
| if (accountId > 0) {
_verifyProofInclusion(
_accountProof.stateRoot,
keccak256(_getAccountInfoBytes(_accountProof.value)),
_accountProof.index,
_accountProof.siblings
);
}
| 30,443 |
40 | // Setter for DAO address/_dao DAO address | function setDao(address _dao) external onlyDao {
dao = _dao;
}
| function setDao(address _dao) external onlyDao {
dao = _dao;
}
| 18,877 |
78 | // This multiplication can't overflow, _secondsPassed will easily fit within 64-bits, and totalPriceChange will easily fit within 128-bits, their product will always fit within 256-bits. | int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration);
| int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration);
| 44,901 |
422 | // Cancels order's quote orderInfo Order info (only order id in lowest 64 bits is used) / | function cancelOrderRFQ(uint256 orderInfo) external {
_invalidateOrder(msg.sender, orderInfo, 0);
}
| function cancelOrderRFQ(uint256 orderInfo) external {
_invalidateOrder(msg.sender, orderInfo, 0);
}
| 12,103 |
4 | // add | if(oldFacet == 0) {
| if(oldFacet == 0) {
| 20,960 |
65 | // Pausing is a very serious situation - we revert to sound the alarms | require(!mintGuardianPaused[cToken], "mint is paused");
| require(!mintGuardianPaused[cToken], "mint is paused");
| 10,597 |
22 | // Calculates the how is gonna be a new cooldown timestamp depending on the sender/receiver situation - If the timestamp of the sender is "better" or the timestamp of the recipient is 0, we take the one of the recipient - Weighted average of from/to cooldown timestamps if:The sender doesn't have the cooldown activated (timestamp 0).The sender timestamp is expiredThe sender has a "worse" timestamp - If the receiver's cooldown timestamp expired (too old), the next is 0 fromCooldownTimestamp Cooldown timestamp of the sender amountToReceive Amount toAddress Address of the recipient toBalance Current balance of the receiverreturn The new cooldown timestamp | ) public view returns (uint256) {
uint256 toCooldownTimestamp = stakersCooldowns[toAddress];
if (toCooldownTimestamp == 0) {
return 0;
}
uint256 minimalValidCooldownTimestamp =
block.timestamp.sub(COOLDOWN_SECONDS).sub(UNSTAKE_WINDOW);
if (minimalValidCooldownTimestamp > toCooldownTimestamp) {
toCooldownTimestamp = 0;
} else {
uint256 fromCooldownTimestamp =
(minimalValidCooldownTimestamp > fromCooldownTimestamp)
? block.timestamp
: fromCooldownTimestamp;
if (fromCooldownTimestamp < toCooldownTimestamp) {
return toCooldownTimestamp;
} else {
toCooldownTimestamp = (
amountToReceive.mul(fromCooldownTimestamp).add(toBalance.mul(toCooldownTimestamp))
)
.div(amountToReceive.add(toBalance));
}
}
return toCooldownTimestamp;
}
| ) public view returns (uint256) {
uint256 toCooldownTimestamp = stakersCooldowns[toAddress];
if (toCooldownTimestamp == 0) {
return 0;
}
uint256 minimalValidCooldownTimestamp =
block.timestamp.sub(COOLDOWN_SECONDS).sub(UNSTAKE_WINDOW);
if (minimalValidCooldownTimestamp > toCooldownTimestamp) {
toCooldownTimestamp = 0;
} else {
uint256 fromCooldownTimestamp =
(minimalValidCooldownTimestamp > fromCooldownTimestamp)
? block.timestamp
: fromCooldownTimestamp;
if (fromCooldownTimestamp < toCooldownTimestamp) {
return toCooldownTimestamp;
} else {
toCooldownTimestamp = (
amountToReceive.mul(fromCooldownTimestamp).add(toBalance.mul(toCooldownTimestamp))
)
.div(amountToReceive.add(toBalance));
}
}
return toCooldownTimestamp;
}
| 31,368 |
17 | // Update Supply | totalSupply = totalSupply.add(1);
| totalSupply = totalSupply.add(1);
| 35,567 |
5 | // exposing transfer method to vault/ | function transferFrom(address _from, address _to, address _vault, uint256 _amount, bytes calldata _data) external;
| function transferFrom(address _from, address _to, address _vault, uint256 _amount, bytes calldata _data) external;
| 24,981 |
81 | // Mints new tokens, increasing totalSupply, initSupply, and a users balance.Limited to onlyMinter modifier/ | function mint(address to, uint256 amount)
external
onlyMinter
returns (bool)
| function mint(address to, uint256 amount)
external
onlyMinter
returns (bool)
| 34,500 |
63 | // when one is 0 stop. put a limit on this | if (pullbit(entropy, count % 256)) {
mybal -= min(mybal, minAURUnit);
} else {
| if (pullbit(entropy, count % 256)) {
mybal -= min(mybal, minAURUnit);
} else {
| 40,170 |
18 | // this contract only has six types of events: it can accept a confirmation, in which case we record owner and operation (hash) alongside it. | event Confirmation(address owner, bytes32 operation);
event Revoke(address owner, bytes32 operation);
| event Confirmation(address owner, bytes32 operation);
event Revoke(address owner, bytes32 operation);
| 9,253 |
12 | // This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. / | function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
| function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
| 980 |
330 | // Gets the details of last added MCR./ return mcrPercx100 Total Minimum Capital Requirement percentage of that month of year(multiplied by 100)./ return vFull Total Pool fund value in Ether used in the last full daily calculation. | function getLastMCR() external view returns (uint mcrPercx100, uint mcrEtherx1E18, uint vFull, uint64 date) {
uint index = allMCRData.length.sub(1);
return (
allMCRData[index].mcrPercx100,
allMCRData[index].mcrEther,
allMCRData[index].vFull,
allMCRData[index].date
);
}
| function getLastMCR() external view returns (uint mcrPercx100, uint mcrEtherx1E18, uint vFull, uint64 date) {
uint index = allMCRData.length.sub(1);
return (
allMCRData[index].mcrPercx100,
allMCRData[index].mcrEther,
allMCRData[index].vFull,
allMCRData[index].date
);
}
| 28,578 |
21 | // end call can be requested by caller if recipient did not published it | function requestEndCall() public {
// only caller can request end his call
require(activeCall[msg.sender] != 0x0);
// save current timestamp
endCallRequestDate[msg.sender] = block.timestamp;
}
| function requestEndCall() public {
// only caller can request end his call
require(activeCall[msg.sender] != 0x0);
// save current timestamp
endCallRequestDate[msg.sender] = block.timestamp;
}
| 20,312 |
3 | // The highest bidder is now the second highest bidder | secondHighestBid = highestBid;
secondHighestBidder = highestBidder;
highestBid = _newBid;
highestBidder = _newBidder;
latestBidTime = now;
| secondHighestBid = highestBid;
secondHighestBidder = highestBidder;
highestBid = _newBid;
highestBidder = _newBidder;
latestBidTime = now;
| 2,641 |
84 | // Update TWAR | _update(
(_baseCached + baseIn).u128(),
(_fyTokenCached + fyTokenIn + tokensMinted).u128(), // Account for the "virtual" fyToken from the new minted LP tokens
_baseCached,
_fyTokenCached
);
| _update(
(_baseCached + baseIn).u128(),
(_fyTokenCached + fyTokenIn + tokensMinted).u128(), // Account for the "virtual" fyToken from the new minted LP tokens
_baseCached,
_fyTokenCached
);
| 43,916 |
108 | // Bouns rate. | uint256 public bonusRateInPercent0 = 33;
uint256 public bonusRateInPercent1 = 20;
| uint256 public bonusRateInPercent0 = 33;
uint256 public bonusRateInPercent1 = 20;
| 27,622 |
41 | // Limit calls to trusted components, in case policies update local storage upon runs | require(
msg.sender == _comptrollerProxy ||
msg.sender == IComptroller(_comptrollerProxy).getIntegrationManager() ||
msg.sender == IComptroller(_comptrollerProxy).getExternalPositionManager(),
"validatePolicies: Caller not allowed"
);
for (uint256 i; i < policies.length; i++) {
require(
IPolicy(policies[i]).validateRule(_comptrollerProxy, _hook, _validationData),
| require(
msg.sender == _comptrollerProxy ||
msg.sender == IComptroller(_comptrollerProxy).getIntegrationManager() ||
msg.sender == IComptroller(_comptrollerProxy).getExternalPositionManager(),
"validatePolicies: Caller not allowed"
);
for (uint256 i; i < policies.length; i++) {
require(
IPolicy(policies[i]).validateRule(_comptrollerProxy, _hook, _validationData),
| 33,540 |
21 | // Next we encode the month string and add it | if (month == 1) {
stringPush(output, "J", "A", "N");
} else if (month == 2) {
| if (month == 1) {
stringPush(output, "J", "A", "N");
} else if (month == 2) {
| 39,040 |
8 | // smart contracts are not allowed to participate / | require(tx.origin == msg.sender, 'not allowed');
| require(tx.origin == msg.sender, 'not allowed');
| 27,177 |
2 | // Constant of allowed number of airline to be registered BY_MEDIATION | uint8 private constant MEDIATION_REGISTERATION_LIMET = 4;
| uint8 private constant MEDIATION_REGISTERATION_LIMET = 4;
| 37,924 |
75 | // dividend events | event DividendSuccess(uint time, address token, uint amount);
event DividendFailure(uint time, string msg);
| event DividendSuccess(uint time, address token, uint amount);
event DividendFailure(uint time, string msg);
| 17,803 |
135 | // Return the templateId of _index token | function tokenByIndex(
uint256 _index
)
public
view
returns(uint256)
| function tokenByIndex(
uint256 _index
)
public
view
returns(uint256)
| 27,406 |
93 | // NOTE: This implementation should be converted to slice operators if the compiler is updated to v0.6.0+ | uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow.
| uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow.
| 28,163 |
195 | // Zero-value | require(uints[0] == 0);
| require(uints[0] == 0);
| 23,206 |
207 | // Reserve NFT by contract owner | function reserveNFT(
uint reserveNum
| function reserveNFT(
uint reserveNum
| 35,859 |
3 | // emitted at each withdraw from address that calls the withdraw function, and of which the shares are withdrawn to address that receives the funds tokenReceived amount of token received by to shares shares corresponding to the token amount withdrawn / | event Withdraw(address indexed from, address indexed to, uint256 tokenReceived, uint256 shares);
| event Withdraw(address indexed from, address indexed to, uint256 tokenReceived, uint256 shares);
| 42,289 |
174 | // Same with this, these should be constant if you never plan on changing them. | uint256 public mintRatePublicWhitelist = 0.055 ether;
uint256 public mintRatePublicSale = 0.069 ether;
| uint256 public mintRatePublicWhitelist = 0.055 ether;
uint256 public mintRatePublicSale = 0.069 ether;
| 46,179 |
0 | // Repeated values for indexing. | string indexed assetSymbolIndexed_,
string indexed recipientAddressIndexed_
);
| string indexed assetSymbolIndexed_,
string indexed recipientAddressIndexed_
);
| 10,654 |
72 | // 判断用户是否可以添加持仓费 | uint256 holdFee = getHoldFeeByOrderID(orderID,currentPrice);
address holder = orders[orderID].holder;
if(userAccount[holder].availableAmount >= holdFee){
newHoldFee = holdFee;
succ = true;
}
| uint256 holdFee = getHoldFeeByOrderID(orderID,currentPrice);
address holder = orders[orderID].holder;
if(userAccount[holder].availableAmount >= holdFee){
newHoldFee = holdFee;
succ = true;
}
| 6,644 |
168 | // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and then delete the last slot (swap and pop). |
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
|
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
| 1,741 |
12 | // Create maker order. Earn 1% of match fee for doing so. | function makeOrder(
uint256 lockUpPeriod,
int64 ratio,
HDGXStructs.Leg[] memory legs
| function makeOrder(
uint256 lockUpPeriod,
int64 ratio,
HDGXStructs.Leg[] memory legs
| 7,888 |
68 | // Internal function which allows inheriting contract to set custom decimals/decimals_ the new decimal value | function _setupDecimals(uint8 decimals_) internal {
// Set the decimals
decimals = decimals_;
}
| function _setupDecimals(uint8 decimals_) internal {
// Set the decimals
decimals = decimals_;
}
| 54,455 |
484 | // update the amount owed on the loan | totalOwed = totalOwed.sub(toPay);
(uint256 principalAmount, uint256 interestAmount) = loans[loanID].payOff(toPay);
| totalOwed = totalOwed.sub(toPay);
(uint256 principalAmount, uint256 interestAmount) = loans[loanID].payOff(toPay);
| 12,228 |
49 | // Notifies the contract that the courtesy period has elapsed./ This is treated as an abort, rather than fraud. | function notifyCourtesyTimeout() public {
self.notifyCourtesyTimeout();
}
| function notifyCourtesyTimeout() public {
self.notifyCourtesyTimeout();
}
| 25,376 |
126 | // Creates a new order _nftAddress - Non fungible registry address _assetId - ID of the published NFT _priceInWei - Price in Wei for the supported coin _expiresAt - Duration of the order (in hours) / | function createOrder(
address _nftAddress,
uint256 _assetId,
uint256 _priceInWei,
uint256 _expiresAt
)
public whenNotPaused
| function createOrder(
address _nftAddress,
uint256 _assetId,
uint256 _priceInWei,
uint256 _expiresAt
)
public whenNotPaused
| 1,599 |
185 | // enable | _autoSwapAndLiquifyEnabled = true;
setTaxLiquify(taxLiquify_, taxLiquifyDecimals_);
emit EnabledAutoSwapAndLiquify();
| _autoSwapAndLiquifyEnabled = true;
setTaxLiquify(taxLiquify_, taxLiquifyDecimals_);
emit EnabledAutoSwapAndLiquify();
| 27,307 |
8 | // Pay with WEA | function ChooseAwea() public {
require((r==0) && (now < limit));
require(token.transferFrom(msg.sender, this, preciowea));
ParticipantesA.push(msg.sender);
}
| function ChooseAwea() public {
require((r==0) && (now < limit));
require(token.transferFrom(msg.sender, this, preciowea));
ParticipantesA.push(msg.sender);
}
| 22,024 |
77 | // reward 주소로 지정된 사용자만이 기능을 수행할 수 있도록해주는 modifier | modifier onlyRewardAdress() {
require(msg.sender == rewardAddress);
_;
}
| modifier onlyRewardAdress() {
require(msg.sender == rewardAddress);
_;
}
| 37,139 |
212 | // Gets the amount of time that must pass before executing a ReconfigurationRequest/ return reconfigurationTimelock_ The timelock value (in seconds) | function getReconfigurationTimelock() public view returns (uint256 reconfigurationTimelock_) {
return reconfigurationTimelock;
}
| function getReconfigurationTimelock() public view returns (uint256 reconfigurationTimelock_) {
return reconfigurationTimelock;
}
| 52,996 |
80 | // Skip forward or rewind time by the specified number of seconds | function skip(uint256 time) internal virtual {
vm.warp(block.timestamp + time);
}
| function skip(uint256 time) internal virtual {
vm.warp(block.timestamp + time);
}
| 30,807 |
75 | // Add _buyPrice to stockBuyOrderPrices[_node][] | it[0] = 99999;
for (it[1] = 0; it[1] < self.stockBuyOrderPrices[_node].length; it[1]++) {
if (self.stockBuyOrderPrices[_node][it[1]] == _buyPrice)
it[0] = it[1];
}
| it[0] = 99999;
for (it[1] = 0; it[1] < self.stockBuyOrderPrices[_node].length; it[1]++) {
if (self.stockBuyOrderPrices[_node][it[1]] == _buyPrice)
it[0] = it[1];
}
| 15,452 |
15 | // Division with safety check/ | function Div(uint a, uint b) internal returns (uint) {
//overflow check; b must not be 0
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
| function Div(uint a, uint b) internal returns (uint) {
//overflow check; b must not be 0
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
| 28,204 |
24 | // Moves `amount` of tokens from `from` to `to`. | * This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), 'ERC20: transfer from the zero address');
require(to != address(0), 'ERC20: transfer to the zero address');
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, 'ERC20: transfer amount exceeds balance');
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
| * This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), 'ERC20: transfer from the zero address');
require(to != address(0), 'ERC20: transfer to the zero address');
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, 'ERC20: transfer amount exceeds balance');
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
| 15,993 |
1 | // The function without name is the default function that is called whenever anyone sends funds to a contract / | function () payable {
if (now < presaleStartDate) throw; // A participant cannot send funds before the presale start date
if (crowdsaleClosed) { // выплачиваем токины
if (msg.value > 0) throw; // если после закрытия перечисляем эфиры
uint reward = balanceOf[msg.sender];
balanceOf[msg.sender] = 0;
if (reward > 0) {
if (!tokenReward.transfer(msg.sender, reward/price)) {
balanceOf[msg.sender] = reward;
}
}
} else { // Сохраняем данные о том кто сколько заплатил
uint amount = msg.value; // сколько переведено средств
balanceOf[msg.sender] += amount; // обновляем баланс
amountRaised += amount; // увеличиваем сумму собранных денег
}
}
| function () payable {
if (now < presaleStartDate) throw; // A participant cannot send funds before the presale start date
if (crowdsaleClosed) { // выплачиваем токины
if (msg.value > 0) throw; // если после закрытия перечисляем эфиры
uint reward = balanceOf[msg.sender];
balanceOf[msg.sender] = 0;
if (reward > 0) {
if (!tokenReward.transfer(msg.sender, reward/price)) {
balanceOf[msg.sender] = reward;
}
}
} else { // Сохраняем данные о том кто сколько заплатил
uint amount = msg.value; // сколько переведено средств
balanceOf[msg.sender] += amount; // обновляем баланс
amountRaised += amount; // увеличиваем сумму собранных денег
}
}
| 27,625 |
103 | // / Ownership adjustments/ |
function updateFee(uint8 _feeDecimals, uint32 _feePercentage)
public
onlyOwner
nonReentrant
|
function updateFee(uint8 _feeDecimals, uint32 _feePercentage)
public
onlyOwner
nonReentrant
| 35,533 |
60 | // remove a role from an address _operator address _role the name of the role / | function removeRole(address _operator, string _role) internal {
roles[_role].remove(_operator);
emit RoleRemoved(_operator, _role);
}
| function removeRole(address _operator, string _role) internal {
roles[_role].remove(_operator);
emit RoleRemoved(_operator, _role);
}
| 17,565 |
60 | // 绑定推荐关系 | function bindParent(address _parent) public virtual;
| function bindParent(address _parent) public virtual;
| 14,242 |
159 | // IMXYellowCakeParkMutants contract / | contract IMXYellowCakeParkMutants is Mintable, ERC721 {
string private _baseURIPath;
constructor(address _owner, address _imx) ERC721("IMXYellowCakeParkMutants", "YCPM") Mintable(_owner, _imx) {}
// Called at the time of withdrawing a minted token from IMX L2 to Mainnet L1.
function _mintFor(
address user,
uint256 id,
bytes memory
) internal override {
_safeMint(user, id);
}
// Set base URI for L1 standards.
function setBaseURI(string memory baseURI) public onlyOwner {
_baseURIPath = baseURI;
}
function _baseURI() internal view override returns (string memory) {
return _baseURIPath;
}
} | contract IMXYellowCakeParkMutants is Mintable, ERC721 {
string private _baseURIPath;
constructor(address _owner, address _imx) ERC721("IMXYellowCakeParkMutants", "YCPM") Mintable(_owner, _imx) {}
// Called at the time of withdrawing a minted token from IMX L2 to Mainnet L1.
function _mintFor(
address user,
uint256 id,
bytes memory
) internal override {
_safeMint(user, id);
}
// Set base URI for L1 standards.
function setBaseURI(string memory baseURI) public onlyOwner {
_baseURIPath = baseURI;
}
function _baseURI() internal view override returns (string memory) {
return _baseURIPath;
}
} | 25,447 |
69 | // StakeStart(auto-generated event)/ | event StakeStart(
| event StakeStart(
| 30,810 |
239 | // Save the penalty using the current state in case it needs to be used. | int potentialPenaltyAmount = s._computeDefaultPenalty();
if (latestTime >= s.endTime) {
s.state = TDS.State.Expired;
emit Expired(s.fixedParameters.symbol, s.endTime);
| int potentialPenaltyAmount = s._computeDefaultPenalty();
if (latestTime >= s.endTime) {
s.state = TDS.State.Expired;
emit Expired(s.fixedParameters.symbol, s.endTime);
| 46,261 |
9 | // Ownable The Ownable contract has an owner address, and provides basic authorization controlfunctions, this simplifies the implementation of "user permissions". / | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor () internal {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
| contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor () internal {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
| 2,735 |
15 | // update layer contract address | function setLayerContractAddress(address _newAddress) external onlyOwner
| function setLayerContractAddress(address _newAddress) external onlyOwner
| 37,706 |
7 | // Check if a referral is valid signature The signature to check (signed referral) referrer The address of the referrer referee The address of the referee expiryTime The expiry time of the referral commissionRate The commissionRate of the referralreturn True if the referral is valid / | function isReferralValid(
bytes memory signature,
address referrer,
address referee,
uint256 expiryTime,
uint256 commissionRate
| function isReferralValid(
bytes memory signature,
address referrer,
address referee,
uint256 expiryTime,
uint256 commissionRate
| 30,544 |
38 | // bytes4(keccak256('balanceOf(address,uint256)')) == 0x00fdd58ebytes4(keccak256('balanceOfBatch(address[],uint256[])')) == 0x4e1273f4bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5bytes4(keccak256('safeTransferFrom(address,address,uint256,uint256,bytes)')) == 0xf242432abytes4(keccak256('safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)')) == 0x2eb2c2d6 => 0x00fdd58e ^ 0x4e1273f4 ^ 0xa22cb465 ^ 0xe985e9c5 ^ 0xf242432a ^ 0x2eb2c2d6 == 0xd9b67a26 / | bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26;
| bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26;
| 3,386 |
4 | // Generate a unique hash that can be checked against | bytes32 myHash = sha256(block.number, msg.sender, _url);
| bytes32 myHash = sha256(block.number, msg.sender, _url);
| 43,221 |
26 | // RandomNumber represents one number. | struct RandomNumber {
address requestProxy;
uint256 renderedNumber;
uint256 originBlock;
uint256 max;
// blocks to wait,
// also maintains pending state
uint8 waitTime;
// was the number revealed within the 256 block window
uint256 expired;
}
| struct RandomNumber {
address requestProxy;
uint256 renderedNumber;
uint256 originBlock;
uint256 max;
// blocks to wait,
// also maintains pending state
uint8 waitTime;
// was the number revealed within the 256 block window
uint256 expired;
}
| 27,772 |
14 | // remove an account's access to this role / | function remove(Role storage role, address account) internal {
require(account != address(0));
require(has(role, account));
role.bearer[account] = false;
}
| function remove(Role storage role, address account) internal {
require(account != address(0));
require(has(role, account));
role.bearer[account] = false;
}
| 4,884 |
108 | // Internal Functions |
function _transferOwnership(
address __owner
)
|
function _transferOwnership(
address __owner
)
| 2,403 |
15 | // function Emergency situation that requires /contribution period to stop or not. | function setHalt(bool halt)
public
onlyOwner
| function setHalt(bool halt)
public
onlyOwner
| 16,650 |
37 | // Override safeBatchTransferFrom function to prevent transfers | function safeBatchTransferFrom(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
| function safeBatchTransferFrom(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
| 6,976 |
982 | // Get a MemoryPointer from AdvancedOrder.obj The AdvancedOrder object. return ptr The MemoryPointer. / | function toMemoryPointer(
AdvancedOrder memory obj
| function toMemoryPointer(
AdvancedOrder memory obj
| 23,854 |
22 | // info of each user (depositor) | struct UserInfo {
// NOTE: in the last changes we made 4 real days into one "contract" day!
uint256 currentlyAssignedRewardAmount; // reward (ERC20 Rentible token) amount, that was already clearly assigned to this UserInfo object (meaning subtracted from dailyErc20RewardAmounts and currentTotalErc20RewardAmount)
uint256 rewardCountedUptoDay; // the "contract" day (stakingDayNumber) up to which currentlyAssignedRewardAmount was already handled
uint256 lptAmount;
}
| struct UserInfo {
// NOTE: in the last changes we made 4 real days into one "contract" day!
uint256 currentlyAssignedRewardAmount; // reward (ERC20 Rentible token) amount, that was already clearly assigned to this UserInfo object (meaning subtracted from dailyErc20RewardAmounts and currentTotalErc20RewardAmount)
uint256 rewardCountedUptoDay; // the "contract" day (stakingDayNumber) up to which currentlyAssignedRewardAmount was already handled
uint256 lptAmount;
}
| 21,118 |
1 | // Whether liquidity launcher has been initialized or not. | bool private initialised;
| bool private initialised;
| 17,358 |
128 | // Base contract for CryptoStrikers. Defines what a card is and how to mint one./The CryptoStrikers Team | contract StrikersBase is ERC721Token("CryptoStrikers", "STRK") {
/// @dev Emit this event whenever we mint a new card (see _mintCard below)
event CardMinted(uint256 cardId);
/// @dev The struct representing the game's main object, a sports trading card.
struct Card {
// The timestamp at which this card was minted.
// With uint32 we are good until 2106, by which point we will have not minted
// a card in like, 88 years.
uint32 mintTime;
// The checklist item represented by this card. See StrikersChecklist.sol for more info.
uint8 checklistId;
// Cards for a given player have a serial number, which gets
// incremented in sequence. For example, if we mint 1000 of a card,
// the third one to be minted has serialNumber = 3 (out of 1000).
uint16 serialNumber;
}
/*** STORAGE ***/
/// @dev All the cards that have been minted, indexed by cardId.
Card[] public cards;
/// @dev Keeps track of how many cards we have minted for a given checklist item
/// to make sure we don't go over the limit for it.
/// NB: uint16 has a capacity of 65,535, but we are not minting more than
/// 4,352 of any given checklist item.
mapping (uint8 => uint16) public mintedCountForChecklistId;
/// @dev A reference to our checklist contract, which contains all the minting limits.
StrikersChecklist public strikersChecklist;
/*** FUNCTIONS ***/
/// @dev For a given owner, returns two arrays. The first contains the IDs of every card owned
/// by this address. The second returns the corresponding checklist ID for each of these cards.
/// There are a few places we need this info in the web app and short of being able to return an
/// actual array of Cards, this is the best solution we could come up with...
function cardAndChecklistIdsForOwner(address _owner) external view returns (uint256[], uint8[]) {
uint256[] memory cardIds = ownedTokens[_owner];
uint256 cardCount = cardIds.length;
uint8[] memory checklistIds = new uint8[](cardCount);
for (uint256 i = 0; i < cardCount; i++) {
uint256 cardId = cardIds[i];
checklistIds[i] = cards[cardId].checklistId;
}
return (cardIds, checklistIds);
}
/// @dev An internal method that creates a new card and stores it.
/// Emits both a CardMinted and a Transfer event.
/// @param _checklistId The ID of the checklistItem represented by the card (see Checklist.sol)
/// @param _owner The card's first owner!
function _mintCard(
uint8 _checklistId,
address _owner
)
internal
returns (uint256)
{
uint16 mintLimit = strikersChecklist.limitForChecklistId(_checklistId);
require(mintLimit == 0 || mintedCountForChecklistId[_checklistId] < mintLimit, "Can't mint any more of this card!");
uint16 serialNumber = ++mintedCountForChecklistId[_checklistId];
Card memory newCard = Card({
mintTime: uint32(now),
checklistId: _checklistId,
serialNumber: serialNumber
});
uint256 newCardId = cards.push(newCard) - 1;
emit CardMinted(newCardId);
_mint(_owner, newCardId);
return newCardId;
}
}
| contract StrikersBase is ERC721Token("CryptoStrikers", "STRK") {
/// @dev Emit this event whenever we mint a new card (see _mintCard below)
event CardMinted(uint256 cardId);
/// @dev The struct representing the game's main object, a sports trading card.
struct Card {
// The timestamp at which this card was minted.
// With uint32 we are good until 2106, by which point we will have not minted
// a card in like, 88 years.
uint32 mintTime;
// The checklist item represented by this card. See StrikersChecklist.sol for more info.
uint8 checklistId;
// Cards for a given player have a serial number, which gets
// incremented in sequence. For example, if we mint 1000 of a card,
// the third one to be minted has serialNumber = 3 (out of 1000).
uint16 serialNumber;
}
/*** STORAGE ***/
/// @dev All the cards that have been minted, indexed by cardId.
Card[] public cards;
/// @dev Keeps track of how many cards we have minted for a given checklist item
/// to make sure we don't go over the limit for it.
/// NB: uint16 has a capacity of 65,535, but we are not minting more than
/// 4,352 of any given checklist item.
mapping (uint8 => uint16) public mintedCountForChecklistId;
/// @dev A reference to our checklist contract, which contains all the minting limits.
StrikersChecklist public strikersChecklist;
/*** FUNCTIONS ***/
/// @dev For a given owner, returns two arrays. The first contains the IDs of every card owned
/// by this address. The second returns the corresponding checklist ID for each of these cards.
/// There are a few places we need this info in the web app and short of being able to return an
/// actual array of Cards, this is the best solution we could come up with...
function cardAndChecklistIdsForOwner(address _owner) external view returns (uint256[], uint8[]) {
uint256[] memory cardIds = ownedTokens[_owner];
uint256 cardCount = cardIds.length;
uint8[] memory checklistIds = new uint8[](cardCount);
for (uint256 i = 0; i < cardCount; i++) {
uint256 cardId = cardIds[i];
checklistIds[i] = cards[cardId].checklistId;
}
return (cardIds, checklistIds);
}
/// @dev An internal method that creates a new card and stores it.
/// Emits both a CardMinted and a Transfer event.
/// @param _checklistId The ID of the checklistItem represented by the card (see Checklist.sol)
/// @param _owner The card's first owner!
function _mintCard(
uint8 _checklistId,
address _owner
)
internal
returns (uint256)
{
uint16 mintLimit = strikersChecklist.limitForChecklistId(_checklistId);
require(mintLimit == 0 || mintedCountForChecklistId[_checklistId] < mintLimit, "Can't mint any more of this card!");
uint16 serialNumber = ++mintedCountForChecklistId[_checklistId];
Card memory newCard = Card({
mintTime: uint32(now),
checklistId: _checklistId,
serialNumber: serialNumber
});
uint256 newCardId = cards.push(newCard) - 1;
emit CardMinted(newCardId);
_mint(_owner, newCardId);
return newCardId;
}
}
| 70,672 |
49 | // Gets the tokens value in terms of USD. return The value of the `amount` of `token`, as a number with the same number of decimals as `amount` passed in to this function./ | function getTokenValue(address token, uint amount) external view returns (uint);
| function getTokenValue(address token, uint amount) external view returns (uint);
| 31,795 |
48 | // Counter for liquify trigger | uint8 private txCount = 0;
uint8 private swapTrigger = 3;
| uint8 private txCount = 0;
uint8 private swapTrigger = 3;
| 7,776 |
306 | // Internal so that feeds inheriting this one are not obligated to have an exposed update(...) method, but can still perform updates | function _updatePrices(address[] ofAssets, uint[] newPrices)
internal
pre_cond(ofAssets.length == newPrices.length)
| function _updatePrices(address[] ofAssets, uint[] newPrices)
internal
pre_cond(ofAssets.length == newPrices.length)
| 74,041 |
9 | // Add money to receiver's account | balanceOf[_to] += _amount;
emit Transfer(_from, _to, _amount);
| balanceOf[_to] += _amount;
emit Transfer(_from, _to, _amount);
| 28,895 |
75 | // Cover Request is fail when request not reaching target & already passing listing expired time | bool isCoverRequestFail = !listingData.isRequestReachTarget(
cover.requestId
) && (block.timestamp > coverRequest.expiredAt);
| bool isCoverRequestFail = !listingData.isRequestReachTarget(
cover.requestId
) && (block.timestamp > coverRequest.expiredAt);
| 10,577 |
113 | // (netCashToAccount <= assetAmountRemaining) | if (w.netCashIncrease.subNoNeg(w.incentivePaid) <= assetAmountRemaining) {
| if (w.netCashIncrease.subNoNeg(w.incentivePaid) <= assetAmountRemaining) {
| 61,853 |
96 | // Ensure we're actually changing the state before we do anything | if (_paused == paused) {
return;
}
| if (_paused == paused) {
return;
}
| 32,904 |
78 | // check for an expired crate | uint256 expires = crates[id].expires;
if (expires > 0 && expires > block.timestamp) {
| uint256 expires = crates[id].expires;
if (expires > 0 && expires > block.timestamp) {
| 3,082 |
23 | // do not invest if we have more debt than want | if (_debtOutstanding > _balanceOfWant) {
return;
}
| if (_debtOutstanding > _balanceOfWant) {
return;
}
| 9,179 |
53 | // Remember to enter percentage times 100. ex., if it is 2.50%, enter 250 Checks for reasonable interest rate parameters | require(MinRate < MaxRate, "Min Rate should be lesser than Max Rate");
require(
HealthyMinUR < HealthyMaxUR,
"HealthyMinUR should be lesser than HealthyMaxUR"
);
require(
HealthyMinRate < HealthyMaxRate,
"HealthyMinRate should be lesser than HealthyMaxRate"
);
owner = msg.sender;
| require(MinRate < MaxRate, "Min Rate should be lesser than Max Rate");
require(
HealthyMinUR < HealthyMaxUR,
"HealthyMinUR should be lesser than HealthyMaxUR"
);
require(
HealthyMinRate < HealthyMaxRate,
"HealthyMinRate should be lesser than HealthyMaxRate"
);
owner = msg.sender;
| 46,691 |
1 | // see{Davinci721, Davinci1155} function used for getting royalty info. for the given tokenId and calculates the royalty Fee for the given sale price. _tokenId unique id of NFT. price sale price of the NFT.returns royalty receivers,royalty value ,it can be calculated from the royaltyFee permiles.dev see {ERC2981} | function royaltyInfo(
uint256 _tokenId,
uint256 price)
external
view
returns(uint96[] memory, address[] memory, uint256);
| function royaltyInfo(
uint256 _tokenId,
uint256 price)
external
view
returns(uint96[] memory, address[] memory, uint256);
| 13,603 |
139 | // Returns the TTL of a node, and any records associated with it. / | function ttl(bytes32 node) constant returns (uint64) {
return records[node].ttl;
}
| function ttl(bytes32 node) constant returns (uint64) {
return records[node].ttl;
}
| 16,343 |
45 | // Give an account access to this role./ | function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
| function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
| 40,564 |
97 | // accepts msg.value for eth or _amount for ERC20 tokens | function userDeposit (uint256 _amount) external payable nonReentrant {
require(presaleStatus() == 1, 'NOT ACTIVE'); // ACTIVE
if (STATUS.WHITELIST_ONLY) {
require(WHITELIST.contains(msg.sender), 'NOT WHITELISTED');
}
// Presale Round 1 - require participant to hold a certain token and balance
if (block.number < PRESALE_INFO.START_BLOCK + STATUS.ROUND1_LENGTH) { // 276 blocks = 1 hour
require(PRESALE_SETTINGS.userHoldsSufficientRound1Token(msg.sender), 'INSUFFICENT ROUND 1 TOKEN BALANCE');
}
BuyerInfo storage buyer = BUYERS[msg.sender];
uint256 amount_in = PRESALE_INFO.PRESALE_IN_ETH ? msg.value : _amount;
uint256 allowance = PRESALE_INFO.MAX_SPEND_PER_BUYER.sub(buyer.baseDeposited);
uint256 remaining = PRESALE_INFO.HARDCAP - STATUS.TOTAL_BASE_COLLECTED;
allowance = allowance > remaining ? remaining : allowance;
if (amount_in > allowance) {
amount_in = allowance;
}
uint256 tokensSold = amount_in.mul(PRESALE_INFO.TOKEN_PRICE).div(10 ** uint256(PRESALE_INFO.B_TOKEN.decimals()));
require(tokensSold > 0, 'ZERO TOKENS');
if (buyer.baseDeposited == 0) {
STATUS.NUM_BUYERS++;
}
buyer.baseDeposited = buyer.baseDeposited.add(amount_in);
buyer.tokensOwed = buyer.tokensOwed.add(tokensSold);
STATUS.TOTAL_BASE_COLLECTED = STATUS.TOTAL_BASE_COLLECTED.add(amount_in);
STATUS.TOTAL_TOKENS_SOLD = STATUS.TOTAL_TOKENS_SOLD.add(tokensSold);
// return unused ETH
if (PRESALE_INFO.PRESALE_IN_ETH && amount_in < msg.value) {
msg.sender.transfer(msg.value.sub(amount_in));
}
// deduct non ETH token from user
if (!PRESALE_INFO.PRESALE_IN_ETH) {
TransferHelper.safeTransferFrom(address(PRESALE_INFO.B_TOKEN), msg.sender, address(this), amount_in);
}
}
| function userDeposit (uint256 _amount) external payable nonReentrant {
require(presaleStatus() == 1, 'NOT ACTIVE'); // ACTIVE
if (STATUS.WHITELIST_ONLY) {
require(WHITELIST.contains(msg.sender), 'NOT WHITELISTED');
}
// Presale Round 1 - require participant to hold a certain token and balance
if (block.number < PRESALE_INFO.START_BLOCK + STATUS.ROUND1_LENGTH) { // 276 blocks = 1 hour
require(PRESALE_SETTINGS.userHoldsSufficientRound1Token(msg.sender), 'INSUFFICENT ROUND 1 TOKEN BALANCE');
}
BuyerInfo storage buyer = BUYERS[msg.sender];
uint256 amount_in = PRESALE_INFO.PRESALE_IN_ETH ? msg.value : _amount;
uint256 allowance = PRESALE_INFO.MAX_SPEND_PER_BUYER.sub(buyer.baseDeposited);
uint256 remaining = PRESALE_INFO.HARDCAP - STATUS.TOTAL_BASE_COLLECTED;
allowance = allowance > remaining ? remaining : allowance;
if (amount_in > allowance) {
amount_in = allowance;
}
uint256 tokensSold = amount_in.mul(PRESALE_INFO.TOKEN_PRICE).div(10 ** uint256(PRESALE_INFO.B_TOKEN.decimals()));
require(tokensSold > 0, 'ZERO TOKENS');
if (buyer.baseDeposited == 0) {
STATUS.NUM_BUYERS++;
}
buyer.baseDeposited = buyer.baseDeposited.add(amount_in);
buyer.tokensOwed = buyer.tokensOwed.add(tokensSold);
STATUS.TOTAL_BASE_COLLECTED = STATUS.TOTAL_BASE_COLLECTED.add(amount_in);
STATUS.TOTAL_TOKENS_SOLD = STATUS.TOTAL_TOKENS_SOLD.add(tokensSold);
// return unused ETH
if (PRESALE_INFO.PRESALE_IN_ETH && amount_in < msg.value) {
msg.sender.transfer(msg.value.sub(amount_in));
}
// deduct non ETH token from user
if (!PRESALE_INFO.PRESALE_IN_ETH) {
TransferHelper.safeTransferFrom(address(PRESALE_INFO.B_TOKEN), msg.sender, address(this), amount_in);
}
}
| 39,105 |
118 | // string memory error = string(abi.encodePacked("Module: requested module not found - ", module)); require(moduleAddress != ZERO_ADDRESS, error); | require(moduleAddress != ZERO_ADDRESS, "Module: requested module not found");
return moduleAddress;
| require(moduleAddress != ZERO_ADDRESS, "Module: requested module not found");
return moduleAddress;
| 45,523 |
4 | // Deploy logic | constructor() {
owner = payable(msg.sender);
}
| constructor() {
owner = payable(msg.sender);
}
| 7,764 |
52 | // collect src tokens | if (srcToken != ETH_TOKEN_ADDRESS) {
require(srcToken.transferFrom(msg.sender, tokenWallet[srcToken], srcAmount));
}
| if (srcToken != ETH_TOKEN_ADDRESS) {
require(srcToken.transferFrom(msg.sender, tokenWallet[srcToken], srcAmount));
}
| 38,356 |
165 | // The amount of Ether in each token. | mapping(uint256 => uint256) internal _funds;
| mapping(uint256 => uint256) internal _funds;
| 31,975 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.