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 |
|---|---|---|---|---|
1 | // Grants `DEFAULT_ADMIN_ROLE` to theaccount that deploys the contract. | * See {ERC20-constructor}.
*/
constructor(uint256 initialSupply)
public
ERC20("Digital Antares Dollar", "dANT")
AccessControl()
{
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_mint(_msgSender(), initialSupply * 10**18);
}
| * See {ERC20-constructor}.
*/
constructor(uint256 initialSupply)
public
ERC20("Digital Antares Dollar", "dANT")
AccessControl()
{
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_mint(_msgSender(), initialSupply * 10**18);
}
| 2,394 |
10 | // when receiving an item from the authorised collection | function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) public override returns (bytes4) {
require(msg.sender == collectionContractAddress, "Can only accept correct collection");
require(address(this).balance >= floorPrice, "Not enough funds available");
ownedTokenIDs[tokenId] = true;
emit NFTReceived(tx.origin);
payable(tx.origin).transfer(floorPrice);
return IERC721Receiver.onERC721Received.selector;
}
| function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) public override returns (bytes4) {
require(msg.sender == collectionContractAddress, "Can only accept correct collection");
require(address(this).balance >= floorPrice, "Not enough funds available");
ownedTokenIDs[tokenId] = true;
emit NFTReceived(tx.origin);
payable(tx.origin).transfer(floorPrice);
return IERC721Receiver.onERC721Received.selector;
}
| 19,598 |
284 | // Get a particular schedule entry for an account.return A pair of uints: (timestamp, synthetix quantity). / | function getVestingScheduleEntry(address account, uint index)
public
view
returns (uint[2])
| function getVestingScheduleEntry(address account, uint index)
public
view
returns (uint[2])
| 33,234 |
4 | // basic checks of matching orders against each other / | function checkOrdersInfo(
Order memory buyOrder,
Order memory sellOrder,
address sender,
uint256 filledAmount,
uint256 filledPrice,
uint256 currentTime,
address allowedMatcher
| function checkOrdersInfo(
Order memory buyOrder,
Order memory sellOrder,
address sender,
uint256 filledAmount,
uint256 filledPrice,
uint256 currentTime,
address allowedMatcher
| 23,161 |
34 | // Migrates the bridge contract to another. Tokens in this contract will be transferred to the new contract. The new bridge contract should use the data stored in `store`. bridgeAddress Address of the new contract / | function migrateBridge(address bridgeAddress) external onlyOwner {
// check zero
if (bridgeAddress == address(0)) {
_revert(ZeroAddress.selector);
}
// check paused
if (!depositPaused || !claimPaused) {
_revert(NotPaused.selector);
}
HELLO_TOKEN.transfer(bridgeAddress, HELLO_TOKEN.balanceOf(address(this)));
}
| function migrateBridge(address bridgeAddress) external onlyOwner {
// check zero
if (bridgeAddress == address(0)) {
_revert(ZeroAddress.selector);
}
// check paused
if (!depositPaused || !claimPaused) {
_revert(NotPaused.selector);
}
HELLO_TOKEN.transfer(bridgeAddress, HELLO_TOKEN.balanceOf(address(this)));
}
| 18,496 |
0 | // Data types and variables / |
uint constant public MAX_OWNER_COUNT = 10;
event Confirmation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event NotEnoughBalance(uint curBalance, uint requestedBalance);
|
uint constant public MAX_OWNER_COUNT = 10;
event Confirmation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event NotEnoughBalance(uint curBalance, uint requestedBalance);
| 23,970 |
11 | // Pre-sale minting cannot happen until the designated time. | require(isPreSaleOpen == true, "presale is not open");
| require(isPreSaleOpen == true, "presale is not open");
| 17,824 |
212 | // Track sender registered for current drop |
lastDropRegistered[msg.sender] = currentDropIndex;
|
lastDropRegistered[msg.sender] = currentDropIndex;
| 1,198 |
433 | // Read Contract | function getProjectDisabled(uint _projectId) external view returns (bool) {
Project storage _project = projects[_projectId];
return _project.disabled;
}
| function getProjectDisabled(uint _projectId) external view returns (bool) {
Project storage _project = projects[_projectId];
return _project.disabled;
}
| 17,629 |
9 | // If true, this address can only transfer tokens to allowlisted addresses and not receive from anyone. / | function isForbidden(address account) public view returns (bool){
return hasFlagInternal(account, FLAG_INDEX_FORBIDDEN);
}
| function isForbidden(address account) public view returns (bool){
return hasFlagInternal(account, FLAG_INDEX_FORBIDDEN);
}
| 11,463 |
8 | // The id of the chain where this coin was deployed | uint256 public chainId;
| uint256 public chainId;
| 12,031 |
58 | // return The token users receive as they unstake. / | function getDistributionToken() public view returns (IERC20) {
assert(_unlockedPool.token() == _lockedPool.token());
return _unlockedPool.token();
}
| function getDistributionToken() public view returns (IERC20) {
assert(_unlockedPool.token() == _lockedPool.token());
return _unlockedPool.token();
}
| 27,987 |
10 | // uint tokenAmount = IERC20(token).balanceOf(address(this)); selladdress[] memory reversePath = new address[](2);reversePath[0] = token;reversePath[1] = uniswapRouter.WETH();IERC20(token).approve(address(this), tokenAmount);uint amountOutMin = 123;tolleranceapproveIfNotAllowed(token, 115792089237316195423570985008687907853269984665640564039457584007913129639935);uniswapRouter.swapExactTokensForETH(tokenAmount, amountOutMin, reversePath, msg.sender, deadline);msg.sender.transfer(address(this).balance); | }
| }
| 10,648 |
10 | // Requests by users for withdrawals. | mapping(address => WithdrawRequest) public withdrawRequests;
| mapping(address => WithdrawRequest) public withdrawRequests;
| 39,178 |
1 | // keeps track of the contract administrator | address public administrator;
| address public administrator;
| 43,287 |
72 | // number of proof stored in the contract / | function proofLength(address _holder) public view returns (uint256) {
return proofLengths[_holder];
}
| function proofLength(address _holder) public view returns (uint256) {
return proofLengths[_holder];
}
| 29,610 |
429 | // uint for use with SafeMath | uint internal _10_MILLION = 1e25; // 1e7 * 1e18 = 1e25
uint internal immutable deploymentStartTime;
address public immutable multisigAddress;
mapping(address => bool) public communityIssuanceAddresses;
uint internal immutable lpRewardsEntitlement;
| uint internal _10_MILLION = 1e25; // 1e7 * 1e18 = 1e25
uint internal immutable deploymentStartTime;
address public immutable multisigAddress;
mapping(address => bool) public communityIssuanceAddresses;
uint internal immutable lpRewardsEntitlement;
| 23,419 |
5 | // if goal is in eth | if(isEth){
IUniswapV2Router(UNISWAP_V2_ROUTER).swapExactTokensForETHSupportingFeeOnTransferTokens(_amountIn, _amountOutMin, path, payable(_to), block.timestamp);
}
| if(isEth){
IUniswapV2Router(UNISWAP_V2_ROUTER).swapExactTokensForETHSupportingFeeOnTransferTokens(_amountIn, _amountOutMin, path, payable(_to), block.timestamp);
}
| 12,661 |
116 | // |/ Enable or disable approval for a third party ("operator") to manage all of caller's tokens _operatorAddress to add to the set of authorized operators _approvedTrue if the operator is approved, false to revoke approval / | function setApprovalForAll(address _operator, bool _approved) external {
require(
msg.sender != _operator,
"ERC1155: setting approval status for self"
);
// Update operator status
operators[msg.sender][_operator] = _approved;
emit ApprovalForAll(msg.sender, _operator, _approved);
}
| function setApprovalForAll(address _operator, bool _approved) external {
require(
msg.sender != _operator,
"ERC1155: setting approval status for self"
);
// Update operator status
operators[msg.sender][_operator] = _approved;
emit ApprovalForAll(msg.sender, _operator, _approved);
}
| 8,105 |
13 | // generate cells | rowpepenBytes = abi.encodePacked(rowpepenBytes, abi.encodePacked(
generateCells(currentRowpepen.boredGame, currentRowpepen.gameplayMode)
));
| rowpepenBytes = abi.encodePacked(rowpepenBytes, abi.encodePacked(
generateCells(currentRowpepen.boredGame, currentRowpepen.gameplayMode)
));
| 22,522 |
362 | // Cannot claim earnings for more than maxEarningsClaimsRounds before LIP-36 This is a number to cause transactions to fail early if we know they will require too much gas to loop through all the necessary rounds to claim earnings The user should instead manually invoke `claimEarnings` to split up the claiming process across multiple transactions | uint256 endLoopRound = _endRound <= lip36Round ? _endRound : lip36Round;
require(endLoopRound.sub(_lastClaimRound) <= maxEarningsClaimsRounds, "too many rounds to claim through");
| uint256 endLoopRound = _endRound <= lip36Round ? _endRound : lip36Round;
require(endLoopRound.sub(_lastClaimRound) <= maxEarningsClaimsRounds, "too many rounds to claim through");
| 23,776 |
135 | // Returns the amount of the given consumable that is required. / | function amountRequired(IConsumable consumable) external view returns (uint256);
| function amountRequired(IConsumable consumable) external view returns (uint256);
| 27,956 |
13 | // Initialize _rewardPerBlock reward per block (in USDC) _startBlock start block _endBlock end block / | function initialize(
uint256 _rewardPerBlock,
uint256 _startBlock,
uint256 _endBlock
| function initialize(
uint256 _rewardPerBlock,
uint256 _startBlock,
uint256 _endBlock
| 31,564 |
57 | // Gets current bonus system./ | function getCurrentBonusSystem() public constant returns (BonusSystem) {
for (uint i = 0; i < bonus.length; i++) {
if (bonus[i].start <= now && bonus[i].end >= now) {
return bonus[i];
}
}
}
| function getCurrentBonusSystem() public constant returns (BonusSystem) {
for (uint i = 0; i < bonus.length; i++) {
if (bonus[i].start <= now && bonus[i].end >= now) {
return bonus[i];
}
}
}
| 50,709 |
364 | // payoutAmount = coveredTokenAmount / maxAmountcoverAmount= coveredTokenAmountcoverAmount / maxAmount | payoutAmount = coveredTokenAmount.mul(coverAmount).div(maxAmount);
| payoutAmount = coveredTokenAmount.mul(coverAmount).div(maxAmount);
| 54,617 |
9 | // requires lp token transfer from proxy to msg.sender | shares = IHypervisor(pos).deposit(deposit0, deposit1, address(this), address(this));
IHypervisor(pos).transfer(to, shares);
| shares = IHypervisor(pos).deposit(deposit0, deposit1, address(this), address(this));
IHypervisor(pos).transfer(to, shares);
| 80,044 |
1 | // Hanya admin yang bisa mengakses | function Admin() public view returns(address) {
return admin;
}
| function Admin() public view returns(address) {
return admin;
}
| 13,885 |
30 | // uint256 dailyIncome = stakes[user].stakedArma / packages[package].day; rewards[user] = Rewards({ total: dailyIncome, balance: dailyIncome, claimed: 0 }); | stakeLenght++;
distLevelReward(user, _busd);
| stakeLenght++;
distLevelReward(user, _busd);
| 4,205 |
22 | // Emergency function to pause Crowdsale. / | function setPaused(bool _paused) public onlyOwner { paused = _paused; }
/**
* @dev Emergency function to drain the contract of any funds.
*/
function drain() public onlyOwner { walletAddress.transfer(this.balance); }
/**
* @dev Function to manually finalize Crowdsale.
*/
function endCrowdsale() public onlyOwner {
usedPositions = investmentPositions;
availablePositions = 0;
token.burn(); // burn all unsold tokens
crowdsaleEnded = true; // mark Crowdsale ended
Ended(raisedEth);
}
| function setPaused(bool _paused) public onlyOwner { paused = _paused; }
/**
* @dev Emergency function to drain the contract of any funds.
*/
function drain() public onlyOwner { walletAddress.transfer(this.balance); }
/**
* @dev Function to manually finalize Crowdsale.
*/
function endCrowdsale() public onlyOwner {
usedPositions = investmentPositions;
availablePositions = 0;
token.burn(); // burn all unsold tokens
crowdsaleEnded = true; // mark Crowdsale ended
Ended(raisedEth);
}
| 23,389 |
42 | // Clear allowance of old, and set allowance of new | approve(crowdSaleAddr, 0);
approve(_crowdSaleAddr, amount);
crowdSaleAddr = _crowdSaleAddr;
| approve(crowdSaleAddr, 0);
approve(_crowdSaleAddr, amount);
crowdSaleAddr = _crowdSaleAddr;
| 7,805 |
4 | // get the NFT contract | NFTManager nftManager = NFTManager(_addressNFTManager);
| NFTManager nftManager = NFTManager(_addressNFTManager);
| 4,205 |
111 | // Allow a user to withdraw any XTK in their schedule that have vested. / | function vest()
external
| function vest()
external
| 19,999 |
40 | // Converts a `uint256` to its ASCII `string` representation. / | function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
uint256 index = digits - 1;
temp = value;
while (temp != 0) {
buffer[index--] = byte(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
| function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
uint256 index = digits - 1;
temp = value;
while (temp != 0) {
buffer[index--] = byte(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
| 109 |
31 | // Identity contract responsible for whitelistingand keeping track of amount of whitelisted users / | contract Identity is IdentityAdminRole, SchemeGuard, Pausable {
using Roles for Roles.Role;
using SafeMath for uint256;
Roles.Role private blacklist;
Roles.Role private whitelist;
Roles.Role private contracts;
uint256 public whitelistedCount = 0;
uint256 public whitelistedContracts = 0;
uint256 public authenticationPeriod = 14;
mapping(address => uint256) public dateAuthenticated;
mapping(address => uint256) public dateAdded;
mapping(address => string) public addrToDID;
mapping(bytes32 => address) public didHashToAddress;
event BlacklistAdded(address indexed account);
event BlacklistRemoved(address indexed account);
event WhitelistedAdded(address indexed account);
event WhitelistedRemoved(address indexed account);
event ContractAdded(address indexed account);
event ContractRemoved(address indexed account);
constructor() public SchemeGuard(Avatar(0)) {}
/* @dev Sets a new value for authenticationPeriod.
* Can only be called by Identity Administrators.
* @param period new value for authenticationPeriod
*/
function setAuthenticationPeriod(uint256 period) public onlyOwner whenNotPaused {
authenticationPeriod = period;
}
/* @dev Sets the authentication date of `account`
* to the current time.
* Can only be called by Identity Administrators.
* @param account address to change its auth date
*/
function authenticate(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
dateAuthenticated[account] = now;
}
/* @dev Adds an address as whitelisted.
* Can only be called by Identity Administrators.
* @param account address to add as whitelisted
*/
function addWhitelisted(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
_addWhitelisted(account);
}
/* @dev Adds an address as whitelisted under a specific ID
* @param account The address to add
* @param did the ID to add account under
*/
function addWhitelistedWithDID(address account, string memory did)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
_addWhitelistedWithDID(account, did);
}
/* @dev Removes an address as whitelisted.
* Can only be called by Identity Administrators.
* @param account address to remove as whitelisted
*/
function removeWhitelisted(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
_removeWhitelisted(account);
}
/* @dev Renounces message sender from whitelisted
*/
function renounceWhitelisted() public whenNotPaused {
_removeWhitelisted(msg.sender);
}
/* @dev Returns true if given address has been added to whitelist
* @param account the address to check
* @return a bool indicating weather the address is present in whitelist
*/
function isWhitelisted(address account) public view returns (bool) {
uint256 daysSinceAuthentication = (now.sub(dateAuthenticated[account])) / 1 days;
return
(daysSinceAuthentication <= authenticationPeriod) && whitelist.has(account);
}
/* @dev Function that gives the date the given user was added
* @param account The address to check
* @return The date the address was added
*/
function lastAuthenticated(address account) public view returns (uint256) {
return dateAuthenticated[account];
}
// /**
// *
// * @dev Function to transfer whitelisted privilege to another address
// * relocates did of sender to give address
// * @param account The address to transfer to
// */
// function transferAccount(address account) public whenNotPaused {
// ERC20 token = avatar.nativeToken();
// require(!isBlacklisted(account), "Cannot transfer to blacklisted");
// require(token.balanceOf(account) == 0, "Account is already in use");
// require(isWhitelisted(msg.sender), "Requester need to be whitelisted");
// require(
// keccak256(bytes(addrToDID[account])) == keccak256(bytes("")),
// "address already has DID"
// );
// string memory did = addrToDID[msg.sender];
// bytes32 pHash = keccak256(bytes(did));
// uint256 balance = token.balanceOf(msg.sender);
// token.transferFrom(msg.sender, account, balance);
// _removeWhitelisted(msg.sender);
// _addWhitelisted(account);
// addrToDID[account] = did;
// didHashToAddress[pHash] = account;
// }
/* @dev Adds an address to blacklist.
* Can only be called by Identity Administrators.
* @param account address to add as blacklisted
*/
function addBlacklisted(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
blacklist.add(account);
emit BlacklistAdded(account);
}
/* @dev Removes an address from blacklist
* Can only be called by Identity Administrators.
* @param account address to remove as blacklisted
*/
function removeBlacklisted(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
blacklist.remove(account);
emit BlacklistRemoved(account);
}
/* @dev Function to add a Contract to list of contracts
* @param account The address to add
*/
function addContract(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
require(isContract(account), "Given address is not a contract");
contracts.add(account);
_addWhitelisted(account);
emit ContractAdded(account);
}
/* @dev Function to remove a Contract from list of contracts
* @param account The address to add
*/
function removeContract(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
contracts.remove(account);
_removeWhitelisted(account);
emit ContractRemoved(account);
}
/* @dev Function to check if given contract is on list of contracts.
* @param address to check
* @return a bool indicating if address is on list of contracts
*/
function isDAOContract(address account) public view returns (bool) {
return contracts.has(account);
}
/* @dev Internal function to add to whitelisted
* @param account the address to add
*/
function _addWhitelisted(address account) internal {
whitelist.add(account);
whitelistedCount += 1;
dateAdded[account] = now;
dateAuthenticated[account] = now;
if (isContract(account)) {
whitelistedContracts += 1;
}
emit WhitelistedAdded(account);
}
/* @dev Internal whitelisting with did function.
* @param account the address to add
* @param did the id to register account under
*/
function _addWhitelistedWithDID(address account, string memory did) internal {
bytes32 pHash = keccak256(bytes(did));
require(didHashToAddress[pHash] == address(0), "DID already registered");
addrToDID[account] = did;
didHashToAddress[pHash] = account;
_addWhitelisted(account);
}
/* @dev Internal function to remove from whitelisted
* @param account the address to add
*/
function _removeWhitelisted(address account) internal {
whitelist.remove(account);
whitelistedCount -= 1;
delete dateAuthenticated[account];
if (isContract(account)) {
whitelistedContracts -= 1;
}
string memory did = addrToDID[account];
bytes32 pHash = keccak256(bytes(did));
delete dateAuthenticated[account];
delete addrToDID[account];
delete didHashToAddress[pHash];
emit WhitelistedRemoved(account);
}
/* @dev Returns true if given address has been added to the blacklist
* @param account the address to check
* @return a bool indicating weather the address is present in the blacklist
*/
function isBlacklisted(address account) public view returns (bool) {
return blacklist.has(account);
}
/* @dev Function to see if given address is a contract
* @return true if address is a contract
*/
function isContract(address _addr) internal view returns (bool) {
uint256 length;
assembly {
length := extcodesize(_addr)
}
return length > 0;
}
}
| contract Identity is IdentityAdminRole, SchemeGuard, Pausable {
using Roles for Roles.Role;
using SafeMath for uint256;
Roles.Role private blacklist;
Roles.Role private whitelist;
Roles.Role private contracts;
uint256 public whitelistedCount = 0;
uint256 public whitelistedContracts = 0;
uint256 public authenticationPeriod = 14;
mapping(address => uint256) public dateAuthenticated;
mapping(address => uint256) public dateAdded;
mapping(address => string) public addrToDID;
mapping(bytes32 => address) public didHashToAddress;
event BlacklistAdded(address indexed account);
event BlacklistRemoved(address indexed account);
event WhitelistedAdded(address indexed account);
event WhitelistedRemoved(address indexed account);
event ContractAdded(address indexed account);
event ContractRemoved(address indexed account);
constructor() public SchemeGuard(Avatar(0)) {}
/* @dev Sets a new value for authenticationPeriod.
* Can only be called by Identity Administrators.
* @param period new value for authenticationPeriod
*/
function setAuthenticationPeriod(uint256 period) public onlyOwner whenNotPaused {
authenticationPeriod = period;
}
/* @dev Sets the authentication date of `account`
* to the current time.
* Can only be called by Identity Administrators.
* @param account address to change its auth date
*/
function authenticate(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
dateAuthenticated[account] = now;
}
/* @dev Adds an address as whitelisted.
* Can only be called by Identity Administrators.
* @param account address to add as whitelisted
*/
function addWhitelisted(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
_addWhitelisted(account);
}
/* @dev Adds an address as whitelisted under a specific ID
* @param account The address to add
* @param did the ID to add account under
*/
function addWhitelistedWithDID(address account, string memory did)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
_addWhitelistedWithDID(account, did);
}
/* @dev Removes an address as whitelisted.
* Can only be called by Identity Administrators.
* @param account address to remove as whitelisted
*/
function removeWhitelisted(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
_removeWhitelisted(account);
}
/* @dev Renounces message sender from whitelisted
*/
function renounceWhitelisted() public whenNotPaused {
_removeWhitelisted(msg.sender);
}
/* @dev Returns true if given address has been added to whitelist
* @param account the address to check
* @return a bool indicating weather the address is present in whitelist
*/
function isWhitelisted(address account) public view returns (bool) {
uint256 daysSinceAuthentication = (now.sub(dateAuthenticated[account])) / 1 days;
return
(daysSinceAuthentication <= authenticationPeriod) && whitelist.has(account);
}
/* @dev Function that gives the date the given user was added
* @param account The address to check
* @return The date the address was added
*/
function lastAuthenticated(address account) public view returns (uint256) {
return dateAuthenticated[account];
}
// /**
// *
// * @dev Function to transfer whitelisted privilege to another address
// * relocates did of sender to give address
// * @param account The address to transfer to
// */
// function transferAccount(address account) public whenNotPaused {
// ERC20 token = avatar.nativeToken();
// require(!isBlacklisted(account), "Cannot transfer to blacklisted");
// require(token.balanceOf(account) == 0, "Account is already in use");
// require(isWhitelisted(msg.sender), "Requester need to be whitelisted");
// require(
// keccak256(bytes(addrToDID[account])) == keccak256(bytes("")),
// "address already has DID"
// );
// string memory did = addrToDID[msg.sender];
// bytes32 pHash = keccak256(bytes(did));
// uint256 balance = token.balanceOf(msg.sender);
// token.transferFrom(msg.sender, account, balance);
// _removeWhitelisted(msg.sender);
// _addWhitelisted(account);
// addrToDID[account] = did;
// didHashToAddress[pHash] = account;
// }
/* @dev Adds an address to blacklist.
* Can only be called by Identity Administrators.
* @param account address to add as blacklisted
*/
function addBlacklisted(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
blacklist.add(account);
emit BlacklistAdded(account);
}
/* @dev Removes an address from blacklist
* Can only be called by Identity Administrators.
* @param account address to remove as blacklisted
*/
function removeBlacklisted(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
blacklist.remove(account);
emit BlacklistRemoved(account);
}
/* @dev Function to add a Contract to list of contracts
* @param account The address to add
*/
function addContract(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
require(isContract(account), "Given address is not a contract");
contracts.add(account);
_addWhitelisted(account);
emit ContractAdded(account);
}
/* @dev Function to remove a Contract from list of contracts
* @param account The address to add
*/
function removeContract(address account)
public
onlyRegistered
onlyIdentityAdmin
whenNotPaused
{
contracts.remove(account);
_removeWhitelisted(account);
emit ContractRemoved(account);
}
/* @dev Function to check if given contract is on list of contracts.
* @param address to check
* @return a bool indicating if address is on list of contracts
*/
function isDAOContract(address account) public view returns (bool) {
return contracts.has(account);
}
/* @dev Internal function to add to whitelisted
* @param account the address to add
*/
function _addWhitelisted(address account) internal {
whitelist.add(account);
whitelistedCount += 1;
dateAdded[account] = now;
dateAuthenticated[account] = now;
if (isContract(account)) {
whitelistedContracts += 1;
}
emit WhitelistedAdded(account);
}
/* @dev Internal whitelisting with did function.
* @param account the address to add
* @param did the id to register account under
*/
function _addWhitelistedWithDID(address account, string memory did) internal {
bytes32 pHash = keccak256(bytes(did));
require(didHashToAddress[pHash] == address(0), "DID already registered");
addrToDID[account] = did;
didHashToAddress[pHash] = account;
_addWhitelisted(account);
}
/* @dev Internal function to remove from whitelisted
* @param account the address to add
*/
function _removeWhitelisted(address account) internal {
whitelist.remove(account);
whitelistedCount -= 1;
delete dateAuthenticated[account];
if (isContract(account)) {
whitelistedContracts -= 1;
}
string memory did = addrToDID[account];
bytes32 pHash = keccak256(bytes(did));
delete dateAuthenticated[account];
delete addrToDID[account];
delete didHashToAddress[pHash];
emit WhitelistedRemoved(account);
}
/* @dev Returns true if given address has been added to the blacklist
* @param account the address to check
* @return a bool indicating weather the address is present in the blacklist
*/
function isBlacklisted(address account) public view returns (bool) {
return blacklist.has(account);
}
/* @dev Function to see if given address is a contract
* @return true if address is a contract
*/
function isContract(address _addr) internal view returns (bool) {
uint256 length;
assembly {
length := extcodesize(_addr)
}
return length > 0;
}
}
| 19,130 |
4 | // Returns the current gradual swap fee update parameters. The current swap fee can be retrieved via `getSwapFeePercentage()`.return startTime - The timestamp when the swap fee update will begin.return endTime - The timestamp when the swap fee update will end.return startSwapFeePercentage - The starting swap fee percentage (could be different from the current value).return endSwapFeePercentage - The final swap fee percentage, when the current timestamp >= endTime. / | function getGradualSwapFeeUpdateParams()
external
| function getGradualSwapFeeUpdateParams()
external
| 25,100 |
68 | // make the swap | uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
| uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
| 6,706 |
218 | // returns the current controller configurationreturn whitelist, the address of the whitelist modulereturn oracle, the address of the oracle modulereturn calculator, the address of the calculator modulereturn pool, the address of the pool module / | function getConfiguration()
external
view
returns (
address,
address,
address,
address
)
| function getConfiguration()
external
view
returns (
address,
address,
address,
address
)
| 6,680 |
195 | // Deposit LP tokens to MasterChef for SRX allocation. | function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accSrxPerShare).div(1e12).sub(user.rewardDebt);
safeSrxTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accSrxPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accSrxPerShare).div(1e12).sub(user.rewardDebt);
safeSrxTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accSrxPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| 28,432 |
14 | // make sure they're an owner | if (ownerIndex == 0) return;
uint ownerIndexBit = 2**ownerIndex;
PendingState storage pending = m_pending[_operation];
if (pending.ownersDone & ownerIndexBit > 0) {
pending.yetNeeded++;
pending.ownersDone -= ownerIndexBit;
emit Revoke(msg.sender, _operation);
}
| if (ownerIndex == 0) return;
uint ownerIndexBit = 2**ownerIndex;
PendingState storage pending = m_pending[_operation];
if (pending.ownersDone & ownerIndexBit > 0) {
pending.yetNeeded++;
pending.ownersDone -= ownerIndexBit;
emit Revoke(msg.sender, _operation);
}
| 79,377 |
4 | // Anxiety statements2, 4, 7, 9, 15, 19, 20, 23, 25, 28, 30, 36, 40, 41 | _a = contributors[_contributor].dass42[1];
_a += contributors[_contributor].dass42[3];
_a += contributors[_contributor].dass42[6];
_a += contributors[_contributor].dass42[8];
_a += contributors[_contributor].dass42[14];
_a += contributors[_contributor].dass42[18];
_a += contributors[_contributor].dass42[19];
_a += contributors[_contributor].dass42[22];
_a += contributors[_contributor].dass42[24];
_a += contributors[_contributor].dass42[27];
| _a = contributors[_contributor].dass42[1];
_a += contributors[_contributor].dass42[3];
_a += contributors[_contributor].dass42[6];
_a += contributors[_contributor].dass42[8];
_a += contributors[_contributor].dass42[14];
_a += contributors[_contributor].dass42[18];
_a += contributors[_contributor].dass42[19];
_a += contributors[_contributor].dass42[22];
_a += contributors[_contributor].dass42[24];
_a += contributors[_contributor].dass42[27];
| 8,449 |
4 | // Sets the deployer as the upgrade admin. | constructor() {
admin = msg.sender;
}
| constructor() {
admin = msg.sender;
}
| 39,299 |
18 | // CH_ENC: Exchange is not contract | require(exchangeArg.isContract(), "CH_ENC");
| require(exchangeArg.isContract(), "CH_ENC");
| 8,238 |
4 | // function isActive(uint256 _hatId) external view returns (bool); |
function isInGoodStanding(address _wearer, uint256 _hatId)
external
view
returns (bool);
function isEligible(address _wearer, uint256 _hatId)
external
view
returns (bool);
|
function isInGoodStanding(address _wearer, uint256 _hatId)
external
view
returns (bool);
function isEligible(address _wearer, uint256 _hatId)
external
view
returns (bool);
| 36,607 |
89 | // should only be called by controller | function salvage(address destination, address token, uint256 amount) external restricted {
require(!unsalvagableTokens[token], "token is defined as not salvageable");
IERC20(token).safeTransfer(destination, amount);
}
| function salvage(address destination, address token, uint256 amount) external restricted {
require(!unsalvagableTokens[token], "token is defined as not salvageable");
IERC20(token).safeTransfer(destination, amount);
}
| 78,720 |
169 | // public | function mint(address _to, uint256 _mintamount) public payable {
uint256 supply = totalSupply();
require(!paused);
require(_mintamount > 0);
require(_mintamount <= maxMintAmount);
require(supply + _mintamount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintamount);
}
for (uint256 i = 1; i <= _mintamount; i++) {
_safeMint(_to, supply + i);
}
}
| function mint(address _to, uint256 _mintamount) public payable {
uint256 supply = totalSupply();
require(!paused);
require(_mintamount > 0);
require(_mintamount <= maxMintAmount);
require(supply + _mintamount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintamount);
}
for (uint256 i = 1; i <= _mintamount; i++) {
_safeMint(_to, supply + i);
}
}
| 81,016 |
25 | // Ensure caller is this contract and self-call context is correctly set. | _enforceSelfCallFrom(this.execute.selector);
bool rollBack = false;
callResults = new CallReturn[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
| _enforceSelfCallFrom(this.execute.selector);
bool rollBack = false;
callResults = new CallReturn[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
| 33,015 |
21 | // setMetaTxRelayer(): Sets the address of the meta transaction relayer/_relayer the address of the relayer | function setMetaTxRelayer(address _relayer)
external
{
require(msg.sender == owner); // Checks that only the owner can call
require(metaTxRelayer == address(0)); // Ensures the meta tx relayer can only be set once
metaTxRelayer = _relayer;
}
| function setMetaTxRelayer(address _relayer)
external
{
require(msg.sender == owner); // Checks that only the owner can call
require(metaTxRelayer == address(0)); // Ensures the meta tx relayer can only be set once
metaTxRelayer = _relayer;
}
| 44,763 |
5 | // all the regular txn data | address to;
uint value;
bytes data;
| address to;
uint value;
bytes data;
| 43,206 |
14 | // Implement Task 1 Transfer Stars | function transferStar(address _to1, uint256 _tokenId) public {
//1. Check if the sender is the ownerOf(_tokenId)
require(msg.sender == ownerOf(_tokenId), "Sender needs to own the token");
//2. Use the transferFrom(from, to, tokenId); function to transfer the Star
transferFrom(msg.sender, _to1, _tokenId);
}
| function transferStar(address _to1, uint256 _tokenId) public {
//1. Check if the sender is the ownerOf(_tokenId)
require(msg.sender == ownerOf(_tokenId), "Sender needs to own the token");
//2. Use the transferFrom(from, to, tokenId); function to transfer the Star
transferFrom(msg.sender, _to1, _tokenId);
}
| 23,904 |
211 | // ============ Events ============ // ============ Modifiers ============ // ============ State Variables ============ //The EIP-712 typehash for the contract's domain | bytes32 public constant DOMAIN_TYPEHASH =
keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)');
| bytes32 public constant DOMAIN_TYPEHASH =
keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)');
| 34,068 |
15 | // Return the status of a dispute._disputeID ID of the dispute to rule. return status The status of the dispute. / | function disputeStatus(uint _disputeID) external view returns(DisputeStatus status);
| function disputeStatus(uint _disputeID) external view returns(DisputeStatus status);
| 55,407 |
9 | // Change signer wallet of the contract to a new account.Can only be called by the current owner. / | function changeSignerRole(address newSignerRole) external onlyOwner {
require(newSignerRole != address(0), "KR: new signer wallet is the zero address");
address oldSignerRole = _signerRole;
_signerRole = newSignerRole;
emit SugnerRoleChanged(oldSignerRole, newSignerRole);
}
| function changeSignerRole(address newSignerRole) external onlyOwner {
require(newSignerRole != address(0), "KR: new signer wallet is the zero address");
address oldSignerRole = _signerRole;
_signerRole = newSignerRole;
emit SugnerRoleChanged(oldSignerRole, newSignerRole);
}
| 23,610 |
18 | // return calculated result | return target;
| return target;
| 47,688 |
51 | // all orders were successfully taken. send to dstAddress | if (dstToken == ETH_TOKEN_ADDRESS) {
dstAddress.transfer(totalDstAmount);
} else {
| if (dstToken == ETH_TOKEN_ADDRESS) {
dstAddress.transfer(totalDstAmount);
} else {
| 5,896 |
54 | // PRIVILEGED GOVERNANCE FUNCTION. Allows governance to remove a module_module Address of the module contract to remove / | function removeModule(address _module) external onlyInitialized onlyOwner {
require(isModule[_module], "Module does not exist");
modules = modules.remove(_module);
isModule[_module] = false;
emit ModuleRemoved(_module);
}
| function removeModule(address _module) external onlyInitialized onlyOwner {
require(isModule[_module], "Module does not exist");
modules = modules.remove(_module);
isModule[_module] = false;
emit ModuleRemoved(_module);
}
| 8,887 |
2 | // Supply parameters | uint256 constant INITIAL_SUPPLY = 126_000_000; //will be vested
uint256 constant RATE_REDUCTION_TIME = YEAR;
uint256[6] public RATES = [
(28_000_000 * 10**18) / YEAR, //epoch 0
(22_400_000 * 10**18) / YEAR, //epoch 1
(16_800_000 * 10**18) / YEAR, //epoch 2
(11_200_000 * 10**18) / YEAR, //epoch 3
(5_600_000 * 10**18) / YEAR, //epoch 4
(2_800_000 * 10**18) / YEAR //epoch 5~
];
| uint256 constant INITIAL_SUPPLY = 126_000_000; //will be vested
uint256 constant RATE_REDUCTION_TIME = YEAR;
uint256[6] public RATES = [
(28_000_000 * 10**18) / YEAR, //epoch 0
(22_400_000 * 10**18) / YEAR, //epoch 1
(16_800_000 * 10**18) / YEAR, //epoch 2
(11_200_000 * 10**18) / YEAR, //epoch 3
(5_600_000 * 10**18) / YEAR, //epoch 4
(2_800_000 * 10**18) / YEAR //epoch 5~
];
| 52,776 |
3 | // 该帐号拥有超级超级权限; people who created the contract own it. | operator = msg.sender;
| operator = msg.sender;
| 29,073 |
9 | // get consensus goal mask/ _claimsMask the ClaimsMask value | function clearAgreementMask(
ClaimsMask _claimsMask
| function clearAgreementMask(
ClaimsMask _claimsMask
| 15,086 |
65 | // taken from https:etherscan.io/address/0x8d12a197cb00d4747a1fe03395095ce2a5cc6819code/ disabled when contract is paused/ | function deposit() payable external whenNotPaused {
tokens[0][msg.sender] = tokens[0][msg.sender].add(msg.value);
emit Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]);
_validateUserActive(msg.sender);
}
| function deposit() payable external whenNotPaused {
tokens[0][msg.sender] = tokens[0][msg.sender].add(msg.value);
emit Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]);
_validateUserActive(msg.sender);
}
| 44,969 |
69 | // VIT token unit. | uint256 public constant TOKEN_UNIT = 10 ** 18;
| uint256 public constant TOKEN_UNIT = 10 ** 18;
| 27,413 |
9 | // Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend)./ | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| 5,674 |
349 | // RENDER / | function setBaseURI(string memory newUri) public onlyOwner {
baseURI = newUri;
}
| function setBaseURI(string memory newUri) public onlyOwner {
baseURI = newUri;
}
| 19,774 |
181 | // method that is simulated by the keepers to see if any work actuallyneeds to be performed. This method does does not actually need to beexecutable, and since it is only ever simulated it can consume lots of gas. To ensure that it is never called, you may want to add thecannotExecute modifier from KeeperBase to your implementation of thismethod. checkData specified in the upkeep registration so it is always thesame for a registered upkeep. This can easily be broken down into specificarguments using `abi.decode`, so multiple upkeeps can be registered on thesame contract and easily differentiated by the contract.return upkeepNeeded | function checkUpkeep(bytes calldata checkData)
external
returns (bool upkeepNeeded, bytes memory performData);
| function checkUpkeep(bytes calldata checkData)
external
returns (bool upkeepNeeded, bytes memory performData);
| 45,414 |
6 | // Check for a price deviation | uint256 price_deviation = Math.bdiv(ethTotal_0, ethTotal_1);
if (
price_deviation > (Math.BONE.add(maxPriceDeviation)) ||
price_deviation < (Math.BONE.sub(maxPriceDeviation))
) {
return true;
}
| uint256 price_deviation = Math.bdiv(ethTotal_0, ethTotal_1);
if (
price_deviation > (Math.BONE.add(maxPriceDeviation)) ||
price_deviation < (Math.BONE.sub(maxPriceDeviation))
) {
return true;
}
| 30,381 |
3 | // check if the team minted or not | bool private teamMintAvalible = true;
| bool private teamMintAvalible = true;
| 39,567 |
23 | // interest rate scaled by 1e18 utilisation rate in BPSinterest rate scaled by 1e18 / BPS = total interest rate scaled by 1e18 | totalInterestRate += utilisationRate * strategy.interestRatePerBlock() / MAX_BPS;
| totalInterestRate += utilisationRate * strategy.interestRatePerBlock() / MAX_BPS;
| 22,025 |
15 | // Func3 : 0x010c2e7e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000d9145cce52d386f254917e481eb44e9943f39138f439b7dc0000000000000000000/Func3 parameter: ["name","0xd8b934580fcE35a11B58C6D73aDeE468a2833fa8","0x010c2e7e",1,[["arg","uint"]]]//Func1: 0x5a823dce0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000 | function GetName() external view returns(string memory){
return Name;
}
| function GetName() external view returns(string memory){
return Name;
}
| 2,654 |
111 | // claim erc1155 | function claimERC1155(
string memory _nftKey,
address _nftContract,
address _owner,
uint256 _amount,
uint256 _tokenId,
bytes memory _data
| function claimERC1155(
string memory _nftKey,
address _nftContract,
address _owner,
uint256 _amount,
uint256 _tokenId,
bytes memory _data
| 7,809 |
85 | // subtract random 10% to 50% current crystals of player defence | uint256 rate =10 + randomNumber(_defAddress, 40);
winCrystals = SafeMath.div(SafeMath.mul(pDefCrystals,rate),100);
if (winCrystals > 0) {
MiningWarContract.subCrystal(_defAddress, winCrystals);
MiningWarContract.addCrystal(_atkAddress, winCrystals);
}
| uint256 rate =10 + randomNumber(_defAddress, 40);
winCrystals = SafeMath.div(SafeMath.mul(pDefCrystals,rate),100);
if (winCrystals > 0) {
MiningWarContract.subCrystal(_defAddress, winCrystals);
MiningWarContract.addCrystal(_atkAddress, winCrystals);
}
| 51,453 |
8 | // The mapping of KYCED users | mapping(address => bool) internal kycUsers;
| mapping(address => bool) internal kycUsers;
| 24,593 |
2 | // added sectionModifier that only allows owner of the bag to Smart Contract AKA Good to use the function | modifier onlyOwner{
require(msg.sender == owner_, "Only owner can do this!");
_;
}
| modifier onlyOwner{
require(msg.sender == owner_, "Only owner can do this!");
_;
}
| 30,678 |
149 | // See {IERC1155721Inventory-safeTransferFrom(address,address,uint256,uint256,bytes)}. / | function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 value,
bytes memory data
) public virtual override {
address sender = _msgSender();
require(to != address(0), "Inventory: transfer to zero");
| function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 value,
bytes memory data
) public virtual override {
address sender = _msgSender();
require(to != address(0), "Inventory: transfer to zero");
| 33,980 |
18 | // Updates the ERC20 mappings. _tokenId The Id of the token. _erc20Contract The address of the erc20 funds being transferred. _value The amount of funds being transferred. / | function updateERC20(
uint256 _tokenId,
address _erc20Contract,
uint256 _value
| function updateERC20(
uint256 _tokenId,
address _erc20Contract,
uint256 _value
| 32,227 |
16 | // Get 32 bytes from data | assembly {
temp := mload(add(data, i))
}
| assembly {
temp := mload(add(data, i))
}
| 45,253 |
49 | // Update the treasury fee for this contractdefaults at 25% of taxFee, It can be set on only by Titan governance.Note contract owner is meant to be a governance contract allowing Titan governance consensus / | function changeFeeInfo(
uint16 treasuryFee,
uint16 rewardFee,
uint16 lotteryFee,
uint16 reserviorFee,
uint16 swapRewardFee,
uint16 burnFee
| function changeFeeInfo(
uint16 treasuryFee,
uint16 rewardFee,
uint16 lotteryFee,
uint16 reserviorFee,
uint16 swapRewardFee,
uint16 burnFee
| 39,119 |
96 | // Set an inverse price up for the currency key currencyKey The currency to update entryPoint The entry price point of the inverted price upperLimit The upper limit, at or above which the price will be frozen lowerLimit The lower limit, at or below which the price will be frozen / | function setInversePricing(bytes4 currencyKey, uint entryPoint, uint upperLimit, uint lowerLimit)
external onlyOwner
| function setInversePricing(bytes4 currencyKey, uint entryPoint, uint upperLimit, uint lowerLimit)
external onlyOwner
| 52,507 |
18 | // UBIProxy A proxy contract for UBI that implements a token interface to interact with other dapps. Note that it isn't an ERC20 and only implements its interface in order to be compatible with Snapshot. / | contract UBIProxy {
IProofOfHumanity public PoH;
IERC20 public UBI;
address public governor = msg.sender;
string public name = "UBI Vote";
string public symbol = "UBIVOTE";
uint8 public decimals = 18;
/** @dev Constructor.
* @param _PoH The address of the related ProofOfHumanity contract.
* @param _UBI The address of the related UBI contract.
*/
constructor(IProofOfHumanity _PoH, IERC20 _UBI) public {
PoH = _PoH;
UBI = _UBI;
}
/** @dev Changes the address of the the related ProofOfHumanity contract.
* @param _PoH The address of the new contract.
*/
function changePoH(IProofOfHumanity _PoH) external {
require(msg.sender == governor, "The caller must be the governor.");
PoH = _PoH;
}
/** @dev Changes the address of the the related UBI contract.
* @param _UBI The address of the new contract.
*/
function changeUBI(IERC20 _UBI) external {
require(msg.sender == governor, "The caller must be the governor.");
UBI = _UBI;
}
/** @dev Changes the address of the the governor.
* @param _governor The address of the new governor.
*/
function changeGovernor(address _governor) external {
require(msg.sender == governor, "The caller must be the governor.");
governor = _governor;
}
/** @dev Returns true if the submission is registered and not expired.
* @param _submissionID The address of the submission.
* @return Whether the submission is registered or not.
*/
function isRegistered(address _submissionID) public view returns (bool) {
return PoH.isRegistered(_submissionID);
}
/**
* @dev Calculates the square root of a number. Uses the Babylonian Method.
* @param x The input.
* @return y The square root of the input.
**/
function sqrt(uint256 x) private pure returns (uint256 y) {
uint256 z = (x + 1) / 2;
y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
}
// ******************** //
// * IERC20 * //
// ******************** //
/** @dev Returns the square root of the UBI balance of a particular submission of the ProofOfHumanity contract.
* Note that this function takes the expiration date into account.
* @param _submissionID The address of the submission.
* @return The balance of the submission.
*/
function balanceOf(address _submissionID) external view returns (uint256) {
return
isRegistered(_submissionID)
? sqrt(UBI.balanceOf(_submissionID))
: 0;
}
/** @dev Returns the total supply of the UBI token.
* This function should really count the square root of each humans balance, but this would be costly.
* @return The total supply.
*/
function totalSupply() external view returns (uint256) {
return UBI.totalSupply();
}
function transfer(address _recipient, uint256 _amount)
external
returns (bool)
{
return false;
}
function allowance(address _owner, address _spender)
external
view
returns (uint256)
{}
function approve(address _spender, uint256 _amount)
external
returns (bool)
{
return false;
}
function transferFrom(
address _sender,
address _recipient,
uint256 _amount
) external returns (bool) {
return false;
}
} | contract UBIProxy {
IProofOfHumanity public PoH;
IERC20 public UBI;
address public governor = msg.sender;
string public name = "UBI Vote";
string public symbol = "UBIVOTE";
uint8 public decimals = 18;
/** @dev Constructor.
* @param _PoH The address of the related ProofOfHumanity contract.
* @param _UBI The address of the related UBI contract.
*/
constructor(IProofOfHumanity _PoH, IERC20 _UBI) public {
PoH = _PoH;
UBI = _UBI;
}
/** @dev Changes the address of the the related ProofOfHumanity contract.
* @param _PoH The address of the new contract.
*/
function changePoH(IProofOfHumanity _PoH) external {
require(msg.sender == governor, "The caller must be the governor.");
PoH = _PoH;
}
/** @dev Changes the address of the the related UBI contract.
* @param _UBI The address of the new contract.
*/
function changeUBI(IERC20 _UBI) external {
require(msg.sender == governor, "The caller must be the governor.");
UBI = _UBI;
}
/** @dev Changes the address of the the governor.
* @param _governor The address of the new governor.
*/
function changeGovernor(address _governor) external {
require(msg.sender == governor, "The caller must be the governor.");
governor = _governor;
}
/** @dev Returns true if the submission is registered and not expired.
* @param _submissionID The address of the submission.
* @return Whether the submission is registered or not.
*/
function isRegistered(address _submissionID) public view returns (bool) {
return PoH.isRegistered(_submissionID);
}
/**
* @dev Calculates the square root of a number. Uses the Babylonian Method.
* @param x The input.
* @return y The square root of the input.
**/
function sqrt(uint256 x) private pure returns (uint256 y) {
uint256 z = (x + 1) / 2;
y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
}
// ******************** //
// * IERC20 * //
// ******************** //
/** @dev Returns the square root of the UBI balance of a particular submission of the ProofOfHumanity contract.
* Note that this function takes the expiration date into account.
* @param _submissionID The address of the submission.
* @return The balance of the submission.
*/
function balanceOf(address _submissionID) external view returns (uint256) {
return
isRegistered(_submissionID)
? sqrt(UBI.balanceOf(_submissionID))
: 0;
}
/** @dev Returns the total supply of the UBI token.
* This function should really count the square root of each humans balance, but this would be costly.
* @return The total supply.
*/
function totalSupply() external view returns (uint256) {
return UBI.totalSupply();
}
function transfer(address _recipient, uint256 _amount)
external
returns (bool)
{
return false;
}
function allowance(address _owner, address _spender)
external
view
returns (uint256)
{}
function approve(address _spender, uint256 _amount)
external
returns (bool)
{
return false;
}
function transferFrom(
address _sender,
address _recipient,
uint256 _amount
) external returns (bool) {
return false;
}
} | 38,141 |
9 | // Gems start ID | uint256 GEMS_START_ID = 1;
| uint256 GEMS_START_ID = 1;
| 30,793 |
29 | // Get queen nodes from range numbersreturn Queens is queen nodes address list / | function getQueenNodes() public view returns (address[] memory) {
uint256 n = rangeNumbers.length;
address[] memory queens = new address[](n);
for (uint256 i = 0; i < rangeNumbers.length; i++) {
queens[i] = getKeyAt(i);
}
return queens;
}
| function getQueenNodes() public view returns (address[] memory) {
uint256 n = rangeNumbers.length;
address[] memory queens = new address[](n);
for (uint256 i = 0; i < rangeNumbers.length; i++) {
queens[i] = getKeyAt(i);
}
return queens;
}
| 36,002 |
75 | // PermittedPartners contract doesn't allow to set a revenueShareInBasisPoints for address zero so revenuShare > 0 implies that revenueSharePartner ~= address(0), BUT revenueShare can be zero for a partener when the adminFee is low | if (revenueShare > 0 && loanExtras.revenueSharePartner != address(0)) {
adminFee -= revenueShare;
| if (revenueShare > 0 && loanExtras.revenueSharePartner != address(0)) {
adminFee -= revenueShare;
| 40,305 |
72 | // (Update operation) update the rewards parameters.userAddr The address of operator return Whether or not the operation succeed/ | function updateRewardParams(address payable userAddr) onlyOperators external returns (bool)
| function updateRewardParams(address payable userAddr) onlyOperators external returns (bool)
| 84,534 |
3 | // Send cross-chain message to target on Optimism. target Contract on Optimism that will receive message. message Data to send to target. / | function relayMessage(address target, bytes calldata message) external payable override {
sendCrossDomainMessage(target, uint32(l2GasLimit), message);
emit MessageRelayed(target, message);
}
| function relayMessage(address target, bytes calldata message) external payable override {
sendCrossDomainMessage(target, uint32(l2GasLimit), message);
emit MessageRelayed(target, message);
}
| 29,580 |
13 | // Now that you have WETH, you can unwrap it to get ETH | weth.withdraw(weth.balanceOf(address(this)));
| weth.withdraw(weth.balanceOf(address(this)));
| 31,022 |
4 | // the erc721 token ID of this vault's token | uint256 public id;
| uint256 public id;
| 85,132 |
44 | // operator address has 2% for no locked. / | function initialOperatorValue(address operator) public onlyOwner {
transfer(operator, noLockedOperatorSupply);
}
| function initialOperatorValue(address operator) public onlyOwner {
transfer(operator, noLockedOperatorSupply);
}
| 68,460 |
188 | // cache values during sync for gas optimization | bool private inSync;
uint256 private yTokenValueCache;
uint256 private loansValueCache;
| bool private inSync;
uint256 private yTokenValueCache;
uint256 private loansValueCache;
| 80,792 |
12 | // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature unique. Appendix F in the Ethereum Yellow paper (https:ethereum.github.io/yellowpaper/paper.pdf), defines the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most signatures from current libraries generate a unique signature with an s-value in the lower half order. If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or vice versa. If your library | if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
| if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
| 1,505 |
134 | // Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. startTokenId - the first token id to be transferredquantity - the amount to be transferred Calling conditions: - When `from` and `to` are both non-zero, ``from``'s `tokenId` will betransferred to `to`.- When `from` is zero, `tokenId` will be minted for `to`. / | function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
| function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
| 7,933 |
9 | // find index to record it | uint length = relationIndexList.length;
uint index;
if (0 == length){
index = 1;
} else {
| uint length = relationIndexList.length;
uint index;
if (0 == length){
index = 1;
} else {
| 13,953 |
106 | // Validate that an allocation cannot be closed before one epoch | alloc.closedAtEpoch = epochManager().currentEpoch();
uint256 epochs = MathUtils.diffOrZero(alloc.closedAtEpoch, alloc.createdAtEpoch);
require(epochs > 0, "<epochs");
| alloc.closedAtEpoch = epochManager().currentEpoch();
uint256 epochs = MathUtils.diffOrZero(alloc.closedAtEpoch, alloc.createdAtEpoch);
require(epochs > 0, "<epochs");
| 25,616 |
9 | // Emmitted when the the StateBridge sets the root history expiry for OpWorldID and PolygonWorldID/rootHistoryExpiry The new root history expiry | event SetRootHistoryExpiry(uint256 rootHistoryExpiry);
| event SetRootHistoryExpiry(uint256 rootHistoryExpiry);
| 26,800 |
175 | // whitelisted checker | function isWhitelisted(address _user) public view returns (bool) {
for (uint256 i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
| function isWhitelisted(address _user) public view returns (bool) {
for (uint256 i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
| 14,235 |
6 | // Getter for the total share held by beneficiaries. / | function totalShare() public view returns (uint256) {
return _totalShare;
}
| function totalShare() public view returns (uint256) {
return _totalShare;
}
| 43,129 |
130 | // Set new opening time_openingTime time in UTX/ | function changeOpeningTIme(uint256 _openingTime) public onlyOwner {
require(_openingTime >= block.timestamp, "opening time is less than current time");
openingTime = _openingTime;
}
| function changeOpeningTIme(uint256 _openingTime) public onlyOwner {
require(_openingTime >= block.timestamp, "opening time is less than current time");
openingTime = _openingTime;
}
| 13,792 |
2 | // Gets all the function selectors provided by a facet./_facet The facet address./ return facetFunctionSelectors_ | function facetFunctionSelectors(address _facet) external view override returns (bytes4[] memory facetFunctionSelectors_) {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
facetFunctionSelectors_ = ds.facetFunctionSelectors[_facet].functionSelectors;
}
| function facetFunctionSelectors(address _facet) external view override returns (bytes4[] memory facetFunctionSelectors_) {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
facetFunctionSelectors_ = ds.facetFunctionSelectors[_facet].functionSelectors;
}
| 3,044 |
20 | // UpgradeabilityProxy This contract represents a proxy where the implementation address to which it will delegate can be upgraded / | contract UpgradeabilityProxy is Proxy, UpgradeabilityStorage {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param version representing the version name of the upgraded implementation
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(uint256 version, address indexed implementation);
/**
* @dev Upgrades the implementation address
* @param version representing the version name of the new implementation to be set
* @param implementation representing the address of the new implementation to be set
*/
function _upgradeTo(uint256 version, address implementation) internal {
require(_implementation != implementation);
require(version > _version);
_version = version;
_implementation = implementation;
emit Upgraded(version, implementation);
}
}
| contract UpgradeabilityProxy is Proxy, UpgradeabilityStorage {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param version representing the version name of the upgraded implementation
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(uint256 version, address indexed implementation);
/**
* @dev Upgrades the implementation address
* @param version representing the version name of the new implementation to be set
* @param implementation representing the address of the new implementation to be set
*/
function _upgradeTo(uint256 version, address implementation) internal {
require(_implementation != implementation);
require(version > _version);
_version = version;
_implementation = implementation;
emit Upgraded(version, implementation);
}
}
| 8,277 |
218 | // Convenience function that returns whether `_sender` is allowedto call function with selector `_selector` on contract `_contract`, asdetermined by this contract's current Admin ACL contract. Expected usecases include minter contracts checking if caller is allowed to calladmin-gated functions on minter contracts. _sender Address of the sender calling function with selector`_selector` on contract `_contract`. _contract Address of the contract being called by `_sender`. _selector Function selector of the function being called by`_sender`.return bool Whether `_sender` is allowed to call function with selector`_selector` on contract `_contract`. assumes the Admin ACL contract is the owner of this contract, whichis expected to always be true. | function adminACLAllowed(
address _sender,
address _contract,
bytes4 _selector
| function adminACLAllowed(
address _sender,
address _contract,
bytes4 _selector
| 13,127 |
2 | // Emitted when an schain is deleted. / | event SchainDeleted(
| event SchainDeleted(
| 27,086 |
237 | // Allows any potential buyer to submit a bid on a token with an auction. When outbidding the current topBidderthe contract returns the value that the previous bidder had escrowed to the contract. / | function bidOnAuction(uint256 tokenId) external payable {
uint256 timestamp = block.timestamp;
Auction memory auction = _tokenIdToAuction[tokenId];
uint256 msgValue = msg.value;
// Tokens that are not on auction always have an endTimestamp of 0
require(timestamp <= auction.endTimestamp, "Auction has already ended");
require(timestamp >= auction.startTimestamp, "Auction has not started yet");
uint256 minPrice = auction.price + auction.minBidIncrement;
if (auction.topBidder == address(0)) {
minPrice = auction.price;
}
require(msgValue >= minPrice, "Bid is too small");
uint256 endTime = auction.endTimestamp;
if (endTime < auction.minLastBidDuration + timestamp) {
endTime = timestamp + auction.minLastBidDuration;
}
Auction memory newAuction = Auction(_msgSender(), msgValue, auction.startTimestamp, endTime, auction.minBidIncrement, auction.minLastBidDuration);
if (auction.topBidder != address(0)) {
// Give the old top bidder their money back
payable(auction.topBidder).transfer(auction.price);
}
_tokenIdToAuction[tokenId] = newAuction;
emit AuctionBidded(tokenId, newAuction.price, newAuction.topBidder);
}
| function bidOnAuction(uint256 tokenId) external payable {
uint256 timestamp = block.timestamp;
Auction memory auction = _tokenIdToAuction[tokenId];
uint256 msgValue = msg.value;
// Tokens that are not on auction always have an endTimestamp of 0
require(timestamp <= auction.endTimestamp, "Auction has already ended");
require(timestamp >= auction.startTimestamp, "Auction has not started yet");
uint256 minPrice = auction.price + auction.minBidIncrement;
if (auction.topBidder == address(0)) {
minPrice = auction.price;
}
require(msgValue >= minPrice, "Bid is too small");
uint256 endTime = auction.endTimestamp;
if (endTime < auction.minLastBidDuration + timestamp) {
endTime = timestamp + auction.minLastBidDuration;
}
Auction memory newAuction = Auction(_msgSender(), msgValue, auction.startTimestamp, endTime, auction.minBidIncrement, auction.minLastBidDuration);
if (auction.topBidder != address(0)) {
// Give the old top bidder their money back
payable(auction.topBidder).transfer(auction.price);
}
_tokenIdToAuction[tokenId] = newAuction;
emit AuctionBidded(tokenId, newAuction.price, newAuction.topBidder);
}
| 18,726 |
64 | // transfer ownershipnewOwner_ the new address to assume ownership responsiblity (the multisig)/ | function transferOwner(address payable newOwner_) public onlyOwner {
owner = newOwner_;
}
| function transferOwner(address payable newOwner_) public onlyOwner {
owner = newOwner_;
}
| 15,555 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.