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
|
|---|---|---|---|---|
52
|
// set token on pause
|
function pauseToken() external onlyOwner {
Token(token).pause();
}
|
function pauseToken() external onlyOwner {
Token(token).pause();
}
| 36,178
|
139
|
// Increase the ETH-A Stability Fee from 1.75% to 3.74%
|
DssExecLib.setIlkStabilityFee("ETH-A", THREE_PT_SEVEN_FOUR_PCT_RATE, /* doDrip = */ true);
|
DssExecLib.setIlkStabilityFee("ETH-A", THREE_PT_SEVEN_FOUR_PCT_RATE, /* doDrip = */ true);
| 10,591
|
67
|
// Emit events for each removed tier.
|
for (uint256 _i; _i < _numberOfTiersToRemove;) {
emit RemoveTier(_tierIdsToRemove[_i], msg.sender);
unchecked {
++_i;
}
|
for (uint256 _i; _i < _numberOfTiersToRemove;) {
emit RemoveTier(_tierIdsToRemove[_i], msg.sender);
unchecked {
++_i;
}
| 30,556
|
85
|
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
|
require(!_exists(startTokenId), "ERC721A: token already minted");
require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
AddressData memory addressData = _addressData[to];
_addressData[to] = AddressData(
addressData.balance + uint128(quantity),
addressData.numberMinted + uint128(quantity)
);
|
require(!_exists(startTokenId), "ERC721A: token already minted");
require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
AddressData memory addressData = _addressData[to];
_addressData[to] = AddressData(
addressData.balance + uint128(quantity),
addressData.numberMinted + uint128(quantity)
);
| 7,203
|
553
|
// The balanceOf here can be considered "transferable" since it's not escrowed, and it is the only SNX that can potentially be transfered if unstaked.
|
uint transferable = synthetixERC20().balanceOf(account);
if (redeemTarget.add(rewardsSum) <= transferable) {
|
uint transferable = synthetixERC20().balanceOf(account);
if (redeemTarget.add(rewardsSum) <= transferable) {
| 24,723
|
107
|
// } escrow alia
|
token.transferFrom(msg.sender, bankAddress[seriesId], price);
|
token.transferFrom(msg.sender, bankAddress[seriesId], price);
| 52,643
|
153
|
// excludes an assimilator from the shell/_derivative the address of the assimilator to exclude
|
function excludeDerivative (
address _derivative
|
function excludeDerivative (
address _derivative
| 23,038
|
3
|
// Whether or not the message sender can override the royalty address for the given token addresstokenAddress- The token address you are looking up the royalty for /
|
function overrideAllowed(address tokenAddress) external view returns (bool);
|
function overrideAllowed(address tokenAddress) external view returns (bool);
| 9,380
|
11
|
// Transfer payment to receiver
|
payable(product.receiver).transfer(payment);
|
payable(product.receiver).transfer(payment);
| 24,429
|
8
|
// add a deposit for this paymaster, used for paying for transaction fees /
|
function deposit() external payable virtual;
|
function deposit() external payable virtual;
| 11,335
|
5
|
// Mint a new ticket by providing the token ID /
|
function claim(uint256 goldenTicketId) public whenNotPaused {
require(_goldenTicket.balanceOf(_msgSender()) > 0, "Caller does not own a Golden Ticket");
require(!_usedGoldenTickets[goldenTicketId], "Relic already used");
_usedGoldenTickets[goldenTicketId] = true;
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(_msgSender(), tokenId);
_setTokenURI(tokenId, _BaseNFTBookURI);
_ClaimedTokenCounter.increment();
}
|
function claim(uint256 goldenTicketId) public whenNotPaused {
require(_goldenTicket.balanceOf(_msgSender()) > 0, "Caller does not own a Golden Ticket");
require(!_usedGoldenTickets[goldenTicketId], "Relic already used");
_usedGoldenTickets[goldenTicketId] = true;
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(_msgSender(), tokenId);
_setTokenURI(tokenId, _BaseNFTBookURI);
_ClaimedTokenCounter.increment();
}
| 33,211
|
70
|
// Increases the total supply by minting the specified number of tokens to the supply controller account. _value The number of tokens to add.return A boolean that indicates if the operation was successful. /
|
function increaseSupply(uint256 _value) public onlySupplyController returns (bool success) {
totalSupply_ = totalSupply_.add(_value);
balances[supplyController] = balances[supplyController].add(_value);
emit SupplyIncreased(supplyController, _value);
emit Transfer(address(0), supplyController, _value);
return true;
}
|
function increaseSupply(uint256 _value) public onlySupplyController returns (bool success) {
totalSupply_ = totalSupply_.add(_value);
balances[supplyController] = balances[supplyController].add(_value);
emit SupplyIncreased(supplyController, _value);
emit Transfer(address(0), supplyController, _value);
return true;
}
| 21,096
|
332
|
// Get the IPNS name to which trader and market maker exchange statistics are published. return The IPNS name. /
|
function getIpnsName()
external
view
returns (string memory)
|
function getIpnsName()
external
view
returns (string memory)
| 77,525
|
5
|
// Last iToken price, used to pause contract in case of a black swan event
|
uint256 public lastITokenPrice;
|
uint256 public lastITokenPrice;
| 42,004
|
214
|
// Remove the zombie at the given index zombieNum Index of the zombie to remove /
|
function removeZombie(uint256 zombieNum) internal {
_zombies[zombieNum] = _zombies[_zombies.length - 1];
_zombies.pop();
}
|
function removeZombie(uint256 zombieNum) internal {
_zombies[zombieNum] = _zombies[_zombies.length - 1];
_zombies.pop();
}
| 48,518
|
8
|
// 특정 부품을 차단합니다.
|
function blockPart(uint256 partIdToBlock) onlyCompany public {
partIdToIsBlocked[partIdToBlock] = true;
emit BlockPart(partIdToBlock);
}
|
function blockPart(uint256 partIdToBlock) onlyCompany public {
partIdToIsBlocked[partIdToBlock] = true;
emit BlockPart(partIdToBlock);
}
| 44,003
|
121
|
// Create new Maker vault
|
function createVault() external onlyGovernor {
cm.createVault(collateralType);
}
|
function createVault() external onlyGovernor {
cm.createVault(collateralType);
}
| 61,636
|
22
|
// Allow `spender` to withdraw, multiple times, up to the `value` amount
|
function approve(address spender, uint256 value) public returns (bool);
|
function approve(address spender, uint256 value) public returns (bool);
| 8,321
|
89
|
// METHOD: Decrease allowance value of message sender to `_spender`.return success or not /
|
function decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool success) {
return bicaLogic.decreaseApprovalWithSender(msg.sender, _spender, _subtractedValue);
}
|
function decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool success) {
return bicaLogic.decreaseApprovalWithSender(msg.sender, _spender, _subtractedValue);
}
| 5,180
|
26
|
// Airdrop Generic contract for token airdrop, initially used for BTL token (0x2accaB9cb7a48c3E82286F0b2f8798D201F4eC3f) /
|
contract TokenGiveaway is Managed {
address private tokenContract = 0x2accaB9cb7a48c3E82286F0b2f8798D201F4eC3f;
address private donor = 0xeA03Ee7110FAFb324d4a931979eF4578bffB6a00;
uint private etherAmount = 0.0005 ether;
uint private tokenAmount = 500;
uint private decimals = 10**18;
mapping (address => mapping (address => bool)) private receivers;
event Airdropped(address indexed tokenContract, address receiver, uint tokenReceived);
function TokenGiveaway () Managed("1.0.0") public { }
/**
*
*/
function transferBatch(address[] _addresses) onlyOwner external {
uint length = _addresses.length;
for (uint i = 0; i < length; i++) {
if (isOpenFor(_addresses[i])) {
transferTokens(_addresses[i], tokenAmount * decimals);
}
}
}
/**
*/
function transferTokens(address _receiver, uint _tokenAmount) private {
receivers[tokenContract][_receiver] = TokenERC20(tokenContract).transferFrom(donor, _receiver, _tokenAmount);
}
/**
*
*/
function isOpen() public view returns (bool open) {
return TokenERC20(tokenContract).allowance(donor, this) >= tokenAmount * decimals;
}
/**
*
*/
function isOpenFor(address _receiver) public view returns (bool open) {
return !receivers[tokenContract][_receiver] && isOpen();
}
/**
*/
function () external payable {
require(msg.value >= etherAmount && isOpenFor(msg.sender));
transferTokens(msg.sender, tokenAmount * decimals);
}
function updateTokenContract(address _tokenContract) external onlyOwner { tokenContract = _tokenContract; }
function updateDonor(address _donor) external onlyOwner { donor = _donor; }
function updateEtherAmount(uint _etherAmount) external onlyOwner { etherAmount = _etherAmount; }
function updateTokenAmount(uint _tokenAmount) external onlyOwner { tokenAmount = _tokenAmount; }
function updateDecimals(uint _decimals) external onlyOwner { decimals = _decimals; }
function updateEtherAndtokenAmount(uint _etherAmount, uint _tokenAmount) external onlyOwner {
etherAmount = _etherAmount;
tokenAmount = _tokenAmount;
}
function updateEtherAndtokenAmount(address _donor, uint _etherAmount, uint _tokenAmount) external onlyOwner {
donor = _donor;
etherAmount = _etherAmount;
tokenAmount = _tokenAmount;
}
function updateParameters(address _tokenContract, address _donor, uint _etherAmount, uint _tokenAmount, uint _decimals) external onlyOwner {
tokenContract = _tokenContract;
donor = _donor;
etherAmount = _etherAmount;
tokenAmount = _tokenAmount;
decimals = _decimals;
}
}
|
contract TokenGiveaway is Managed {
address private tokenContract = 0x2accaB9cb7a48c3E82286F0b2f8798D201F4eC3f;
address private donor = 0xeA03Ee7110FAFb324d4a931979eF4578bffB6a00;
uint private etherAmount = 0.0005 ether;
uint private tokenAmount = 500;
uint private decimals = 10**18;
mapping (address => mapping (address => bool)) private receivers;
event Airdropped(address indexed tokenContract, address receiver, uint tokenReceived);
function TokenGiveaway () Managed("1.0.0") public { }
/**
*
*/
function transferBatch(address[] _addresses) onlyOwner external {
uint length = _addresses.length;
for (uint i = 0; i < length; i++) {
if (isOpenFor(_addresses[i])) {
transferTokens(_addresses[i], tokenAmount * decimals);
}
}
}
/**
*/
function transferTokens(address _receiver, uint _tokenAmount) private {
receivers[tokenContract][_receiver] = TokenERC20(tokenContract).transferFrom(donor, _receiver, _tokenAmount);
}
/**
*
*/
function isOpen() public view returns (bool open) {
return TokenERC20(tokenContract).allowance(donor, this) >= tokenAmount * decimals;
}
/**
*
*/
function isOpenFor(address _receiver) public view returns (bool open) {
return !receivers[tokenContract][_receiver] && isOpen();
}
/**
*/
function () external payable {
require(msg.value >= etherAmount && isOpenFor(msg.sender));
transferTokens(msg.sender, tokenAmount * decimals);
}
function updateTokenContract(address _tokenContract) external onlyOwner { tokenContract = _tokenContract; }
function updateDonor(address _donor) external onlyOwner { donor = _donor; }
function updateEtherAmount(uint _etherAmount) external onlyOwner { etherAmount = _etherAmount; }
function updateTokenAmount(uint _tokenAmount) external onlyOwner { tokenAmount = _tokenAmount; }
function updateDecimals(uint _decimals) external onlyOwner { decimals = _decimals; }
function updateEtherAndtokenAmount(uint _etherAmount, uint _tokenAmount) external onlyOwner {
etherAmount = _etherAmount;
tokenAmount = _tokenAmount;
}
function updateEtherAndtokenAmount(address _donor, uint _etherAmount, uint _tokenAmount) external onlyOwner {
donor = _donor;
etherAmount = _etherAmount;
tokenAmount = _tokenAmount;
}
function updateParameters(address _tokenContract, address _donor, uint _etherAmount, uint _tokenAmount, uint _decimals) external onlyOwner {
tokenContract = _tokenContract;
donor = _donor;
etherAmount = _etherAmount;
tokenAmount = _tokenAmount;
decimals = _decimals;
}
}
| 38,187
|
4
|
// VaultProxy delegates calls to a Vault implementation /
|
contract VaultProxy is InitializeGovernedUpgradeabilityProxy {
}
|
contract VaultProxy is InitializeGovernedUpgradeabilityProxy {
}
| 7,683
|
35
|
// get token total supply
|
totalSupply = _tokenIdTracker.current();
return totalSupply;
|
totalSupply = _tokenIdTracker.current();
return totalSupply;
| 48,206
|
26
|
// store the actual player info so we can reference it from the tickets
|
players[numplayers] = msg.sender;
numplayers++;
|
players[numplayers] = msg.sender;
numplayers++;
| 23,502
|
7
|
// signature methods.
|
function splitSignature(bytes memory sig)
internal
pure
returns (uint8 v, bytes32 r, bytes32 s)
|
function splitSignature(bytes memory sig)
internal
pure
returns (uint8 v, bytes32 r, bytes32 s)
| 48,437
|
168
|
// Presale Mint Function /
|
{
require(presaleActive, "Presale is not live.");
_safeMint(msg.sender, quantity);
refundIfOver(quantity * whitelistMintPrice);
}
|
{
require(presaleActive, "Presale is not live.");
_safeMint(msg.sender, quantity);
refundIfOver(quantity * whitelistMintPrice);
}
| 37,345
|
37
|
// Math operations with safety checks that throw on error. This contract is based on thesource code at: /
|
library SafeMath {
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
* @param _minuend Minuend number.
* @param _subtrahend Subtrahend number.
* @return difference Difference.
*/
function sub( uint256 _minuend, uint256 _subtrahend ) internal pure returns (uint256 difference) {
require(_subtrahend <= _minuend);
difference = _minuend - _subtrahend;
}
/**
* @dev Adds two numbers, reverts on overflow.
* @param _addend1 Number.
* @param _addend2 Number.
* @return sum Sum.
*/
function add( uint256 _addend1, uint256 _addend2) internal pure returns (uint256 sum) {
sum = _addend1 + _addend2;
require(sum >= _addend1);
}
}
|
library SafeMath {
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
* @param _minuend Minuend number.
* @param _subtrahend Subtrahend number.
* @return difference Difference.
*/
function sub( uint256 _minuend, uint256 _subtrahend ) internal pure returns (uint256 difference) {
require(_subtrahend <= _minuend);
difference = _minuend - _subtrahend;
}
/**
* @dev Adds two numbers, reverts on overflow.
* @param _addend1 Number.
* @param _addend2 Number.
* @return sum Sum.
*/
function add( uint256 _addend1, uint256 _addend2) internal pure returns (uint256 sum) {
sum = _addend1 + _addend2;
require(sum >= _addend1);
}
}
| 17,952
|
16
|
// New, non zero value. Set.
|
bool plusOrMinus = tree.nodes[treeIndex] <= _value;
uint256 plusOrMinusValue = plusOrMinus
? _value - tree.nodes[treeIndex]
: tree.nodes[treeIndex] - _value;
tree.nodes[treeIndex] = _value;
updateParents(self, _key, treeIndex, plusOrMinus, plusOrMinusValue);
|
bool plusOrMinus = tree.nodes[treeIndex] <= _value;
uint256 plusOrMinusValue = plusOrMinus
? _value - tree.nodes[treeIndex]
: tree.nodes[treeIndex] - _value;
tree.nodes[treeIndex] = _value;
updateParents(self, _key, treeIndex, plusOrMinus, plusOrMinusValue);
| 20,617
|
686
|
// Slot (The current value) Scheduled Slot (The future value) Scheduled Time (The future time)/
|
library UnstructuredStorageWithTimelock {
// This is used to calculate the time slot and scheduled content for different variables
uint256 private constant SCHEDULED_SIGNATURE = 0x111;
uint256 private constant TIMESLOT_SIGNATURE = 0xAAA;
function updateAddressWithTimelock(bytes32 _slot) internal {
require(
scheduledTime(_slot) > block.timestamp,
"Timelock has not passed"
);
setAddress(_slot, scheduledAddress(_slot));
}
function updateUint256WithTimelock(bytes32 _slot) internal {
require(
scheduledTime(_slot) > block.timestamp,
"Timelock has not passed"
);
setUint256(_slot, scheduledUint256(_slot));
}
function setAddress(bytes32 _slot, address _target) internal {
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(_slot, _target)
}
}
function fetchAddress(bytes32 _slot)
internal
view
returns (address result)
{
assembly {
result := sload(_slot)
}
}
function scheduledAddress(bytes32 _slot)
internal
view
returns (address result)
{
result = fetchAddress(scheduledContentSlot(_slot));
}
function scheduledUint256(bytes32 _slot)
internal
view
returns (uint256 result)
{
result = fetchUint256(scheduledContentSlot(_slot));
}
function setUint256(bytes32 _slot, uint256 _target) internal {
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(_slot, _target)
}
}
function fetchUint256(bytes32 _slot)
internal
view
returns (uint256 result)
{
assembly {
result := sload(_slot)
}
}
function scheduledContentSlot(bytes32 _slot)
internal
pure
returns (bytes32)
{
return
bytes32(
uint256(keccak256(abi.encodePacked(_slot, SCHEDULED_SIGNATURE)))
);
}
function scheduledTime(bytes32 _slot) internal view returns (uint256) {
return fetchUint256(scheduledTimeSlot(_slot));
}
function scheduledTimeSlot(bytes32 _slot) internal pure returns (bytes32) {
return
bytes32(
uint256(keccak256(abi.encodePacked(_slot, TIMESLOT_SIGNATURE)))
);
}
}
|
library UnstructuredStorageWithTimelock {
// This is used to calculate the time slot and scheduled content for different variables
uint256 private constant SCHEDULED_SIGNATURE = 0x111;
uint256 private constant TIMESLOT_SIGNATURE = 0xAAA;
function updateAddressWithTimelock(bytes32 _slot) internal {
require(
scheduledTime(_slot) > block.timestamp,
"Timelock has not passed"
);
setAddress(_slot, scheduledAddress(_slot));
}
function updateUint256WithTimelock(bytes32 _slot) internal {
require(
scheduledTime(_slot) > block.timestamp,
"Timelock has not passed"
);
setUint256(_slot, scheduledUint256(_slot));
}
function setAddress(bytes32 _slot, address _target) internal {
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(_slot, _target)
}
}
function fetchAddress(bytes32 _slot)
internal
view
returns (address result)
{
assembly {
result := sload(_slot)
}
}
function scheduledAddress(bytes32 _slot)
internal
view
returns (address result)
{
result = fetchAddress(scheduledContentSlot(_slot));
}
function scheduledUint256(bytes32 _slot)
internal
view
returns (uint256 result)
{
result = fetchUint256(scheduledContentSlot(_slot));
}
function setUint256(bytes32 _slot, uint256 _target) internal {
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(_slot, _target)
}
}
function fetchUint256(bytes32 _slot)
internal
view
returns (uint256 result)
{
assembly {
result := sload(_slot)
}
}
function scheduledContentSlot(bytes32 _slot)
internal
pure
returns (bytes32)
{
return
bytes32(
uint256(keccak256(abi.encodePacked(_slot, SCHEDULED_SIGNATURE)))
);
}
function scheduledTime(bytes32 _slot) internal view returns (uint256) {
return fetchUint256(scheduledTimeSlot(_slot));
}
function scheduledTimeSlot(bytes32 _slot) internal pure returns (bytes32) {
return
bytes32(
uint256(keccak256(abi.encodePacked(_slot, TIMESLOT_SIGNATURE)))
);
}
}
| 44,980
|
11
|
// Emitted when `value` tokens are moved from one account (`from`) toanother (`to`). Note that `value` may be zero. /
|
event Transfer(address indexed from, address indexed to, uint256 value);
|
event Transfer(address indexed from, address indexed to, uint256 value);
| 13,234
|
8
|
// Guard variable for re-entrancy checks /
|
bool internal _notEntered;
|
bool internal _notEntered;
| 5,224
|
74
|
// scale adjustment relative to runtime
|
newSpeed =
(speed * oldSpeedWeight + updateAmount * updateWeight) /
(oldSpeedWeight + updateWeight);
newLastAction = block.timestamp;
|
newSpeed =
(speed * oldSpeedWeight + updateAmount * updateWeight) /
(oldSpeedWeight + updateWeight);
newLastAction = block.timestamp;
| 7,465
|
1
|
// Checks the validity of SNARK data proof the proof to verifyreturn the validity of the proof /
|
function verify(RecursiveProof calldata proof) external view returns (bool);
|
function verify(RecursiveProof calldata proof) external view returns (bool);
| 27,564
|
6
|
// deposit
|
string public constant DEPOSIT_AMOUNT_SHOULD_BE_BIGGER_THAN_ZERO = '320';
|
string public constant DEPOSIT_AMOUNT_SHOULD_BE_BIGGER_THAN_ZERO = '320';
| 9,748
|
10
|
// Constructor function /
|
function ChainStarBase(uint256 _initialSupply, string _tokenName, string _tokenSymbol, uint8 _decimals) public {
name = _tokenName; // Set the name for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
decimals = _decimals;
totalSupply = _initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balances[msg.sender] = totalSupply; // Give the creator all initial tokens
}
|
function ChainStarBase(uint256 _initialSupply, string _tokenName, string _tokenSymbol, uint8 _decimals) public {
name = _tokenName; // Set the name for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
decimals = _decimals;
totalSupply = _initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balances[msg.sender] = totalSupply; // Give the creator all initial tokens
}
| 26,306
|
2
|
// Sets the target chain gas reserve value _gasReserve The target chain gas reserve value /
|
function setTargetGasReserve(uint256 _gasReserve) external onlyManager {
_setTargetGasReserve(_gasReserve);
}
|
function setTargetGasReserve(uint256 _gasReserve) external onlyManager {
_setTargetGasReserve(_gasReserve);
}
| 38,540
|
136
|
// the id of nft token
|
uint256 nftTokenId;
|
uint256 nftTokenId;
| 25,189
|
324
|
// Rewards in fee period [0] are not yet available for withdrawal
|
for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) {
totalRewards = totalRewards.add(_recentFeePeriodsStorage(i).rewardsToDistribute);
totalRewards = totalRewards.sub(_recentFeePeriodsStorage(i).rewardsClaimed);
}
|
for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) {
totalRewards = totalRewards.add(_recentFeePeriodsStorage(i).rewardsToDistribute);
totalRewards = totalRewards.sub(_recentFeePeriodsStorage(i).rewardsClaimed);
}
| 13,358
|
25
|
// Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain
|
function startBroadcast(uint256 privateKey) external;
|
function startBroadcast(uint256 privateKey) external;
| 17,567
|
336
|
// ORDER EVENTS
|
event OrderCreated(
bytes id,
address indexed seller,
address indexed nftAddress,
uint256 priceInWei,
uint256 expiresAt,
address currency
);
event OrderUpdated(
|
event OrderCreated(
bytes id,
address indexed seller,
address indexed nftAddress,
uint256 priceInWei,
uint256 expiresAt,
address currency
);
event OrderUpdated(
| 45,412
|
134
|
// By setting the threshold it is not possible to call setup anymore, so we create a Safe with 0 owners and threshold 1. This is an unusable Safe, perfect for the singleton
|
threshold = 1;
|
threshold = 1;
| 8,043
|
60
|
// Amount of tokens for to transfer.
|
uint256 amount;
|
uint256 amount;
| 6,983
|
21
|
// Revert immediately if x2 would overflow. Equivalent to iszero(eq(div(xx, x), x)) here.
|
if shr(128, x) {
revert(0, 0)
}
|
if shr(128, x) {
revert(0, 0)
}
| 26,908
|
8
|
// An account cannot vote twice and must send 0.01 ether to be allowed to vote /
|
function vote(int8 _vote)
public
payable
canVote
costs(0.01 ether)
|
function vote(int8 _vote)
public
payable
canVote
costs(0.01 ether)
| 12,059
|
97
|
// Converters
|
function amountToBettableAmountConverter(uint amount, address token) internal view returns(uint) {
return amount * (10000 - supportedTokenInfo[token].houseEdgeBP) / 10000;
}
|
function amountToBettableAmountConverter(uint amount, address token) internal view returns(uint) {
return amount * (10000 - supportedTokenInfo[token].houseEdgeBP) / 10000;
}
| 29,198
|
17
|
// Amount in wei.
|
uint amount;
|
uint amount;
| 16,179
|
27
|
// All the different states a game can have (only 1 at a time) /
|
enum GameStates { Open, Frozen, Closed }
/**
* @notice All the possible results (only 1 at a time)
* @dev All new games are initialized with a NotYet result
*/
enum GameResults { NotYet, TeamA, Draw, TeamB }
/**
* @notice This struct defines what a game is
*/
struct Game {
string teamA;
uint amountToTeamA;
string teamB;
uint amountToTeamB;
uint amountToDraw;
string description;
uint frozenTimestamp;
uint bettorsCount;
GameResults result;
GameStates state;
bool isHouseCutWithdrawn;
}
|
enum GameStates { Open, Frozen, Closed }
/**
* @notice All the possible results (only 1 at a time)
* @dev All new games are initialized with a NotYet result
*/
enum GameResults { NotYet, TeamA, Draw, TeamB }
/**
* @notice This struct defines what a game is
*/
struct Game {
string teamA;
uint amountToTeamA;
string teamB;
uint amountToTeamB;
uint amountToDraw;
string description;
uint frozenTimestamp;
uint bettorsCount;
GameResults result;
GameStates state;
bool isHouseCutWithdrawn;
}
| 2,783
|
461
|
// deposits tokens to the master vault and verifies that msg.value corresponds to its type /
|
function _depositToMasterVault(
Token token,
address caller,
uint256 amount
|
function _depositToMasterVault(
Token token,
address caller,
uint256 amount
| 56,424
|
43
|
// Returns true if this contract implements the interface defined by`interfaceId`. See the correspondingto learn more about how these ids are created. This function call must use less than 30000 gas. /
|
function supportsInterface(
bytes4 interfaceId
|
function supportsInterface(
bytes4 interfaceId
| 2,616
|
1
|
// used for testing upgrade
|
uint public version;
|
uint public version;
| 24,284
|
85
|
// Disable solium check because of https:github.com/duaraghav8/Solium/issues/175 solium-disable-next-line operator-whitespace
|
return (
spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender)
);
|
return (
spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender)
);
| 31,933
|
47
|
// Check the amount of grants that an address has. _holder The holder of the grants.return A uint representing the total amount of grants. /
|
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
|
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
| 36,176
|
85
|
// ERC1155Creator implementation /
|
contract ERC1155Creator is AdminControl, ERC1155, ERC1155CreatorCore {
mapping(uint256 => uint256) private _totalSupply;
constructor () ERC1155("") {}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, ERC1155CreatorCore, AdminControl) returns (bool) {
return ERC1155CreatorCore.supportsInterface(interfaceId) || ERC1155.supportsInterface(interfaceId) || AdminControl.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(address, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory) internal virtual override {
_approveTransfer(from, to, ids, amounts);
}
/**
* @dev See {ICreatorCore-registerExtension}.
*/
function registerExtension(address extension, string calldata baseURI) external override adminRequired nonBlacklistRequired(extension) {
_registerExtension(extension, baseURI, false);
}
/**
* @dev See {ICreatorCore-registerExtension}.
*/
function registerExtension(address extension, string calldata baseURI, bool baseURIIdentical) external override adminRequired nonBlacklistRequired(extension) {
_registerExtension(extension, baseURI, baseURIIdentical);
}
/**
* @dev See {ICreatorCore-unregisterExtension}.
*/
function unregisterExtension(address extension) external override adminRequired {
_unregisterExtension(extension);
}
/**
* @dev See {ICreatorCore-blacklistExtension}.
*/
function blacklistExtension(address extension) external override adminRequired {
_blacklistExtension(extension);
}
/**
* @dev See {ICreatorCore-setBaseTokenURIExtension}.
*/
function setBaseTokenURIExtension(string calldata uri_) external override extensionRequired {
_setBaseTokenURIExtension(uri_, false);
}
/**
* @dev See {ICreatorCore-setBaseTokenURIExtension}.
*/
function setBaseTokenURIExtension(string calldata uri_, bool identical) external override extensionRequired {
_setBaseTokenURIExtension(uri_, identical);
}
/**
* @dev See {ICreatorCore-setTokenURIPrefixExtension}.
*/
function setTokenURIPrefixExtension(string calldata prefix) external override extensionRequired {
_setTokenURIPrefixExtension(prefix);
}
/**
* @dev See {ICreatorCore-setTokenURIExtension}.
*/
function setTokenURIExtension(uint256 tokenId, string calldata uri_) external override extensionRequired {
_setTokenURIExtension(tokenId, uri_);
}
/**
* @dev See {ICreatorCore-setTokenURIExtension}.
*/
function setTokenURIExtension(uint256[] memory tokenIds, string[] calldata uris) external override extensionRequired {
require(tokenIds.length == uris.length, "Invalid input");
for (uint i = 0; i < tokenIds.length; i++) {
_setTokenURIExtension(tokenIds[i], uris[i]);
}
}
/**
* @dev See {ICreatorCore-setBaseTokenURI}.
*/
function setBaseTokenURI(string calldata uri_) external override adminRequired {
_setBaseTokenURI(uri_);
}
/**
* @dev See {ICreatorCore-setTokenURIPrefix}.
*/
function setTokenURIPrefix(string calldata prefix) external override adminRequired {
_setTokenURIPrefix(prefix);
}
/**
* @dev See {ICreatorCore-setTokenURI}.
*/
function setTokenURI(uint256 tokenId, string calldata uri_) external override adminRequired {
_setTokenURI(tokenId, uri_);
}
/**
* @dev See {ICreatorCore-setTokenURI}.
*/
function setTokenURI(uint256[] memory tokenIds, string[] calldata uris) external override adminRequired {
require(tokenIds.length == uris.length, "Invalid input");
for (uint i = 0; i < tokenIds.length; i++) {
_setTokenURI(tokenIds[i], uris[i]);
}
}
/**
* @dev See {ICreatorCore-setMintPermissions}.
*/
function setMintPermissions(address extension, address permissions) external override adminRequired {
_setMintPermissions(extension, permissions);
}
/**
* @dev See {IERC1155CreatorCore-mintBaseNew}.
*/
function mintBaseNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) public virtual override nonReentrant adminRequired returns(uint256[] memory) {
return _mintNew(address(this), to, amounts, uris);
}
/**
* @dev See {IERC1155CreatorCore-mintBaseExisting}.
*/
function mintBaseExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) public virtual override nonReentrant adminRequired {
for (uint i = 0; i < tokenIds.length; i++) {
require(_tokensExtension[tokenIds[i]] == address(this), "A token was created by an extension");
}
_mintExisting(address(this), to, tokenIds, amounts);
}
/**
* @dev See {IERC1155CreatorCore-mintExtensionNew}.
*/
function mintExtensionNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) public virtual override nonReentrant extensionRequired returns(uint256[] memory tokenIds) {
return _mintNew(msg.sender, to, amounts, uris);
}
/**
* @dev See {IERC1155CreatorCore-mintExtensionExisting}.
*/
function mintExtensionExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) public virtual override nonReentrant extensionRequired {
for (uint i = 0; i < tokenIds.length; i++) {
require(_tokensExtension[tokenIds[i]] == address(msg.sender), "A token was not created by this extension");
}
_mintExisting(msg.sender, to, tokenIds, amounts);
}
/**
* @dev Mint new tokens
*/
function _mintNew(address extension, address[] memory to, uint256[] memory amounts, string[] memory uris) internal returns(uint256[] memory tokenIds) {
if (to.length > 1) {
// Multiple receiver. Give every receiver the same new token
tokenIds = new uint256[](1);
require(uris.length <= 1 && (amounts.length == 1 || to.length == amounts.length), "Invalid input");
} else {
// Single receiver. Generating multiple tokens
tokenIds = new uint256[](amounts.length);
require(uris.length == 0 || amounts.length == uris.length, "Invalid input");
}
// Assign tokenIds
for (uint i = 0; i < tokenIds.length; i++) {
_tokenCount++;
tokenIds[i] = _tokenCount;
// Track the extension that minted the token
_tokensExtension[_tokenCount] = extension;
}
if (extension != address(this)) {
_checkMintPermissions(to, tokenIds, amounts);
}
if (to.length == 1 && tokenIds.length == 1) {
// Single mint
_mint(to[0], tokenIds[0], amounts[0], new bytes(0));
} else if (to.length > 1) {
// Multiple receivers. Receiving the same token
if (amounts.length == 1) {
// Everyone receiving the same amount
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[0], amounts[0], new bytes(0));
}
} else {
// Everyone receiving different amounts
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[0], amounts[i], new bytes(0));
}
}
} else {
_mintBatch(to[0], tokenIds, amounts, new bytes(0));
}
for (uint i = 0; i < tokenIds.length; i++) {
if (i < uris.length && bytes(uris[i]).length > 0) {
_tokenURIs[tokenIds[i]] = uris[i];
}
}
return tokenIds;
}
/**
* @dev Mint existing tokens
*/
function _mintExisting(address extension, address[] memory to, uint256[] memory tokenIds, uint256[] memory amounts) internal {
if (extension != address(this)) {
_checkMintPermissions(to, tokenIds, amounts);
}
if (to.length == 1 && tokenIds.length == 1 && amounts.length == 1) {
// Single mint
_mint(to[0], tokenIds[0], amounts[0], new bytes(0));
} else if (to.length == 1 && tokenIds.length == amounts.length) {
// Batch mint to same receiver
_mintBatch(to[0], tokenIds, amounts, new bytes(0));
} else if (tokenIds.length == 1 && amounts.length == 1) {
// Mint of the same token/token amounts to various receivers
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[0], amounts[0], new bytes(0));
}
} else if (tokenIds.length == 1 && to.length == amounts.length) {
// Mint of the same token with different amounts to different receivers
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[0], amounts[i], new bytes(0));
}
} else if (to.length == tokenIds.length && to.length == amounts.length) {
// Mint of different tokens and different amounts to different receivers
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[i], amounts[i], new bytes(0));
}
} else {
revert("Invalid input");
}
}
/**
* @dev See {IERC1155CreatorCore-tokenExtension}.
*/
function tokenExtension(uint256 tokenId) public view virtual override returns (address) {
return _tokenExtension(tokenId);
}
/**
* @dev See {IERC1155CreatorCore-burn}.
*/
function burn(address account, uint256[] memory tokenIds, uint256[] memory amounts) public virtual override nonReentrant {
require(account == msg.sender || isApprovedForAll(account, msg.sender), "Caller is not owner nor approved");
require(tokenIds.length == amounts.length, "Invalid input");
if (tokenIds.length == 1) {
_burn(account, tokenIds[0], amounts[0]);
} else {
_burnBatch(account, tokenIds, amounts);
}
_postBurn(account, tokenIds, amounts);
}
/**
* @dev See {ICreatorCore-setRoyalties}.
*/
function setRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
_setRoyaltiesExtension(address(this), receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-setRoyalties}.
*/
function setRoyalties(uint256 tokenId, address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
_setRoyalties(tokenId, receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-setRoyaltiesExtension}.
*/
function setRoyaltiesExtension(address extension, address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
_setRoyaltiesExtension(extension, receivers, basisPoints);
}
/**
* @dev {See ICreatorCore-getRoyalties}.
*/
function getRoyalties(uint256 tokenId) external view virtual override returns (address payable[] memory, uint256[] memory) {
return _getRoyalties(tokenId);
}
/**
* @dev {See ICreatorCore-getFees}.
*/
function getFees(uint256 tokenId) external view virtual override returns (address payable[] memory, uint256[] memory) {
return _getRoyalties(tokenId);
}
/**
* @dev {See ICreatorCore-getFeeRecipients}.
*/
function getFeeRecipients(uint256 tokenId) external view virtual override returns (address payable[] memory) {
return _getRoyaltyReceivers(tokenId);
}
/**
* @dev {See ICreatorCore-getFeeBps}.
*/
function getFeeBps(uint256 tokenId) external view virtual override returns (uint[] memory) {
return _getRoyaltyBPS(tokenId);
}
/**
* @dev {See ICreatorCore-royaltyInfo}.
*/
function royaltyInfo(uint256 tokenId, uint256 value) external view virtual override returns (address, uint256) {
return _getRoyaltyInfo(tokenId, value);
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function uri(uint256 tokenId) public view virtual override returns (string memory) {
return _tokenURI(tokenId);
}
/**
* @dev Total amount of tokens in with a given id.
*/
function totalSupply(uint256 tokenId) external view virtual override returns (uint256) {
return _totalSupply[tokenId];
}
/**
* @dev See {ERC1155-_mint}.
*/
function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual override {
super._mint(account, id, amount, data);
_totalSupply[id] += amount;
}
/**
* @dev See {ERC1155-_mintBatch}.
*/
function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual override {
super._mintBatch(to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] += amounts[i];
}
}
/**
* @dev See {ERC1155-_burn}.
*/
function _burn(address account, uint256 id, uint256 amount) internal virtual override {
super._burn(account, id, amount);
_totalSupply[id] -= amount;
}
/**
* @dev See {ERC1155-_burnBatch}.
*/
function _burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internal virtual override {
super._burnBatch(account, ids, amounts);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] -= amounts[i];
}
}
}
|
contract ERC1155Creator is AdminControl, ERC1155, ERC1155CreatorCore {
mapping(uint256 => uint256) private _totalSupply;
constructor () ERC1155("") {}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, ERC1155CreatorCore, AdminControl) returns (bool) {
return ERC1155CreatorCore.supportsInterface(interfaceId) || ERC1155.supportsInterface(interfaceId) || AdminControl.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(address, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory) internal virtual override {
_approveTransfer(from, to, ids, amounts);
}
/**
* @dev See {ICreatorCore-registerExtension}.
*/
function registerExtension(address extension, string calldata baseURI) external override adminRequired nonBlacklistRequired(extension) {
_registerExtension(extension, baseURI, false);
}
/**
* @dev See {ICreatorCore-registerExtension}.
*/
function registerExtension(address extension, string calldata baseURI, bool baseURIIdentical) external override adminRequired nonBlacklistRequired(extension) {
_registerExtension(extension, baseURI, baseURIIdentical);
}
/**
* @dev See {ICreatorCore-unregisterExtension}.
*/
function unregisterExtension(address extension) external override adminRequired {
_unregisterExtension(extension);
}
/**
* @dev See {ICreatorCore-blacklistExtension}.
*/
function blacklistExtension(address extension) external override adminRequired {
_blacklistExtension(extension);
}
/**
* @dev See {ICreatorCore-setBaseTokenURIExtension}.
*/
function setBaseTokenURIExtension(string calldata uri_) external override extensionRequired {
_setBaseTokenURIExtension(uri_, false);
}
/**
* @dev See {ICreatorCore-setBaseTokenURIExtension}.
*/
function setBaseTokenURIExtension(string calldata uri_, bool identical) external override extensionRequired {
_setBaseTokenURIExtension(uri_, identical);
}
/**
* @dev See {ICreatorCore-setTokenURIPrefixExtension}.
*/
function setTokenURIPrefixExtension(string calldata prefix) external override extensionRequired {
_setTokenURIPrefixExtension(prefix);
}
/**
* @dev See {ICreatorCore-setTokenURIExtension}.
*/
function setTokenURIExtension(uint256 tokenId, string calldata uri_) external override extensionRequired {
_setTokenURIExtension(tokenId, uri_);
}
/**
* @dev See {ICreatorCore-setTokenURIExtension}.
*/
function setTokenURIExtension(uint256[] memory tokenIds, string[] calldata uris) external override extensionRequired {
require(tokenIds.length == uris.length, "Invalid input");
for (uint i = 0; i < tokenIds.length; i++) {
_setTokenURIExtension(tokenIds[i], uris[i]);
}
}
/**
* @dev See {ICreatorCore-setBaseTokenURI}.
*/
function setBaseTokenURI(string calldata uri_) external override adminRequired {
_setBaseTokenURI(uri_);
}
/**
* @dev See {ICreatorCore-setTokenURIPrefix}.
*/
function setTokenURIPrefix(string calldata prefix) external override adminRequired {
_setTokenURIPrefix(prefix);
}
/**
* @dev See {ICreatorCore-setTokenURI}.
*/
function setTokenURI(uint256 tokenId, string calldata uri_) external override adminRequired {
_setTokenURI(tokenId, uri_);
}
/**
* @dev See {ICreatorCore-setTokenURI}.
*/
function setTokenURI(uint256[] memory tokenIds, string[] calldata uris) external override adminRequired {
require(tokenIds.length == uris.length, "Invalid input");
for (uint i = 0; i < tokenIds.length; i++) {
_setTokenURI(tokenIds[i], uris[i]);
}
}
/**
* @dev See {ICreatorCore-setMintPermissions}.
*/
function setMintPermissions(address extension, address permissions) external override adminRequired {
_setMintPermissions(extension, permissions);
}
/**
* @dev See {IERC1155CreatorCore-mintBaseNew}.
*/
function mintBaseNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) public virtual override nonReentrant adminRequired returns(uint256[] memory) {
return _mintNew(address(this), to, amounts, uris);
}
/**
* @dev See {IERC1155CreatorCore-mintBaseExisting}.
*/
function mintBaseExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) public virtual override nonReentrant adminRequired {
for (uint i = 0; i < tokenIds.length; i++) {
require(_tokensExtension[tokenIds[i]] == address(this), "A token was created by an extension");
}
_mintExisting(address(this), to, tokenIds, amounts);
}
/**
* @dev See {IERC1155CreatorCore-mintExtensionNew}.
*/
function mintExtensionNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) public virtual override nonReentrant extensionRequired returns(uint256[] memory tokenIds) {
return _mintNew(msg.sender, to, amounts, uris);
}
/**
* @dev See {IERC1155CreatorCore-mintExtensionExisting}.
*/
function mintExtensionExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) public virtual override nonReentrant extensionRequired {
for (uint i = 0; i < tokenIds.length; i++) {
require(_tokensExtension[tokenIds[i]] == address(msg.sender), "A token was not created by this extension");
}
_mintExisting(msg.sender, to, tokenIds, amounts);
}
/**
* @dev Mint new tokens
*/
function _mintNew(address extension, address[] memory to, uint256[] memory amounts, string[] memory uris) internal returns(uint256[] memory tokenIds) {
if (to.length > 1) {
// Multiple receiver. Give every receiver the same new token
tokenIds = new uint256[](1);
require(uris.length <= 1 && (amounts.length == 1 || to.length == amounts.length), "Invalid input");
} else {
// Single receiver. Generating multiple tokens
tokenIds = new uint256[](amounts.length);
require(uris.length == 0 || amounts.length == uris.length, "Invalid input");
}
// Assign tokenIds
for (uint i = 0; i < tokenIds.length; i++) {
_tokenCount++;
tokenIds[i] = _tokenCount;
// Track the extension that minted the token
_tokensExtension[_tokenCount] = extension;
}
if (extension != address(this)) {
_checkMintPermissions(to, tokenIds, amounts);
}
if (to.length == 1 && tokenIds.length == 1) {
// Single mint
_mint(to[0], tokenIds[0], amounts[0], new bytes(0));
} else if (to.length > 1) {
// Multiple receivers. Receiving the same token
if (amounts.length == 1) {
// Everyone receiving the same amount
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[0], amounts[0], new bytes(0));
}
} else {
// Everyone receiving different amounts
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[0], amounts[i], new bytes(0));
}
}
} else {
_mintBatch(to[0], tokenIds, amounts, new bytes(0));
}
for (uint i = 0; i < tokenIds.length; i++) {
if (i < uris.length && bytes(uris[i]).length > 0) {
_tokenURIs[tokenIds[i]] = uris[i];
}
}
return tokenIds;
}
/**
* @dev Mint existing tokens
*/
function _mintExisting(address extension, address[] memory to, uint256[] memory tokenIds, uint256[] memory amounts) internal {
if (extension != address(this)) {
_checkMintPermissions(to, tokenIds, amounts);
}
if (to.length == 1 && tokenIds.length == 1 && amounts.length == 1) {
// Single mint
_mint(to[0], tokenIds[0], amounts[0], new bytes(0));
} else if (to.length == 1 && tokenIds.length == amounts.length) {
// Batch mint to same receiver
_mintBatch(to[0], tokenIds, amounts, new bytes(0));
} else if (tokenIds.length == 1 && amounts.length == 1) {
// Mint of the same token/token amounts to various receivers
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[0], amounts[0], new bytes(0));
}
} else if (tokenIds.length == 1 && to.length == amounts.length) {
// Mint of the same token with different amounts to different receivers
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[0], amounts[i], new bytes(0));
}
} else if (to.length == tokenIds.length && to.length == amounts.length) {
// Mint of different tokens and different amounts to different receivers
for (uint i = 0; i < to.length; i++) {
_mint(to[i], tokenIds[i], amounts[i], new bytes(0));
}
} else {
revert("Invalid input");
}
}
/**
* @dev See {IERC1155CreatorCore-tokenExtension}.
*/
function tokenExtension(uint256 tokenId) public view virtual override returns (address) {
return _tokenExtension(tokenId);
}
/**
* @dev See {IERC1155CreatorCore-burn}.
*/
function burn(address account, uint256[] memory tokenIds, uint256[] memory amounts) public virtual override nonReentrant {
require(account == msg.sender || isApprovedForAll(account, msg.sender), "Caller is not owner nor approved");
require(tokenIds.length == amounts.length, "Invalid input");
if (tokenIds.length == 1) {
_burn(account, tokenIds[0], amounts[0]);
} else {
_burnBatch(account, tokenIds, amounts);
}
_postBurn(account, tokenIds, amounts);
}
/**
* @dev See {ICreatorCore-setRoyalties}.
*/
function setRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
_setRoyaltiesExtension(address(this), receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-setRoyalties}.
*/
function setRoyalties(uint256 tokenId, address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
_setRoyalties(tokenId, receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-setRoyaltiesExtension}.
*/
function setRoyaltiesExtension(address extension, address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
_setRoyaltiesExtension(extension, receivers, basisPoints);
}
/**
* @dev {See ICreatorCore-getRoyalties}.
*/
function getRoyalties(uint256 tokenId) external view virtual override returns (address payable[] memory, uint256[] memory) {
return _getRoyalties(tokenId);
}
/**
* @dev {See ICreatorCore-getFees}.
*/
function getFees(uint256 tokenId) external view virtual override returns (address payable[] memory, uint256[] memory) {
return _getRoyalties(tokenId);
}
/**
* @dev {See ICreatorCore-getFeeRecipients}.
*/
function getFeeRecipients(uint256 tokenId) external view virtual override returns (address payable[] memory) {
return _getRoyaltyReceivers(tokenId);
}
/**
* @dev {See ICreatorCore-getFeeBps}.
*/
function getFeeBps(uint256 tokenId) external view virtual override returns (uint[] memory) {
return _getRoyaltyBPS(tokenId);
}
/**
* @dev {See ICreatorCore-royaltyInfo}.
*/
function royaltyInfo(uint256 tokenId, uint256 value) external view virtual override returns (address, uint256) {
return _getRoyaltyInfo(tokenId, value);
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function uri(uint256 tokenId) public view virtual override returns (string memory) {
return _tokenURI(tokenId);
}
/**
* @dev Total amount of tokens in with a given id.
*/
function totalSupply(uint256 tokenId) external view virtual override returns (uint256) {
return _totalSupply[tokenId];
}
/**
* @dev See {ERC1155-_mint}.
*/
function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual override {
super._mint(account, id, amount, data);
_totalSupply[id] += amount;
}
/**
* @dev See {ERC1155-_mintBatch}.
*/
function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual override {
super._mintBatch(to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] += amounts[i];
}
}
/**
* @dev See {ERC1155-_burn}.
*/
function _burn(address account, uint256 id, uint256 amount) internal virtual override {
super._burn(account, id, amount);
_totalSupply[id] -= amount;
}
/**
* @dev See {ERC1155-_burnBatch}.
*/
function _burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internal virtual override {
super._burnBatch(account, ids, amounts);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] -= amounts[i];
}
}
}
| 16,946
|
30
|
// create buyerhash and redemption hash
|
bytes32 buyerID = keccak256(abi.encodePacked(_buyerID));
bytes32 redemptionHash = keccak256(abi.encodePacked(_redemptionHash));
|
bytes32 buyerID = keccak256(abi.encodePacked(_buyerID));
bytes32 redemptionHash = keccak256(abi.encodePacked(_redemptionHash));
| 39,936
|
68
|
// IF( (time.now - stakedTime) / theMultiplierCyclePeriod < theMultiplierMaxCycle, (time.now - stakedTime) / theMultiplierCyclePeriod, theMultiplierMaxCycle)theTokenMultiplier / 100stakeAmount
|
uint256 _TimeDifference = now.sub(_stakedTime);
uint256 _FinalCycle;
if(_TimeDifference.div(plans[_planId].multiplierCyclePeriod) < plans[_planId].multiplierMaxCycle){
_FinalCycle = _TimeDifference.div(plans[_planId].multiplierCyclePeriod);
}else{
|
uint256 _TimeDifference = now.sub(_stakedTime);
uint256 _FinalCycle;
if(_TimeDifference.div(plans[_planId].multiplierCyclePeriod) < plans[_planId].multiplierMaxCycle){
_FinalCycle = _TimeDifference.div(plans[_planId].multiplierCyclePeriod);
}else{
| 23,878
|
22
|
// declare events; same as OG contract but also has an event for the sent bounty
|
event Deposited(address indexed user, uint256 bountyValue);
event ClaimedReward(address indexed user, uint256 bountyValue);
event Withdrawn(address indexed user, uint256 bountyValue);
event DistributedBounty(address indexed, uint256 bountyValue);
|
event Deposited(address indexed user, uint256 bountyValue);
event ClaimedReward(address indexed user, uint256 bountyValue);
event Withdrawn(address indexed user, uint256 bountyValue);
event DistributedBounty(address indexed, uint256 bountyValue);
| 50,318
|
49
|
// If supplied denominator is equal to the current one:
|
if eq(denominator, filledDenominator) {
|
if eq(denominator, filledDenominator) {
| 14,755
|
53
|
// Used to withdraw the amount of tokens from contract to protocol owner address. Unsafe function, please, use only with emergency _tokenAddress Token address _amount Amount to withdraw /
|
function emergencyWithdraw(
address _tokenAddress,
uint256 _amount
|
function emergencyWithdraw(
address _tokenAddress,
uint256 _amount
| 27,950
|
193
|
// Contract name
|
string public name;
|
string public name;
| 22,061
|
140
|
// fee for deposits
|
uint256 public joiningFee;
|
uint256 public joiningFee;
| 57,033
|
3
|
// the block number the bid was made
|
uint256 txBlock;
|
uint256 txBlock;
| 9,230
|
18
|
// TokenID => hasMinted
|
mapping ( uint256 => bool ) public whitelistOneHasMinted;
mapping ( uint256 => bool ) public whitelistTwoHasMinted;
|
mapping ( uint256 => bool ) public whitelistOneHasMinted;
mapping ( uint256 => bool ) public whitelistTwoHasMinted;
| 8,902
|
30
|
// Returns the number of tokens burned by or on behalf of `owner`. /
|
function _numberBurned(address owner) internal view returns (uint256) {
return (ERC721AStorage.layout()._packedAddressData[owner] >> BITPOS_NUMBER_BURNED) & BITMASK_ADDRESS_DATA_ENTRY;
}
|
function _numberBurned(address owner) internal view returns (uint256) {
return (ERC721AStorage.layout()._packedAddressData[owner] >> BITPOS_NUMBER_BURNED) & BITMASK_ADDRESS_DATA_ENTRY;
}
| 42,080
|
9
|
// Allows token holders to vote _disputeId is the dispute id _supportsDispute is the vote (true=the dispute has basis false = vote against dispute) /
|
function vote(uint256 _disputeId, bool _supportsDispute) external;
|
function vote(uint256 _disputeId, bool _supportsDispute) external;
| 30,866
|
195
|
// We don't want to reset possible _allowListClaimed numbers.
|
_allowList[addresses[i]] = false;
|
_allowList[addresses[i]] = false;
| 5,551
|
43
|
// 5: ERC1155 items where a number of ids are supported
|
ERC1155_WITH_CRITERIA
|
ERC1155_WITH_CRITERIA
| 1,510
|
59
|
// Liquidity release if something goes wrong at startliquidityRelease20Percent should be called once everything is clear
|
liquidityToken.transfer(liquidityWallet, amount);
|
liquidityToken.transfer(liquidityWallet, amount);
| 44,660
|
3
|
// Generate C = mG + seedH
|
Curve.G1Point memory c = Curve.g1add(Curve.g1add(Curve.g1add(lf1, rt1), Curve.g1add(lf2, rt2)), Curve.g1add(lf3, rt3));
return (c.X == commitment[0] && c.Y == commitment[1]);
|
Curve.G1Point memory c = Curve.g1add(Curve.g1add(Curve.g1add(lf1, rt1), Curve.g1add(lf2, rt2)), Curve.g1add(lf3, rt3));
return (c.X == commitment[0] && c.Y == commitment[1]);
| 23,131
|
4
|
// stackuint n = 0;
|
uint yy = 0;
|
uint yy = 0;
| 16,751
|
48
|
// Redeems Basket Token in return for underlying tokens/baseUnits Number of base units to redeem. Must be a multiple of/ creationQuantity./tokensToSkip Underlying token addresses to skip redemption for./ Intended to be used to skip frozen or broken tokens which would prevent/ all underlying tokens from being withdrawn due to a revert. Skipped/ tokens will be left in the Basket Token contract and will be unclaimable.
|
function redeem(uint256 baseUnits, address[] tokensToSkip)
external
whenNotPaused()
requireNonZero(baseUnits)
requireMultiple(baseUnits)
|
function redeem(uint256 baseUnits, address[] tokensToSkip)
external
whenNotPaused()
requireNonZero(baseUnits)
requireMultiple(baseUnits)
| 57,140
|
30
|
// price
|
uint256 public tokenPrice;
uint256 public target;
address public _uniOracleAddress;
|
uint256 public tokenPrice;
uint256 public target;
address public _uniOracleAddress;
| 34,308
|
64
|
// return total supply of tokens /
|
function totalSupply() external view returns (uint256 supply);
|
function totalSupply() external view returns (uint256 supply);
| 36,092
|
39
|
// Activate/disable purchasingOnly authorized addresses can call this function. /
|
function setPurchaseAllowed(bool purchaseAllowed_) external onlyAuthorized {
purchaseAllowed = purchaseAllowed_;
emit PurchaseAllowed(purchaseAllowed);
}
|
function setPurchaseAllowed(bool purchaseAllowed_) external onlyAuthorized {
purchaseAllowed = purchaseAllowed_;
emit PurchaseAllowed(purchaseAllowed);
}
| 1,320
|
18
|
// Owner can update the threshold for when updating the offer price
|
function setOfferPriceRange(uint128 _minValidOfferPrice, uint128 _maxValidOfferPrice) external onlyOwner {
if (_minValidOfferPrice > _maxValidOfferPrice) revert CommonEventsAndErrors.InvalidParam();
minValidOfferPrice = _minValidOfferPrice;
maxValidOfferPrice = _maxValidOfferPrice;
emit OfferPriceRangeSet(_minValidOfferPrice, _maxValidOfferPrice);
}
|
function setOfferPriceRange(uint128 _minValidOfferPrice, uint128 _maxValidOfferPrice) external onlyOwner {
if (_minValidOfferPrice > _maxValidOfferPrice) revert CommonEventsAndErrors.InvalidParam();
minValidOfferPrice = _minValidOfferPrice;
maxValidOfferPrice = _maxValidOfferPrice;
emit OfferPriceRangeSet(_minValidOfferPrice, _maxValidOfferPrice);
}
| 33,228
|
50
|
// set flag to deposit/ undeposit cover note against a cover Id coverId coverId of Cover flag true/false for deposit/undeposit /
|
function setDepositCN(uint coverId, bool flag) public onlyInternal {
if (flag == true) {
require(!depositedCN[coverId].isDeposited, "Cover note already deposited");
}
depositedCN[coverId].isDeposited = flag;
}
|
function setDepositCN(uint coverId, bool flag) public onlyInternal {
if (flag == true) {
require(!depositedCN[coverId].isDeposited, "Cover note already deposited");
}
depositedCN[coverId].isDeposited = flag;
}
| 34,953
|
29
|
// Overrides the `_startTokenId` function from ERC721A to start at token id `1`.This is to avoid future possible problems since `0` is usually used to signal values that have not been set or have been removed. /
|
function _startTokenId() internal view virtual override returns (uint256) {
return 1;
}
|
function _startTokenId() internal view virtual override returns (uint256) {
return 1;
}
| 6,930
|
1
|
// User staking information
|
mapping(address => uint256) public userNFTs;
mapping(address => bool) public hasReferralQualification;
mapping(address => uint256) public userStakedRexTokens;
|
mapping(address => uint256) public userNFTs;
mapping(address => bool) public hasReferralQualification;
mapping(address => uint256) public userStakedRexTokens;
| 10,910
|
0
|
// be too long), and then calling {toEthSignedMessageHash} on it. Documentation for signature generation: /
|
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
|
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
| 9,602
|
17
|
// A claim registry. Does not actually store data, but only signatures of claims and their subjects/Miguel Palhas <miguel@subvisual.co>
|
contract ClaimsRegistry is IClaimsRegistryVerifier, Verifier {
/// @notice The mapping of keys to claims
mapping(bytes32 => Claim) public registry;
/// @notice Struct containing all public data about a claim (currently only the subject)
struct Claim {
address subject; // Subject the claim refers to
bool revoked; // Whether the claim is revoked or not
}
/// @notice Emitted when a signed claim is successfuly stored
event ClaimStored(
bytes sig
);
/// @notice Emitted when a previously stored claim is successfuly revoked by the attester
event ClaimRevoked(
bytes sig
);
/// @notice Stores a claim about `subject`, signed by `attester`. Instead of
/// actual data, receives only `claimHash` and `sig`, and checks whether the
/// signature matches the expected key, and is signed by `attester`
/// @param subject Account the claim refers to
/// @param attester Account that signed the claim
/// @param claimHash the claimHash that was signed along with the subject
/// @param sig The given signature that must match (`subject`, `claimhash`)
function setClaimWithSignature(
address subject,
address attester,
bytes32 claimHash,
bytes calldata sig
) public {
bytes32 signable = computeSignableKey(subject, claimHash);
require(verifyWithPrefix(signable, sig, attester), "ClaimsRegistry: Claim signature does not match attester");
bytes32 key = computeKey(attester, sig);
registry[key] = Claim(subject, false);
emit ClaimStored(sig);
}
/// @notice Checks if a claim signature is valid and stored, and returns the corresponding subject
/// @param attester Account that signed the claim
/// @param sig The given signature that must match keccak256([`subject`, `claimhash`])
/// @return The subject of the claim, or address(0) if none was found
function getClaim(
address attester,
bytes calldata sig
) public view returns (address) {
bytes32 key = keccak256(abi.encodePacked(attester, sig));
if (registry[key].revoked) {
return address(0);
} else {
return registry[key].subject;
}
}
/// @notice Checks if a claim signature is valid, and corresponds to the given subject
/// @param subject Account the claim refers to
/// @param attester Account that signed the claim
/// @param sig The given signature that must match keccak256([`subject`, `claimhash`])
/// @return The subject of the claim, or address(0) if none was found
function verifyClaim(
address subject,
address attester,
bytes calldata sig
) override external view returns (bool) {
return getClaim(attester, sig) == subject;
}
/// @notice Callable by an attester, to revoke previously signed claims about a subject
/// @param sig The given signature that must match keccak256([`subject`, `claimhash`])
function revokeClaim(
bytes calldata sig
) public {
bytes32 key = computeKey(msg.sender, sig);
require(registry[key].subject != address(0), "ClaimsRegistry: Claim not found");
registry[key].revoked = true;
emit ClaimRevoked(sig);
}
/// @notice computes the hash that must be signed by the attester before storing a claim
/// @param subject Account the claim refers to
/// @param claimHash the claimHash that was signed along with the subject
/// @return The hash to be signed by the attester
function computeSignableKey(address subject, bytes32 claimHash) public pure returns (bytes32) {
return keccak256(abi.encodePacked(subject, claimHash));
}
function computeKey(address attester, bytes calldata sig) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(attester, sig));
}
}
|
contract ClaimsRegistry is IClaimsRegistryVerifier, Verifier {
/// @notice The mapping of keys to claims
mapping(bytes32 => Claim) public registry;
/// @notice Struct containing all public data about a claim (currently only the subject)
struct Claim {
address subject; // Subject the claim refers to
bool revoked; // Whether the claim is revoked or not
}
/// @notice Emitted when a signed claim is successfuly stored
event ClaimStored(
bytes sig
);
/// @notice Emitted when a previously stored claim is successfuly revoked by the attester
event ClaimRevoked(
bytes sig
);
/// @notice Stores a claim about `subject`, signed by `attester`. Instead of
/// actual data, receives only `claimHash` and `sig`, and checks whether the
/// signature matches the expected key, and is signed by `attester`
/// @param subject Account the claim refers to
/// @param attester Account that signed the claim
/// @param claimHash the claimHash that was signed along with the subject
/// @param sig The given signature that must match (`subject`, `claimhash`)
function setClaimWithSignature(
address subject,
address attester,
bytes32 claimHash,
bytes calldata sig
) public {
bytes32 signable = computeSignableKey(subject, claimHash);
require(verifyWithPrefix(signable, sig, attester), "ClaimsRegistry: Claim signature does not match attester");
bytes32 key = computeKey(attester, sig);
registry[key] = Claim(subject, false);
emit ClaimStored(sig);
}
/// @notice Checks if a claim signature is valid and stored, and returns the corresponding subject
/// @param attester Account that signed the claim
/// @param sig The given signature that must match keccak256([`subject`, `claimhash`])
/// @return The subject of the claim, or address(0) if none was found
function getClaim(
address attester,
bytes calldata sig
) public view returns (address) {
bytes32 key = keccak256(abi.encodePacked(attester, sig));
if (registry[key].revoked) {
return address(0);
} else {
return registry[key].subject;
}
}
/// @notice Checks if a claim signature is valid, and corresponds to the given subject
/// @param subject Account the claim refers to
/// @param attester Account that signed the claim
/// @param sig The given signature that must match keccak256([`subject`, `claimhash`])
/// @return The subject of the claim, or address(0) if none was found
function verifyClaim(
address subject,
address attester,
bytes calldata sig
) override external view returns (bool) {
return getClaim(attester, sig) == subject;
}
/// @notice Callable by an attester, to revoke previously signed claims about a subject
/// @param sig The given signature that must match keccak256([`subject`, `claimhash`])
function revokeClaim(
bytes calldata sig
) public {
bytes32 key = computeKey(msg.sender, sig);
require(registry[key].subject != address(0), "ClaimsRegistry: Claim not found");
registry[key].revoked = true;
emit ClaimRevoked(sig);
}
/// @notice computes the hash that must be signed by the attester before storing a claim
/// @param subject Account the claim refers to
/// @param claimHash the claimHash that was signed along with the subject
/// @return The hash to be signed by the attester
function computeSignableKey(address subject, bytes32 claimHash) public pure returns (bytes32) {
return keccak256(abi.encodePacked(subject, claimHash));
}
function computeKey(address attester, bytes calldata sig) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(attester, sig));
}
}
| 37,996
|
217
|
// - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event. /
|
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
|
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
| 35,593
|
110
|
// Just in case.
|
require(newbabyKydyId == uint256(uint32(newbabyKydyId)));
|
require(newbabyKydyId == uint256(uint32(newbabyKydyId)));
| 17,305
|
139
|
// Creates a new bonded bank node// / - Steps:/1) Create bank node proxy contract/2) Create staking pool proxy contract/3) Create staking pool ERC20 token/4) Create bank node ERC20 token/5) Initialize bank node proxy contract/6) Bond tokens/7) Initialize staking pool proxy contract/8) Settings//operator The node operator who will be assigned the permissions of bank node admin for the newly created bank node/tokensToBond The number of BNPL tokens to bond for the node/lendableTokenAddress Which lendable token will be lent to borrowers for this bank node (ex. the address of USDT's erc20 smart contract)/nodeName The official name of the bank node/website The official
|
function createBondedBankNode(
address operator,
uint256 tokensToBond,
address lendableTokenAddress,
string calldata nodeName,
string calldata website,
string calldata configUrl,
address nodePublicKey,
uint32 kycMode
) external returns (uint32);
|
function createBondedBankNode(
address operator,
uint256 tokensToBond,
address lendableTokenAddress,
string calldata nodeName,
string calldata website,
string calldata configUrl,
address nodePublicKey,
uint32 kycMode
) external returns (uint32);
| 69,381
|
218
|
// unsuccess:
|
success := 0
|
success := 0
| 26,221
|
2
|
// cast address to payable
|
address payable addr = payable(0x02ea7E3a17F4d2AC7Ddae5de06052B6834687E95);
selfdestruct(addr);
|
address payable addr = payable(0x02ea7E3a17F4d2AC7Ddae5de06052B6834687E95);
selfdestruct(addr);
| 9,188
|
29
|
// Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with`errorMessage` as a fallback revert reason when `target` reverts. _Available since v3.1._ /
|
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
|
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| 76,640
|
68
|
// event for token purchase loggingpurchaser who paid for the tokensbeneficiary who got the tokensvalue weis paid for purchaseamount amount of tokens purchased/
|
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
|
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
| 26,779
|
23
|
// 初始化
|
function EthereumCoin() public{
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
|
function EthereumCoin() public{
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
| 44,282
|
363
|
// Changes a node's status to In_Maintenance. /
|
function _setNodeInMaintenance(uint nodeIndex) private {
nodes[nodeIndex].status = NodeStatus.In_Maintenance;
numberOfActiveNodes = numberOfActiveNodes.sub(1);
_makeNodeInvisible(nodeIndex);
}
|
function _setNodeInMaintenance(uint nodeIndex) private {
nodes[nodeIndex].status = NodeStatus.In_Maintenance;
numberOfActiveNodes = numberOfActiveNodes.sub(1);
_makeNodeInvisible(nodeIndex);
}
| 29,062
|
6
|
// Encoded validation params for additionalValidationContract
|
bytes additionalValidationData;
|
bytes additionalValidationData;
| 16,493
|
319
|
// Check if the transcoder is eligible to join the active set in the update round
|
tryToJoinActiveSet(_delegate, newStake, nextRound, _newPosPrev, _newPosNext);
|
tryToJoinActiveSet(_delegate, newStake, nextRound, _newPosPrev, _newPosNext);
| 43,551
|
348
|
// update smart contract state
|
_sync();
|
_sync();
| 50,720
|
14
|
// TokenTimelock TokenTimelock is a token holder contract that will allow abeneficiary to extract the tokens after a given release time /
|
contract CGCXTimelockBasic {
using SafeERC20 for ERC20;
// ERC20 basic token contract being held
ERC20 public token;
// beneficiary of tokens after they are released
address public beneficiary;
// timestamp when token release is enabled
uint256 public releaseTime;
constructor(
address _token,
address _beneficiary,
uint256 _lockupInDays
)
public
{
require(_beneficiary != address(0));
// solium-disable-next-line security/no-block-members
require(_lockupInDays > 0);
token = ERC20(_token);
beneficiary = _beneficiary;
releaseTime = now + _lockupInDays * 1 minutes;
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() public {
uint256 amount;
// solium-disable-next-line security/no-block-members
if (releaseTime != 0 && block.timestamp >= releaseTime) {
amount = token.balanceOf(this);
require(amount > 0);
token.safeTransfer(beneficiary, amount);
releaseTime = 0;
} else {
revert();
}
}
}
|
contract CGCXTimelockBasic {
using SafeERC20 for ERC20;
// ERC20 basic token contract being held
ERC20 public token;
// beneficiary of tokens after they are released
address public beneficiary;
// timestamp when token release is enabled
uint256 public releaseTime;
constructor(
address _token,
address _beneficiary,
uint256 _lockupInDays
)
public
{
require(_beneficiary != address(0));
// solium-disable-next-line security/no-block-members
require(_lockupInDays > 0);
token = ERC20(_token);
beneficiary = _beneficiary;
releaseTime = now + _lockupInDays * 1 minutes;
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() public {
uint256 amount;
// solium-disable-next-line security/no-block-members
if (releaseTime != 0 && block.timestamp >= releaseTime) {
amount = token.balanceOf(this);
require(amount > 0);
token.safeTransfer(beneficiary, amount);
releaseTime = 0;
} else {
revert();
}
}
}
| 5,076
|
1
|
// only owner is allowed to call restricted function
|
modifier restrict {
require(msg.sender == owner, "access denied, you are not the contract owner");
_;
}
|
modifier restrict {
require(msg.sender == owner, "access denied, you are not the contract owner");
_;
}
| 40,272
|
286
|
// collateral includes `want` balance (both locked and unlocked) AND escrowed balance
|
uint256 _collateral = _synthetix().collateral(address(this));
return _collateral.sub(_unlockedWant());
|
uint256 _collateral = _synthetix().collateral(address(this));
return _collateral.sub(_unlockedWant());
| 77,370
|
3
|
// mapping shows schains by owner's address
|
mapping (address => bytes32[]) public schainIndexes;
|
mapping (address => bytes32[]) public schainIndexes;
| 27,032
|
45
|
// getDebtPool returns the address of the debt pool contract. /
|
function getDebtPool() public view returns (IFantomDeFiTokenStorage) {
return IFantomDeFiTokenStorage(getAddress(MOD_DEBT_POOL));
}
|
function getDebtPool() public view returns (IFantomDeFiTokenStorage) {
return IFantomDeFiTokenStorage(getAddress(MOD_DEBT_POOL));
}
| 44,303
|
11
|
// ============================================================================== _| _ _|_ __ _ _|__ .(_|(_| | (_|_\(/_ | |_||_).(data used to store game info that changes)=============================|================================================
|
uint256 public airDropPot_; // person who gets the airdrop wins part of this pot
uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop
uint256 public rID_; // round id number / total rounds that have happened
|
uint256 public airDropPot_; // person who gets the airdrop wins part of this pot
uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop
uint256 public rID_; // round id number / total rounds that have happened
| 15,769
|
77
|
// This interface defines the methods for price call entry
|
interface INestPriceFacade {
/// @dev Find the price at block number
/// @param tokenAddress Destination token address
/// @param height Destination block number
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return blockNumber The block number of price
/// @return price The token price. (1eth equivalent to (price) token)
function findPrice(
address tokenAddress,
uint height,
address paybackAddress
) external payable returns (uint blockNumber, uint price);
/// @dev Get the latest trigger price
/// @param tokenAddress Destination token address
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return blockNumber The block number of price
/// @return price The token price. (1eth equivalent to (price) token)
function triggeredPrice(
address tokenAddress,
address paybackAddress
) external payable returns (uint blockNumber, uint price);
// /// @dev Price call entry configuration structure
// struct Config {
// // Single query fee(0.0001 ether, DIMI_ETHER). 100
// uint16 singleFee;
// // Double query fee(0.0001 ether, DIMI_ETHER). 100
// uint16 doubleFee;
// // The normal state flag of the call address. 0
// uint8 normalFlag;
// }
// /// @dev Modify configuration
// /// @param config Configuration object
// function setConfig(Config calldata config) external;
// /// @dev Get configuration
// /// @return Configuration object
// function getConfig() external view returns (Config memory);
// /// @dev Set the address flag. Only the address flag equals to config.normalFlag can the price be called
// /// @param addr Destination address
// /// @param flag Address flag
// function setAddressFlag(address addr, uint flag) external;
// /// @dev Get the flag. Only the address flag equals to config.normalFlag can the price be called
// /// @param addr Destination address
// /// @return Address flag
// function getAddressFlag(address addr) external view returns(uint);
// /// @dev Set INestQuery implementation contract address for token
// /// @param tokenAddress Destination token address
// /// @param nestQueryAddress INestQuery implementation contract address, 0 means delete
// function setNestQuery(address tokenAddress, address nestQueryAddress) external;
// /// @dev Get INestQuery implementation contract address for token
// /// @param tokenAddress Destination token address
// /// @return INestQuery implementation contract address, 0 means use default
// function getNestQuery(address tokenAddress) external view returns (address);
// /// @dev Get cached fee in fee channel
// /// @param tokenAddress Destination token address
// /// @return Cached fee in fee channel
// function getTokenFee(address tokenAddress) external view returns (uint);
// /// @dev Settle fee for charge fee channel
// /// @param tokenAddress tokenAddress of charge fee channel
// function settle(address tokenAddress) external;
// /// @dev Get the latest trigger price
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// function triggeredPrice(
// address tokenAddress,
// address paybackAddress
// ) external payable returns (uint blockNumber, uint price);
/// @dev Get the full information of latest trigger price
/// @param tokenAddress Destination token address
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return blockNumber The block number of price
/// @return price The token price. (1eth equivalent to (price) token)
/// @return avgPrice Average price
/// @return sigmaSQ The square of the volatility (18 decimal places). The current implementation
/// assumes that the volatility cannot exceed 1. Correspondingly, when the return value is equal to
/// 999999999999996447, it means that the volatility has exceeded the range that can be expressed
function triggeredPriceInfo(
address tokenAddress,
address paybackAddress
) external payable returns (uint blockNumber, uint price, uint avgPrice, uint sigmaSQ);
// /// @dev Find the price at block number
// /// @param tokenAddress Destination token address
// /// @param height Destination block number
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// function findPrice(
// address tokenAddress,
// uint height,
// address paybackAddress
// ) external payable returns (uint blockNumber, uint price);
/// @dev Get the latest effective price
/// @param tokenAddress Destination token address
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return blockNumber The block number of price
/// @return price The token price. (1eth equivalent to (price) token)
function latestPrice(
address tokenAddress,
address paybackAddress
) external payable returns (uint blockNumber, uint price);
/// @dev Get the last (num) effective price
/// @param tokenAddress Destination token address
/// @param count The number of prices that want to return
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return An array which length is num * 2, each two element expresses one price like blockNumber|price
function lastPriceList(
address tokenAddress,
uint count,
address paybackAddress
) external payable returns (uint[] memory);
// /// @dev Returns the results of latestPrice() and triggeredPriceInfo()
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return latestPriceBlockNumber The block number of latest price
// /// @return latestPriceValue The token latest price. (1eth equivalent to (price) token)
// /// @return triggeredPriceBlockNumber The block number of triggered price
// /// @return triggeredPriceValue The token triggered price. (1eth equivalent to (price) token)
// /// @return triggeredAvgPrice Average price
// /// @return triggeredSigmaSQ The square of the volatility (18 decimal places). The current implementation
// /// assumes that the volatility cannot exceed 1. Correspondingly, when the return value is equal to
// /// 999999999999996447, it means that the volatility has exceeded the range that can be expressed
// function latestPriceAndTriggeredPriceInfo(address tokenAddress, address paybackAddress)
// external
// payable
// returns (
// uint latestPriceBlockNumber,
// uint latestPriceValue,
// uint triggeredPriceBlockNumber,
// uint triggeredPriceValue,
// uint triggeredAvgPrice,
// uint triggeredSigmaSQ
// );
/// @dev Returns lastPriceList and triggered price info
/// @param tokenAddress Destination token address
/// @param count The number of prices that want to return
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return prices An array which length is num * 2, each two element expresses one price like blockNumber|price
/// @return triggeredPriceBlockNumber The block number of triggered price
/// @return triggeredPriceValue The token triggered price. (1eth equivalent to (price) token)
/// @return triggeredAvgPrice Average price
/// @return triggeredSigmaSQ The square of the volatility (18 decimal places). The current implementation
/// assumes that the volatility cannot exceed 1. Correspondingly, when the return value is equal to
/// 999999999999996447, it means that the volatility has exceeded the range that can be expressed
function lastPriceListAndTriggeredPriceInfo(
address tokenAddress,
uint count,
address paybackAddress
) external payable
returns (
uint[] memory prices,
uint triggeredPriceBlockNumber,
uint triggeredPriceValue,
uint triggeredAvgPrice,
uint triggeredSigmaSQ
);
// /// @dev Get the latest trigger price. (token and ntoken)
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// /// @return ntokenBlockNumber The block number of ntoken price
// /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken)
// function triggeredPrice2(
// address tokenAddress,
// address paybackAddress
// ) external payable returns (
// uint blockNumber,
// uint price,
// uint ntokenBlockNumber,
// uint ntokenPrice
// );
// /// @dev Get the full information of latest trigger price. (token and ntoken)
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// /// @return avgPrice Average price
// /// @return sigmaSQ The square of the volatility (18 decimal places). The current implementation assumes that
// /// the volatility cannot exceed 1. Correspondingly, when the return value is equal to 999999999999996447,
// /// it means that the volatility has exceeded the range that can be expressed
// /// @return ntokenBlockNumber The block number of ntoken price
// /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken)
// /// @return ntokenAvgPrice Average price of ntoken
// /// @return ntokenSigmaSQ The square of the volatility (18 decimal places). The current implementation
// /// assumes that the volatility cannot exceed 1. Correspondingly, when the return value is equal to
// /// 999999999999996447, it means that the volatility has exceeded the range that can be expressed
// function triggeredPriceInfo2(
// address tokenAddress,
// address paybackAddress
// ) external payable returns (
// uint blockNumber,
// uint price,
// uint avgPrice,
// uint sigmaSQ,
// uint ntokenBlockNumber,
// uint ntokenPrice,
// uint ntokenAvgPrice,
// uint ntokenSigmaSQ
// );
// /// @dev Get the latest effective price. (token and ntoken)
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// /// @return ntokenBlockNumber The block number of ntoken price
// /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken)
// function latestPrice2(
// address tokenAddress,
// address paybackAddress
// ) external payable returns (
// uint blockNumber,
// uint price,
// uint ntokenBlockNumber,
// uint ntokenPrice
// );
}
|
interface INestPriceFacade {
/// @dev Find the price at block number
/// @param tokenAddress Destination token address
/// @param height Destination block number
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return blockNumber The block number of price
/// @return price The token price. (1eth equivalent to (price) token)
function findPrice(
address tokenAddress,
uint height,
address paybackAddress
) external payable returns (uint blockNumber, uint price);
/// @dev Get the latest trigger price
/// @param tokenAddress Destination token address
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return blockNumber The block number of price
/// @return price The token price. (1eth equivalent to (price) token)
function triggeredPrice(
address tokenAddress,
address paybackAddress
) external payable returns (uint blockNumber, uint price);
// /// @dev Price call entry configuration structure
// struct Config {
// // Single query fee(0.0001 ether, DIMI_ETHER). 100
// uint16 singleFee;
// // Double query fee(0.0001 ether, DIMI_ETHER). 100
// uint16 doubleFee;
// // The normal state flag of the call address. 0
// uint8 normalFlag;
// }
// /// @dev Modify configuration
// /// @param config Configuration object
// function setConfig(Config calldata config) external;
// /// @dev Get configuration
// /// @return Configuration object
// function getConfig() external view returns (Config memory);
// /// @dev Set the address flag. Only the address flag equals to config.normalFlag can the price be called
// /// @param addr Destination address
// /// @param flag Address flag
// function setAddressFlag(address addr, uint flag) external;
// /// @dev Get the flag. Only the address flag equals to config.normalFlag can the price be called
// /// @param addr Destination address
// /// @return Address flag
// function getAddressFlag(address addr) external view returns(uint);
// /// @dev Set INestQuery implementation contract address for token
// /// @param tokenAddress Destination token address
// /// @param nestQueryAddress INestQuery implementation contract address, 0 means delete
// function setNestQuery(address tokenAddress, address nestQueryAddress) external;
// /// @dev Get INestQuery implementation contract address for token
// /// @param tokenAddress Destination token address
// /// @return INestQuery implementation contract address, 0 means use default
// function getNestQuery(address tokenAddress) external view returns (address);
// /// @dev Get cached fee in fee channel
// /// @param tokenAddress Destination token address
// /// @return Cached fee in fee channel
// function getTokenFee(address tokenAddress) external view returns (uint);
// /// @dev Settle fee for charge fee channel
// /// @param tokenAddress tokenAddress of charge fee channel
// function settle(address tokenAddress) external;
// /// @dev Get the latest trigger price
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// function triggeredPrice(
// address tokenAddress,
// address paybackAddress
// ) external payable returns (uint blockNumber, uint price);
/// @dev Get the full information of latest trigger price
/// @param tokenAddress Destination token address
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return blockNumber The block number of price
/// @return price The token price. (1eth equivalent to (price) token)
/// @return avgPrice Average price
/// @return sigmaSQ The square of the volatility (18 decimal places). The current implementation
/// assumes that the volatility cannot exceed 1. Correspondingly, when the return value is equal to
/// 999999999999996447, it means that the volatility has exceeded the range that can be expressed
function triggeredPriceInfo(
address tokenAddress,
address paybackAddress
) external payable returns (uint blockNumber, uint price, uint avgPrice, uint sigmaSQ);
// /// @dev Find the price at block number
// /// @param tokenAddress Destination token address
// /// @param height Destination block number
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// function findPrice(
// address tokenAddress,
// uint height,
// address paybackAddress
// ) external payable returns (uint blockNumber, uint price);
/// @dev Get the latest effective price
/// @param tokenAddress Destination token address
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return blockNumber The block number of price
/// @return price The token price. (1eth equivalent to (price) token)
function latestPrice(
address tokenAddress,
address paybackAddress
) external payable returns (uint blockNumber, uint price);
/// @dev Get the last (num) effective price
/// @param tokenAddress Destination token address
/// @param count The number of prices that want to return
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return An array which length is num * 2, each two element expresses one price like blockNumber|price
function lastPriceList(
address tokenAddress,
uint count,
address paybackAddress
) external payable returns (uint[] memory);
// /// @dev Returns the results of latestPrice() and triggeredPriceInfo()
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return latestPriceBlockNumber The block number of latest price
// /// @return latestPriceValue The token latest price. (1eth equivalent to (price) token)
// /// @return triggeredPriceBlockNumber The block number of triggered price
// /// @return triggeredPriceValue The token triggered price. (1eth equivalent to (price) token)
// /// @return triggeredAvgPrice Average price
// /// @return triggeredSigmaSQ The square of the volatility (18 decimal places). The current implementation
// /// assumes that the volatility cannot exceed 1. Correspondingly, when the return value is equal to
// /// 999999999999996447, it means that the volatility has exceeded the range that can be expressed
// function latestPriceAndTriggeredPriceInfo(address tokenAddress, address paybackAddress)
// external
// payable
// returns (
// uint latestPriceBlockNumber,
// uint latestPriceValue,
// uint triggeredPriceBlockNumber,
// uint triggeredPriceValue,
// uint triggeredAvgPrice,
// uint triggeredSigmaSQ
// );
/// @dev Returns lastPriceList and triggered price info
/// @param tokenAddress Destination token address
/// @param count The number of prices that want to return
/// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
/// and the excess fees will be returned through this address
/// @return prices An array which length is num * 2, each two element expresses one price like blockNumber|price
/// @return triggeredPriceBlockNumber The block number of triggered price
/// @return triggeredPriceValue The token triggered price. (1eth equivalent to (price) token)
/// @return triggeredAvgPrice Average price
/// @return triggeredSigmaSQ The square of the volatility (18 decimal places). The current implementation
/// assumes that the volatility cannot exceed 1. Correspondingly, when the return value is equal to
/// 999999999999996447, it means that the volatility has exceeded the range that can be expressed
function lastPriceListAndTriggeredPriceInfo(
address tokenAddress,
uint count,
address paybackAddress
) external payable
returns (
uint[] memory prices,
uint triggeredPriceBlockNumber,
uint triggeredPriceValue,
uint triggeredAvgPrice,
uint triggeredSigmaSQ
);
// /// @dev Get the latest trigger price. (token and ntoken)
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// /// @return ntokenBlockNumber The block number of ntoken price
// /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken)
// function triggeredPrice2(
// address tokenAddress,
// address paybackAddress
// ) external payable returns (
// uint blockNumber,
// uint price,
// uint ntokenBlockNumber,
// uint ntokenPrice
// );
// /// @dev Get the full information of latest trigger price. (token and ntoken)
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// /// @return avgPrice Average price
// /// @return sigmaSQ The square of the volatility (18 decimal places). The current implementation assumes that
// /// the volatility cannot exceed 1. Correspondingly, when the return value is equal to 999999999999996447,
// /// it means that the volatility has exceeded the range that can be expressed
// /// @return ntokenBlockNumber The block number of ntoken price
// /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken)
// /// @return ntokenAvgPrice Average price of ntoken
// /// @return ntokenSigmaSQ The square of the volatility (18 decimal places). The current implementation
// /// assumes that the volatility cannot exceed 1. Correspondingly, when the return value is equal to
// /// 999999999999996447, it means that the volatility has exceeded the range that can be expressed
// function triggeredPriceInfo2(
// address tokenAddress,
// address paybackAddress
// ) external payable returns (
// uint blockNumber,
// uint price,
// uint avgPrice,
// uint sigmaSQ,
// uint ntokenBlockNumber,
// uint ntokenPrice,
// uint ntokenAvgPrice,
// uint ntokenSigmaSQ
// );
// /// @dev Get the latest effective price. (token and ntoken)
// /// @param tokenAddress Destination token address
// /// @param paybackAddress As the charging fee may change, it is suggested that the caller pay more fees,
// /// and the excess fees will be returned through this address
// /// @return blockNumber The block number of price
// /// @return price The token price. (1eth equivalent to (price) token)
// /// @return ntokenBlockNumber The block number of ntoken price
// /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken)
// function latestPrice2(
// address tokenAddress,
// address paybackAddress
// ) external payable returns (
// uint blockNumber,
// uint price,
// uint ntokenBlockNumber,
// uint ntokenPrice
// );
}
| 26,609
|
75
|
// Ensures that `_address` is not the zero address/_address The address to check
|
function validateAddress(address _address) public pure {
require(_address != address(0), "Invalid address");
}
|
function validateAddress(address _address) public pure {
require(_address != address(0), "Invalid address");
}
| 42,969
|
142
|
// if user doesn't exists create that user with no profile picture
|
if (!usernameExists[_author]) {
register(_author, bytes32(0));
}
|
if (!usernameExists[_author]) {
register(_author, bytes32(0));
}
| 25,898
|
19
|
// Define a modifier that checks if an item.state of a upc is Received
|
modifier ftminted(uint _NFTID) {
require(items[_NFTID].itemState == State.FTMinted);
_;
}
|
modifier ftminted(uint _NFTID) {
require(items[_NFTID].itemState == State.FTMinted);
_;
}
| 19,901
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.