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 |
|---|---|---|---|---|
5 | // masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated. | address masterCopy;
| address masterCopy;
| 13,128 |
67 | // NOTE: here we are multiplying by 1e3 to get precise decimal values. | timelyRewardRatio = timeSinceLastClaimed.mul(1e3).div(vestFor);
| timelyRewardRatio = timeSinceLastClaimed.mul(1e3).div(vestFor);
| 22,083 |
37 | // Function to add non upgradable contract in registry of all contracts contractName is the name of the contract contractAddress is the contract address only maintainer can issue call to this method / | function addNonUpgradableContractToAddress(
string contractName,
address contractAddress
)
public
onlyCoreDev
| function addNonUpgradableContractToAddress(
string contractName,
address contractAddress
)
public
onlyCoreDev
| 37,536 |
23 | // lib/dpass/lib/openzeppelin-contracts/src/drafts/Counters.sol/ pragma solidity ^0.5.0; // import "../math/SafeMath.sol"; // Counters Matt Condon (@shrugs) Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the numberof elements in a mapping, issuing ERC721 ids, or counting request ids. Include with `using Counters for Counters.Counter;` | * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using SafeMath for uint256;
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
counter._value += 1;
}
function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
}
| * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using SafeMath for uint256;
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
counter._value += 1;
}
function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
}
| 26,799 |
118 | // Gives permission to `to` to transfer `tokenId` token to another account.The approval is cleared when the token is transferred. Only a single account can be approved at a time, so approving thezero address clears previous approvals. Requirements: - The caller must own the token or be an approved operator.- `tokenId` must exist. Emits an {Approval} event. / | function approve(address to, uint256 tokenId) external payable;
| function approve(address to, uint256 tokenId) external payable;
| 487 |
4 | // Admin-only to force unstake a user's tokens./_user The user to force withdraw/_amount The amount to force withdraw | function forceUnstake(address _user, uint256 _amount) external onlyOwner {
tls.forceUnstake(_user, _amount);
}
| function forceUnstake(address _user, uint256 _amount) external onlyOwner {
tls.forceUnstake(_user, _amount);
}
| 19,709 |
9 | // The number of rebase cycles since inception | uint256 public epoch;
uint256 private constant DECIMALS = 18;
| uint256 public epoch;
uint256 private constant DECIMALS = 18;
| 38,980 |
12 | // Deploy the contract | constructor() ERC721A("Reincarnation Pass", "BBRP")
| constructor() ERC721A("Reincarnation Pass", "BBRP")
| 35,411 |
24 | // admin function to reject a previously approved batch/ Requires that the Batch-NFT has not been fractionalized yet | function rejectApprovedWithComment(uint256 tokenId, string memory comment)
external
virtual
onlyOwner
whenNotPaused
| function rejectApprovedWithComment(uint256 tokenId, string memory comment)
external
virtual
onlyOwner
whenNotPaused
| 16,068 |
221 | // Lock some tokens as a new sub-stake_info Staker structure_nextPeriod Next period_staker Staker_value Amount of tokens which will be locked_unlockingDuration Amount of periods during which tokens will be unlocked when wind down is enabled/ | function lockAndCreate(
StakerInfo storage _info,
uint16 _nextPeriod,
address _staker,
uint256 _value,
uint16 _unlockingDuration
)
internal
| function lockAndCreate(
StakerInfo storage _info,
uint16 _nextPeriod,
address _staker,
uint256 _value,
uint16 _unlockingDuration
)
internal
| 50,062 |
244 | // The actual token contract, the default controller is the msg.sender/that deploys the contract, so usually this token will be deployed by a/token controller contract, which Giveth will call a "Campaign" | contract MiniMeToken is Controlled {
string public name; //The Token's name: e.g. DigixDAO Tokens
uint8 public decimals; //Number of decimals of the smallest unit
string public symbol; //An identifier: e.g. REP
string public version = "MMT_0.1"; //An arbitrary versioning scheme
/// @dev `Checkpoint` is the structure that attaches a block number to a
/// given value, the block number attached is the one that last changed the
/// value
struct Checkpoint {
// `fromBlock` is the block number that the value was generated from
uint128 fromBlock;
// `value` is the amount of tokens at a specific block number
uint128 value;
}
// `parentToken` is the Token address that was cloned to produce this token;
// it will be 0x0 for a token that was not cloned
MiniMeToken public parentToken;
// `parentSnapShotBlock` is the block number from the Parent Token that was
// used to determine the initial distribution of the Clone Token
uint public parentSnapShotBlock;
// `creationBlock` is the block number that the Clone Token was created
uint public creationBlock;
// `balances` is the map that tracks the balance of each address, in this
// contract when the balance changes the block number that the change
// occurred is also included in the map
mapping (address => Checkpoint[]) balances;
// `allowed` tracks any extra transfer rights as in all ERC20 tokens
mapping (address => mapping (address => uint256)) allowed;
// Tracks the history of the `totalSupply` of the token
Checkpoint[] totalSupplyHistory;
// Flag that determines if the token is transferable or not.
bool public transfersEnabled;
// The factory used to create new clone tokens
MiniMeTokenFactory public tokenFactory;
////////////////
// Constructor
////////////////
/// @notice Constructor to create a MiniMeToken
/// @param _tokenFactory The address of the MiniMeTokenFactory contract that
/// will create the Clone token contracts, the token factory needs to be
/// deployed first
/// @param _parentToken Address of the parent token, set to 0x0 if it is a
/// new token
/// @param _parentSnapShotBlock Block of the parent token that will
/// determine the initial distribution of the clone token, set to 0 if it
/// is a new token
/// @param _tokenName Name of the new token
/// @param _decimalUnits Number of decimals of the new token
/// @param _tokenSymbol Token Symbol for the new token
/// @param _transfersEnabled If true, tokens will be able to be transferred
function MiniMeToken(
MiniMeTokenFactory _tokenFactory,
MiniMeToken _parentToken,
uint _parentSnapShotBlock,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
bool _transfersEnabled
) public
{
tokenFactory = _tokenFactory;
name = _tokenName; // Set the name
decimals = _decimalUnits; // Set the decimals
symbol = _tokenSymbol; // Set the symbol
parentToken = _parentToken;
parentSnapShotBlock = _parentSnapShotBlock;
transfersEnabled = _transfersEnabled;
creationBlock = block.number;
}
///////////////////
// ERC20 Methods
///////////////////
/// @notice Send `_amount` tokens to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
return doTransfer(msg.sender, _to, _amount);
}
/// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
/// is approved by `_from`
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) {
// The controller of this contract can move tokens around at will,
// this is important to recognize! Confirm that you trust the
// controller of this contract, which in most situations should be
// another open source smart contract or 0x0
if (msg.sender != controller) {
require(transfersEnabled);
// The standard ERC 20 transferFrom functionality
if (allowed[_from][msg.sender] < _amount)
return false;
allowed[_from][msg.sender] -= _amount;
}
return doTransfer(_from, _to, _amount);
}
/// @dev This is the actual transfer function in the token contract, it can
/// only be called by other functions in this contract.
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function doTransfer(address _from, address _to, uint _amount) internal returns(bool) {
if (_amount == 0) {
return true;
}
require(parentSnapShotBlock < block.number);
// Do not allow transfer to 0x0 or the token contract itself
require((_to != 0) && (_to != address(this)));
// If the amount being transfered is more than the balance of the
// account the transfer returns false
var previousBalanceFrom = balanceOfAt(_from, block.number);
if (previousBalanceFrom < _amount) {
return false;
}
// Alerts the token controller of the transfer
if (isContract(controller)) {
// Adding the ` == true` makes the linter shut up so...
require(ITokenController(controller).onTransfer(_from, _to, _amount) == true);
}
// First update the balance array with the new value for the address
// sending the tokens
updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
// Then update the balance array with the new value for the address
// receiving the tokens
var previousBalanceTo = balanceOfAt(_to, block.number);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
// An event to make the transfer easy to find on the blockchain
Transfer(_from, _to, _amount);
return true;
}
/// @param _owner The address that's balance is being requested
/// @return The balance of `_owner` at the current block
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
/// its behalf. This is a modified version of the ERC20 approve function
/// to be a little bit safer
/// @param _spender The address of the account able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @return True if the approval was successful
function approve(address _spender, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender,0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
// Alerts the token controller of the approve function call
if (isContract(controller)) {
// Adding the ` == true` makes the linter shut up so...
require(ITokenController(controller).onApprove(msg.sender, _spender, _amount) == true);
}
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
/// @dev This function makes it easy to read the `allowed[]` map
/// @param _owner The address of the account that owns the token
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens of _owner that _spender is allowed
/// to spend
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
/// its behalf, and then a function is triggered in the contract that is
/// being approved, `_spender`. This allows users to use their tokens to
/// interact with contracts in one function call instead of two
/// @param _spender The address of the contract able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @return True if the function call was successful
function approveAndCall(ApproveAndCallFallBack _spender, uint256 _amount, bytes _extraData) public returns (bool success) {
require(approve(_spender, _amount));
_spender.receiveApproval(
msg.sender,
_amount,
this,
_extraData
);
return true;
}
/// @dev This function makes it easy to get the total number of tokens
/// @return The total number of tokens
function totalSupply() public constant returns (uint) {
return totalSupplyAt(block.number);
}
////////////////
// Query balance and totalSupply in History
////////////////
/// @dev Queries the balance of `_owner` at a specific `_blockNumber`
/// @param _owner The address from which the balance will be retrieved
/// @param _blockNumber The block number when the balance is queried
/// @return The balance at `_blockNumber`
function balanceOfAt(address _owner, uint _blockNumber) public constant returns (uint) {
// These next few lines are used when the balance of the token is
// requested before a check point was ever created for this token, it
// requires that the `parentToken.balanceOfAt` be queried at the
// genesis block for that token as this contains initial balance of
// this token
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
} else {
// Has no parent
return 0;
}
// This will return the expected balance during normal situations
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
/// @notice Total amount of tokens at a specific `_blockNumber`.
/// @param _blockNumber The block number when the totalSupply is queried
/// @return The total amount of tokens at `_blockNumber`
function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
// These next few lines are used when the totalSupply of the token is
// requested before a check point was ever created for this token, it
// requires that the `parentToken.totalSupplyAt` be queried at the
// genesis block for this token as that contains totalSupply of this
// token at this block number.
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
} else {
return 0;
}
// This will return the expected totalSupply during normal situations
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
////////////////
// Clone Token Method
////////////////
/// @notice Creates a new clone token with the initial distribution being
/// this token at `_snapshotBlock`
/// @param _cloneTokenName Name of the clone token
/// @param _cloneDecimalUnits Number of decimals of the smallest unit
/// @param _cloneTokenSymbol Symbol of the clone token
/// @param _snapshotBlock Block when the distribution of the parent token is
/// copied to set the initial distribution of the new clone token;
/// if the block is zero than the actual block, the current block is used
/// @param _transfersEnabled True if transfers are allowed in the clone
/// @return The address of the new MiniMeToken Contract
function createCloneToken(
string _cloneTokenName,
uint8 _cloneDecimalUnits,
string _cloneTokenSymbol,
uint _snapshotBlock,
bool _transfersEnabled
) public returns(MiniMeToken)
{
uint256 snapshot = _snapshotBlock == 0 ? block.number - 1 : _snapshotBlock;
MiniMeToken cloneToken = tokenFactory.createCloneToken(
this,
snapshot,
_cloneTokenName,
_cloneDecimalUnits,
_cloneTokenSymbol,
_transfersEnabled
);
cloneToken.changeController(msg.sender);
// An event to make the token easy to find on the blockchain
NewCloneToken(address(cloneToken), snapshot);
return cloneToken;
}
////////////////
// Generate and destroy tokens
////////////////
/// @notice Generates `_amount` tokens that are assigned to `_owner`
/// @param _owner The address that will be assigned the new tokens
/// @param _amount The quantity of tokens generated
/// @return True if the tokens are generated correctly
function generateTokens(address _owner, uint _amount) onlyController public returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
uint previousBalanceTo = balanceOf(_owner);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
Transfer(0, _owner, _amount);
return true;
}
/// @notice Burns `_amount` tokens from `_owner`
/// @param _owner The address that will lose the tokens
/// @param _amount The quantity of tokens to burn
/// @return True if the tokens are burned correctly
function destroyTokens(address _owner, uint _amount) onlyController public returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply >= _amount);
uint previousBalanceFrom = balanceOf(_owner);
require(previousBalanceFrom >= _amount);
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
Transfer(_owner, 0, _amount);
return true;
}
////////////////
// Enable tokens transfers
////////////////
/// @notice Enables token holders to transfer their tokens freely if true
/// @param _transfersEnabled True if transfers are allowed in the clone
function enableTransfers(bool _transfersEnabled) onlyController public {
transfersEnabled = _transfersEnabled;
}
////////////////
// Internal helper functions to query and set a value in a snapshot array
////////////////
/// @dev `getValueAt` retrieves the number of tokens at a given block number
/// @param checkpoints The history of values being queried
/// @param _block The block number to retrieve the value at
/// @return The number of tokens being queried
function getValueAt(Checkpoint[] storage checkpoints, uint _block) constant internal returns (uint) {
if (checkpoints.length == 0)
return 0;
// Shortcut for the actual value
if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints[checkpoints.length-1].value;
if (_block < checkpoints[0].fromBlock)
return 0;
// Binary search of the value in the array
uint min = 0;
uint max = checkpoints.length-1;
while (max > min) {
uint mid = (max + min + 1) / 2;
if (checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return checkpoints[min].value;
}
/// @dev `updateValueAtNow` used to update the `balances` map and the
/// `totalSupplyHistory`
/// @param checkpoints The history of data being updated
/// @param _value The new number of tokens
function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value) internal {
if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
newCheckPoint.fromBlock = uint128(block.number);
newCheckPoint.value = uint128(_value);
} else {
Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length - 1];
oldCheckPoint.value = uint128(_value);
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0)
return false;
assembly {
size := extcodesize(_addr)
}
return size>0;
}
/// @dev Helper function to return a min betwen the two uints
function min(uint a, uint b) pure internal returns (uint) {
return a < b ? a : b;
}
/// @notice The fallback function: If the contract's controller has not been
/// set to 0, then the `proxyPayment` method is called which relays the
/// ether and creates tokens as described in the token controller contract
function () external payable {
require(isContract(controller));
// Adding the ` == true` makes the linter shut up so...
require(ITokenController(controller).proxyPayment.value(msg.value)(msg.sender) == true);
}
//////////
// Safety Methods
//////////
/// @notice This method can be used by the controller to extract mistakenly
/// sent tokens to this contract.
/// @param _token The address of the token contract that you want to recover
/// set to 0 in case you want to extract ether.
function claimTokens(address _token) onlyController public {
if (_token == 0x0) {
controller.transfer(this.balance);
return;
}
MiniMeToken token = MiniMeToken(_token);
uint balance = token.balanceOf(this);
token.transfer(controller, balance);
ClaimedTokens(_token, controller, balance);
}
////////////////
// Events
////////////////
event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _amount
);
}
| contract MiniMeToken is Controlled {
string public name; //The Token's name: e.g. DigixDAO Tokens
uint8 public decimals; //Number of decimals of the smallest unit
string public symbol; //An identifier: e.g. REP
string public version = "MMT_0.1"; //An arbitrary versioning scheme
/// @dev `Checkpoint` is the structure that attaches a block number to a
/// given value, the block number attached is the one that last changed the
/// value
struct Checkpoint {
// `fromBlock` is the block number that the value was generated from
uint128 fromBlock;
// `value` is the amount of tokens at a specific block number
uint128 value;
}
// `parentToken` is the Token address that was cloned to produce this token;
// it will be 0x0 for a token that was not cloned
MiniMeToken public parentToken;
// `parentSnapShotBlock` is the block number from the Parent Token that was
// used to determine the initial distribution of the Clone Token
uint public parentSnapShotBlock;
// `creationBlock` is the block number that the Clone Token was created
uint public creationBlock;
// `balances` is the map that tracks the balance of each address, in this
// contract when the balance changes the block number that the change
// occurred is also included in the map
mapping (address => Checkpoint[]) balances;
// `allowed` tracks any extra transfer rights as in all ERC20 tokens
mapping (address => mapping (address => uint256)) allowed;
// Tracks the history of the `totalSupply` of the token
Checkpoint[] totalSupplyHistory;
// Flag that determines if the token is transferable or not.
bool public transfersEnabled;
// The factory used to create new clone tokens
MiniMeTokenFactory public tokenFactory;
////////////////
// Constructor
////////////////
/// @notice Constructor to create a MiniMeToken
/// @param _tokenFactory The address of the MiniMeTokenFactory contract that
/// will create the Clone token contracts, the token factory needs to be
/// deployed first
/// @param _parentToken Address of the parent token, set to 0x0 if it is a
/// new token
/// @param _parentSnapShotBlock Block of the parent token that will
/// determine the initial distribution of the clone token, set to 0 if it
/// is a new token
/// @param _tokenName Name of the new token
/// @param _decimalUnits Number of decimals of the new token
/// @param _tokenSymbol Token Symbol for the new token
/// @param _transfersEnabled If true, tokens will be able to be transferred
function MiniMeToken(
MiniMeTokenFactory _tokenFactory,
MiniMeToken _parentToken,
uint _parentSnapShotBlock,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
bool _transfersEnabled
) public
{
tokenFactory = _tokenFactory;
name = _tokenName; // Set the name
decimals = _decimalUnits; // Set the decimals
symbol = _tokenSymbol; // Set the symbol
parentToken = _parentToken;
parentSnapShotBlock = _parentSnapShotBlock;
transfersEnabled = _transfersEnabled;
creationBlock = block.number;
}
///////////////////
// ERC20 Methods
///////////////////
/// @notice Send `_amount` tokens to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
return doTransfer(msg.sender, _to, _amount);
}
/// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
/// is approved by `_from`
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) {
// The controller of this contract can move tokens around at will,
// this is important to recognize! Confirm that you trust the
// controller of this contract, which in most situations should be
// another open source smart contract or 0x0
if (msg.sender != controller) {
require(transfersEnabled);
// The standard ERC 20 transferFrom functionality
if (allowed[_from][msg.sender] < _amount)
return false;
allowed[_from][msg.sender] -= _amount;
}
return doTransfer(_from, _to, _amount);
}
/// @dev This is the actual transfer function in the token contract, it can
/// only be called by other functions in this contract.
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function doTransfer(address _from, address _to, uint _amount) internal returns(bool) {
if (_amount == 0) {
return true;
}
require(parentSnapShotBlock < block.number);
// Do not allow transfer to 0x0 or the token contract itself
require((_to != 0) && (_to != address(this)));
// If the amount being transfered is more than the balance of the
// account the transfer returns false
var previousBalanceFrom = balanceOfAt(_from, block.number);
if (previousBalanceFrom < _amount) {
return false;
}
// Alerts the token controller of the transfer
if (isContract(controller)) {
// Adding the ` == true` makes the linter shut up so...
require(ITokenController(controller).onTransfer(_from, _to, _amount) == true);
}
// First update the balance array with the new value for the address
// sending the tokens
updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
// Then update the balance array with the new value for the address
// receiving the tokens
var previousBalanceTo = balanceOfAt(_to, block.number);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
// An event to make the transfer easy to find on the blockchain
Transfer(_from, _to, _amount);
return true;
}
/// @param _owner The address that's balance is being requested
/// @return The balance of `_owner` at the current block
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
/// its behalf. This is a modified version of the ERC20 approve function
/// to be a little bit safer
/// @param _spender The address of the account able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @return True if the approval was successful
function approve(address _spender, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender,0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
// Alerts the token controller of the approve function call
if (isContract(controller)) {
// Adding the ` == true` makes the linter shut up so...
require(ITokenController(controller).onApprove(msg.sender, _spender, _amount) == true);
}
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
/// @dev This function makes it easy to read the `allowed[]` map
/// @param _owner The address of the account that owns the token
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens of _owner that _spender is allowed
/// to spend
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
/// its behalf, and then a function is triggered in the contract that is
/// being approved, `_spender`. This allows users to use their tokens to
/// interact with contracts in one function call instead of two
/// @param _spender The address of the contract able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @return True if the function call was successful
function approveAndCall(ApproveAndCallFallBack _spender, uint256 _amount, bytes _extraData) public returns (bool success) {
require(approve(_spender, _amount));
_spender.receiveApproval(
msg.sender,
_amount,
this,
_extraData
);
return true;
}
/// @dev This function makes it easy to get the total number of tokens
/// @return The total number of tokens
function totalSupply() public constant returns (uint) {
return totalSupplyAt(block.number);
}
////////////////
// Query balance and totalSupply in History
////////////////
/// @dev Queries the balance of `_owner` at a specific `_blockNumber`
/// @param _owner The address from which the balance will be retrieved
/// @param _blockNumber The block number when the balance is queried
/// @return The balance at `_blockNumber`
function balanceOfAt(address _owner, uint _blockNumber) public constant returns (uint) {
// These next few lines are used when the balance of the token is
// requested before a check point was ever created for this token, it
// requires that the `parentToken.balanceOfAt` be queried at the
// genesis block for that token as this contains initial balance of
// this token
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
} else {
// Has no parent
return 0;
}
// This will return the expected balance during normal situations
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
/// @notice Total amount of tokens at a specific `_blockNumber`.
/// @param _blockNumber The block number when the totalSupply is queried
/// @return The total amount of tokens at `_blockNumber`
function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
// These next few lines are used when the totalSupply of the token is
// requested before a check point was ever created for this token, it
// requires that the `parentToken.totalSupplyAt` be queried at the
// genesis block for this token as that contains totalSupply of this
// token at this block number.
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
} else {
return 0;
}
// This will return the expected totalSupply during normal situations
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
////////////////
// Clone Token Method
////////////////
/// @notice Creates a new clone token with the initial distribution being
/// this token at `_snapshotBlock`
/// @param _cloneTokenName Name of the clone token
/// @param _cloneDecimalUnits Number of decimals of the smallest unit
/// @param _cloneTokenSymbol Symbol of the clone token
/// @param _snapshotBlock Block when the distribution of the parent token is
/// copied to set the initial distribution of the new clone token;
/// if the block is zero than the actual block, the current block is used
/// @param _transfersEnabled True if transfers are allowed in the clone
/// @return The address of the new MiniMeToken Contract
function createCloneToken(
string _cloneTokenName,
uint8 _cloneDecimalUnits,
string _cloneTokenSymbol,
uint _snapshotBlock,
bool _transfersEnabled
) public returns(MiniMeToken)
{
uint256 snapshot = _snapshotBlock == 0 ? block.number - 1 : _snapshotBlock;
MiniMeToken cloneToken = tokenFactory.createCloneToken(
this,
snapshot,
_cloneTokenName,
_cloneDecimalUnits,
_cloneTokenSymbol,
_transfersEnabled
);
cloneToken.changeController(msg.sender);
// An event to make the token easy to find on the blockchain
NewCloneToken(address(cloneToken), snapshot);
return cloneToken;
}
////////////////
// Generate and destroy tokens
////////////////
/// @notice Generates `_amount` tokens that are assigned to `_owner`
/// @param _owner The address that will be assigned the new tokens
/// @param _amount The quantity of tokens generated
/// @return True if the tokens are generated correctly
function generateTokens(address _owner, uint _amount) onlyController public returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
uint previousBalanceTo = balanceOf(_owner);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
Transfer(0, _owner, _amount);
return true;
}
/// @notice Burns `_amount` tokens from `_owner`
/// @param _owner The address that will lose the tokens
/// @param _amount The quantity of tokens to burn
/// @return True if the tokens are burned correctly
function destroyTokens(address _owner, uint _amount) onlyController public returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply >= _amount);
uint previousBalanceFrom = balanceOf(_owner);
require(previousBalanceFrom >= _amount);
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
Transfer(_owner, 0, _amount);
return true;
}
////////////////
// Enable tokens transfers
////////////////
/// @notice Enables token holders to transfer their tokens freely if true
/// @param _transfersEnabled True if transfers are allowed in the clone
function enableTransfers(bool _transfersEnabled) onlyController public {
transfersEnabled = _transfersEnabled;
}
////////////////
// Internal helper functions to query and set a value in a snapshot array
////////////////
/// @dev `getValueAt` retrieves the number of tokens at a given block number
/// @param checkpoints The history of values being queried
/// @param _block The block number to retrieve the value at
/// @return The number of tokens being queried
function getValueAt(Checkpoint[] storage checkpoints, uint _block) constant internal returns (uint) {
if (checkpoints.length == 0)
return 0;
// Shortcut for the actual value
if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints[checkpoints.length-1].value;
if (_block < checkpoints[0].fromBlock)
return 0;
// Binary search of the value in the array
uint min = 0;
uint max = checkpoints.length-1;
while (max > min) {
uint mid = (max + min + 1) / 2;
if (checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return checkpoints[min].value;
}
/// @dev `updateValueAtNow` used to update the `balances` map and the
/// `totalSupplyHistory`
/// @param checkpoints The history of data being updated
/// @param _value The new number of tokens
function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value) internal {
if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
newCheckPoint.fromBlock = uint128(block.number);
newCheckPoint.value = uint128(_value);
} else {
Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length - 1];
oldCheckPoint.value = uint128(_value);
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0)
return false;
assembly {
size := extcodesize(_addr)
}
return size>0;
}
/// @dev Helper function to return a min betwen the two uints
function min(uint a, uint b) pure internal returns (uint) {
return a < b ? a : b;
}
/// @notice The fallback function: If the contract's controller has not been
/// set to 0, then the `proxyPayment` method is called which relays the
/// ether and creates tokens as described in the token controller contract
function () external payable {
require(isContract(controller));
// Adding the ` == true` makes the linter shut up so...
require(ITokenController(controller).proxyPayment.value(msg.value)(msg.sender) == true);
}
//////////
// Safety Methods
//////////
/// @notice This method can be used by the controller to extract mistakenly
/// sent tokens to this contract.
/// @param _token The address of the token contract that you want to recover
/// set to 0 in case you want to extract ether.
function claimTokens(address _token) onlyController public {
if (_token == 0x0) {
controller.transfer(this.balance);
return;
}
MiniMeToken token = MiniMeToken(_token);
uint balance = token.balanceOf(this);
token.transfer(controller, balance);
ClaimedTokens(_token, controller, balance);
}
////////////////
// Events
////////////////
event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _amount
);
}
| 13,085 |
1 | // returns an account's total withdrawable rewards (principal balance + newly earned rewards) _account account addressreturn account's total unclaimed rewards / | function withdrawableRewards(address _account) public view virtual returns (uint256) {
return
(controller.staked(_account) * (rewardPerToken - userRewardPerTokenPaid[_account])) /
1e18 +
userRewards[_account];
}
| function withdrawableRewards(address _account) public view virtual returns (uint256) {
return
(controller.staked(_account) * (rewardPerToken - userRewardPerTokenPaid[_account])) /
1e18 +
userRewards[_account];
}
| 5,665 |
60 | // See {IERC721-balanceOf}. / | function balanceOf(address owner) public view virtual override returns (uint256) {
| function balanceOf(address owner) public view virtual override returns (uint256) {
| 2,893 |
27 | // Initiates an Ether transfer between two wallets_from Address from which the Ether is sent from_to Address to which the Ether is sent_value Amount of wei sent | function moveEther(FundWallet _from, address _to, uint256 _value)
public
onlyOwner
| function moveEther(FundWallet _from, address _to, uint256 _value)
public
onlyOwner
| 25,826 |
23 | // Slice the sighash. | _returnData := add(_returnData, 0x04)
| _returnData := add(_returnData, 0x04)
| 2,069 |
13 | // Mainnet neutral tokens | neutralTokens[address(0x8e769EAA31375D13a1247dE1e64987c28Bed987E)] = true;
neutralTokens[address(0x739D93f2b116E6aD754e173655c635Bd5D8d664c)] = true;
neutralTokens[address(0xfea2468C55E80aB9487f6E6189C79Ce31E1f9Ea7)] = true;
neutralTokens[address(0x939D73E26138f4B483368F96d17D2B4dCc5bc84f)] = true;
| neutralTokens[address(0x8e769EAA31375D13a1247dE1e64987c28Bed987E)] = true;
neutralTokens[address(0x739D93f2b116E6aD754e173655c635Bd5D8d664c)] = true;
neutralTokens[address(0xfea2468C55E80aB9487f6E6189C79Ce31E1f9Ea7)] = true;
neutralTokens[address(0x939D73E26138f4B483368F96d17D2B4dCc5bc84f)] = true;
| 32,603 |
109 | // A cursor pointing to the revert flag, starts after the length field of the data object | let memPtr := add(data, 32)
| let memPtr := add(data, 32)
| 7,337 |
301 | // Returns the current quorum numerator. See {quorumDenominator}. / | function quorumNumerator() public view virtual returns (uint256) {
return _quorumNumerator;
}
| function quorumNumerator() public view virtual returns (uint256) {
return _quorumNumerator;
}
| 60,081 |
18 | // Close the crowdsale/ | function closeCrowdsale()
isOwner
| function closeCrowdsale()
isOwner
| 37,141 |
10 | // Delegate to internal OpenZeppelin burn function | _burn(_tokenId);
| _burn(_tokenId);
| 66,360 |
102 | // EIP-20 token decimals for this token / | uint256 public decimals;
| uint256 public decimals;
| 37,327 |
14 | // Remove single address into the whitelist.Note: Use this function for a single address save transaction fee/ | function removeFromWhitelist(address addr) onlyOwner public {
participants[addr].whitelisted = false;
}
| function removeFromWhitelist(address addr) onlyOwner public {
participants[addr].whitelisted = false;
}
| 46,913 |
13 | // Set new alloc points for an option pool. Can only be called by the owner or premia diamond _pool Address of option pool contract _allocPoints Weight of this pool in the reward calculation / | function setPoolAllocPoints(address _pool, uint256 _allocPoints)
external
override
onlyDiamondOrOwner
| function setPoolAllocPoints(address _pool, uint256 _allocPoints)
external
override
onlyDiamondOrOwner
| 37,239 |
64 | // Remove node from a storage linkedlist. | function checkAndRemoveFromPendingGroup(address node) private returns(bool) {
uint prev = HEAD_I;
uint curr = pendingGroupList[prev];
while (curr != HEAD_I) {
PendingGroup storage pgrp = pendingGroups[curr];
(, bool found) = findNodeFromList(pgrp.memberList, node);
if (found) {
cleanUpPendingGroup(curr, node);
return true;
}
prev = curr;
curr = pendingGroupList[prev];
}
return false;
}
| function checkAndRemoveFromPendingGroup(address node) private returns(bool) {
uint prev = HEAD_I;
uint curr = pendingGroupList[prev];
while (curr != HEAD_I) {
PendingGroup storage pgrp = pendingGroups[curr];
(, bool found) = findNodeFromList(pgrp.memberList, node);
if (found) {
cleanUpPendingGroup(curr, node);
return true;
}
prev = curr;
curr = pendingGroupList[prev];
}
return false;
}
| 38,768 |
207 | // increments the value of _currentTokenID / | function _incrementTokenTypeId() internal virtual {
_currentTokenID++;
}
| function _incrementTokenTypeId() internal virtual {
_currentTokenID++;
}
| 45,721 |
226 | // Return the approx logarithm of a value with log(x) where x <= 1.1.All values are in integers with (1e18 == 1.0). Requirements: - input value x must be greater than 1e18 / | function _logApprox(uint256 x) internal pure returns (uint256 y) {
uint256 one = W_ONE;
require(x >= one, "logApprox: x must >= 1");
uint256 z = x - one;
uint256 zz = z.mul(z).div(one);
uint256 zzz = zz.mul(z).div(one);
uint256 zzzz = zzz.mul(z).div(one);
uint256 zzzzz = zzzz.mul(z).div(one);
return z.sub(zz.div(2)).add(zzz.div(3)).sub(zzzz.div(4)).add(zzzzz.div(5));
}
| function _logApprox(uint256 x) internal pure returns (uint256 y) {
uint256 one = W_ONE;
require(x >= one, "logApprox: x must >= 1");
uint256 z = x - one;
uint256 zz = z.mul(z).div(one);
uint256 zzz = zz.mul(z).div(one);
uint256 zzzz = zzz.mul(z).div(one);
uint256 zzzzz = zzzz.mul(z).div(one);
return z.sub(zz.div(2)).add(zzz.div(3)).sub(zzzz.div(4)).add(zzzzz.div(5));
}
| 71,040 |
135 | // Oracle info | OracleInfo memory thisOracle = oracle_info[token_address];
| OracleInfo memory thisOracle = oracle_info[token_address];
| 27,849 |
289 | // Check parameters existence. | require(parameters[_paramsHash].queuedVoteRequiredPercentage >= 50);
| require(parameters[_paramsHash].queuedVoteRequiredPercentage >= 50);
| 7,694 |
88 | // loop all dates | for (uint8 i = 0; i < PERIOD_DATES.length; i++) {
uint256 nPeriodInterest = arrInterests[i];
uint256 nPeriodDate = PERIOD_DATES[i];
if (_nPaymentDate >= nPeriodDate) {
| for (uint8 i = 0; i < PERIOD_DATES.length; i++) {
uint256 nPeriodInterest = arrInterests[i];
uint256 nPeriodDate = PERIOD_DATES[i];
if (_nPaymentDate >= nPeriodDate) {
| 18,785 |
3 | // Maps SocialToken creator to deployed SocialToken address | mapping(address => address) private _tokens;
| mapping(address => address) private _tokens;
| 17,848 |
5 | // Copies 'len' bytes from 'srcPtr' to 'destPtr'. NOTE: This function does not check if memory is allocated, it only copies the bytes. | function memcopy(uint srcPtr, uint destPtr, uint len) internal pure {
uint offset = 0;
uint size = len / WORD_SIZE;
// Copy word-length chunks while possible.
for (uint i = 0; i < size; i++) {
offset = i * WORD_SIZE;
assembly {
mstore(add(destPtr, offset), mload(add(srcPtr, offset)))
}
}
offset = size*WORD_SIZE;
uint mask = ONES << 8*(32 - len % WORD_SIZE);
assembly {
let nSrc := add(srcPtr, offset)
let nDest := add(destPtr, offset)
mstore(nDest, or(and(mload(nSrc), mask), and(mload(nDest), not(mask))))
}
}
| function memcopy(uint srcPtr, uint destPtr, uint len) internal pure {
uint offset = 0;
uint size = len / WORD_SIZE;
// Copy word-length chunks while possible.
for (uint i = 0; i < size; i++) {
offset = i * WORD_SIZE;
assembly {
mstore(add(destPtr, offset), mload(add(srcPtr, offset)))
}
}
offset = size*WORD_SIZE;
uint mask = ONES << 8*(32 - len % WORD_SIZE);
assembly {
let nSrc := add(srcPtr, offset)
let nDest := add(destPtr, offset)
mstore(nDest, or(and(mload(nSrc), mask), and(mload(nDest), not(mask))))
}
}
| 11,097 |
27 | // Ensure that sender has revealed a vote | VoteCommit memory senderVote = votes[msg.sender];
require(
(senderVote.choice == Choice.A) || (senderVote.choice == Choice.B),
"Cannot claim payout without revealed vote."
);
| VoteCommit memory senderVote = votes[msg.sender];
require(
(senderVote.choice == Choice.A) || (senderVote.choice == Choice.B),
"Cannot claim payout without revealed vote."
);
| 48,763 |
21 | // Calculate tokens amount that is sent to withdrawAddress.return Amount of tokens that can be sent. / | function getAvailableTokensToWithdraw () public view returns (uint256 tokensToSend) {
uint256 tokensUnlockedPercentage = getTokensUnlockedPercentage();
// In the case of stuck tokens we allow the withdrawal of them all after vesting period ends.
if (tokensUnlockedPercentage >= 100) {
tokensToSend = bitcca.balanceOf(this);
} else {
tokensToSend = getTokensAmountAllowedToWithdraw(tokensUnlockedPercentage);
}
}
| function getAvailableTokensToWithdraw () public view returns (uint256 tokensToSend) {
uint256 tokensUnlockedPercentage = getTokensUnlockedPercentage();
// In the case of stuck tokens we allow the withdrawal of them all after vesting period ends.
if (tokensUnlockedPercentage >= 100) {
tokensToSend = bitcca.balanceOf(this);
} else {
tokensToSend = getTokensAmountAllowedToWithdraw(tokensUnlockedPercentage);
}
}
| 41,266 |
233 | // Returns the text of a mood based on the supplied type/mood The MoodType/ return The mood text | function moodForType(IBear3Traits.MoodType mood) external pure returns (string memory);
| function moodForType(IBear3Traits.MoodType mood) external pure returns (string memory);
| 14,059 |
27 | // Internal pure function to supply the name of the underlying token.return The name of the underlying token. / | function _getUnderlyingName() internal pure returns (string memory underlyingName);
| function _getUnderlyingName() internal pure returns (string memory underlyingName);
| 49,525 |
2 | // Implements a URI for a collection which is shared by all tokens. HardlyDifficult / | abstract contract SharedURICollection is ERC721Upgradeable {
string private $baseURI;
/**
* @notice Set the base URI to be used for all tokens.
* @param uri The base URI to use.
*/
function _setBaseURI(string calldata uri) internal {
if (bytes(uri).length == 0) {
revert SharedURICollection_URI_Not_Set();
}
$baseURI = uri;
}
/**
* @inheritdoc ERC721Upgradeable
*/
function _baseURI() internal view virtual override returns (string memory uri) {
uri = $baseURI;
}
}
| abstract contract SharedURICollection is ERC721Upgradeable {
string private $baseURI;
/**
* @notice Set the base URI to be used for all tokens.
* @param uri The base URI to use.
*/
function _setBaseURI(string calldata uri) internal {
if (bytes(uri).length == 0) {
revert SharedURICollection_URI_Not_Set();
}
$baseURI = uri;
}
/**
* @inheritdoc ERC721Upgradeable
*/
function _baseURI() internal view virtual override returns (string memory uri) {
uri = $baseURI;
}
}
| 33,579 |
19 | // Returns each address that signed a hashed message (`hash`) from acollection of `signatures`. The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:this function rejects them by requiring the `s` value to be in the lowerhalf order, and the `v` value to be either 27 or 28. NOTE: This call _does not revert_ if a signature is invalid, or if thesigner is otherwise unable to be retrieved. In those scenarios, the zeroaddress is returned for that signature. IMPORTANT: `hash` _must_ be the result of a hash operation for theverification to be secure: it is possible to craft signatures that recoverto arbitrary | function _recoverGroup(
bytes32 hash,
bytes memory signatures
| function _recoverGroup(
bytes32 hash,
bytes memory signatures
| 28,513 |
190 | // Transfers ownership of the contract to a new account (`newOwner`).Can only be called by the current owner.force setup DEFAULT_ADMIN_ROLE to owner, in case him has renounced DEFAULT_ADMIN_ROLEbeacuse he need to have almost DEFAULT_ADMIN_ROLE role to grant all role to the newOwnerRevoke all roles to the previous ownerGrants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, `PAUSER_ROLE` to the new owner / | function transferOwnership(address newOwner) public override onlyOwner {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
grantRole(DEFAULT_ADMIN_ROLE, newOwner);
grantRole(MINTER_ROLE, newOwner);
grantRole(PAUSER_ROLE, newOwner);
revokeRole(MINTER_ROLE, _msgSender());
revokeRole(PAUSER_ROLE, _msgSender());
revokeRole(DEFAULT_ADMIN_ROLE, _msgSender());
super.transferOwnership(newOwner);
}
| function transferOwnership(address newOwner) public override onlyOwner {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
grantRole(DEFAULT_ADMIN_ROLE, newOwner);
grantRole(MINTER_ROLE, newOwner);
grantRole(PAUSER_ROLE, newOwner);
revokeRole(MINTER_ROLE, _msgSender());
revokeRole(PAUSER_ROLE, _msgSender());
revokeRole(DEFAULT_ADMIN_ROLE, _msgSender());
super.transferOwnership(newOwner);
}
| 6,169 |
386 | // move right bound `j` to the middle position `k - 1`: element at position `k` is bigger and cannot be the result | j = k - 1;
| j = k - 1;
| 49,950 |
87 | // This contract aims to provide an inheritable way to recover tokens from a contract not meant to hold tokens To use this contract, have your token-ignoring contract inherit this one and implement getLostAndFoundMaster to decide who can move lost tokens. Of course, this contract imposes support costs upon whoever is the lost and found master. | contract LostAndFoundToken {
/**
* @return Address of the account that handles movements.
*/
function getLostAndFoundMaster() internal view returns (address);
/**
* @param agent Address that will be able to move tokens with transferFrom
* @param tokens Amount of tokens approved for transfer
* @param token_contract Contract of the token
*/
function enableLostAndFound(address agent, uint tokens, EIP20Token token_contract) public {
require(msg.sender == getLostAndFoundMaster());
// We use approve instead of transfer to minimize the possibility of the lost and found master
// getting them stuck in another address by accident.
token_contract.approve(agent, tokens);
}
}
| contract LostAndFoundToken {
/**
* @return Address of the account that handles movements.
*/
function getLostAndFoundMaster() internal view returns (address);
/**
* @param agent Address that will be able to move tokens with transferFrom
* @param tokens Amount of tokens approved for transfer
* @param token_contract Contract of the token
*/
function enableLostAndFound(address agent, uint tokens, EIP20Token token_contract) public {
require(msg.sender == getLostAndFoundMaster());
// We use approve instead of transfer to minimize the possibility of the lost and found master
// getting them stuck in another address by accident.
token_contract.approve(agent, tokens);
}
}
| 73,753 |
94 | // recalculate deposit weight | uint256 previousWeight = stakeDeposit.weight;
uint256 newWeight = (((stakeDeposit.lockedUntil - stakeDeposit.lockedFrom) *
WEIGHT_MULTIPLIER) /
365 days +
WEIGHT_MULTIPLIER) * (stakeDeposit.tokenAmount - _amount);
| uint256 previousWeight = stakeDeposit.weight;
uint256 newWeight = (((stakeDeposit.lockedUntil - stakeDeposit.lockedFrom) *
WEIGHT_MULTIPLIER) /
365 days +
WEIGHT_MULTIPLIER) * (stakeDeposit.tokenAmount - _amount);
| 35,979 |
159 | // boolean to declare if contract is whitelisted | bool public immutable whitelistedContract;
| bool public immutable whitelistedContract;
| 69,475 |
113 | // nft owner address | address nftOwner;
| address nftOwner;
| 3,763 |
52 | // Donate ETH tokens to contract (Owner)/ | function donation()
external payable
| function donation()
external payable
| 36,907 |
29 | // ============ MUTATIVE FUNCTIONS ========== |
function addLiquidity(
uint256[] calldata amounts,
uint256 minToMint,
uint256 deadline
|
function addLiquidity(
uint256[] calldata amounts,
uint256 minToMint,
uint256 deadline
| 15,087 |
28 | // To be set at a later date when the platform is developed / | function setAddonsAddress(address addonsAddress) onlyOwner public {
_addonsAddress = addonsAddress;
}
| function setAddonsAddress(address addonsAddress) onlyOwner public {
_addonsAddress = addonsAddress;
}
| 39,427 |
45 | // Addresses for second batch release | address[] secondBatchAddresses;
uint256 sIndex = 0;
| address[] secondBatchAddresses;
uint256 sIndex = 0;
| 78,443 |
33 | // Allows an owner to submit and confirm a transaction./destination Transaction target address./value Transaction ether value./data Transaction data payload./ return Returns transaction ID. | function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
| function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
| 2,749 |
36 | // ERC20 standard function | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_to != 0x0);
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(validateTransferAmount(_from,_value));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_to != 0x0);
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(validateTransferAmount(_from,_value));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| 3,104 |
102 | // A hook function checking if the mass of the NFT in the `to` wallethas reached the soft cap before it is being transferred. / | function _beforeTokenTransfer(address, address to, uint256) private view {
if (!specialWallets[to]) {
if (_tokenOf(to) != 0) { // a non-existent token
require(_massOf(_tokenOf(to)) < cap, "Exceeding cap");
}
}
}
| function _beforeTokenTransfer(address, address to, uint256) private view {
if (!specialWallets[to]) {
if (_tokenOf(to) != 0) { // a non-existent token
require(_massOf(_tokenOf(to)) < cap, "Exceeding cap");
}
}
}
| 5,575 |
17 | // implements the permit function/_owner the owner of the funds/_spender the _spender/_value the amount/_deadline the deadline timestamp, type(uint256).max for no deadline/_v signature param/_r signature param/_s signature param | function permit(
address _owner,
address _spender,
uint256 _value,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
| function permit(
address _owner,
address _spender,
uint256 _value,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
| 46,956 |
33 | // Emit event that everything is fine | emit WithdrawRequestSucceeded(lastExchangePrice, _queryID);
| emit WithdrawRequestSucceeded(lastExchangePrice, _queryID);
| 7,582 |
107 | // See {IERC721-getApproved}. / | function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
| function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
| 208 |
22 | // EMERGENCY ONLY. Disable accept new position without going through Timelock in case of emergency. | function emergencySetAcceptDebt(address[] calldata addrs, bool isAcceptDebt) external onlyGovernor {
uint256 len = addrs.length;
for (uint256 idx = 0; idx < len; idx++) {
workers[addrs[idx]].acceptDebt = isAcceptDebt;
emit SetConfig(
_msgSender(),
addrs[idx],
workers[addrs[idx]].acceptDebt,
workers[addrs[idx]].workFactor,
workers[addrs[idx]].killFactor,
workers[addrs[idx]].maxPriceDiff
);
}
}
| function emergencySetAcceptDebt(address[] calldata addrs, bool isAcceptDebt) external onlyGovernor {
uint256 len = addrs.length;
for (uint256 idx = 0; idx < len; idx++) {
workers[addrs[idx]].acceptDebt = isAcceptDebt;
emit SetConfig(
_msgSender(),
addrs[idx],
workers[addrs[idx]].acceptDebt,
workers[addrs[idx]].workFactor,
workers[addrs[idx]].killFactor,
workers[addrs[idx]].maxPriceDiff
);
}
}
| 52,047 |
58 | // Put a token up for auction. _tokenId ID of token to auction, sender must be owner _startingPrice Price of item (in wei) at beginning of auction _endingPrice Price of item (in wei) at end of auction _duration Length of auction (in seconds) / | function createAuction(
uint256 _tokenId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration
)
whenNotPaused
external
| function createAuction(
uint256 _tokenId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration
)
whenNotPaused
external
| 15,120 |
2 | // Max approve token in | _params.tokenIn.maxApproveIfNecessary(_params.allowanceTarget);
| _params.tokenIn.maxApproveIfNecessary(_params.allowanceTarget);
| 16,325 |
5 | // https:docs.synthetix.io/contracts/Owned | abstract contract Owned {
address public owner;
address public nominatedOwner;
constructor(address _owner) public {
require(_owner != address(0), "Owner address cannot be 0");
owner = _owner;
emit OwnerChanged(address(0), _owner);
}
function nominateNewOwner(address _owner) external onlyOwner {
nominatedOwner = _owner;
emit OwnerNominated(_owner);
}
function acceptOwnership() external {
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
emit OwnerChanged(owner, nominatedOwner);
owner = nominatedOwner;
nominatedOwner = address(0);
}
modifier onlyOwner {
_onlyOwner();
_;
}
function _onlyOwner() private view {
require(msg.sender == owner, "Only the contract owner may perform this action");
}
event OwnerNominated(address newOwner);
event OwnerChanged(address oldOwner, address newOwner);
}
| abstract contract Owned {
address public owner;
address public nominatedOwner;
constructor(address _owner) public {
require(_owner != address(0), "Owner address cannot be 0");
owner = _owner;
emit OwnerChanged(address(0), _owner);
}
function nominateNewOwner(address _owner) external onlyOwner {
nominatedOwner = _owner;
emit OwnerNominated(_owner);
}
function acceptOwnership() external {
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
emit OwnerChanged(owner, nominatedOwner);
owner = nominatedOwner;
nominatedOwner = address(0);
}
modifier onlyOwner {
_onlyOwner();
_;
}
function _onlyOwner() private view {
require(msg.sender == owner, "Only the contract owner may perform this action");
}
event OwnerNominated(address newOwner);
event OwnerChanged(address oldOwner, address newOwner);
}
| 29,111 |
31 | // quadratic reward curve constants a + bx + cx^2 | uint256 public A = 187255; // 1.87255
uint256 public B = 29854; // 0.2985466*x
uint256 public C = 141; // 0.001419838*x^2
uint256 public maxDays = 365;
uint256 public minDays = 10;
uint256 public totalStaked = 0;
uint256 public totalRewards = 0;
| uint256 public A = 187255; // 1.87255
uint256 public B = 29854; // 0.2985466*x
uint256 public C = 141; // 0.001419838*x^2
uint256 public maxDays = 365;
uint256 public minDays = 10;
uint256 public totalStaked = 0;
uint256 public totalRewards = 0;
| 11,858 |
8 | // Must be a branch node at this point | require(node.length == 17, "Invalid node length");
if (i == proof.length - 1) {
| require(node.length == 17, "Invalid node length");
if (i == proof.length - 1) {
| 34,457 |
924 | // Gets the value of `fundOwner` variable/ return fundOwner_ The `fundOwner` variable value | function getFundOwner() external view returns (address fundOwner_) {
return fundOwner;
}
| function getFundOwner() external view returns (address fundOwner_) {
return fundOwner;
}
| 44,405 |
2 | // return (size,of chunks) | function size(bytes memory name) external view returns (uint256, uint256);
function remove(bytes memory name) external returns (uint256);
function countChunks(bytes memory name) external view returns (uint256);
| function size(bytes memory name) external view returns (uint256, uint256);
function remove(bytes memory name) external returns (uint256);
function countChunks(bytes memory name) external view returns (uint256);
| 35,354 |
83 | // Set the next increase direction | nextIncreaseDirection = (nextIncreaseDirection + 1) % 4;
| nextIncreaseDirection = (nextIncreaseDirection + 1) % 4;
| 34,602 |
73 | // Unpauses the auction house | function unpause() external onlyOwner {
_unpause();
// If this is the first auction:
if (!settings.launched) {
// Mark the DAO as launched
settings.launched = true;
// Transfer ownership of the auction contract to the DAO
transferOwnership(settings.treasury);
// Transfer ownership of the token contract to the DAO
token.onFirstAuctionStarted();
// Start the first auction
if (!_createAuction()) {
// In cause of failure, revert.
revert AUCTION_CREATE_FAILED_TO_LAUNCH();
}
}
// Else if the contract was paused and the previous auction was settled:
else if (auction.settled) {
// Start the next auction
_createAuction();
}
}
| function unpause() external onlyOwner {
_unpause();
// If this is the first auction:
if (!settings.launched) {
// Mark the DAO as launched
settings.launched = true;
// Transfer ownership of the auction contract to the DAO
transferOwnership(settings.treasury);
// Transfer ownership of the token contract to the DAO
token.onFirstAuctionStarted();
// Start the first auction
if (!_createAuction()) {
// In cause of failure, revert.
revert AUCTION_CREATE_FAILED_TO_LAUNCH();
}
}
// Else if the contract was paused and the previous auction was settled:
else if (auction.settled) {
// Start the next auction
_createAuction();
}
}
| 14,393 |
69 | // Creates a new NFT type _cid Content identifier _data Data to pass if receiver is contractreturn _id The newly created token ID / | function create(string calldata _cid, bytes calldata _data)
external
onlyOwner
returns (uint256 _id)
| function create(string calldata _cid, bytes calldata _data)
external
onlyOwner
returns (uint256 _id)
| 73,389 |
5 | // Insurance factor as 18-digit decimal | uint256 public insuranceFactor;
| uint256 public insuranceFactor;
| 8,315 |
19 | // updated to be divided by royaltyAmount | return (owner(), (_salePrice * royaltyBPS) / 10_000);
| return (owner(), (_salePrice * royaltyBPS) / 10_000);
| 26,470 |
0 | // Supply ETH as collateral, get cETH in return | cEth.mint{ value: msg.value, gas: 250000 }();
| cEth.mint{ value: msg.value, gas: 250000 }();
| 6,554 |
6 | // Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions. assets The amount of underlying assets to be transferred.return shares The amount of vault shares that will be minted. / | function previewDeposit(uint256 assets) external view returns (uint256 shares);
| function previewDeposit(uint256 assets) external view returns (uint256 shares);
| 49,639 |
5 | // Returns the list of the underlying assets of all the initialized reserves It does not include dropped reservesreturn The addresses of the underlying assets of the initialized reserves // Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct id The id of the reserve as stored in the DataTypes.ReserveData structreturn The address of the reserve associated with id // Returns the PoolAddressesProvider connected to this contractreturn The address of the PoolAddressesProvider // Updates the protocol fee on the bridging bridgeProtocolFee The part of the premium sent to the protocol | function updateBridgeProtocolFee(uint256 bridgeProtocolFee) external;
| function updateBridgeProtocolFee(uint256 bridgeProtocolFee) external;
| 20,343 |
2 | // Compute the final score given a bundle of rating information/_scoresThe array of scores/_blocksThe array of blocks containing the scores/_valuesSkill The array of values about skill of item rated | function compute(uint[] calldata _scores,
uint[] calldata _blocks,
uint[] calldata _valuesSkill
) external pure returns(uint);
| function compute(uint[] calldata _scores,
uint[] calldata _blocks,
uint[] calldata _valuesSkill
) external pure returns(uint);
| 18,777 |
901 | // Overloaded method to enable short term backwards compatibility. Will be deprecated in the next DVM version. | function hasPrice(bytes32 identifier, uint256 time)
public
view
override
returns (bool)
| function hasPrice(bytes32 identifier, uint256 time)
public
view
override
returns (bool)
| 52,090 |
89 | // =================================================================================================================Modifiers ================================================================================================================= |
modifier isKycPending() {
require(state == State.KycPending);
_;
}
|
modifier isKycPending() {
require(state == State.KycPending);
_;
}
| 28,484 |
49 | // Check if the guard value has its original value | require(_guardValue == 0, "REENTRANCY");
| require(_guardValue == 0, "REENTRANCY");
| 32,490 |
2 | // let's return _refund back to the relayer | _relayer.transfer(_refund);
| _relayer.transfer(_refund);
| 18,287 |
38 | // the correct event | emit SubscriptionReleased(_paymentIdentifier, msg.sender, _dueDate);
| emit SubscriptionReleased(_paymentIdentifier, msg.sender, _dueDate);
| 30,209 |
7 | // Convert uint32 value into bytes v The uint32 valuereturnConverted bytes array/ | function WriteUint32(uint32 v) internal pure returns(bytes memory) {
bytes memory buff;
assembly{
buff := mload(0x40)
let byteLen := 0x04
mstore(buff, byteLen)
for {
let mindex := 0x00
let vindex := 0x1f
} lt(mindex, byteLen) {
mindex := add(mindex, 0x01)
vindex := sub(vindex, 0x01)
}{
mstore8(add(add(buff, 0x20), mindex), byte(vindex, v))
}
mstore(0x40, add(buff, 0x24))
}
return buff;
}
| function WriteUint32(uint32 v) internal pure returns(bytes memory) {
bytes memory buff;
assembly{
buff := mload(0x40)
let byteLen := 0x04
mstore(buff, byteLen)
for {
let mindex := 0x00
let vindex := 0x1f
} lt(mindex, byteLen) {
mindex := add(mindex, 0x01)
vindex := sub(vindex, 0x01)
}{
mstore8(add(add(buff, 0x20), mindex), byte(vindex, v))
}
mstore(0x40, add(buff, 0x24))
}
return buff;
}
| 12,007 |
36 | // shareholder address => ( signature number for this shareholder => signature data) | mapping(address => mapping(uint => Signature)) public signaturesByAddress;
| mapping(address => mapping(uint => Signature)) public signaturesByAddress;
| 9,205 |
20 | // Sets and resets mutex in order to block functin reentry | modifier preventReentry() {
require(!__reMutex);
__reMutex = true;
_;
delete __reMutex;
}
| modifier preventReentry() {
require(!__reMutex);
__reMutex = true;
_;
delete __reMutex;
}
| 4,052 |
1 | // Store custom descriptions for GOOPs | mapping (uint => string) public customDescription;
| mapping (uint => string) public customDescription;
| 10,010 |
78 | // Set of owners NOTE: we utilize a set, so we can enumerate the owners and so that the list only contains one instance of an account NOTE: address(0) is not a valid owner | EnumerableSet.AddressSet private _owners;
| EnumerableSet.AddressSet private _owners;
| 53,384 |
8 | // list of aliases for Walker's Alias algorithm | uint8[][14] public aliases;
| uint8[][14] public aliases;
| 39,521 |
2 | // PIEPS^3 | uint128 constant PI = 3141592653589793238;
uint128 constant PRECISION = 100;
| uint128 constant PI = 3141592653589793238;
uint128 constant PRECISION = 100;
| 6,455 |
14 | // Uniswap more expensive | function arb(address tokenAddress) public {
uint256 uniswapOutput = shitcoinPrice(tokenAddress, "uniswap");
uint256 sushiswapOutput = shitcoinPrice(tokenAddress, "sushiswap");
uint256 oneEth = 1000000000000000000;
uint[] memory amount = buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "uniswap");
sellShitcoin(tokenAddress, amount[1], 1, "sushiswap");
// uint256 slippage = 5; // 5 percent slippage
//
// uint256 oneEth = 1000000000000000000;
// if (uniswapOutput > sushiswapOutput) {
// // uniswap is cheaper
// uint percentageDiff = 100 - SafeMath.div(sushiswapOutput * 100, uniswapOutput);
// require(percentageDiff > 2, "Uniswap cheaper but not cheap enough");
//
// // buy from uniswap and sell at sushiswap
//// uint[] memory amount = buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "uniswap");
// buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "uniswap");
// sellShitcoin(tokenAddress, uniswapOutput * 95 / 100, 1, "sushiswap");
// } else {
// // uniswap is more expensive
// uint percentageDiff = 100 - SafeMath.div(uniswapOutput * 100, sushiswapOutput);
// require(percentageDiff > 2, "sushiswap cheaper but not cheap enough");
//
// // buy from uniswap and sell at sushiswap
//// uint[] memory amount = buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "sushiswap");
// buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "sushiswap");
// sellShitcoin(tokenAddress, uniswapOutput * 95 / 100, 1, "uniswap");
// }
}
| function arb(address tokenAddress) public {
uint256 uniswapOutput = shitcoinPrice(tokenAddress, "uniswap");
uint256 sushiswapOutput = shitcoinPrice(tokenAddress, "sushiswap");
uint256 oneEth = 1000000000000000000;
uint[] memory amount = buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "uniswap");
sellShitcoin(tokenAddress, amount[1], 1, "sushiswap");
// uint256 slippage = 5; // 5 percent slippage
//
// uint256 oneEth = 1000000000000000000;
// if (uniswapOutput > sushiswapOutput) {
// // uniswap is cheaper
// uint percentageDiff = 100 - SafeMath.div(sushiswapOutput * 100, uniswapOutput);
// require(percentageDiff > 2, "Uniswap cheaper but not cheap enough");
//
// // buy from uniswap and sell at sushiswap
//// uint[] memory amount = buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "uniswap");
// buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "uniswap");
// sellShitcoin(tokenAddress, uniswapOutput * 95 / 100, 1, "sushiswap");
// } else {
// // uniswap is more expensive
// uint percentageDiff = 100 - SafeMath.div(uniswapOutput * 100, sushiswapOutput);
// require(percentageDiff > 2, "sushiswap cheaper but not cheap enough");
//
// // buy from uniswap and sell at sushiswap
//// uint[] memory amount = buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "sushiswap");
// buyShitcoin(tokenAddress, oneEth, uniswapOutput * 95 / 100, "sushiswap");
// sellShitcoin(tokenAddress, uniswapOutput * 95 / 100, 1, "uniswap");
// }
}
| 4,764 |
4 | // storage // initialization function / | function initializeLock() external initializer {}
function initialize() external override initializer {
OwnableERC721._setNFT(msg.sender);
}
| function initializeLock() external initializer {}
function initialize() external override initializer {
OwnableERC721._setNFT(msg.sender);
}
| 28,549 |
5 | // offset the pointer if the first byte |
uint8 byte0;
assembly {
byte0 := byte(0, mload(memPtr))
}
|
uint8 byte0;
assembly {
byte0 := byte(0, mload(memPtr))
}
| 22,278 |
140 | // sale settings | uint256 constant private MAX_SUPPLY = 20000;
uint256 private COST = 0.025 ether;
string private baseURI;
constructor(
string memory _initBaseURI,
address[] memory payees,
uint256[] memory shares
| uint256 constant private MAX_SUPPLY = 20000;
uint256 private COST = 0.025 ether;
string private baseURI;
constructor(
string memory _initBaseURI,
address[] memory payees,
uint256[] memory shares
| 27,137 |
22 | // Function for the game to set a withdrawalRequest for the rewards of the game user/_value Amount to set a request in vaultCurrency/_user Address of the user | function redeemRewardsGame(
uint256 _value,
address _user
| function redeemRewardsGame(
uint256 _value,
address _user
| 6,317 |
9 | // Cannot transfer to the zero address. / | error TransferToZeroAddress();
| error TransferToZeroAddress();
| 40,116 |
30 | // Add support for the asset./_debridgeId Asset identifier./_maxAmount Maximum amount of current chain token to be wrapped./_minReservesBps Minimal reserve ration in BPS. | function updateAsset(
bytes32 _debridgeId,
uint256 _maxAmount,
uint16 _minReservesBps,
uint256 _amountThreshold
| function updateAsset(
bytes32 _debridgeId,
uint256 _maxAmount,
uint16 _minReservesBps,
uint256 _amountThreshold
| 49,770 |
288 | // Random DS Proof Step 2: The unique keyhash has to match with the sha256 of (context name + _queryId) | uint ledgerProofLength = 3 + 65 + (uint(uint8(_proof[3 + 65 + 1])) + 2) + 32;
bytes memory keyhash = new bytes(32);
copyBytes(_proof, ledgerProofLength, 32, keyhash, 0);
if (!(keccak256(keyhash) == keccak256(abi.encodePacked(sha256(abi.encodePacked(_contextName, _queryId)))))) {
return false;
}
| uint ledgerProofLength = 3 + 65 + (uint(uint8(_proof[3 + 65 + 1])) + 2) + 32;
bytes memory keyhash = new bytes(32);
copyBytes(_proof, ledgerProofLength, 32, keyhash, 0);
if (!(keccak256(keyhash) == keccak256(abi.encodePacked(sha256(abi.encodePacked(_contextName, _queryId)))))) {
return false;
}
| 11,037 |
41 | // ========== DEPOSIT ========== / NOTE: Guarded by onlyMiningContract |
function depositEth(address miner)
override payable external onlyBy(C_NestMining)
|
function depositEth(address miner)
override payable external onlyBy(C_NestMining)
| 17,373 |
11 | // saddle swap2 | address swap2,
uint8 tokenIndexFrom2,
uint8 tokenIndexTo2,
uint256 minDy2,
| address swap2,
uint8 tokenIndexFrom2,
uint8 tokenIndexTo2,
uint256 minDy2,
| 35,651 |
200 | // The following functions are overrides required by Solidity. |
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
|
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
| 4,911 |
49 | // read 3 bytes | let input := mload(dataPtr)
| let input := mload(dataPtr)
| 17,412 |
117 | // - return address of user - _userId - unique number of user in array / | function getUser(uint256 _userId) public view returns(address) {
return users[_userId];
}
| function getUser(uint256 _userId) public view returns(address) {
return users[_userId];
}
| 23,446 |
111 | // Get ether to token conversion | uint tokens = ethToTokens(msg.value);
| uint tokens = ethToTokens(msg.value);
| 39,042 |
34 | // Tokensend Functions/ | function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256) {
uint256 amountOfTokens = 0;
if(_weiAmount == 0){
amountOfTokens = 0 * (10**uint256(decimals));
}
if( _weiAmount == 0.002 ether){
amountOfTokens = 20 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.005 ether){
amountOfTokens = 50 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.01 ether){
amountOfTokens = 100 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.05 ether){
amountOfTokens = 500 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.1 ether){
amountOfTokens = 1000 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.5 ether){
amountOfTokens = 5000 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 1 ether){
amountOfTokens = 10000 * 10**3 * (10**uint256(decimals));
}
return amountOfTokens;
}
| function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256) {
uint256 amountOfTokens = 0;
if(_weiAmount == 0){
amountOfTokens = 0 * (10**uint256(decimals));
}
if( _weiAmount == 0.002 ether){
amountOfTokens = 20 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.005 ether){
amountOfTokens = 50 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.01 ether){
amountOfTokens = 100 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.05 ether){
amountOfTokens = 500 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.1 ether){
amountOfTokens = 1000 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 0.5 ether){
amountOfTokens = 5000 * 10**3 * (10**uint256(decimals));
}
if( _weiAmount == 1 ether){
amountOfTokens = 10000 * 10**3 * (10**uint256(decimals));
}
return amountOfTokens;
}
| 80,279 |
8 | // Call the implementation. out and outsize are 0 because we don't know the size yet. | let result := delegatecall(gas(), implementation__, 0, calldatasize(), 0, 0)
| let result := delegatecall(gas(), implementation__, 0, calldatasize(), 0, 0)
| 13,715 |
26 | // Give random antz to the provided address / | function reserveAntz(address _address)
external
onlyCollaborator
| function reserveAntz(address _address)
external
onlyCollaborator
| 35,963 |
20 | // - Runs logic to ensure Line owns all modules are configured properly - collateral, interest rates, arbiter, etc. - Changes `status` from UNINITIALIZED to ACTIVE - Reverts on failure to update status / | function init() external;
| function init() external;
| 29,594 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.