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 |
|---|---|---|---|---|
72 | // Add the NFT to the trader's purchased list | if (nfts[_nftId[i]].owner != address(0)) {
removePurchasedNFT(nfts[_nftId[i]].owner, _nftId[i]);
}
| if (nfts[_nftId[i]].owner != address(0)) {
removePurchasedNFT(nfts[_nftId[i]].owner, _nftId[i]);
}
| 8,889 |
129 | // Creates a new pool & then initializes the pool/_token0 The contract address of token0 of the pool/_token1 The contract address of token1 of the pool/data Necessary data needed to create pool/ In data we will provide the `fee` amount of the v3 pool for the specified token pair,/ also `sqrtPriceX96` The initial square root price of the pool/ return _pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address | function createPair(
address _token0,
address _token1,
bytes memory data
) external returns (address _pool);
| function createPair(
address _token0,
address _token1,
bytes memory data
) external returns (address _pool);
| 59,192 |
3 | // Mint a token / | function mintOne(address, uint256) external payable override {
revert("not implemented");
}
| function mintOne(address, uint256) external payable override {
revert("not implemented");
}
| 37,886 |
113 | // Donate a skin to player. Only COO can operate | function donateSkin(uint128 specifiedAppearance, address donee) external whenNotPaused onlyCOO {
Skin memory newSkin = Skin({appearance: specifiedAppearance, cooldownEndTime: uint64(now), mixingWithId: 0});
skins[nextSkinId] = newSkin;
skinIdToOwner[nextSkinId] = donee;
isOnSale[nextSkinId] = false;
// Emit the create event
CreateNewSkin(nextSkinId, donee);
nextSkinId++;
numSkinOfAccounts[donee] += 1;
skinCreatedNum += 1;
}
| function donateSkin(uint128 specifiedAppearance, address donee) external whenNotPaused onlyCOO {
Skin memory newSkin = Skin({appearance: specifiedAppearance, cooldownEndTime: uint64(now), mixingWithId: 0});
skins[nextSkinId] = newSkin;
skinIdToOwner[nextSkinId] = donee;
isOnSale[nextSkinId] = false;
// Emit the create event
CreateNewSkin(nextSkinId, donee);
nextSkinId++;
numSkinOfAccounts[donee] += 1;
skinCreatedNum += 1;
}
| 54,238 |
8 | // Approve module in ZMM | alice.setApprovalForModule(address(module), true);
| alice.setApprovalForModule(address(module), true);
| 45,660 |
14 | // send refund back to sender | if (!msg.sender.send(amount_to_refund)) throw;
| if (!msg.sender.send(amount_to_refund)) throw;
| 32,273 |
373 | // Emitted when mint is paused/unpaused by admin or pause guardian | event MintPaused(address iToken, bool paused);
function _setMintPaused(address iToken, bool paused) external;
function _setAllMintPaused(bool paused) external;
| event MintPaused(address iToken, bool paused);
function _setMintPaused(address iToken, bool paused) external;
function _setAllMintPaused(bool paused) external;
| 40,619 |
48 | // Mints OffsetsnumberOfNFTs uint256 number of NFTs to mint / | function mintNFT(uint256 numberOfNFTs) public payable {
require(totalSupply() < MAX_NFT_SUPPLY, "Sale has already ended");
require(numberOfNFTs > 0, "numberOfNFTs cannot be 0");
if (totalSupply() < 10) {
require(
numberOfNFTs == 1,
"You may not collect more than 1 NFT at a time"
);
} else {
require(
numberOfNFTs <= 10,
"You may not collect more than 10 NFTs at once"
);
}
require(
totalSupply().add(numberOfNFTs) <= MAX_NFT_SUPPLY,
"Exceeds MAX_NFT_SUPPLY"
);
require(
getNFTPrice().mul(numberOfNFTs) == msg.value,
"Ether value sent is not correct"
);
for (uint256 i = 0; i < numberOfNFTs; i++) {
uint256 mintIndex = totalSupply() + 1;
if (block.timestamp < REVEAL_TIMESTAMP) {
_mintedBeforeReveal[mintIndex] = true;
}
_safeMint(msg.sender, mintIndex);
}
}
| function mintNFT(uint256 numberOfNFTs) public payable {
require(totalSupply() < MAX_NFT_SUPPLY, "Sale has already ended");
require(numberOfNFTs > 0, "numberOfNFTs cannot be 0");
if (totalSupply() < 10) {
require(
numberOfNFTs == 1,
"You may not collect more than 1 NFT at a time"
);
} else {
require(
numberOfNFTs <= 10,
"You may not collect more than 10 NFTs at once"
);
}
require(
totalSupply().add(numberOfNFTs) <= MAX_NFT_SUPPLY,
"Exceeds MAX_NFT_SUPPLY"
);
require(
getNFTPrice().mul(numberOfNFTs) == msg.value,
"Ether value sent is not correct"
);
for (uint256 i = 0; i < numberOfNFTs; i++) {
uint256 mintIndex = totalSupply() + 1;
if (block.timestamp < REVEAL_TIMESTAMP) {
_mintedBeforeReveal[mintIndex] = true;
}
_safeMint(msg.sender, mintIndex);
}
}
| 23,161 |
49 | // Minimum Deposit in USD cents | uint256 public constant minContributionUSDc = 1000;
| uint256 public constant minContributionUSDc = 1000;
| 45,567 |
41 | // ========== RESTRICTED FUNCTIONS (YPOOL_WORKER) ========== //Fulfill a swap request for a user by YPool worker/ Closing a swap MUST be performed on target chain and only by YPool worker/swapDesc is the swap info for swapping on DEX on target chain, not the info of the swap request user initiated on source chain/swapDesc Description of the swap on DEX, see IAggregator.SwapDescription/aggregatorData Raw data consists of instructions to swap user's token for YPool token/fromChainId Source chain id of the swap request/fromSwapId Swap id of the swap request | function closeSwap(
IAggregator.SwapDescription calldata swapDesc,
bytes memory aggregatorData,
uint32 fromChainId,
uint256 fromSwapId
| function closeSwap(
IAggregator.SwapDescription calldata swapDesc,
bytes memory aggregatorData,
uint32 fromChainId,
uint256 fromSwapId
| 35,477 |
14 | // Returns all the chat messages communicated in a channel | function readMessage(address friend_key) external view returns(message[] memory) {
bytes32 chatCode = _getChatCode(msg.sender, friend_key);
return allMessages[chatCode];
}
| function readMessage(address friend_key) external view returns(message[] memory) {
bytes32 chatCode = _getChatCode(msg.sender, friend_key);
return allMessages[chatCode];
}
| 37,949 |
11 | // Pause redeems until unpause is called. this pauses the whole contract. / | function pause() external override onlyOwner {
_pause();
}
| function pause() external override onlyOwner {
_pause();
}
| 17,342 |
0 | // Calculate the key for a staking incentive/key The components used to compute the incentive identifier/ return incentiveId The identifier for the incentive | function compute(IUniswapV3Staker.IncentiveKey memory key) internal pure returns (bytes32 incentiveId) {
return keccak256(abi.encode(key));
}
| function compute(IUniswapV3Staker.IncentiveKey memory key) internal pure returns (bytes32 incentiveId) {
return keccak256(abi.encode(key));
}
| 43,237 |
17 | // Obtain the project goal./projectId Id of the project./ return goal amount to fund in wei. | function getProjectGoal(uint projectId) public view validProject(projectId) returns (uint){
return projects[projectId].goal;
}
| function getProjectGoal(uint projectId) public view validProject(projectId) returns (uint){
return projects[projectId].goal;
}
| 4,098 |
81 | // getter function for long term lockup wallet address / | function longTermLockUp() public view override returns(address) {
return _longTermLockUp;
}
| function longTermLockUp() public view override returns(address) {
return _longTermLockUp;
}
| 26,074 |
39 | // Apply order fill fraction to offer item end amount. | uint256 endAmount = _getFraction(
numerator,
denominator,
offerItem.endAmount
);
| uint256 endAmount = _getFraction(
numerator,
denominator,
offerItem.endAmount
);
| 33,151 |
5 | // Owners are the Masters or the Academy. Only them can add projects in portfolio, because they validate the project before add it. | require (!compareStrings(projectName, ""), "portfolio: invalid name");
require (!(projectAddress == address(0x0)), "portfolio: invalid address");
require (projectList.exists(projectName), "portfolio: project not exists");
require (projectList.isActive(projectName), "portfolio: project not active");
require(msg.sender == projectList.getMasterAddressByName(projectName), "Only Master can add project in portfolio");
| require (!compareStrings(projectName, ""), "portfolio: invalid name");
require (!(projectAddress == address(0x0)), "portfolio: invalid address");
require (projectList.exists(projectName), "portfolio: project not exists");
require (projectList.isActive(projectName), "portfolio: project not active");
require(msg.sender == projectList.getMasterAddressByName(projectName), "Only Master can add project in portfolio");
| 10,494 |
6 | // Testing retrieval of all guests | function testGetGuestAddressByItemIdInArray() public {
// Store guests in memory rather than contract's storage
address[16] memory guests = registry.getGuests();
Assert.equal(guests[expectedItemId], expectedGuest, "Guests claiming the expected item should be this contract");
}
| function testGetGuestAddressByItemIdInArray() public {
// Store guests in memory rather than contract's storage
address[16] memory guests = registry.getGuests();
Assert.equal(guests[expectedItemId], expectedGuest, "Guests claiming the expected item should be this contract");
}
| 30,976 |
2 | // function withdraw( uint _value | // ) onlyOwner payable public returns(bool) {
// require(address(this).balance >= _value);
// owner.transfer(_value);
// return true;
// }
| // ) onlyOwner payable public returns(bool) {
// require(address(this).balance >= _value);
// owner.transfer(_value);
// return true;
// }
| 41,809 |
311 | // Store challenge | uint256 challengeId = nextChallengeId++;
Challenge storage challenge = challenges[challengeId];
challenge.actionId = _actionId;
challenge.challenger = _challenger;
challenge.endDate = getTimestamp64().add(_requirement.challengeDuration);
challenge.context = _context;
challenge.settlementOffer = _settlementOffer;
challenge.challengerFinishedEvidence = _finishedSubmittingEvidence;
| uint256 challengeId = nextChallengeId++;
Challenge storage challenge = challenges[challengeId];
challenge.actionId = _actionId;
challenge.challenger = _challenger;
challenge.endDate = getTimestamp64().add(_requirement.challengeDuration);
challenge.context = _context;
challenge.settlementOffer = _settlementOffer;
challenge.challengerFinishedEvidence = _finishedSubmittingEvidence;
| 58,264 |
8 | // Executes a transfer operation in the context of Stoa.// asset The asset to transfer./ amountThe amount to transfer./ recipient The recipient of the transfer. | function _transfer(
address asset,
uint256 amount,
address recipient
| function _transfer(
address asset,
uint256 amount,
address recipient
| 10,648 |
5 | // Dividents for bonds security token | contract Dividents is Governance {
using SafeMath for uint256;
//map user->token->config
mapping(address => mapping(address => Config)) public dvDetails;
uint256 public INTREVAL = 1 weeks;
///config struct of dividents
struct Config {
address token;
uint256 periods;//total periods
uint256 periodIndex;//current period.start form 0.
uint256 claimed;//total claimed
uint256 toClaim;//calculated
uint256 percent;//percent of profit.
uint256 start;//start time of new config
}
///@dev config
function config(address _token, uint256 _periods, uint256 _percent) public onlyOwner returns (bool){
Config memory cf = Config({
token : _token,
periods : _periods,
periodIndex : 0,
claimed : 0,
toClaim : 0,
percent : _percent,
start : block.timestamp
});
calculateNextDvd(msg.sender, cf);
dvDetails[msg.sender][_token] = cf;
}
///@dev calculate the next period of dividents and reset the config
///@param _user user address
///@param _config config of user
function calculateNextDvd(address _user, Config _config) internal view{
require(_config.periods > _config.periodIndex, "periods end");
uint256 balance = SecurityToken(_config.token).balanceOf(_user);
_config.toClaim += balance.mul(_config.percent).div(100);
_config.periodIndex += 1;
}
///@dev claim dividents
///@param _token token to claim
function claim(address _token){
Config memory cf = dvDetails[msg.sender][_token];
require(block.timestamp.sub(cf.start) > INTREVAL, "still in old period,please wait.");
require(cf.toClaim > 0, "nothing to claim.");
uint256 amount = cf.toClaim;
cf.claimed += amount;
cf.toClaim = 0;
calculateNextDvd(msg.sender, cf);
require(SecurityToken(_token).transfer(msg.sender, amount), "do transfer token errors");
}
}
| contract Dividents is Governance {
using SafeMath for uint256;
//map user->token->config
mapping(address => mapping(address => Config)) public dvDetails;
uint256 public INTREVAL = 1 weeks;
///config struct of dividents
struct Config {
address token;
uint256 periods;//total periods
uint256 periodIndex;//current period.start form 0.
uint256 claimed;//total claimed
uint256 toClaim;//calculated
uint256 percent;//percent of profit.
uint256 start;//start time of new config
}
///@dev config
function config(address _token, uint256 _periods, uint256 _percent) public onlyOwner returns (bool){
Config memory cf = Config({
token : _token,
periods : _periods,
periodIndex : 0,
claimed : 0,
toClaim : 0,
percent : _percent,
start : block.timestamp
});
calculateNextDvd(msg.sender, cf);
dvDetails[msg.sender][_token] = cf;
}
///@dev calculate the next period of dividents and reset the config
///@param _user user address
///@param _config config of user
function calculateNextDvd(address _user, Config _config) internal view{
require(_config.periods > _config.periodIndex, "periods end");
uint256 balance = SecurityToken(_config.token).balanceOf(_user);
_config.toClaim += balance.mul(_config.percent).div(100);
_config.periodIndex += 1;
}
///@dev claim dividents
///@param _token token to claim
function claim(address _token){
Config memory cf = dvDetails[msg.sender][_token];
require(block.timestamp.sub(cf.start) > INTREVAL, "still in old period,please wait.");
require(cf.toClaim > 0, "nothing to claim.");
uint256 amount = cf.toClaim;
cf.claimed += amount;
cf.toClaim = 0;
calculateNextDvd(msg.sender, cf);
require(SecurityToken(_token).transfer(msg.sender, amount), "do transfer token errors");
}
}
| 25,707 |
14 | // See {IERC721Market-offerForSaleToAddress}. | function offerForSaleToAddress(
uint256 index,
uint256 minSalePriceInWei,
address toAddress
) public onlyOwnerOf(index) onlyValidIndex(index) {
_offerForSale(index, minSalePriceInWei, toAddress);
}
| function offerForSaleToAddress(
uint256 index,
uint256 minSalePriceInWei,
address toAddress
) public onlyOwnerOf(index) onlyValidIndex(index) {
_offerForSale(index, minSalePriceInWei, toAddress);
}
| 40,434 |
0 | // Expiration Mask: predicate := PredicateHelper.timestampBelow(deadline) Maker Nonce: predicate := this.nonceEquals(makerAddress, makerNonce) |
event OrderFilled(
address indexed maker,
bytes32 orderHash,
uint256 remaining
);
event OrderFilledRFQ(
bytes32 orderHash,
uint256 makingAmount
|
event OrderFilled(
address indexed maker,
bytes32 orderHash,
uint256 remaining
);
event OrderFilledRFQ(
bytes32 orderHash,
uint256 makingAmount
| 12,860 |
46 | // keccak256(MessageSent(bytes)) | bytes32 public constant SEND_MESSAGE_EVENT_SIG = 0x8c5261668696ce22758910d05bab8f186d6eb247ceac2af2e82c7dc17669b036;
| bytes32 public constant SEND_MESSAGE_EVENT_SIG = 0x8c5261668696ce22758910d05bab8f186d6eb247ceac2af2e82c7dc17669b036;
| 53,319 |
2,182 | // 1093 | entry "authentiquely" : ENG_ADVERB
| entry "authentiquely" : ENG_ADVERB
| 21,929 |
25 | // make sure submissions are open | require(!submissionsPaused, "Submissions are paused. Please check back later.");
| require(!submissionsPaused, "Submissions are paused. Please check back later.");
| 35,416 |
3 | // TODO change to interface if that ever gets added to the parser | contract RngRequester {
function acceptRandom(bytes32 id, bytes result);
}
| contract RngRequester {
function acceptRandom(bytes32 id, bytes result);
}
| 7,724 |
469 | // See {Governor-_quorumReached}. In this module, only forVotes count toward the quorum. / | function _quorumReached(uint256 proposalId) internal view virtual override returns (bool) {
ProposalDetails storage details = _proposalDetails[proposalId];
return quorum(proposalSnapshot(proposalId)) <= details.forVotes;
}
| function _quorumReached(uint256 proposalId) internal view virtual override returns (bool) {
ProposalDetails storage details = _proposalDetails[proposalId];
return quorum(proposalSnapshot(proposalId)) <= details.forVotes;
}
| 20,275 |
49 | // providing a counter dispute proof with higher nonce | require(!channels[ch_key].dispute_started_by_left == msg.sender < params.partner, "Only your partner can counter dispute");
require(channels[ch_key].dispute_nonce < params.dispute_nonce, "New nonce must be greater");
require(params.entries_hash == keccak256(abi.encode(params.entries)), "Invalid entries_hash");
finalizeChannel(msg.sender, params.partner, params.entries);
return true;
| require(!channels[ch_key].dispute_started_by_left == msg.sender < params.partner, "Only your partner can counter dispute");
require(channels[ch_key].dispute_nonce < params.dispute_nonce, "New nonce must be greater");
require(params.entries_hash == keccak256(abi.encode(params.entries)), "Invalid entries_hash");
finalizeChannel(msg.sender, params.partner, params.entries);
return true;
| 40,022 |
9 | // Returns tuple containing last valid price and timestamp, as well as status code of latest update/ request that got posted to the Witnet Request Board./ return _lastPrice Last valid price reported back from the Witnet oracle./ return _lastTimestamp EVM-timestamp of the last valid price./ return _lastDrTxHash Hash of the Witnet Data Request that solved the last valid price./ return _latestUpdateStatus Status code of the latest update request. | function lastValue()
external view
virtual override
returns (
int _lastPrice,
uint _lastTimestamp,
bytes32 _lastDrTxHash,
uint _latestUpdateStatus
)
| function lastValue()
external view
virtual override
returns (
int _lastPrice,
uint _lastTimestamp,
bytes32 _lastDrTxHash,
uint _latestUpdateStatus
)
| 22,151 |
0 | // emit ERC721Received(_operator, _from, _tokenId, _data, gasleft()); |
return ERC721_RECEIVED_DRAFT;
|
return ERC721_RECEIVED_DRAFT;
| 22,607 |
9 | // transfer confirm when `to` receive assets successfully. | function transferInterChainConfirm(uint transId) public returns(bool) {
if (transferMap[transId].id == 0) {
retLog(10019);
return false;
}
Transfer storage transfer = transferMap[transId];
UserInfo storage fromUser = userMap[transfer.from];
fromUser.unAvailAssets -= transfer.amount;
transfer.status = 0;
transferMap[transId] = transfer;
userMap[transfer.from] = fromUser;
retLog(0);
transferLog(transId);
return true;
}
| function transferInterChainConfirm(uint transId) public returns(bool) {
if (transferMap[transId].id == 0) {
retLog(10019);
return false;
}
Transfer storage transfer = transferMap[transId];
UserInfo storage fromUser = userMap[transfer.from];
fromUser.unAvailAssets -= transfer.amount;
transfer.status = 0;
transferMap[transId] = transfer;
userMap[transfer.from] = fromUser;
retLog(0);
transferLog(transId);
return true;
}
| 27,616 |
5 | // Function to convert the candidateList to a string returns eg - modi, mamta, rahul / | function concatCandidates() private returns(string){
for(uint i=0; i<candidateList.length; i++){
candidates = string(abi.encodePacked(candidates, bytes32ToString(candidateList[i]),","));
}
return string(candidates);
}
| function concatCandidates() private returns(string){
for(uint i=0; i<candidateList.length; i++){
candidates = string(abi.encodePacked(candidates, bytes32ToString(candidateList[i]),","));
}
return string(candidates);
}
| 27,013 |
11 | // transfer the amount to the follower | payable(follower).transfer(msg.value);
emit Follow(msg.sender, follower);
| payable(follower).transfer(msg.value);
emit Follow(msg.sender, follower);
| 17,754 |
39 | // solium-disable-next-line arg-overflow | safeTransferFrom(_from, _to, _tokenId, "");
| safeTransferFrom(_from, _to, _tokenId, "");
| 17,829 |
4 | // The utilization point at which the jump multiplier is applied / | uint public kink;
| uint public kink;
| 33,302 |
23 | // The function containing the painting of a heart on the NFT. The token is the canvas. | function heart() public {
require(false,"nope");
assembly{
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0x0000ff0000ff0000ff0000a00000ffffffa00000ff0000ff0000ff0000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffff000000ffffff) //first black dot of the heart black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff0000001111ff0000000fff) //second heart line black/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0x0000001110001111ff1111ff1111ff000000000abcffffffffffdfffffff) //third heart line black/red/red/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xfffffff1100110000ff0000ff0000ff0000ff0000ff001100fffffffffff) //fourth heart line black/red/red/red/red/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffff)
sstore(69, 0x1aa1100001100ff1100ff1100ff1100ff1100ff1100ff1111ff111111fff) //fifth line black/red/red/red/red/red/red/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0x1aa1100001100ff1100ff1100ff1100ff1100ff1100ff1111ff111111fff) //sixth line same as fifth
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffff)
sstore(69, 0x1aa1100001100ff1100ff1100ff1100111100ff1100ff1111ff111111fff) //seventh line black/red/red/red/black/red/red/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xaFFFFFF110022110022110022FFFFFF110022110022111122FFFFFFfffff) //last line white/black/black/black/white/black/black/black/white
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
}
}
| function heart() public {
require(false,"nope");
assembly{
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0x0000ff0000ff0000ff0000a00000ffffffa00000ff0000ff0000ff0000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffff000000ffffff) //first black dot of the heart black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff0000001111ff0000000fff) //second heart line black/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0x0000001110001111ff1111ff1111ff000000000abcffffffffffdfffffff) //third heart line black/red/red/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xfffffff1100110000ff0000ff0000ff0000ff0000ff001100fffffffffff) //fourth heart line black/red/red/red/red/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffff)
sstore(69, 0x1aa1100001100ff1100ff1100ff1100ff1100ff1100ff1111ff111111fff) //fifth line black/red/red/red/red/red/red/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0x1aa1100001100ff1100ff1100ff1100ff1100ff1100ff1111ff111111fff) //sixth line same as fifth
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffff)
sstore(69, 0x1aa1100001100ff1100ff1100ff1100111100ff1100ff1111ff111111fff) //seventh line black/red/red/red/black/red/red/red/black
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xaFFFFFF110022110022110022FFFFFF110022110022111122FFFFFFfffff) //last line white/black/black/black/white/black/black/black/white
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xa00000a00000a00000ffffffffffffffffffa00000a00000a00000)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
sstore(69, 0xffffffffffffffffffffffffffffffffffffff)
}
}
| 20,799 |
16 | // Cancels a swap offer for a token / | function cancelSwapOffer() public {
require(offers[msg.sender].from != address(0), "No offer to cancel.");
uint256 id = offers[msg.sender].id;
uint256 forId = offers[msg.sender].forId;
delete offers[msg.sender];
swapOfferAddresses.remove(msg.sender);
emit SwapOfferCancelled(msg.sender, id, forId);
}
| function cancelSwapOffer() public {
require(offers[msg.sender].from != address(0), "No offer to cancel.");
uint256 id = offers[msg.sender].id;
uint256 forId = offers[msg.sender].forId;
delete offers[msg.sender];
swapOfferAddresses.remove(msg.sender);
emit SwapOfferCancelled(msg.sender, id, forId);
}
| 9,931 |
2 | // fees in the live version the; enlistingFee will be 0.01 ether and the wageringFee will be 0.005 ether | uint256 constant enlistingFee = 0;
uint256 constant wageringFee = 0;
| uint256 constant enlistingFee = 0;
uint256 constant wageringFee = 0;
| 48,446 |
10 | // The contract has 2 stages: 1 - The initial state. The owner is able to add addresses to the whitelist, and any whitelisted addresses can deposit or withdraw eth to the contract. 2 - The eth is sent from the contract to the receiver. Unused eth can be claimed by contributors immediately. Once tokens are sent to the contract, the owner enables withdrawals and contributors can withdraw their tokens. | uint8 public contractStage = 1;
| uint8 public contractStage = 1;
| 25,755 |
14 | // minimalWbtcPrice 为 btc / eth 价格. 当前价格下输入30即可 | function distributeReward(uint256 minimalWbtcPrice) external onlyOperator {
uint256 totalWbtc = 0;
for (uint256 i=0; i<lpStakings.length; i++) {
address lpStaking = lpStakings[i];
address rewardToken = stakingRewardToken[lpStaking];
uint256 accumulateFee = ILpStaking(lpStaking).getAccumulateFee();
if (rewardToken == wbtc) {
ILpStaking(lpStaking).feeWithdraw(marsStakingForWbtc);
totalWbtc += accumulateFee;
} else {
ILpStaking(lpStaking).feeWithdraw(address(this));
IWETH(weth).deposit{value: accumulateFee}();
assert(IWETH(weth).transfer(wbtc_weth_pair, accumulateFee));
(uint256 wbtcReserve, uint256 wethReserve, ) = IUniswapV2Pair(wbtc_weth_pair).getReserves();
uint256 amountOut = getAmountOut(accumulateFee, wethReserve, wbtcReserve);
uint256 actualPrice = accumulateFee / 1e10 / amountOut;
require(actualPrice >= minimalWbtcPrice, "price move");
IUniswapV2Pair(wbtc_weth_pair).swap(amountOut, 0, marsStakingForWbtc, new bytes(0));
totalWbtc += amountOut;
}
}
if (totalWbtc > 0) {
IStakingRewardsWbtc(marsStakingForWbtc).notifyRewardAmount(totalWbtc, 864000);
}
}
| function distributeReward(uint256 minimalWbtcPrice) external onlyOperator {
uint256 totalWbtc = 0;
for (uint256 i=0; i<lpStakings.length; i++) {
address lpStaking = lpStakings[i];
address rewardToken = stakingRewardToken[lpStaking];
uint256 accumulateFee = ILpStaking(lpStaking).getAccumulateFee();
if (rewardToken == wbtc) {
ILpStaking(lpStaking).feeWithdraw(marsStakingForWbtc);
totalWbtc += accumulateFee;
} else {
ILpStaking(lpStaking).feeWithdraw(address(this));
IWETH(weth).deposit{value: accumulateFee}();
assert(IWETH(weth).transfer(wbtc_weth_pair, accumulateFee));
(uint256 wbtcReserve, uint256 wethReserve, ) = IUniswapV2Pair(wbtc_weth_pair).getReserves();
uint256 amountOut = getAmountOut(accumulateFee, wethReserve, wbtcReserve);
uint256 actualPrice = accumulateFee / 1e10 / amountOut;
require(actualPrice >= minimalWbtcPrice, "price move");
IUniswapV2Pair(wbtc_weth_pair).swap(amountOut, 0, marsStakingForWbtc, new bytes(0));
totalWbtc += amountOut;
}
}
if (totalWbtc > 0) {
IStakingRewardsWbtc(marsStakingForWbtc).notifyRewardAmount(totalWbtc, 864000);
}
}
| 752 |
68 | // This function is called to check that a merkle proof is a valid merkle proofParam: _merkleProof => An array of bytes32 that represent the "proof" that the address is on the merkle treereturns(bool) => The bool saying whether the proof is verified or not | function checkValidity(bytes32[] calldata _merkleProof)
public
view
returns (bool)
| function checkValidity(bytes32[] calldata _merkleProof)
public
view
returns (bool)
| 37,745 |
13 | // liquidity balance variable | uint256 private _tTotalForLiquidity;
uint256 private _rTotalForLiquidity;
event LiquifyEnabledUpdated(bool enabled);
event Liquify(uint256 tokensAdded, uint256 ethAdded);
event BurnFeeChanged(uint256 percentage);
event CashBackFeeChanged(uint256 percentage);
event NFTCashBackChanged(uint256 percentage);
event LiquidityFeeChanged(uint256 percentage);
event DevFeeChanged(uint256 percentage);
| uint256 private _tTotalForLiquidity;
uint256 private _rTotalForLiquidity;
event LiquifyEnabledUpdated(bool enabled);
event Liquify(uint256 tokensAdded, uint256 ethAdded);
event BurnFeeChanged(uint256 percentage);
event CashBackFeeChanged(uint256 percentage);
event NFTCashBackChanged(uint256 percentage);
event LiquidityFeeChanged(uint256 percentage);
event DevFeeChanged(uint256 percentage);
| 40,926 |
4 | // Mint reserve tokens. to Recipient address. numberToMint Quantity of tokens to mint. / | function devMint(address to, uint256 numberToMint) external onlyRole(SUPPORT_ROLE) {
uint256 reserveSupply_ = reserveSupply;
require(numberToMint <= reserveSupply_, "Exceeds reserve limit");
reserveSupply = reserveSupply_ - numberToMint;
_mintTokens(to, numberToMint);
}
| function devMint(address to, uint256 numberToMint) external onlyRole(SUPPORT_ROLE) {
uint256 reserveSupply_ = reserveSupply;
require(numberToMint <= reserveSupply_, "Exceeds reserve limit");
reserveSupply = reserveSupply_ - numberToMint;
_mintTokens(to, numberToMint);
}
| 34,602 |
262 | // Withdraw LP tokens from liquidity mining pool and harvests rewards/incentives address - Liquidity mining pool/value uint - value to withdraw | function withdrawAndHarvest(address incentives, uint value) external {
GebIncentivesLike incentivesContract = GebIncentivesLike(incentives);
DSTokenLike rewardToken = DSTokenLike(incentivesContract.rewardsToken());
DSTokenLike lpToken = DSTokenLike(incentivesContract.stakingToken());
incentivesContract.withdraw(value);
getRewards(incentives);
lpToken.transfer(msg.sender, lpToken.balanceOf(address(this)));
}
| function withdrawAndHarvest(address incentives, uint value) external {
GebIncentivesLike incentivesContract = GebIncentivesLike(incentives);
DSTokenLike rewardToken = DSTokenLike(incentivesContract.rewardsToken());
DSTokenLike lpToken = DSTokenLike(incentivesContract.stakingToken());
incentivesContract.withdraw(value);
getRewards(incentives);
lpToken.transfer(msg.sender, lpToken.balanceOf(address(this)));
}
| 38,228 |
64 | // Remove staker | delete _stakers[sender];
emit StakerRemoved(sender);
| delete _stakers[sender];
emit StakerRemoved(sender);
| 35,420 |
360 | // Make royalty fee claimable and add to total | _claimable[minter] += minterFee;
_totalClaimable += minterFee;
| _claimable[minter] += minterFee;
_totalClaimable += minterFee;
| 2,603 |
1 | // Per product collateral state | mapping(IProduct => OptimisticLedger) private _products;
| mapping(IProduct => OptimisticLedger) private _products;
| 21,463 |
9 | // Add a wallet address to an existing contact | function addWalletToContact(string memory _name, address _wallet) public onlyOwner {
// Add the wallet to the contact
contacts[_name].wallets.push(_wallet);
}
| function addWalletToContact(string memory _name, address _wallet) public onlyOwner {
// Add the wallet to the contact
contacts[_name].wallets.push(_wallet);
}
| 17,890 |
4 | // Returns current floor value / | function floor() public view returns (uint256) {
if (currentSupply == 0) {
return address(this).balance;
}
return address(this).balance / currentSupply;
}
| function floor() public view returns (uint256) {
if (currentSupply == 0) {
return address(this).balance;
}
return address(this).balance / currentSupply;
}
| 16,294 |
172 | // verifySignature checks the the provided signature matches the/ provided parameters. Returns a 4-byte value as defined by ERC1271. | function isValidSignature(bytes32 sigHash, bytes calldata signature) external view override returns (bytes4) {
address mintAuthority_ = getMintAuthority();
require(mintAuthority_ != address(0x0), "SignatureVerifier: mintAuthority not initialized");
if (mintAuthority_ == ECDSA.recover(sigHash, signature)) {
return CORRECT_SIGNATURE_RETURN_VALUE;
} else {
return INCORRECT_SIGNATURE_RETURN_VALUE;
}
}
| function isValidSignature(bytes32 sigHash, bytes calldata signature) external view override returns (bytes4) {
address mintAuthority_ = getMintAuthority();
require(mintAuthority_ != address(0x0), "SignatureVerifier: mintAuthority not initialized");
if (mintAuthority_ == ECDSA.recover(sigHash, signature)) {
return CORRECT_SIGNATURE_RETURN_VALUE;
} else {
return INCORRECT_SIGNATURE_RETURN_VALUE;
}
}
| 70,221 |
3 | // hash Hash to be checked. account Address of the hash will be checked for.return True if hash has already been used by this account address. / | function isHashUsed(bytes32 hash, address account) public view returns (bool) {
return isHashUsed_[hash][account];
}
| function isHashUsed(bytes32 hash, address account) public view returns (bool) {
return isHashUsed_[hash][account];
}
| 9,650 |
54 | // Returns the list of active tiers / | function getActiveTiers() public view returns (uint256[] memory) {
uint256[] memory tiers = new uint256[](getNActiveTiers());
uint256 index = 0;
for(uint256 tier = 0 ; tier < _nTiers ; tier++) {
if(isActiveTier(tier)) {
tiers[index] = tier;
index++;
}
}
return tiers;
}
| function getActiveTiers() public view returns (uint256[] memory) {
uint256[] memory tiers = new uint256[](getNActiveTiers());
uint256 index = 0;
for(uint256 tier = 0 ; tier < _nTiers ; tier++) {
if(isActiveTier(tier)) {
tiers[index] = tier;
index++;
}
}
return tiers;
}
| 18,561 |
32 | // Burn price ratio is 0.9 | uint256 constant burn_ratio = 9 * fmk / 10;
| uint256 constant burn_ratio = 9 * fmk / 10;
| 41,655 |
276 | // We use this to save work computing terms | int256 realTerm = REAL_ONE;
for (int216 n = 0; n < maxIterations; n++) {
| int256 realTerm = REAL_ONE;
for (int216 n = 0; n < maxIterations; n++) {
| 37,136 |
114 | // Standard Burnable Token Adds burnFrom method to ERC20 implementations / | contract StandardBurnableToken is BurnableToken, StandardToken {
/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param _from address The address which you want to send tokens from
* @param _value uint256 The amount of token to be burned
*/
function burnFrom(address _from, uint256 _value) public onlyOwner {
require(_value <= allowed[_from][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
_burn(_from, _value);
}
}
| contract StandardBurnableToken is BurnableToken, StandardToken {
/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param _from address The address which you want to send tokens from
* @param _value uint256 The amount of token to be burned
*/
function burnFrom(address _from, uint256 _value) public onlyOwner {
require(_value <= allowed[_from][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
_burn(_from, _value);
}
}
| 32,234 |
6 | // bytes executeFuncSignature | ISygmaAdapter(address(0)).storeHashes.selector,
| ISygmaAdapter(address(0)).storeHashes.selector,
| 24,540 |
39 | // reference to Pytheas for checking that a colonist has mined enoughrEON to make an attempt as well as pay from this amount, either thecurrent mint cost ona successful pirate mint, or pirate tax on a failed attempt. | IPytheas public pytheas;
| IPytheas public pytheas;
| 49,266 |
9 | // status functions / | function getBalance(ERC20 token) public view returns(uint) {
if (token == ETH_TOKEN_ADDRESS)
return this.balance;
else {
address wallet = tokenWallet[token];
uint balanceOfWallet = token.balanceOf(wallet);
uint allowanceOfWallet = token.allowance(wallet, this);
return (balanceOfWallet < allowanceOfWallet) ? balanceOfWallet : allowanceOfWallet;
}
}
| function getBalance(ERC20 token) public view returns(uint) {
if (token == ETH_TOKEN_ADDRESS)
return this.balance;
else {
address wallet = tokenWallet[token];
uint balanceOfWallet = token.balanceOf(wallet);
uint allowanceOfWallet = token.allowance(wallet, this);
return (balanceOfWallet < allowanceOfWallet) ? balanceOfWallet : allowanceOfWallet;
}
}
| 7,813 |
4 | // 0x80ac58cd ===bytes4(keccak256('balanceOf(address)')) ^bytes4(keccak256('ownerOf(uint256)')) ^bytes4(keccak256('approve(address,uint256)')) ^bytes4(keccak256('getApproved(uint256)')) ^bytes4(keccak256('setApprovalForAll(address,bool)')) ^bytes4(keccak256('isApprovedForAll(address,address)')) ^bytes4(keccak256('transferFrom(address,address,uint256)')) ^bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) / |
bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79;
|
bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79;
| 25,735 |
8 | // Check that the goal is a positive number | require(_goal > 0, "The goal must be a positive number");
| require(_goal > 0, "The goal must be a positive number");
| 25,775 |
43 | // If we check and the interest rate is no longer negative then we allow normal 1 to 1 withdraws [even if the speedbump was hit less than 48 hours ago, to prevent possible griefing] | if (holdings < localSupply) {
| if (holdings < localSupply) {
| 5,085 |
50 | // ------------------------------------------------------------------------------------------------ Events ------------------------------------------------------------------------------------------------ |
event LogIncomeReceived(address indexed _sender, uint _paymentAmount);
event LogIncomeCollected(uint _block, address _address, uint _amount);
|
event LogIncomeReceived(address indexed _sender, uint _paymentAmount);
event LogIncomeCollected(uint _block, address _address, uint _amount);
| 17,604 |
2 | // Set deployer as an immutable controller that can update channel statuses. | address private immutable _controller;
| address private immutable _controller;
| 33,409 |
49 | // Accounting storage mapping account addresses to how much COMP they owe the protocol. | mapping(address => uint) public compReceivable;
| mapping(address => uint) public compReceivable;
| 17,064 |
5 | // Canonical NaN value. / | bytes16 private constant NaN = 0x7FFF8000000000000000000000000000;
| bytes16 private constant NaN = 0x7FFF8000000000000000000000000000;
| 23,782 |
3 | // Domain getters - you can also get all Domain data by calling the auto-generated domains(domainName) method | function getDomainHolder(string calldata _domainName) public override view returns(address) {
return domains[strings.lower(_domainName)].holder;
}
| function getDomainHolder(string calldata _domainName) public override view returns(address) {
return domains[strings.lower(_domainName)].holder;
}
| 20,160 |
218 | // Both arrays are ordered:/ | uint[] public probabilities;
uint[] public multipliers;
uint public totalAmountWagered;
event LOG_newSpinsContainer(bytes32 myid, address playerAddress, uint amountWagered, uint nSpins);
event LOG_SpinExecuted(bytes32 myid, address playerAddress, uint spinIndex, uint numberDrawn, uint grossPayoutForSpin);
event LOG_SpinsContainerInfo(bytes32 myid, address playerAddress, uint netPayout);
LedgerProofVerifyI externalContract;
| uint[] public probabilities;
uint[] public multipliers;
uint public totalAmountWagered;
event LOG_newSpinsContainer(bytes32 myid, address playerAddress, uint amountWagered, uint nSpins);
event LOG_SpinExecuted(bytes32 myid, address playerAddress, uint spinIndex, uint numberDrawn, uint grossPayoutForSpin);
event LOG_SpinsContainerInfo(bytes32 myid, address playerAddress, uint netPayout);
LedgerProofVerifyI externalContract;
| 32,718 |
79 | // when buy | if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
| if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
| 30,961 |
80 | // check that contract have enough balance for exchange and protocol fee | require(getBalance(_exData.srcAddr) >= _exData.srcAmount, ERR_SRC_AMOUNT);
require(getBalance(KYBER_ETH_ADDRESS) >= _exData.offchainData.protocolFee, ERR_PROTOCOL_FEE);
ERC20(_exData.srcAddr).safeApprove(_exData.offchainData.allowanceTarget, _exData.srcAmount);
| require(getBalance(_exData.srcAddr) >= _exData.srcAmount, ERR_SRC_AMOUNT);
require(getBalance(KYBER_ETH_ADDRESS) >= _exData.offchainData.protocolFee, ERR_PROTOCOL_FEE);
ERC20(_exData.srcAddr).safeApprove(_exData.offchainData.allowanceTarget, _exData.srcAmount);
| 15,390 |
13 | // ------------------------------------------------------------------------ Complete token sale ------------------------------------------------------------------------ | function setComplete(bool _completed) public {
require(msg.sender == owner);
completed = _completed;
}
| function setComplete(bool _completed) public {
require(msg.sender == owner);
completed = _completed;
}
| 25,495 |
21 | // participants for the daily period | mapping(uint => address[]) participantsDaily;
| mapping(uint => address[]) participantsDaily;
| 36,848 |
27 | // if (for some reason) token is already staked | if (since[tokenId] > 0
| if (since[tokenId] > 0
| 50,544 |
46 | // Tokens for early contributors, should be allocated by function | balances[0] = 62500000e18; // 62.5M
| balances[0] = 62500000e18; // 62.5M
| 20,214 |
36 | // Calculate the amount of tokens now based on inflation rate | uint256 newTokens = _inflationCalculate(intervalsSinceLastMint);
| uint256 newTokens = _inflationCalculate(intervalsSinceLastMint);
| 44,725 |
4 | // shares Number of rewards shares to redeem for VISRto Address to which redeemed pool assets are sentfrom Address from which liquidity tokens are sent return rewards Amount of visr redeemed by the submitted liquidity tokens | function withdraw(
uint256 shares,
address to,
address from
| function withdraw(
uint256 shares,
address to,
address from
| 29,713 |
33 | // Dequeue verified inbound roots and insert them into the aggregator tree. Will dequeue a fixed maximum amount of roots to prevent out of gas errors. As such, thismethod is public and separate from `propagate` so we can curtail an overloaded queue as needed. Reverts if no verified inbound roots are found. return bytes32 The new aggregate root.return uint256 The updated count (number of leaves). / | function dequeue() public whenNotPaused returns (bytes32, uint256) {
// Get all of the verified roots from the queue.
bytes32[] memory _verifiedInboundRoots = pendingInboundRoots.dequeueVerified(delayBlocks, DEQUEUE_MAX);
// If there's nothing dequeued, just return the root and count.
if (_verifiedInboundRoots.length == 0) {
return MERKLE.rootAndCount();
}
// Insert the leaves into the aggregator tree (method will also calculate and return the current
// aggregate root and count).
(bytes32 _aggregateRoot, uint256 _count) = MERKLE.insert(_verifiedInboundRoots);
emit RootsAggregated(_aggregateRoot, _count, _verifiedInboundRoots);
return (_aggregateRoot, _count);
}
| function dequeue() public whenNotPaused returns (bytes32, uint256) {
// Get all of the verified roots from the queue.
bytes32[] memory _verifiedInboundRoots = pendingInboundRoots.dequeueVerified(delayBlocks, DEQUEUE_MAX);
// If there's nothing dequeued, just return the root and count.
if (_verifiedInboundRoots.length == 0) {
return MERKLE.rootAndCount();
}
// Insert the leaves into the aggregator tree (method will also calculate and return the current
// aggregate root and count).
(bytes32 _aggregateRoot, uint256 _count) = MERKLE.insert(_verifiedInboundRoots);
emit RootsAggregated(_aggregateRoot, _count, _verifiedInboundRoots);
return (_aggregateRoot, _count);
}
| 38,267 |
0 | // Emitted when `tokenId` token is transferred from `from` to `to`./ | event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
| event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
| 15,628 |
32 | // Make sure there aren't already (or will be) too many swap tokens | require((ERC20(swap_token_address).balanceOf(address(this)) + token_amount) <= swap_token_cap[swap_token_address], "Swap token cap reached");
| require((ERC20(swap_token_address).balanceOf(address(this)) + token_amount) <= swap_token_cap[swap_token_address], "Swap token cap reached");
| 9,955 |
422 | // Gets current Balance of token i, Bi, and weight of token i, Wi, from BPool. | uint256 tokenBalance = bPool.getBalance(erc20);
uint256 tokenWeight = bPool.getDenormalizedWeight(erc20);
bool xfer = IERC20(erc20).transferFrom(from, address(this), amount);
require(xfer, "ERR_ERC20_FALSE");
bPool.rebind(
erc20,
BalancerSafeMath.badd(tokenBalance, amount),
tokenWeight
);
| uint256 tokenBalance = bPool.getBalance(erc20);
uint256 tokenWeight = bPool.getDenormalizedWeight(erc20);
bool xfer = IERC20(erc20).transferFrom(from, address(this), amount);
require(xfer, "ERR_ERC20_FALSE");
bPool.rebind(
erc20,
BalancerSafeMath.badd(tokenBalance, amount),
tokenWeight
);
| 16,274 |
31 | // ClaimsProxy dYdXContract which claims DYDX rewards from multiple contracts on behalf of a user.Requires the following permissions: - Set as the CLAIMS_PROXY on the SafetyModuleV1 contract. - Has role CLAIM_OPERATOR_ROLE on the LiquidityStakingV1 contract. - Has role CLAIM_OPERATOR_ROLE on the MerkleDistributorV1 contract. / | contract ClaimsProxy {
using SafeMath for uint256;
// ============ Constants ============
ISafetyModuleV1 public immutable SAFETY_MODULE;
ILiquidityStakingV1 public immutable LIQUIDITY_STAKING;
IMerkleDistributorV1 public immutable MERKLE_DISTRIBUTOR;
ITreasuryVester public immutable REWARDS_TREASURY_VESTER;
// ============ Constructor ============
constructor(
ISafetyModuleV1 safetyModule,
ILiquidityStakingV1 liquidityStaking,
IMerkleDistributorV1 merkleDistributor,
ITreasuryVester rewardsTreasuryVester
) {
SAFETY_MODULE = safetyModule;
LIQUIDITY_STAKING = liquidityStaking;
MERKLE_DISTRIBUTOR = merkleDistributor;
REWARDS_TREASURY_VESTER = rewardsTreasuryVester;
}
// ============ External Functions ============
/**
* @notice Claim rewards from zero or more rewards contracts. All rewards are sent directly to
* the sender's address.
*
* @param claimSafetyRewards Whether or not to claim rewards from SafetyModuleV1.
* @param claimLiquidityRewards Whether or not to claim rewards from LiquidityStakingV1.
* @param merkleCumulativeAmount The cumulative rewards amount for the user in the
* MerkleDistributorV1 rewards Merkle tree, or zero to skip
* claiming from this contract.
* @param merkleProof The Merkle proof for the user's cumulative rewards.
* @param vestFromTreasuryVester Whether or not to vest rewards from the rewards treasury
* vester to the rewards treasury (e.g. set to true if rewards
* treasury has insufficient funds for users, and false otherwise).
*
* @return The total number of rewards claimed.
*/
function claimRewards(
bool claimSafetyRewards,
bool claimLiquidityRewards,
uint256 merkleCumulativeAmount,
bytes32[] calldata merkleProof,
bool vestFromTreasuryVester
)
external
returns (uint256)
{
if (vestFromTreasuryVester) {
// call rewards treasury vester so that rewards treasury has sufficient rewards
REWARDS_TREASURY_VESTER.claim();
}
address user = msg.sender;
uint256 amount1 = 0;
uint256 amount2 = 0;
uint256 amount3 = 0;
if (claimSafetyRewards) {
amount1 = SAFETY_MODULE.claimRewardsFor(user, user);
}
if (claimLiquidityRewards) {
amount2 = LIQUIDITY_STAKING.claimRewardsFor(user, user);
}
if (merkleCumulativeAmount != 0) {
amount3 = MERKLE_DISTRIBUTOR.claimRewardsFor(user, merkleCumulativeAmount, merkleProof);
}
return amount1.add(amount2).add(amount3);
}
}
| contract ClaimsProxy {
using SafeMath for uint256;
// ============ Constants ============
ISafetyModuleV1 public immutable SAFETY_MODULE;
ILiquidityStakingV1 public immutable LIQUIDITY_STAKING;
IMerkleDistributorV1 public immutable MERKLE_DISTRIBUTOR;
ITreasuryVester public immutable REWARDS_TREASURY_VESTER;
// ============ Constructor ============
constructor(
ISafetyModuleV1 safetyModule,
ILiquidityStakingV1 liquidityStaking,
IMerkleDistributorV1 merkleDistributor,
ITreasuryVester rewardsTreasuryVester
) {
SAFETY_MODULE = safetyModule;
LIQUIDITY_STAKING = liquidityStaking;
MERKLE_DISTRIBUTOR = merkleDistributor;
REWARDS_TREASURY_VESTER = rewardsTreasuryVester;
}
// ============ External Functions ============
/**
* @notice Claim rewards from zero or more rewards contracts. All rewards are sent directly to
* the sender's address.
*
* @param claimSafetyRewards Whether or not to claim rewards from SafetyModuleV1.
* @param claimLiquidityRewards Whether or not to claim rewards from LiquidityStakingV1.
* @param merkleCumulativeAmount The cumulative rewards amount for the user in the
* MerkleDistributorV1 rewards Merkle tree, or zero to skip
* claiming from this contract.
* @param merkleProof The Merkle proof for the user's cumulative rewards.
* @param vestFromTreasuryVester Whether or not to vest rewards from the rewards treasury
* vester to the rewards treasury (e.g. set to true if rewards
* treasury has insufficient funds for users, and false otherwise).
*
* @return The total number of rewards claimed.
*/
function claimRewards(
bool claimSafetyRewards,
bool claimLiquidityRewards,
uint256 merkleCumulativeAmount,
bytes32[] calldata merkleProof,
bool vestFromTreasuryVester
)
external
returns (uint256)
{
if (vestFromTreasuryVester) {
// call rewards treasury vester so that rewards treasury has sufficient rewards
REWARDS_TREASURY_VESTER.claim();
}
address user = msg.sender;
uint256 amount1 = 0;
uint256 amount2 = 0;
uint256 amount3 = 0;
if (claimSafetyRewards) {
amount1 = SAFETY_MODULE.claimRewardsFor(user, user);
}
if (claimLiquidityRewards) {
amount2 = LIQUIDITY_STAKING.claimRewardsFor(user, user);
}
if (merkleCumulativeAmount != 0) {
amount3 = MERKLE_DISTRIBUTOR.claimRewardsFor(user, merkleCumulativeAmount, merkleProof);
}
return amount1.add(amount2).add(amount3);
}
}
| 12,661 |
20 | // get lock id | bytes32 lockID = calculateLockID(msg.sender, token);
| bytes32 lockID = calculateLockID(msg.sender, token);
| 28,555 |
207 | // Claim one teji with whitelist proof./signature Whitelist proof signature. | function claimWhitelist(bytes memory signature) external {
require(_currentIndex < 1000, "Tejiverse: max supply exceeded");
require(saleState == 1, "Tejiverse: whitelist sale is not open");
require(!_boughtPresale[msg.sender], "Tejiverse: already claimed");
bytes32 digest = keccak256(abi.encodePacked(address(this), msg.sender));
require(digest.toEthSignedMessageHash().recover(signature) == signer, "Tejiverse: invalid signature");
_boughtPresale[msg.sender] = true;
_safeMint(msg.sender, 1);
}
| function claimWhitelist(bytes memory signature) external {
require(_currentIndex < 1000, "Tejiverse: max supply exceeded");
require(saleState == 1, "Tejiverse: whitelist sale is not open");
require(!_boughtPresale[msg.sender], "Tejiverse: already claimed");
bytes32 digest = keccak256(abi.encodePacked(address(this), msg.sender));
require(digest.toEthSignedMessageHash().recover(signature) == signer, "Tejiverse: invalid signature");
_boughtPresale[msg.sender] = true;
_safeMint(msg.sender, 1);
}
| 20,852 |
6 | // ``` TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as | * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
| * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
| 7,626 |
12 | // Calculate xy rounding down, where x is signed 64.64 fixed point numberand y is unsigned 256-bit integer number.Revert on overflow.x signed 64.64 fixed point number y unsigned 256-bit integer numberreturn unsigned 256-bit integer number / | function mulu (int128 x, uint256 y) internal pure returns (uint256) {
if (y == 0) return 0;
require (x >= 0);
uint256 lo = (uint256 (x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
uint256 hi = uint256 (x) * (y >> 128);
require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
hi <<= 64;
require (hi <=
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);
return hi + lo;
}
| function mulu (int128 x, uint256 y) internal pure returns (uint256) {
if (y == 0) return 0;
require (x >= 0);
uint256 lo = (uint256 (x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
uint256 hi = uint256 (x) * (y >> 128);
require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
hi <<= 64;
require (hi <=
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);
return hi + lo;
}
| 24,277 |
6 | // error//variable//validator/ | modifier validArea(uint256 _area) {
require(_area == 0 || _area == 1, AREA_IS_NOT_VALID);
_;
}
| modifier validArea(uint256 _area) {
require(_area == 0 || _area == 1, AREA_IS_NOT_VALID);
_;
}
| 45,440 |
2 | // Withdraw wrapped ether to get ether | function withdraw(uint256) external;
| function withdraw(uint256) external;
| 19,389 |
2 | // When a case is created then the escrow is created. If the sender confirms or the handlerconfirms then the escrow is released. escrowId id of the escrow partyA The address that will receive the money if the escrow is released partyB The address of the person who sent the money partyArbitrator The address of the person who is handling the case closed Whether the escrow has been closed description The text describing what the escrow is determineTime The time the escrow can be judged. This is optional if set to 0. pendingAssetB The assets to be deposited by partyB / | struct EscrowVault {
uint256 escrowId;
address partyA;
address partyB;
uint256 nftA;
uint256 nftB;
address partyArbitrator;
uint256 arbitratorFeeBps;
string description;
uint256 createTime;
uint256 determineTime;
bool started;
bool closed;
DepositAsset pendingAssetB;
address winner;
}
| struct EscrowVault {
uint256 escrowId;
address partyA;
address partyB;
uint256 nftA;
uint256 nftB;
address partyArbitrator;
uint256 arbitratorFeeBps;
string description;
uint256 createTime;
uint256 determineTime;
bool started;
bool closed;
DepositAsset pendingAssetB;
address winner;
}
| 9,016 |
192 | // Remove the pair's channel counter | pair_hash = getParticipantsHash(participant1, participant2);
delete participants_hash_to_channel_identifier[pair_hash];
| pair_hash = getParticipantsHash(participant1, participant2);
delete participants_hash_to_channel_identifier[pair_hash];
| 27,827 |
145 | // never overflows, and + overflow is desired | TWAPObservationHistory.push(
TWAPObservation(
blockTimestamp,
price0CumulativeLast() + uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed,
price1CumulativeLast() + uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed
)
);
| TWAPObservationHistory.push(
TWAPObservation(
blockTimestamp,
price0CumulativeLast() + uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed,
price1CumulativeLast() + uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed
)
);
| 26,551 |
303 | // Reads an immutable arg with type uint64/argOffset The offset of the arg in the packed data/ return arg The arg value | function _getArgUint64(uint256 argOffset) internal pure returns (uint64 arg) {
uint256 offset = _getImmutableArgsOffset();
// solhint-disable-next-line no-inline-assembly
assembly {
arg := shr(0xc0, calldataload(add(offset, argOffset)))
}
}
| function _getArgUint64(uint256 argOffset) internal pure returns (uint64 arg) {
uint256 offset = _getImmutableArgsOffset();
// solhint-disable-next-line no-inline-assembly
assembly {
arg := shr(0xc0, calldataload(add(offset, argOffset)))
}
}
| 60,148 |
13 | // Executes the swap returning the amountIn needed to spend to receive the desired amountOut. | amountIn = swapRouter.exactOutputSingle(params);
| amountIn = swapRouter.exactOutputSingle(params);
| 14,532 |
178 | // Update reward variables for all pools. Be careful of gas spending! | function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
| function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
| 2,588 |
22 | // ICO starting and ending blocks, can be changed as needed | uint256 public icoStartBlock;
| uint256 public icoStartBlock;
| 39,696 |
15 | // function to submit a new proposal / | function propose(bytes32 key, uint value, bytes32 offchain) public {
Proposal memory p;
p.key = key;
p.value = value;
p.deadline = now + params["votingWindow"];
p.status = 1;
proposals.push(p);
emit __propose(proposals.length - 1, offchain);
}
| function propose(bytes32 key, uint value, bytes32 offchain) public {
Proposal memory p;
p.key = key;
p.value = value;
p.deadline = now + params["votingWindow"];
p.status = 1;
proposals.push(p);
emit __propose(proposals.length - 1, offchain);
}
| 32,226 |
480 | // Create a new DAOFactory, creating DAOs with Kernels proxied to `_baseKernel`, ACLs proxied to `_baseACL`, and new EVMScriptRegistries created from `_regFactory`._baseKernel Base Kernel_baseACL Base ACL_regFactory EVMScriptRegistry factory/ | constructor(IKernel _baseKernel, IACL _baseACL, EVMScriptRegistryFactory _regFactory) public {
// No need to init as it cannot be killed by devops199
if (address(_regFactory) != address(0)) {
regFactory = _regFactory;
}
baseKernel = _baseKernel;
baseACL = _baseACL;
}
| constructor(IKernel _baseKernel, IACL _baseACL, EVMScriptRegistryFactory _regFactory) public {
// No need to init as it cannot be killed by devops199
if (address(_regFactory) != address(0)) {
regFactory = _regFactory;
}
baseKernel = _baseKernel;
baseACL = _baseACL;
}
| 49,129 |
130 | // Makes the contract active | isActive = true;
| isActive = true;
| 11,088 |
182 | // Mapping from positionId -> uint256, which stores the total amount of owedToken that has ever been repaid to the lender for each position. Does not reset. | mapping (bytes32 => uint256) totalOwedTokenRepaidToLender;
| mapping (bytes32 => uint256) totalOwedTokenRepaidToLender;
| 35,135 |
108 | // | * @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping(address => bool) public feeExcludedAddress;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (uint256 => bool) public isAirdroped;
mapping (uint256 => uint256) lastReward;
uint256 private _totalSupply;
// Daily Rewards Distributions Start from
uint256 private rewardStartDate;
bool public dailyReward = false;
uint256 public rewardAmount = 2 ether;
// ends in a month;
uint256 public airdropEndDate = 1634991797;
string private _name;
string private _symbol;
uint private _decimals = 18;
uint private _lockTime;
address public _Owner;
address public _previousOwner;
address public _fundAddress;
address public liquidityPair;
uint public teamFee = 500; //0.2% divisor 100
bool public sellLimiter; //by default false
uint public sellLimit = 50000 * 10 ** 18; //sell limit if sellLimiter is true
IHorse public horseContract;
uint256 public _maxTxAmount = 5000000 * 10**18;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event airdropClaimed(uint256 tokenID, address tokenOwner);
event claimedDailyReward(uint256 tokenID, address claimer, uint256 timestamp);
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory _nm, string memory _sym, IHorse _horseContract) public {
_name = _nm;
_symbol = _sym;
_Owner = msg.sender;
rewardStartDate = block.timestamp;
horseContract = _horseContract;
feeExcludedAddress[msg.sender] = true;
_fundAddress = address(0xA25D6e6E02D1fD7A886b83A906c91cde7eD8DdFC);
}
modifier onlyOwner{
require(msg.sender == _Owner, 'Only Owner Can Call This Function');
_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function calculateTeamFee(uint256 _amount) internal view returns (uint256) {
return _amount.mul(teamFee).div(
10**4
);
}
function setTeamFee(uint Tfee) public onlyOwner{
require(Tfee < 1500," Fee can't exceed to 15%");
teamFee = Tfee;
}
function toggleSellLimit() external onlyOwner() {
sellLimiter = !sellLimiter;
}
function stopReward() external onlyOwner() {
require(dailyReward, "Daily Reward Already Stopped");
dailyReward = false;
}
function startReward() public onlyOwner{
require(!dailyReward, "Daily Reward Already Running");
dailyReward = true;
rewardStartDate = block.timestamp;
}
function changeRewardAmount(uint256 _amount) public onlyOwner{
rewardAmount = _amount;
}
function setLiquidityPairAddress(address liquidityPairAddress) public onlyOwner{
liquidityPair = liquidityPairAddress;
}
function changeSellLimit(uint256 _sellLimit) public onlyOwner{
sellLimit = _sellLimit;
}
function changeMaxtx(uint256 _maxtx) public onlyOwner{
_maxTxAmount = _maxtx;
}
function changeFundAddress(address Taddress) public onlyOwner{
_fundAddress = Taddress;
}
function changeAirdropEndDate(uint256 endDate) public onlyOwner{
require(endDate > block.timestamp,"End Date must be a future timestamp");
airdropEndDate = endDate;
}
function addExcludedAddress(address excludedA) public onlyOwner{
feeExcludedAddress[excludedA] = true;
}
function removeExcludedAddress(address excludedA) public onlyOwner{
feeExcludedAddress[excludedA] = false;
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_Owner, newOwner);
_Owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _Owner;
_Owner = address(0);
_lockTime = block.timestamp + time;
emit OwnershipTransferred(_Owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(block.timestamp > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_Owner, _previousOwner);
_Owner = _previousOwner;
}
function multiTransfer(address[] memory receivers, uint256[] memory amounts) public {
require(receivers.length != 0, 'Cannot Proccess Null Transaction');
require(receivers.length == amounts.length, 'Address and Amount array length must be same');
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
}
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
if(feeExcludedAddress[recipient] || feeExcludedAddress[_msgSender()]){
_transferExcluded(_msgSender(), recipient, amount);
}else{
_transfer(_msgSender(), recipient, amount);
}
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
if(feeExcludedAddress[recipient] || feeExcludedAddress[sender]){
_transferExcluded(sender, recipient, amount);
}else{
_transfer(sender, recipient, amount);
}
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transferExcluded(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if(sender != _Owner && recipient != _Owner)
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if(recipient == liquidityPair && balanceOf(liquidityPair) > 0 && sellLimiter){
require(amount < sellLimit, 'Cannot sell more than sellLimit');
}
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if(sender != _Owner && recipient != _Owner)
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if(recipient == liquidityPair && balanceOf(liquidityPair) > 0 && sellLimiter){
require(amount < sellLimit, 'Cannot sell more than sellLimit');
}
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
uint256 tokenToTransfer = amount.sub(calculateTeamFee(amount));
_balances[recipient] += tokenToTransfer;
_balances[_fundAddress] += calculateTeamFee(amount);
emit Transfer(sender, recipient, tokenToTransfer);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function addSupply(uint256 amount) public onlyOwner{
_mint(msg.sender, amount);
}
function claimAirdrop(uint256 tokenID) public {
require(airdropEndDate > block.timestamp, "Airdrop is ended");
require(horseContract.ownerOf(tokenID) == msg.sender, "You aren't own this NFT token");
require(!isAirdroped[tokenID],"This token ID already claimed airdrop");
_mint(msg.sender, 1000 ether);
isAirdroped[tokenID] = true;
emit airdropClaimed(tokenID, msg.sender);
}
function bulkClaimAirdrop(uint256[] memory tokenIDs) public {
require(airdropEndDate > block.timestamp, "Airdrop is ended");
for (uint256 i = 0; i < tokenIDs.length; i++) {
require(horseContract.ownerOf(tokenIDs[i]) == msg.sender, "You aren't own this NFT token");
require(!isAirdroped[tokenIDs[i]],"This token ID already claimed airdrop");
_mint(msg.sender, 1000 ether);
isAirdroped[tokenIDs[i]] = true;
emit airdropClaimed(tokenIDs[i], msg.sender);
}
}
function checkDailyReward(uint256 tokenID) public view returns (uint256){
uint256 lastdate = (lastReward[tokenID] > rewardStartDate) ? lastReward[tokenID] : rewardStartDate;
uint256 rewardDays = (block.timestamp - lastdate).div(1 days);
return rewardDays.mul(rewardAmount);
}
function claimDailyReward(uint256 tokenID) public {
require(dailyReward," Daily Rewards Are Stopped ");
require(horseContract.ownerOf(tokenID) == msg.sender, "You aren't own this NFT token");
require(checkDailyReward(tokenID) > 0, "There is no claimable reward");
_mint(msg.sender, checkDailyReward(tokenID));
lastReward[tokenID] = block.timestamp;
emit claimedDailyReward(tokenID, msg.sender, block.timestamp);
}
function bulkClaimRewards(uint256[] memory tokenIDs) public {
require(dailyReward," Daily Rewards Are Stopped ");
uint256 total;
for (uint256 i = 0; i < tokenIDs.length; i++) {
require(horseContract.ownerOf(tokenIDs[i]) == msg.sender, "You aren't own this NFT token");
total += checkDailyReward(tokenIDs[i]);
if(checkDailyReward(tokenIDs[i]) > 0){
lastReward[tokenIDs[i]] = block.timestamp;
}
}
require(total > 0, "There is no claimable reward");
_mint(msg.sender, total);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(uint256 amount) public virtual {
require(_balances[msg.sender] >= amount,'insufficient balance!');
_beforeTokenTransfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
| * @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping(address => bool) public feeExcludedAddress;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (uint256 => bool) public isAirdroped;
mapping (uint256 => uint256) lastReward;
uint256 private _totalSupply;
// Daily Rewards Distributions Start from
uint256 private rewardStartDate;
bool public dailyReward = false;
uint256 public rewardAmount = 2 ether;
// ends in a month;
uint256 public airdropEndDate = 1634991797;
string private _name;
string private _symbol;
uint private _decimals = 18;
uint private _lockTime;
address public _Owner;
address public _previousOwner;
address public _fundAddress;
address public liquidityPair;
uint public teamFee = 500; //0.2% divisor 100
bool public sellLimiter; //by default false
uint public sellLimit = 50000 * 10 ** 18; //sell limit if sellLimiter is true
IHorse public horseContract;
uint256 public _maxTxAmount = 5000000 * 10**18;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event airdropClaimed(uint256 tokenID, address tokenOwner);
event claimedDailyReward(uint256 tokenID, address claimer, uint256 timestamp);
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory _nm, string memory _sym, IHorse _horseContract) public {
_name = _nm;
_symbol = _sym;
_Owner = msg.sender;
rewardStartDate = block.timestamp;
horseContract = _horseContract;
feeExcludedAddress[msg.sender] = true;
_fundAddress = address(0xA25D6e6E02D1fD7A886b83A906c91cde7eD8DdFC);
}
modifier onlyOwner{
require(msg.sender == _Owner, 'Only Owner Can Call This Function');
_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function calculateTeamFee(uint256 _amount) internal view returns (uint256) {
return _amount.mul(teamFee).div(
10**4
);
}
function setTeamFee(uint Tfee) public onlyOwner{
require(Tfee < 1500," Fee can't exceed to 15%");
teamFee = Tfee;
}
function toggleSellLimit() external onlyOwner() {
sellLimiter = !sellLimiter;
}
function stopReward() external onlyOwner() {
require(dailyReward, "Daily Reward Already Stopped");
dailyReward = false;
}
function startReward() public onlyOwner{
require(!dailyReward, "Daily Reward Already Running");
dailyReward = true;
rewardStartDate = block.timestamp;
}
function changeRewardAmount(uint256 _amount) public onlyOwner{
rewardAmount = _amount;
}
function setLiquidityPairAddress(address liquidityPairAddress) public onlyOwner{
liquidityPair = liquidityPairAddress;
}
function changeSellLimit(uint256 _sellLimit) public onlyOwner{
sellLimit = _sellLimit;
}
function changeMaxtx(uint256 _maxtx) public onlyOwner{
_maxTxAmount = _maxtx;
}
function changeFundAddress(address Taddress) public onlyOwner{
_fundAddress = Taddress;
}
function changeAirdropEndDate(uint256 endDate) public onlyOwner{
require(endDate > block.timestamp,"End Date must be a future timestamp");
airdropEndDate = endDate;
}
function addExcludedAddress(address excludedA) public onlyOwner{
feeExcludedAddress[excludedA] = true;
}
function removeExcludedAddress(address excludedA) public onlyOwner{
feeExcludedAddress[excludedA] = false;
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_Owner, newOwner);
_Owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _Owner;
_Owner = address(0);
_lockTime = block.timestamp + time;
emit OwnershipTransferred(_Owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(block.timestamp > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_Owner, _previousOwner);
_Owner = _previousOwner;
}
function multiTransfer(address[] memory receivers, uint256[] memory amounts) public {
require(receivers.length != 0, 'Cannot Proccess Null Transaction');
require(receivers.length == amounts.length, 'Address and Amount array length must be same');
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
}
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
if(feeExcludedAddress[recipient] || feeExcludedAddress[_msgSender()]){
_transferExcluded(_msgSender(), recipient, amount);
}else{
_transfer(_msgSender(), recipient, amount);
}
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
if(feeExcludedAddress[recipient] || feeExcludedAddress[sender]){
_transferExcluded(sender, recipient, amount);
}else{
_transfer(sender, recipient, amount);
}
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transferExcluded(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if(sender != _Owner && recipient != _Owner)
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if(recipient == liquidityPair && balanceOf(liquidityPair) > 0 && sellLimiter){
require(amount < sellLimit, 'Cannot sell more than sellLimit');
}
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if(sender != _Owner && recipient != _Owner)
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if(recipient == liquidityPair && balanceOf(liquidityPair) > 0 && sellLimiter){
require(amount < sellLimit, 'Cannot sell more than sellLimit');
}
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
uint256 tokenToTransfer = amount.sub(calculateTeamFee(amount));
_balances[recipient] += tokenToTransfer;
_balances[_fundAddress] += calculateTeamFee(amount);
emit Transfer(sender, recipient, tokenToTransfer);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function addSupply(uint256 amount) public onlyOwner{
_mint(msg.sender, amount);
}
function claimAirdrop(uint256 tokenID) public {
require(airdropEndDate > block.timestamp, "Airdrop is ended");
require(horseContract.ownerOf(tokenID) == msg.sender, "You aren't own this NFT token");
require(!isAirdroped[tokenID],"This token ID already claimed airdrop");
_mint(msg.sender, 1000 ether);
isAirdroped[tokenID] = true;
emit airdropClaimed(tokenID, msg.sender);
}
function bulkClaimAirdrop(uint256[] memory tokenIDs) public {
require(airdropEndDate > block.timestamp, "Airdrop is ended");
for (uint256 i = 0; i < tokenIDs.length; i++) {
require(horseContract.ownerOf(tokenIDs[i]) == msg.sender, "You aren't own this NFT token");
require(!isAirdroped[tokenIDs[i]],"This token ID already claimed airdrop");
_mint(msg.sender, 1000 ether);
isAirdroped[tokenIDs[i]] = true;
emit airdropClaimed(tokenIDs[i], msg.sender);
}
}
function checkDailyReward(uint256 tokenID) public view returns (uint256){
uint256 lastdate = (lastReward[tokenID] > rewardStartDate) ? lastReward[tokenID] : rewardStartDate;
uint256 rewardDays = (block.timestamp - lastdate).div(1 days);
return rewardDays.mul(rewardAmount);
}
function claimDailyReward(uint256 tokenID) public {
require(dailyReward," Daily Rewards Are Stopped ");
require(horseContract.ownerOf(tokenID) == msg.sender, "You aren't own this NFT token");
require(checkDailyReward(tokenID) > 0, "There is no claimable reward");
_mint(msg.sender, checkDailyReward(tokenID));
lastReward[tokenID] = block.timestamp;
emit claimedDailyReward(tokenID, msg.sender, block.timestamp);
}
function bulkClaimRewards(uint256[] memory tokenIDs) public {
require(dailyReward," Daily Rewards Are Stopped ");
uint256 total;
for (uint256 i = 0; i < tokenIDs.length; i++) {
require(horseContract.ownerOf(tokenIDs[i]) == msg.sender, "You aren't own this NFT token");
total += checkDailyReward(tokenIDs[i]);
if(checkDailyReward(tokenIDs[i]) > 0){
lastReward[tokenIDs[i]] = block.timestamp;
}
}
require(total > 0, "There is no claimable reward");
_mint(msg.sender, total);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(uint256 amount) public virtual {
require(_balances[msg.sender] >= amount,'insufficient balance!');
_beforeTokenTransfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
| 31,051 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.