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
|
|---|---|---|---|---|
0
|
// prevent any possible accidental triggering of developer only conditions
|
bool public dev = true;
|
bool public dev = true;
| 40,005
|
62
|
// Pack targets as two uint96 values into a single storage slot. This results in targets being capped to 96 bits, but that should be more than enough.
|
_setMiscData(
WordCodec.encodeUint(lowerTarget, _LOWER_TARGET_OFFSET) |
WordCodec.encodeUint(upperTarget, _UPPER_TARGET_OFFSET)
);
emit TargetsSet(mainToken, lowerTarget, upperTarget);
|
_setMiscData(
WordCodec.encodeUint(lowerTarget, _LOWER_TARGET_OFFSET) |
WordCodec.encodeUint(upperTarget, _UPPER_TARGET_OFFSET)
);
emit TargetsSet(mainToken, lowerTarget, upperTarget);
| 24,991
|
6
|
// Checks if `holder` is barred from transferring tokens./holder The target holder address./ return locked Whether `holder` is barred from transferring tokens.
|
function isLocked(address holder) external view returns (bool locked);
|
function isLocked(address holder) external view returns (bool locked);
| 26,451
|
15
|
// sets the collectionAddress variable _collectionAddress - new address of the collection /
|
function setCollectionAddress(address _collectionAddress) external onlyOwner {
collectionAddress = _collectionAddress;
}
|
function setCollectionAddress(address _collectionAddress) external onlyOwner {
collectionAddress = _collectionAddress;
}
| 11,293
|
13
|
// compute the source tokens needed to get the required amount with the worst case rate
|
estimatedSourceAmount = requiredDestTokenAmount.mul(sourceToDestPrecision).div(expectedRate);
|
estimatedSourceAmount = requiredDestTokenAmount.mul(sourceToDestPrecision).div(expectedRate);
| 54,033
|
74
|
// Get contributor addresses to manage refunds or token claims./If the sale is not yet successful, then it searches in the RefundVault./If the sale is successful, it searches in contributors./_pending If true, then returns addresses which didn't get refunded or their tokens distributed to them/_claimed If true, then returns already refunded or token distributed addresses/ return contributors Array of addresses of contributors
|
function getContributors(bool _pending, bool _claimed) view public returns (address[] memory contributors) {
uint256 i = 0;
uint256 results = 0;
address[] memory _contributors = new address[](contributorsKeys.length);
// if we have reached our goal, then search in contributors, since this is what we want to monitor
if (goalReached()) {
for (i = 0; i < contributorsKeys.length; i++) {
if (_pending && stakes[contributorsKeys[i]] > 0 || _claimed && stakes[contributorsKeys[i]] == 0) {
_contributors[results] = contributorsKeys[i];
results++;
}
}
} else {
// otherwise search in the refund vault
for (i = 0; i < contributorsKeys.length; i++) {
if (_pending && vault.deposited(contributorsKeys[i]) > 0 || _claimed && vault.deposited(contributorsKeys[i]) == 0) {
_contributors[results] = contributorsKeys[i];
results++;
}
}
}
contributors = new address[](results);
for (i = 0; i < results; i++) {
contributors[i] = _contributors[i];
}
return contributors;
}
|
function getContributors(bool _pending, bool _claimed) view public returns (address[] memory contributors) {
uint256 i = 0;
uint256 results = 0;
address[] memory _contributors = new address[](contributorsKeys.length);
// if we have reached our goal, then search in contributors, since this is what we want to monitor
if (goalReached()) {
for (i = 0; i < contributorsKeys.length; i++) {
if (_pending && stakes[contributorsKeys[i]] > 0 || _claimed && stakes[contributorsKeys[i]] == 0) {
_contributors[results] = contributorsKeys[i];
results++;
}
}
} else {
// otherwise search in the refund vault
for (i = 0; i < contributorsKeys.length; i++) {
if (_pending && vault.deposited(contributorsKeys[i]) > 0 || _claimed && vault.deposited(contributorsKeys[i]) == 0) {
_contributors[results] = contributorsKeys[i];
results++;
}
}
}
contributors = new address[](results);
for (i = 0; i < results; i++) {
contributors[i] = _contributors[i];
}
return contributors;
}
| 33,492
|
50
|
// Update implementation address for wallets_newLogic New implementation logic for wallet proxies If the number of wallets is sufficiently large this function may run out of gas/
|
function updateWalletImplementation(address _newLogic) external override onlyOwner {
uint256 i;
for (i = 0; i < wallets.length(); i++) {
address walletAddress;
// .at function returns a tuple of (uint256, address)
(, walletAddress) = wallets.at(i);
walletFactory.updateProxyImplementation(walletAddress, _newLogic);
}
}
|
function updateWalletImplementation(address _newLogic) external override onlyOwner {
uint256 i;
for (i = 0; i < wallets.length(); i++) {
address walletAddress;
// .at function returns a tuple of (uint256, address)
(, walletAddress) = wallets.at(i);
walletFactory.updateProxyImplementation(walletAddress, _newLogic);
}
}
| 29,738
|
21
|
// construct the next hat id
|
newHatId = getNextId(_admin);
|
newHatId = getNextId(_admin);
| 21,932
|
22
|
// every ticket
|
for (uint k = 0; k < _times; k++) {
bool _useGoldKey = false;
if (_goldKeys > 0 && goldKeyRepo[msg.sender] > 0) { // can use gold key?
_goldKeys--; // reduce you keys you want
goldKeyRepo[msg.sender]--; // reduce you keys in repo
_useGoldKey = true;
}
|
for (uint k = 0; k < _times; k++) {
bool _useGoldKey = false;
if (_goldKeys > 0 && goldKeyRepo[msg.sender] > 0) { // can use gold key?
_goldKeys--; // reduce you keys you want
goldKeyRepo[msg.sender]--; // reduce you keys in repo
_useGoldKey = true;
}
| 33,785
|
275
|
// Used to collect accumulated protocol fees. /
|
function collectProtocol(
uint256 amount0,
uint256 amount1,
address to
|
function collectProtocol(
uint256 amount0,
uint256 amount1,
address to
| 42,277
|
391
|
// Allows `_spender` to spend no more than `_value` network tokens and `_primordialValue` Primordial tokens in your behalf _spender The address authorized to spend _value The max amount of network tokens they can spend _primordialValue The max amount of network tokens they can spendreturn true on success /
|
function approveTokens(address _spender, uint256 _value, uint256 _primordialValue) public returns (bool success) {
require (super.approve(_spender, _value));
require (approvePrimordialToken(_spender, _primordialValue));
return true;
}
|
function approveTokens(address _spender, uint256 _value, uint256 _primordialValue) public returns (bool success) {
require (super.approve(_spender, _value));
require (approvePrimordialToken(_spender, _primordialValue));
return true;
}
| 32,583
|
1
|
// ////xSOLACE Token.
|
function xsolace() external view returns (address);
|
function xsolace() external view returns (address);
| 37,260
|
5
|
// Stake CAKE tokens to MasterChef
|
function enterStaking(uint256 _amount) external;
|
function enterStaking(uint256 _amount) external;
| 6,197
|
199
|
// Dynamically call the appropriate selector
|
(bool success, bytes memory returnData) = _pool.call{value: outgoingNativeAssetAmount}(
|
(bool success, bytes memory returnData) = _pool.call{value: outgoingNativeAssetAmount}(
| 22,254
|
241
|
// count of auctions
|
uint32 auctionsCount;
|
uint32 auctionsCount;
| 12,619
|
6
|
// Whitelists
|
bytes32 public merkleRoot =
0x26c30cfb5c1c0d4e24d2722e6191042fd8c1275bffee1c5c060d0c80fcfaae1a;
|
bytes32 public merkleRoot =
0x26c30cfb5c1c0d4e24d2722e6191042fd8c1275bffee1c5c060d0c80fcfaae1a;
| 19,415
|
30
|
// fetch receipts
|
function _receiptsToLeaves(uint256 _start, uint256 _leafCount) private view returns (bytes32[] memory){
bytes32[] memory leaves = new bytes32[](_leafCount);
for (uint256 i = _start; i < _start + _leafCount; i++) {
(
,
,
string memory targetAddress,
uint256 amount,
,
,
) = receiptProvider.receipts(i);
bytes32 amountHash = sha256(abi.encodePacked(amount));
bytes32 targetAddressHash = sha256(abi.encodePacked(targetAddress));
bytes32 receiptIdHash = sha256(abi.encodePacked(i));
leaves[i - _start] = (sha256(abi.encode(amountHash, targetAddressHash, receiptIdHash)));
}
return leaves;
}
|
function _receiptsToLeaves(uint256 _start, uint256 _leafCount) private view returns (bytes32[] memory){
bytes32[] memory leaves = new bytes32[](_leafCount);
for (uint256 i = _start; i < _start + _leafCount; i++) {
(
,
,
string memory targetAddress,
uint256 amount,
,
,
) = receiptProvider.receipts(i);
bytes32 amountHash = sha256(abi.encodePacked(amount));
bytes32 targetAddressHash = sha256(abi.encodePacked(targetAddress));
bytes32 receiptIdHash = sha256(abi.encodePacked(i));
leaves[i - _start] = (sha256(abi.encode(amountHash, targetAddressHash, receiptIdHash)));
}
return leaves;
}
| 27,521
|
18
|
// expmods[14] = trace_generator^(2(trace_length / 2 - 1)).
|
mstore(0x3260, expmod(/*trace_generator*/ mload(0x440), mul(2, sub(div(/*trace_length*/ mload(0x80), 2), 1)), PRIME))
|
mstore(0x3260, expmod(/*trace_generator*/ mload(0x440), mul(2, sub(div(/*trace_length*/ mload(0x80), 2), 1)), PRIME))
| 33,688
|
124
|
// globalConstraintsPre that determine pre- conditions for all actions on the controller
|
GlobalConstraint[] globalConstraintsPre;
|
GlobalConstraint[] globalConstraintsPre;
| 68,614
|
129
|
// Price (in wei) at beginning of auction
|
uint256 startingPrice;
|
uint256 startingPrice;
| 16,348
|
121
|
// pragma solidity ^0.5.0; // import "abdk-libraries-solidity/ABDKMath64x64.sol"; // import "./Orchestrator.sol"; // import "./PartitionedLiquidity.sol"; // import "./ProportionalLiquidity.sol"; // import "./SelectiveLiquidity.sol"; // import "./Shells.sol"; // import "./Swaps.sol"; // import "./ViewLiquidity.sol"; /
|
contract ShellStorage {
address public owner;
string public constant name = "Shells";
string public constant symbol = "SHL";
uint8 public constant decimals = 18;
Shell public shell;
struct Shell {
int128 alpha;
int128 beta;
int128 delta;
int128 epsilon;
int128 lambda;
int128[] weights;
uint totalSupply;
Assimilator[] assets;
mapping (address => Assimilator) assimilators;
mapping (address => uint) balances;
mapping (address => mapping (address => uint)) allowances;
}
struct Assimilator {
address addr;
uint8 ix;
}
mapping (address => PartitionTicket) public partitionTickets;
struct PartitionTicket {
uint[] claims;
bool initialized;
}
address[] public derivatives;
address[] public numeraires;
address[] public reserves;
bool public partitioned = false;
bool public frozen = false;
bool internal notEntered = true;
}
|
contract ShellStorage {
address public owner;
string public constant name = "Shells";
string public constant symbol = "SHL";
uint8 public constant decimals = 18;
Shell public shell;
struct Shell {
int128 alpha;
int128 beta;
int128 delta;
int128 epsilon;
int128 lambda;
int128[] weights;
uint totalSupply;
Assimilator[] assets;
mapping (address => Assimilator) assimilators;
mapping (address => uint) balances;
mapping (address => mapping (address => uint)) allowances;
}
struct Assimilator {
address addr;
uint8 ix;
}
mapping (address => PartitionTicket) public partitionTickets;
struct PartitionTicket {
uint[] claims;
bool initialized;
}
address[] public derivatives;
address[] public numeraires;
address[] public reserves;
bool public partitioned = false;
bool public frozen = false;
bool internal notEntered = true;
}
| 41,949
|
91
|
// Multiplier on the marginRatio for this market
|
Decimal.D256 marginPremium;
|
Decimal.D256 marginPremium;
| 803
|
3
|
// ^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ _Available since v4.1._ /
|
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
|
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
| 22,297
|
256
|
// Singleton - Base for singleton contracts (should always be first super contract)/ This contract is tightly coupled to our proxy contract (see `proxies/GnosisSafeProxy.sol`)/Richard Meissner - <[email protected]>
|
contract Singleton {
// singleton always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.
// It should also always be ensured that the address is stored alone (uses a full word)
address private singleton;
}
|
contract Singleton {
// singleton always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.
// It should also always be ensured that the address is stored alone (uses a full word)
address private singleton;
}
| 16,793
|
187
|
// emits {LinkStarted} event toChain target chain id token token contract address to receiver address amount amount of tokens to be transferred return bool/
|
function deposit(
uint256 toChain,
address token,
address to,
uint256 amount
) public
onlySupportedToken(token)
notBlacklisted(msg.sender)
notBlacklisted(to)
nonPaused()
|
function deposit(
uint256 toChain,
address token,
address to,
uint256 amount
) public
onlySupportedToken(token)
notBlacklisted(msg.sender)
notBlacklisted(to)
nonPaused()
| 20,261
|
172
|
// RequestCore object
|
RequestCore public requestCore;
|
RequestCore public requestCore;
| 47,827
|
44
|
// Distributes STAKE tokens
|
contract Distribution is Ownable, IDistribution {
using SafeMath for uint256;
using Address for address;
/// @dev Emits when preInitialize method has been called
/// @param token The address of ERC677BridgeToken
/// @param caller The address of the caller
event PreInitialized(address token, address caller);
/// @dev Emits when initialize method has been called
/// @param caller The address of the caller
event Initialized(address caller);
/// @dev Emits when an installment for the specified pool has been made
/// @param pool The index of the pool
/// @param value The installment value
/// @param caller The address of the caller
event InstallmentMade(uint8 indexed pool, uint256 value, address caller);
/// @dev Emits when the pool address was changed
/// @param pool The index of the pool
/// @param oldAddress Old address
/// @param newAddress New address
event PoolAddressChanged(uint8 indexed pool, address oldAddress, address newAddress);
/// @dev The instance of ERC677BridgeToken
IERC677BridgeToken public token;
uint8 constant ECOSYSTEM_FUND = 1;
uint8 constant PUBLIC_OFFERING = 2;
uint8 constant PRIVATE_OFFERING_1 = 3;
uint8 constant PRIVATE_OFFERING_2 = 4;
uint8 constant FOUNDATION_REWARD = 5;
uint8 constant EXCHANGE_RELATED_ACTIVITIES = 6;
/// @dev Pool address
mapping (uint8 => address) public poolAddress;
/// @dev Pool total amount of tokens
mapping (uint8 => uint256) public stake;
/// @dev Amount of left tokens to distribute for the pool
mapping (uint8 => uint256) public tokensLeft;
/// @dev Pool cliff period (in seconds)
mapping (uint8 => uint256) public cliff;
/// @dev Total number of installments for the pool
mapping (uint8 => uint256) public numberOfInstallments;
/// @dev Number of installments that were made
mapping (uint8 => uint256) public numberOfInstallmentsMade;
/// @dev The value of one-time installment for the pool
mapping (uint8 => uint256) public installmentValue;
/// @dev The value to transfer to the pool at cliff
mapping (uint8 => uint256) public valueAtCliff;
/// @dev Boolean variable that contains whether the value for the pool at cliff was paid or not
mapping (uint8 => bool) public wasValueAtCliffPaid;
/// @dev Boolean variable that contains whether all installments for the pool were made or not
mapping (uint8 => bool) public installmentsEnded;
/// @dev The total token supply
uint256 constant public supply = 27000000 ether;
/// @dev The timestamp of the distribution start
uint256 public distributionStartTimestamp;
/// @dev The timestamp of pre-initialization
uint256 public preInitializationTimestamp;
/// @dev Boolean variable that indicates whether the contract was pre-initialized
bool public isPreInitialized = false;
/// @dev Boolean variable that indicates whether the contract was initialized
bool public isInitialized = false;
/// @dev Checks that the contract is initialized
modifier initialized() {
require(isInitialized, "not initialized");
_;
}
/// @dev Checks that the installments for the given pool are started and are not ended already
/// @param _pool The index of the pool
modifier active(uint8 _pool) {
require(
// solium-disable-next-line security/no-block-members
_now() >= distributionStartTimestamp.add(cliff[_pool]) && !installmentsEnded[_pool],
"installments are not active for this pool"
);
_;
}
/// @dev Sets up constants and pools addresses that are used in distribution
/// @param _ecosystemFundAddress The address of the Ecosystem Fund
/// @param _publicOfferingAddress The address of the Public Offering
/// @param _privateOfferingAddress_1 The address of the first PrivateOfferingDistribution contract
/// @param _privateOfferingAddress_2 The address of the second PrivateOfferingDistribution contract
/// @param _foundationAddress The address of the Foundation
/// @param _exchangeRelatedActivitiesAddress The address of the Exchange Related Activities
constructor(
address _ecosystemFundAddress,
address _publicOfferingAddress,
address _privateOfferingAddress_1,
address _privateOfferingAddress_2,
address _foundationAddress,
address _exchangeRelatedActivitiesAddress
) public {
// validate provided addresses
require(
_privateOfferingAddress_1.isContract() &&
_privateOfferingAddress_2.isContract(),
"not a contract address"
);
_validateAddress(_ecosystemFundAddress);
_validateAddress(_publicOfferingAddress);
_validateAddress(_foundationAddress);
_validateAddress(_exchangeRelatedActivitiesAddress);
poolAddress[ECOSYSTEM_FUND] = _ecosystemFundAddress;
poolAddress[PUBLIC_OFFERING] = _publicOfferingAddress;
poolAddress[PRIVATE_OFFERING_1] = _privateOfferingAddress_1;
poolAddress[PRIVATE_OFFERING_2] = _privateOfferingAddress_2;
poolAddress[FOUNDATION_REWARD] = _foundationAddress;
poolAddress[EXCHANGE_RELATED_ACTIVITIES] = _exchangeRelatedActivitiesAddress;
// initialize token amounts
stake[ECOSYSTEM_FUND] = 10881023 ether;
stake[PUBLIC_OFFERING] = 1000000 ether;
stake[PRIVATE_OFFERING_1] = IPrivateOfferingDistribution(poolAddress[PRIVATE_OFFERING_1]).poolStake();
stake[PRIVATE_OFFERING_2] = IPrivateOfferingDistribution(poolAddress[PRIVATE_OFFERING_2]).poolStake();
stake[FOUNDATION_REWARD] = 4000000 ether;
stake[EXCHANGE_RELATED_ACTIVITIES] = 3000000 ether;
require(
stake[ECOSYSTEM_FUND] // solium-disable-line operator-whitespace
.add(stake[PUBLIC_OFFERING])
.add(stake[PRIVATE_OFFERING_1])
.add(stake[PRIVATE_OFFERING_2])
.add(stake[FOUNDATION_REWARD])
.add(stake[EXCHANGE_RELATED_ACTIVITIES])
== supply,
"wrong sum of pools stakes"
);
tokensLeft[ECOSYSTEM_FUND] = stake[ECOSYSTEM_FUND];
tokensLeft[PUBLIC_OFFERING] = stake[PUBLIC_OFFERING];
tokensLeft[PRIVATE_OFFERING_1] = stake[PRIVATE_OFFERING_1];
tokensLeft[PRIVATE_OFFERING_2] = stake[PRIVATE_OFFERING_2];
tokensLeft[FOUNDATION_REWARD] = stake[FOUNDATION_REWARD];
tokensLeft[EXCHANGE_RELATED_ACTIVITIES] = stake[EXCHANGE_RELATED_ACTIVITIES];
valueAtCliff[ECOSYSTEM_FUND] = stake[ECOSYSTEM_FUND].mul(10).div(100); // 10%
valueAtCliff[PRIVATE_OFFERING_1] = stake[PRIVATE_OFFERING_1].mul(10).div(100); // 10%
valueAtCliff[PRIVATE_OFFERING_2] = stake[PRIVATE_OFFERING_2].mul(5).div(100); // 5%
valueAtCliff[FOUNDATION_REWARD] = stake[FOUNDATION_REWARD].mul(20).div(100); // 20%
cliff[ECOSYSTEM_FUND] = 48 weeks;
cliff[FOUNDATION_REWARD] = 12 weeks;
cliff[PRIVATE_OFFERING_1] = 4 weeks;
cliff[PRIVATE_OFFERING_2] = 4 weeks;
numberOfInstallments[ECOSYSTEM_FUND] = 672; // 96 weeks
numberOfInstallments[PRIVATE_OFFERING_1] = 224; // 32 weeks
numberOfInstallments[PRIVATE_OFFERING_2] = 224; // 32 weeks
numberOfInstallments[FOUNDATION_REWARD] = 252; // 36 weeks
installmentValue[ECOSYSTEM_FUND] = _calculateInstallmentValue(ECOSYSTEM_FUND);
installmentValue[PRIVATE_OFFERING_1] = _calculateInstallmentValue(
PRIVATE_OFFERING_1,
stake[PRIVATE_OFFERING_1].mul(35).div(100) // 25% will be distributed at initializing and 10% at cliff
);
installmentValue[PRIVATE_OFFERING_2] = _calculateInstallmentValue(
PRIVATE_OFFERING_2,
stake[PRIVATE_OFFERING_2].mul(20).div(100) // 15% will be distributed at initializing and 5% at cliff
);
installmentValue[FOUNDATION_REWARD] = _calculateInstallmentValue(FOUNDATION_REWARD);
}
/// @dev Pre-initializes the contract after the token is created.
/// Distributes tokens for Public Offering and Exchange Related Activities
/// @param _tokenAddress The address of the STAKE token
function preInitialize(address _tokenAddress) external onlyOwner {
require(!isPreInitialized, "already pre-initialized");
token = IERC677BridgeToken(_tokenAddress);
uint256 balance = token.balanceOf(address(this));
require(balance == supply, "wrong contract balance");
preInitializationTimestamp = _now(); // solium-disable-line security/no-block-members
isPreInitialized = true;
token.transferDistribution(poolAddress[PUBLIC_OFFERING], stake[PUBLIC_OFFERING]); // 100%
token.transferDistribution(poolAddress[EXCHANGE_RELATED_ACTIVITIES], stake[EXCHANGE_RELATED_ACTIVITIES]); // 100%
tokensLeft[PUBLIC_OFFERING] = tokensLeft[PUBLIC_OFFERING].sub(stake[PUBLIC_OFFERING]);
tokensLeft[EXCHANGE_RELATED_ACTIVITIES] = tokensLeft[EXCHANGE_RELATED_ACTIVITIES].sub(stake[EXCHANGE_RELATED_ACTIVITIES]);
emit PreInitialized(_tokenAddress, msg.sender);
emit InstallmentMade(PUBLIC_OFFERING, stake[PUBLIC_OFFERING], msg.sender);
emit InstallmentMade(EXCHANGE_RELATED_ACTIVITIES, stake[EXCHANGE_RELATED_ACTIVITIES], msg.sender);
}
/// @dev Initializes token distribution
function initialize() external {
require(isPreInitialized, "not pre-initialized");
require(!isInitialized, "already initialized");
if (_now().sub(preInitializationTimestamp) < 90 days) { // solium-disable-line security/no-block-members
require(isOwner(), "for now only owner can call this method");
}
IPrivateOfferingDistribution(poolAddress[PRIVATE_OFFERING_1]).initialize(address(token));
IPrivateOfferingDistribution(poolAddress[PRIVATE_OFFERING_2]).initialize(address(token));
distributionStartTimestamp = _now(); // solium-disable-line security/no-block-members
isInitialized = true;
uint256 privateOfferingPrerelease_1 = stake[PRIVATE_OFFERING_1].mul(25).div(100); // 25%
token.transfer(poolAddress[PRIVATE_OFFERING_1], privateOfferingPrerelease_1);
tokensLeft[PRIVATE_OFFERING_1] = tokensLeft[PRIVATE_OFFERING_1].sub(privateOfferingPrerelease_1);
uint256 privateOfferingPrerelease_2 = stake[PRIVATE_OFFERING_2].mul(15).div(100); // 15%
token.transfer(poolAddress[PRIVATE_OFFERING_2], privateOfferingPrerelease_2);
tokensLeft[PRIVATE_OFFERING_2] = tokensLeft[PRIVATE_OFFERING_2].sub(privateOfferingPrerelease_2);
emit Initialized(msg.sender);
emit InstallmentMade(PRIVATE_OFFERING_1, privateOfferingPrerelease_1, msg.sender);
emit InstallmentMade(PRIVATE_OFFERING_2, privateOfferingPrerelease_2, msg.sender);
}
/// @dev Changes the address of the specified pool
/// @param _pool The index of the pool (only ECOSYSTEM_FUND or FOUNDATION_REWARD)
/// @param _newAddress The new address for the change
function changePoolAddress(uint8 _pool, address _newAddress) external {
require(_pool == ECOSYSTEM_FUND || _pool == FOUNDATION_REWARD, "wrong pool");
require(msg.sender == poolAddress[_pool], "not authorized");
_validateAddress(_newAddress);
emit PoolAddressChanged(_pool, poolAddress[_pool], _newAddress);
poolAddress[_pool] = _newAddress;
}
/// @dev Makes an installment for one of the following pools: Private Offering, Ecosystem Fund, Foundation
/// @param _pool The index of the pool
function makeInstallment(uint8 _pool) public initialized active(_pool) {
require(
_pool == PRIVATE_OFFERING_1 ||
_pool == PRIVATE_OFFERING_2 ||
_pool == ECOSYSTEM_FUND ||
_pool == FOUNDATION_REWARD,
"wrong pool"
);
uint256 value = 0;
if (!wasValueAtCliffPaid[_pool]) {
value = valueAtCliff[_pool];
wasValueAtCliffPaid[_pool] = true;
}
uint256 availableNumberOfInstallments = _calculateNumberOfAvailableInstallments(_pool);
value = value.add(installmentValue[_pool].mul(availableNumberOfInstallments));
require(value > 0, "no installments available");
uint256 remainder = _updatePoolData(_pool, value, availableNumberOfInstallments);
value = value.add(remainder);
if (_pool == PRIVATE_OFFERING_1 || _pool == PRIVATE_OFFERING_2) {
token.transfer(poolAddress[_pool], value);
} else {
token.transferDistribution(poolAddress[_pool], value);
}
emit InstallmentMade(_pool, value, msg.sender);
}
/// @dev This method is called after the STAKE tokens are transferred to this contract
function onTokenTransfer(address, uint256, bytes memory) public pure returns (bool) {
revert("sending tokens to this contract is not allowed");
}
/// @dev The removed implementation of the ownership renouncing
function renounceOwnership() public onlyOwner {
revert("not implemented");
}
function _now() internal view returns (uint256) {
return now; // solium-disable-line security/no-block-members
}
/// @dev Updates the given pool data after each installment:
/// the remaining number of tokens,
/// the number of made installments.
/// If the last installment are done and the tokens remained
/// then transfers them to the pool and marks that all installments for the given pool are made
/// @param _pool The index of the pool
/// @param _value Current installment value
/// @param _currentNumberOfInstallments Number of installment that are made
function _updatePoolData(
uint8 _pool,
uint256 _value,
uint256 _currentNumberOfInstallments
) internal returns (uint256) {
uint256 remainder = 0;
tokensLeft[_pool] = tokensLeft[_pool].sub(_value);
numberOfInstallmentsMade[_pool] = numberOfInstallmentsMade[_pool].add(_currentNumberOfInstallments);
if (numberOfInstallmentsMade[_pool] >= numberOfInstallments[_pool]) {
if (tokensLeft[_pool] > 0) {
remainder = tokensLeft[_pool];
tokensLeft[_pool] = 0;
}
_endInstallment(_pool);
}
return remainder;
}
/// @dev Marks that all installments for the given pool are made
/// @param _pool The index of the pool
function _endInstallment(uint8 _pool) internal {
installmentsEnded[_pool] = true;
}
/// @dev Calculates the value of the installment for 1 day for the given pool
/// @param _pool The index of the pool
/// @param _valueAtCliff Custom value to distribute at cliff
function _calculateInstallmentValue(
uint8 _pool,
uint256 _valueAtCliff
) internal view returns (uint256) {
return stake[_pool].sub(_valueAtCliff).div(numberOfInstallments[_pool]);
}
/// @dev Calculates the value of the installment for 1 day for the given pool
/// @param _pool The index of the pool
function _calculateInstallmentValue(uint8 _pool) internal view returns (uint256) {
return _calculateInstallmentValue(_pool, valueAtCliff[_pool]);
}
/// @dev Calculates the number of available installments for the given pool
/// @param _pool The index of the pool
/// @return The number of available installments
function _calculateNumberOfAvailableInstallments(
uint8 _pool
) internal view returns (
uint256 availableNumberOfInstallments
) {
uint256 paidDays = numberOfInstallmentsMade[_pool].mul(1 days);
uint256 lastTimestamp = distributionStartTimestamp.add(cliff[_pool]).add(paidDays);
// solium-disable-next-line security/no-block-members
availableNumberOfInstallments = _now().sub(lastTimestamp).div(1 days);
if (numberOfInstallmentsMade[_pool].add(availableNumberOfInstallments) > numberOfInstallments[_pool]) {
availableNumberOfInstallments = numberOfInstallments[_pool].sub(numberOfInstallmentsMade[_pool]);
}
}
/// @dev Checks for an empty address
function _validateAddress(address _address) internal pure {
if (_address == address(0)) {
revert("invalid address");
}
}
}
|
contract Distribution is Ownable, IDistribution {
using SafeMath for uint256;
using Address for address;
/// @dev Emits when preInitialize method has been called
/// @param token The address of ERC677BridgeToken
/// @param caller The address of the caller
event PreInitialized(address token, address caller);
/// @dev Emits when initialize method has been called
/// @param caller The address of the caller
event Initialized(address caller);
/// @dev Emits when an installment for the specified pool has been made
/// @param pool The index of the pool
/// @param value The installment value
/// @param caller The address of the caller
event InstallmentMade(uint8 indexed pool, uint256 value, address caller);
/// @dev Emits when the pool address was changed
/// @param pool The index of the pool
/// @param oldAddress Old address
/// @param newAddress New address
event PoolAddressChanged(uint8 indexed pool, address oldAddress, address newAddress);
/// @dev The instance of ERC677BridgeToken
IERC677BridgeToken public token;
uint8 constant ECOSYSTEM_FUND = 1;
uint8 constant PUBLIC_OFFERING = 2;
uint8 constant PRIVATE_OFFERING_1 = 3;
uint8 constant PRIVATE_OFFERING_2 = 4;
uint8 constant FOUNDATION_REWARD = 5;
uint8 constant EXCHANGE_RELATED_ACTIVITIES = 6;
/// @dev Pool address
mapping (uint8 => address) public poolAddress;
/// @dev Pool total amount of tokens
mapping (uint8 => uint256) public stake;
/// @dev Amount of left tokens to distribute for the pool
mapping (uint8 => uint256) public tokensLeft;
/// @dev Pool cliff period (in seconds)
mapping (uint8 => uint256) public cliff;
/// @dev Total number of installments for the pool
mapping (uint8 => uint256) public numberOfInstallments;
/// @dev Number of installments that were made
mapping (uint8 => uint256) public numberOfInstallmentsMade;
/// @dev The value of one-time installment for the pool
mapping (uint8 => uint256) public installmentValue;
/// @dev The value to transfer to the pool at cliff
mapping (uint8 => uint256) public valueAtCliff;
/// @dev Boolean variable that contains whether the value for the pool at cliff was paid or not
mapping (uint8 => bool) public wasValueAtCliffPaid;
/// @dev Boolean variable that contains whether all installments for the pool were made or not
mapping (uint8 => bool) public installmentsEnded;
/// @dev The total token supply
uint256 constant public supply = 27000000 ether;
/// @dev The timestamp of the distribution start
uint256 public distributionStartTimestamp;
/// @dev The timestamp of pre-initialization
uint256 public preInitializationTimestamp;
/// @dev Boolean variable that indicates whether the contract was pre-initialized
bool public isPreInitialized = false;
/// @dev Boolean variable that indicates whether the contract was initialized
bool public isInitialized = false;
/// @dev Checks that the contract is initialized
modifier initialized() {
require(isInitialized, "not initialized");
_;
}
/// @dev Checks that the installments for the given pool are started and are not ended already
/// @param _pool The index of the pool
modifier active(uint8 _pool) {
require(
// solium-disable-next-line security/no-block-members
_now() >= distributionStartTimestamp.add(cliff[_pool]) && !installmentsEnded[_pool],
"installments are not active for this pool"
);
_;
}
/// @dev Sets up constants and pools addresses that are used in distribution
/// @param _ecosystemFundAddress The address of the Ecosystem Fund
/// @param _publicOfferingAddress The address of the Public Offering
/// @param _privateOfferingAddress_1 The address of the first PrivateOfferingDistribution contract
/// @param _privateOfferingAddress_2 The address of the second PrivateOfferingDistribution contract
/// @param _foundationAddress The address of the Foundation
/// @param _exchangeRelatedActivitiesAddress The address of the Exchange Related Activities
constructor(
address _ecosystemFundAddress,
address _publicOfferingAddress,
address _privateOfferingAddress_1,
address _privateOfferingAddress_2,
address _foundationAddress,
address _exchangeRelatedActivitiesAddress
) public {
// validate provided addresses
require(
_privateOfferingAddress_1.isContract() &&
_privateOfferingAddress_2.isContract(),
"not a contract address"
);
_validateAddress(_ecosystemFundAddress);
_validateAddress(_publicOfferingAddress);
_validateAddress(_foundationAddress);
_validateAddress(_exchangeRelatedActivitiesAddress);
poolAddress[ECOSYSTEM_FUND] = _ecosystemFundAddress;
poolAddress[PUBLIC_OFFERING] = _publicOfferingAddress;
poolAddress[PRIVATE_OFFERING_1] = _privateOfferingAddress_1;
poolAddress[PRIVATE_OFFERING_2] = _privateOfferingAddress_2;
poolAddress[FOUNDATION_REWARD] = _foundationAddress;
poolAddress[EXCHANGE_RELATED_ACTIVITIES] = _exchangeRelatedActivitiesAddress;
// initialize token amounts
stake[ECOSYSTEM_FUND] = 10881023 ether;
stake[PUBLIC_OFFERING] = 1000000 ether;
stake[PRIVATE_OFFERING_1] = IPrivateOfferingDistribution(poolAddress[PRIVATE_OFFERING_1]).poolStake();
stake[PRIVATE_OFFERING_2] = IPrivateOfferingDistribution(poolAddress[PRIVATE_OFFERING_2]).poolStake();
stake[FOUNDATION_REWARD] = 4000000 ether;
stake[EXCHANGE_RELATED_ACTIVITIES] = 3000000 ether;
require(
stake[ECOSYSTEM_FUND] // solium-disable-line operator-whitespace
.add(stake[PUBLIC_OFFERING])
.add(stake[PRIVATE_OFFERING_1])
.add(stake[PRIVATE_OFFERING_2])
.add(stake[FOUNDATION_REWARD])
.add(stake[EXCHANGE_RELATED_ACTIVITIES])
== supply,
"wrong sum of pools stakes"
);
tokensLeft[ECOSYSTEM_FUND] = stake[ECOSYSTEM_FUND];
tokensLeft[PUBLIC_OFFERING] = stake[PUBLIC_OFFERING];
tokensLeft[PRIVATE_OFFERING_1] = stake[PRIVATE_OFFERING_1];
tokensLeft[PRIVATE_OFFERING_2] = stake[PRIVATE_OFFERING_2];
tokensLeft[FOUNDATION_REWARD] = stake[FOUNDATION_REWARD];
tokensLeft[EXCHANGE_RELATED_ACTIVITIES] = stake[EXCHANGE_RELATED_ACTIVITIES];
valueAtCliff[ECOSYSTEM_FUND] = stake[ECOSYSTEM_FUND].mul(10).div(100); // 10%
valueAtCliff[PRIVATE_OFFERING_1] = stake[PRIVATE_OFFERING_1].mul(10).div(100); // 10%
valueAtCliff[PRIVATE_OFFERING_2] = stake[PRIVATE_OFFERING_2].mul(5).div(100); // 5%
valueAtCliff[FOUNDATION_REWARD] = stake[FOUNDATION_REWARD].mul(20).div(100); // 20%
cliff[ECOSYSTEM_FUND] = 48 weeks;
cliff[FOUNDATION_REWARD] = 12 weeks;
cliff[PRIVATE_OFFERING_1] = 4 weeks;
cliff[PRIVATE_OFFERING_2] = 4 weeks;
numberOfInstallments[ECOSYSTEM_FUND] = 672; // 96 weeks
numberOfInstallments[PRIVATE_OFFERING_1] = 224; // 32 weeks
numberOfInstallments[PRIVATE_OFFERING_2] = 224; // 32 weeks
numberOfInstallments[FOUNDATION_REWARD] = 252; // 36 weeks
installmentValue[ECOSYSTEM_FUND] = _calculateInstallmentValue(ECOSYSTEM_FUND);
installmentValue[PRIVATE_OFFERING_1] = _calculateInstallmentValue(
PRIVATE_OFFERING_1,
stake[PRIVATE_OFFERING_1].mul(35).div(100) // 25% will be distributed at initializing and 10% at cliff
);
installmentValue[PRIVATE_OFFERING_2] = _calculateInstallmentValue(
PRIVATE_OFFERING_2,
stake[PRIVATE_OFFERING_2].mul(20).div(100) // 15% will be distributed at initializing and 5% at cliff
);
installmentValue[FOUNDATION_REWARD] = _calculateInstallmentValue(FOUNDATION_REWARD);
}
/// @dev Pre-initializes the contract after the token is created.
/// Distributes tokens for Public Offering and Exchange Related Activities
/// @param _tokenAddress The address of the STAKE token
function preInitialize(address _tokenAddress) external onlyOwner {
require(!isPreInitialized, "already pre-initialized");
token = IERC677BridgeToken(_tokenAddress);
uint256 balance = token.balanceOf(address(this));
require(balance == supply, "wrong contract balance");
preInitializationTimestamp = _now(); // solium-disable-line security/no-block-members
isPreInitialized = true;
token.transferDistribution(poolAddress[PUBLIC_OFFERING], stake[PUBLIC_OFFERING]); // 100%
token.transferDistribution(poolAddress[EXCHANGE_RELATED_ACTIVITIES], stake[EXCHANGE_RELATED_ACTIVITIES]); // 100%
tokensLeft[PUBLIC_OFFERING] = tokensLeft[PUBLIC_OFFERING].sub(stake[PUBLIC_OFFERING]);
tokensLeft[EXCHANGE_RELATED_ACTIVITIES] = tokensLeft[EXCHANGE_RELATED_ACTIVITIES].sub(stake[EXCHANGE_RELATED_ACTIVITIES]);
emit PreInitialized(_tokenAddress, msg.sender);
emit InstallmentMade(PUBLIC_OFFERING, stake[PUBLIC_OFFERING], msg.sender);
emit InstallmentMade(EXCHANGE_RELATED_ACTIVITIES, stake[EXCHANGE_RELATED_ACTIVITIES], msg.sender);
}
/// @dev Initializes token distribution
function initialize() external {
require(isPreInitialized, "not pre-initialized");
require(!isInitialized, "already initialized");
if (_now().sub(preInitializationTimestamp) < 90 days) { // solium-disable-line security/no-block-members
require(isOwner(), "for now only owner can call this method");
}
IPrivateOfferingDistribution(poolAddress[PRIVATE_OFFERING_1]).initialize(address(token));
IPrivateOfferingDistribution(poolAddress[PRIVATE_OFFERING_2]).initialize(address(token));
distributionStartTimestamp = _now(); // solium-disable-line security/no-block-members
isInitialized = true;
uint256 privateOfferingPrerelease_1 = stake[PRIVATE_OFFERING_1].mul(25).div(100); // 25%
token.transfer(poolAddress[PRIVATE_OFFERING_1], privateOfferingPrerelease_1);
tokensLeft[PRIVATE_OFFERING_1] = tokensLeft[PRIVATE_OFFERING_1].sub(privateOfferingPrerelease_1);
uint256 privateOfferingPrerelease_2 = stake[PRIVATE_OFFERING_2].mul(15).div(100); // 15%
token.transfer(poolAddress[PRIVATE_OFFERING_2], privateOfferingPrerelease_2);
tokensLeft[PRIVATE_OFFERING_2] = tokensLeft[PRIVATE_OFFERING_2].sub(privateOfferingPrerelease_2);
emit Initialized(msg.sender);
emit InstallmentMade(PRIVATE_OFFERING_1, privateOfferingPrerelease_1, msg.sender);
emit InstallmentMade(PRIVATE_OFFERING_2, privateOfferingPrerelease_2, msg.sender);
}
/// @dev Changes the address of the specified pool
/// @param _pool The index of the pool (only ECOSYSTEM_FUND or FOUNDATION_REWARD)
/// @param _newAddress The new address for the change
function changePoolAddress(uint8 _pool, address _newAddress) external {
require(_pool == ECOSYSTEM_FUND || _pool == FOUNDATION_REWARD, "wrong pool");
require(msg.sender == poolAddress[_pool], "not authorized");
_validateAddress(_newAddress);
emit PoolAddressChanged(_pool, poolAddress[_pool], _newAddress);
poolAddress[_pool] = _newAddress;
}
/// @dev Makes an installment for one of the following pools: Private Offering, Ecosystem Fund, Foundation
/// @param _pool The index of the pool
function makeInstallment(uint8 _pool) public initialized active(_pool) {
require(
_pool == PRIVATE_OFFERING_1 ||
_pool == PRIVATE_OFFERING_2 ||
_pool == ECOSYSTEM_FUND ||
_pool == FOUNDATION_REWARD,
"wrong pool"
);
uint256 value = 0;
if (!wasValueAtCliffPaid[_pool]) {
value = valueAtCliff[_pool];
wasValueAtCliffPaid[_pool] = true;
}
uint256 availableNumberOfInstallments = _calculateNumberOfAvailableInstallments(_pool);
value = value.add(installmentValue[_pool].mul(availableNumberOfInstallments));
require(value > 0, "no installments available");
uint256 remainder = _updatePoolData(_pool, value, availableNumberOfInstallments);
value = value.add(remainder);
if (_pool == PRIVATE_OFFERING_1 || _pool == PRIVATE_OFFERING_2) {
token.transfer(poolAddress[_pool], value);
} else {
token.transferDistribution(poolAddress[_pool], value);
}
emit InstallmentMade(_pool, value, msg.sender);
}
/// @dev This method is called after the STAKE tokens are transferred to this contract
function onTokenTransfer(address, uint256, bytes memory) public pure returns (bool) {
revert("sending tokens to this contract is not allowed");
}
/// @dev The removed implementation of the ownership renouncing
function renounceOwnership() public onlyOwner {
revert("not implemented");
}
function _now() internal view returns (uint256) {
return now; // solium-disable-line security/no-block-members
}
/// @dev Updates the given pool data after each installment:
/// the remaining number of tokens,
/// the number of made installments.
/// If the last installment are done and the tokens remained
/// then transfers them to the pool and marks that all installments for the given pool are made
/// @param _pool The index of the pool
/// @param _value Current installment value
/// @param _currentNumberOfInstallments Number of installment that are made
function _updatePoolData(
uint8 _pool,
uint256 _value,
uint256 _currentNumberOfInstallments
) internal returns (uint256) {
uint256 remainder = 0;
tokensLeft[_pool] = tokensLeft[_pool].sub(_value);
numberOfInstallmentsMade[_pool] = numberOfInstallmentsMade[_pool].add(_currentNumberOfInstallments);
if (numberOfInstallmentsMade[_pool] >= numberOfInstallments[_pool]) {
if (tokensLeft[_pool] > 0) {
remainder = tokensLeft[_pool];
tokensLeft[_pool] = 0;
}
_endInstallment(_pool);
}
return remainder;
}
/// @dev Marks that all installments for the given pool are made
/// @param _pool The index of the pool
function _endInstallment(uint8 _pool) internal {
installmentsEnded[_pool] = true;
}
/// @dev Calculates the value of the installment for 1 day for the given pool
/// @param _pool The index of the pool
/// @param _valueAtCliff Custom value to distribute at cliff
function _calculateInstallmentValue(
uint8 _pool,
uint256 _valueAtCliff
) internal view returns (uint256) {
return stake[_pool].sub(_valueAtCliff).div(numberOfInstallments[_pool]);
}
/// @dev Calculates the value of the installment for 1 day for the given pool
/// @param _pool The index of the pool
function _calculateInstallmentValue(uint8 _pool) internal view returns (uint256) {
return _calculateInstallmentValue(_pool, valueAtCliff[_pool]);
}
/// @dev Calculates the number of available installments for the given pool
/// @param _pool The index of the pool
/// @return The number of available installments
function _calculateNumberOfAvailableInstallments(
uint8 _pool
) internal view returns (
uint256 availableNumberOfInstallments
) {
uint256 paidDays = numberOfInstallmentsMade[_pool].mul(1 days);
uint256 lastTimestamp = distributionStartTimestamp.add(cliff[_pool]).add(paidDays);
// solium-disable-next-line security/no-block-members
availableNumberOfInstallments = _now().sub(lastTimestamp).div(1 days);
if (numberOfInstallmentsMade[_pool].add(availableNumberOfInstallments) > numberOfInstallments[_pool]) {
availableNumberOfInstallments = numberOfInstallments[_pool].sub(numberOfInstallmentsMade[_pool]);
}
}
/// @dev Checks for an empty address
function _validateAddress(address _address) internal pure {
if (_address == address(0)) {
revert("invalid address");
}
}
}
| 6,260
|
4
|
// proposed price
|
mapping(uint256 => uint256) public singlePrice;
mapping(uint256 => route) private routes;
mapping(address => uint256) public num;
mapping(uint256 => mapping(address => bool)) private isProve;
address pledgeA;
|
mapping(uint256 => uint256) public singlePrice;
mapping(uint256 => route) private routes;
mapping(address => uint256) public num;
mapping(uint256 => mapping(address => bool)) private isProve;
address pledgeA;
| 3,384
|
32
|
// Sets `amount` as the allowance of `spender` over `owner`'s tokens,given `owner`'s signed approval.
|
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
/**
* @dev Returns the current ERC2612 nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
}
|
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
/**
* @dev Returns the current ERC2612 nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
}
| 6,630
|
11
|
// Fetching campaign from storage then populating campaigns as 'i'.
|
Campaign storage item = campaigns[i];
|
Campaign storage item = campaigns[i];
| 2,443
|
26
|
// next line would revert with div by zero but require to emit reason
|
require(rates[bSymbol].rate > 0, "rates[bSymbol] must be > 0");
|
require(rates[bSymbol].rate > 0, "rates[bSymbol] must be > 0");
| 672
|
249
|
// the pool migrator contract
|
IPoolMigrator private immutable _poolMigrator;
|
IPoolMigrator private immutable _poolMigrator;
| 75,528
|
104
|
// (paperBalance + debt)user.balance / totalLPbalance - user.loss
|
return
paper
.balanceOf(address(this))
.add(debt)
.mul(users[_user].amount)
.div(paperWethLP.balanceOf(address(this)))
.sub(users[_user].loss);
|
return
paper
.balanceOf(address(this))
.add(debt)
.mul(users[_user].amount)
.div(paperWethLP.balanceOf(address(this)))
.sub(users[_user].loss);
| 30,896
|
58
|
// Bird's BDelegator Interface/
|
contract BDelegatorInterface is BDelegationStorage {
/**
* @notice Emitted when implementation is changed
*/
event NewImplementation(address oldImplementation, address newImplementation);
/**
* @notice Called by the admin to update the implementation of the delegator
* @param implementation_ The address of the new implementation for delegation
* @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
* @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
*/
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public;
}
|
contract BDelegatorInterface is BDelegationStorage {
/**
* @notice Emitted when implementation is changed
*/
event NewImplementation(address oldImplementation, address newImplementation);
/**
* @notice Called by the admin to update the implementation of the delegator
* @param implementation_ The address of the new implementation for delegation
* @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
* @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
*/
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public;
}
| 5,269
|
3
|
// Swaps all the ABIv1 held by the caller to ABIv2.Emits Swap event if the swap is successful. /
|
function swap() external {
_swapFor(msg.sender, ABIv1.balanceOf(msg.sender));
}
|
function swap() external {
_swapFor(msg.sender, ABIv1.balanceOf(msg.sender));
}
| 28,434
|
16
|
// payable for eth payments..
|
function deposit() payable external {
tokenBalances[msg.sender][address(0)] = add(tokenBalances[msg.sender][address(0)], msg.value);
emit Deposit(msg.sender, msg.value);
}
|
function deposit() payable external {
tokenBalances[msg.sender][address(0)] = add(tokenBalances[msg.sender][address(0)], msg.value);
emit Deposit(msg.sender, msg.value);
}
| 28,618
|
235
|
// abi.encodePacked is being used to concatenate strings
|
return string(abi.encodePacked(_baseURI, _tokenURI));
|
return string(abi.encodePacked(_baseURI, _tokenURI));
| 28,005
|
6
|
// Indicator of if a Synthetic badge ID is open to carv;
|
mapping(uint256 => bool) private _openToCarv;
|
mapping(uint256 => bool) private _openToCarv;
| 51,772
|
38
|
// get address of marketing team./
|
function getBeneficiaryMarket() public view returns (address) {
return beneficiary_market;
}
|
function getBeneficiaryMarket() public view returns (address) {
return beneficiary_market;
}
| 17,029
|
16
|
// events ERC20 events
|
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
|
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
| 41,915
|
185
|
// util function for checking if the twamm is up to date
|
function twammUpToDate() public override view returns (bool) {
return block.timestamp == longTermOrders.lastVirtualOrderTimestamp;
}
|
function twammUpToDate() public override view returns (bool) {
return block.timestamp == longTermOrders.lastVirtualOrderTimestamp;
}
| 44,773
|
31
|
// owner only function to activate or deactivate the public sale
|
function setPublicSale() public onlyRealOwner {
emit PublicSaleUpdated(!publicSale);
publicSale = !publicSale;
}
|
function setPublicSale() public onlyRealOwner {
emit PublicSaleUpdated(!publicSale);
publicSale = !publicSale;
}
| 18,323
|
4
|
// Undo deprecate on this contractThe re-enables anything disabled by deprecation /
|
function undeprecate() external onlyDeprecator whenDeprecated {
deprecatedBlock = 0;
rollover = false;
emit Undeprecated();
}
|
function undeprecate() external onlyDeprecator whenDeprecated {
deprecatedBlock = 0;
rollover = false;
emit Undeprecated();
}
| 47,558
|
113
|
// Implementation of the basic standard multi-token. _Available since v3.1._ /
|
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
|
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
| 11,907
|
10
|
// Get current cumulative liquidity WHAPcoins
|
function get_CurrentLiquidity() public view returns (uint256) {
return _WHAPcoinContract.balanceOf(address(this));
}
|
function get_CurrentLiquidity() public view returns (uint256) {
return _WHAPcoinContract.balanceOf(address(this));
}
| 8,606
|
24
|
// Function that returns the final date of a guess _index uint256 The description of the Guessreturn string The final date of the guess /
|
function getGuessTitle (uint256 _index) isOwner external view returns (string) {
return guesses[_index].title;
}
|
function getGuessTitle (uint256 _index) isOwner external view returns (string) {
return guesses[_index].title;
}
| 46,537
|
10
|
// creator of the pool
|
address creator;
|
address creator;
| 13,285
|
4
|
// Transfer tokens by manager from Payer's address to Payee's address amount transfer amountreturn True if successful /
|
function transferByManager(address from, address to, uint256 amount)
external
virtual
onlyManager
inWhitelist(from)
inWhitelist(to)
returns (bool)
|
function transferByManager(address from, address to, uint256 amount)
external
virtual
onlyManager
inWhitelist(from)
inWhitelist(to)
returns (bool)
| 31,634
|
11
|
// 0 - Dai, 1 - Usdt, 2 - Usdc
|
function triggerAllocate(uint index) public payable {
if (index >= 3 || bondingCurves[index].isTimeEnded() == false) return;
if (stables[index].balanceOf(address(bondingCurves[index])) == 0) {
// swap from uniswap v2 and send to bondingCurves[index]
require(msg.value > 0 && msg.value <= 0.002 ether, "feed (0, 0.002] ether");
address[] memory path = new address[](2);
path[0] = WETH;
path[1] = address(stables[index]);
uint[] memory amounts = uniswapRouter.swapExactETHForTokens{value : msg.value}(0, path, address(bondingCurves[index]), block.timestamp);
require(amounts[amounts.length - 1] > 0, "swapped stable > 0");
}
bondingCurves[index].allocate();
uint bal = IERC20(Rusd).balanceOf(address(this));
if (bal > 0) {
IERC20(Rusd).transfer(msg.sender, bal);
}
}
|
function triggerAllocate(uint index) public payable {
if (index >= 3 || bondingCurves[index].isTimeEnded() == false) return;
if (stables[index].balanceOf(address(bondingCurves[index])) == 0) {
// swap from uniswap v2 and send to bondingCurves[index]
require(msg.value > 0 && msg.value <= 0.002 ether, "feed (0, 0.002] ether");
address[] memory path = new address[](2);
path[0] = WETH;
path[1] = address(stables[index]);
uint[] memory amounts = uniswapRouter.swapExactETHForTokens{value : msg.value}(0, path, address(bondingCurves[index]), block.timestamp);
require(amounts[amounts.length - 1] > 0, "swapped stable > 0");
}
bondingCurves[index].allocate();
uint bal = IERC20(Rusd).balanceOf(address(this));
if (bal > 0) {
IERC20(Rusd).transfer(msg.sender, bal);
}
}
| 35,170
|
116
|
// The following are runtime variables after publish
|
uint256 publishedAt; // time that published.
uint256 timesToCall;
uint256 soldCount;
|
uint256 publishedAt; // time that published.
uint256 timesToCall;
uint256 soldCount;
| 20,168
|
10
|
// Optional mapping for token URIs
|
mapping (uint256 => string) private _tokenURIs;
|
mapping (uint256 => string) private _tokenURIs;
| 45,008
|
348
|
// we want to use statechanging for safety
|
(uint256 deposits, uint256 borrows) = getLivePosition();
|
(uint256 deposits, uint256 borrows) = getLivePosition();
| 38,328
|
13
|
// Get the First Random Word Response from Chainlink /
|
function getFirstRandomWord() external view returns (uint256) {
return s_randomWords[0];
}
|
function getFirstRandomWord() external view returns (uint256) {
return s_randomWords[0];
}
| 81,934
|
88
|
// Converts an amount of (virtual) tokens from this contract to real/ tokens based on the claims previously performed by the caller./amount How many virtual tokens to convert into real tokens.
|
function swap(uint256 amount) external {
makeVestingSwappable();
_swap(amount);
}
|
function swap(uint256 amount) external {
makeVestingSwappable();
_swap(amount);
}
| 66,338
|
4
|
// This function implement proxy for befor transfer hook form OpenZeppelin ERC20. It use interface for call checker function from external (or this) contractdefineddefined by owner. /
|
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
require(to != address(this), "This contract not accept tokens" );
}
|
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
require(to != address(this), "This contract not accept tokens" );
}
| 69,286
|
145
|
// Transfer /
|
function testCannotTransferFromIfDefault() public {
// bid and set price
_bid(PIXEL_PRICE, PIXEL_PRICE);
_rollBlock();
vm.startPrank(PIXEL_OWNER);
currency.approve(address(registry), 0);
registry.transferFrom(PIXEL_OWNER, PIXEL_OWNER_1, PIXEL_ID);
vm.stopPrank();
// ownership was transferred to zero address
assertEq(thespace.getOwner(PIXEL_ID), address(0));
// price was reset to mint tax since it was burned
uint256 mintTax = 50 * (10**uint256(currency.decimals()));
_setMintTax(mintTax);
assertEq(thespace.getPrice(PIXEL_ID), mintTax);
// tax was clear
_bidAs(PIXEL_OWNER_1, mintTax);
assertEq(thespace.getTax(PIXEL_ID), 0);
}
|
function testCannotTransferFromIfDefault() public {
// bid and set price
_bid(PIXEL_PRICE, PIXEL_PRICE);
_rollBlock();
vm.startPrank(PIXEL_OWNER);
currency.approve(address(registry), 0);
registry.transferFrom(PIXEL_OWNER, PIXEL_OWNER_1, PIXEL_ID);
vm.stopPrank();
// ownership was transferred to zero address
assertEq(thespace.getOwner(PIXEL_ID), address(0));
// price was reset to mint tax since it was burned
uint256 mintTax = 50 * (10**uint256(currency.decimals()));
_setMintTax(mintTax);
assertEq(thespace.getPrice(PIXEL_ID), mintTax);
// tax was clear
_bidAs(PIXEL_OWNER_1, mintTax);
assertEq(thespace.getTax(PIXEL_ID), 0);
}
| 19,583
|
122
|
// Calculate loss _totalDebt Total collateral debt of this strategyreturn _loss Realized loss in collateral token /
|
function _realizeLoss(uint256 _totalDebt) internal virtual returns (uint256 _loss);
|
function _realizeLoss(uint256 _totalDebt) internal virtual returns (uint256 _loss);
| 7,730
|
250
|
// this is a part of a harvest call Send all of our LP tokens to the proxy and deposit to the gauge if we have any
|
uint256 _toInvest = balanceOfWant();
if (_toInvest > 0) {
want.safeTransfer(address(proxy), _toInvest);
proxy.deposit(gauge, address(want));
}
|
uint256 _toInvest = balanceOfWant();
if (_toInvest > 0) {
want.safeTransfer(address(proxy), _toInvest);
proxy.deposit(gauge, address(want));
}
| 18,355
|
83
|
// Encode the length and return it
|
for (uint256 i = 0; i < nBytes; i++) {
b[i] = bytes1(uint8(x / (2**(8 * (nBytes - 1 - i)))));
}
|
for (uint256 i = 0; i < nBytes; i++) {
b[i] = bytes1(uint8(x / (2**(8 * (nBytes - 1 - i)))));
}
| 5,219
|
2
|
// ==============================
|
function buy(address _referredBy) public payable {
purchaseInternal(msg.value, _referredBy);
}
|
function buy(address _referredBy) public payable {
purchaseInternal(msg.value, _referredBy);
}
| 8,914
|
4
|
// publicPRESALE MINT
|
function mintPresale(address _to, uint16 _mintAmount) public payable {
//uint256 supply = totalSupply();
require(presaleWallets[msg.sender] == true, "You are not on the presale whitelist.");
require(presaleStart <= block.timestamp && publicStart >= block.timestamp);
require(_mintAmount > 0);
require(_mintAmount <= maxPresaleMintAmount, "You can only mint 3 in presale.");
require(totalSupply + _mintAmount <= maxPresaleSupply, "Purchase would exceed max presale tokens.");
require(cost >= cost * _mintAmount, "Ether value sent is not correct.");
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, totalSupply + i);
}
totalSupply += _mintAmount;
}
|
function mintPresale(address _to, uint16 _mintAmount) public payable {
//uint256 supply = totalSupply();
require(presaleWallets[msg.sender] == true, "You are not on the presale whitelist.");
require(presaleStart <= block.timestamp && publicStart >= block.timestamp);
require(_mintAmount > 0);
require(_mintAmount <= maxPresaleMintAmount, "You can only mint 3 in presale.");
require(totalSupply + _mintAmount <= maxPresaleSupply, "Purchase would exceed max presale tokens.");
require(cost >= cost * _mintAmount, "Ether value sent is not correct.");
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, totalSupply + i);
}
totalSupply += _mintAmount;
}
| 2,004
|
1
|
// function to create new campaign
|
function createCampaign(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) { //parameter its going to take in, its public means we can access it from frontend and it will return a id so 256
Campaign storage campaign = campaigns[numberOfCampaigns]; //jab bhi new campaign banega total campaign increment ho jayenge
require(campaign.deadline < block.timestamp, "The deadline should be a date in the future."); // require is like a check that need to happen for code to proceed(yahan we are checking that deadline should be in future)
campaign.owner = _owner;
campaign.title = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0; //at start
campaign.image = _image;
numberOfCampaigns++; //total campaign increment ho jayega
return numberOfCampaigns - 1; //it will be index of newly created campaign
}
|
function createCampaign(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) { //parameter its going to take in, its public means we can access it from frontend and it will return a id so 256
Campaign storage campaign = campaigns[numberOfCampaigns]; //jab bhi new campaign banega total campaign increment ho jayenge
require(campaign.deadline < block.timestamp, "The deadline should be a date in the future."); // require is like a check that need to happen for code to proceed(yahan we are checking that deadline should be in future)
campaign.owner = _owner;
campaign.title = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0; //at start
campaign.image = _image;
numberOfCampaigns++; //total campaign increment ho jayega
return numberOfCampaigns - 1; //it will be index of newly created campaign
}
| 16,428
|
48
|
// Inserts a batch into the chain of batches. _transactionRoot Root of the transaction tree for this batch. _batchSize Number of elements in the batch. _numQueuedTransactions Number of queue transactions in the batch. _timestamp The latest batch timestamp. _blockNumber The latest batch blockNumber. /
|
function _appendBatch(
bytes32 _transactionRoot,
uint256 _batchSize,
uint256 _numQueuedTransactions,
uint40 _timestamp,
uint40 _blockNumber
|
function _appendBatch(
bytes32 _transactionRoot,
uint256 _batchSize,
uint256 _numQueuedTransactions,
uint40 _timestamp,
uint40 _blockNumber
| 2,263
|
110
|
// See {ERC20-_burn}. /
|
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
|
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
| 1,544
|
3
|
// Contract logic
|
bool public closed; // is the distribution closed
bool public paused; // is the distribution paused
bool public isFunded; // distribution can only start when required seed tokens have been funded
bool public initialized; // is this contract initialized [not necessary that it is funded]
bool public minimumReached; // if the softCap[minimum limit of funding token] is reached
bool public maximumReached; // if the hardCap[maximum limit of funding token] is reached
uint256 public totalFunderCount; // Total funders that have contributed.
uint256 public seedRemainder; // Amount of seed tokens remaining to be distributed
uint256 public seedClaimed; // Amount of seed token claimed by the user.
|
bool public closed; // is the distribution closed
bool public paused; // is the distribution paused
bool public isFunded; // distribution can only start when required seed tokens have been funded
bool public initialized; // is this contract initialized [not necessary that it is funded]
bool public minimumReached; // if the softCap[minimum limit of funding token] is reached
bool public maximumReached; // if the hardCap[maximum limit of funding token] is reached
uint256 public totalFunderCount; // Total funders that have contributed.
uint256 public seedRemainder; // Amount of seed tokens remaining to be distributed
uint256 public seedClaimed; // Amount of seed token claimed by the user.
| 25,807
|
1
|
// Total of percents./
|
uint8 constant MAX_PERCENTS = 100;
|
uint8 constant MAX_PERCENTS = 100;
| 11,999
|
183
|
// returns the maximum stable rate borrow size, in percentage of the available liquidity./
|
function getMaxStableRateBorrowSizePercent() external pure returns (uint256) {
return MAX_STABLE_RATE_BORROW_SIZE_PERCENT;
}
|
function getMaxStableRateBorrowSizePercent() external pure returns (uint256) {
return MAX_STABLE_RATE_BORROW_SIZE_PERCENT;
}
| 34,827
|
61
|
// Approve max is ok because it's only to this contract and this contract has no other functionality Also some ERC20 tokens will fail when approving a set amount twice, such as USDT. Must approve 0 first. This circumvests that issue.
|
tokenA.approve(address(router), uint256(-1));
tokenB.approve(address(router), uint256(-1));
|
tokenA.approve(address(router), uint256(-1));
tokenB.approve(address(router), uint256(-1));
| 45,675
|
101
|
// if there is a figure at current field return it
|
if (self.fields[uint(currentIndex)] != Pieces(Piece.EMPTY))
return int8(currentIndex);
|
if (self.fields[uint(currentIndex)] != Pieces(Piece.EMPTY))
return int8(currentIndex);
| 42,926
|
50
|
// -------------------------------------------------------------------------- Miner --------------------------------------------------------------------------/get a free miner/
|
function getFreeMiner() public disableContract isNotOver
|
function getFreeMiner() public disableContract isNotOver
| 57,752
|
236
|
// Public sale not active modifier
|
modifier whenPublicSaleNotActive() {
require(
!publicSaleActive && publicSaleStartTime == 0,
'Public sale is already active'
);
_;
}
|
modifier whenPublicSaleNotActive() {
require(
!publicSaleActive && publicSaleStartTime == 0,
'Public sale is already active'
);
_;
}
| 63,968
|
7
|
// returning the contract's balance in wei
|
function getBalance() public view returns(uint){
// only the manager is allowed to call it
require(msg.sender == manager);
return address(this).balance;
}
|
function getBalance() public view returns(uint){
// only the manager is allowed to call it
require(msg.sender == manager);
return address(this).balance;
}
| 17,265
|
6
|
// Set maker balance
|
vm.deal(address(maker), 100 ether);
|
vm.deal(address(maker), 100 ether);
| 15,739
|
44
|
// ``` As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)and `uint256` (`UintSet`) are supported. /
|
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
|
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
| 7,040
|
10
|
// check members
|
uint8 totalShares = 0;
for (uint8 i = 0; i < shareholders_.length; i++) {
Member memory member = Member(shareholders_[i], 0, 0);
uint8 shares = member.shareholder.shares;
address account = member.shareholder.account;
|
uint8 totalShares = 0;
for (uint8 i = 0; i < shareholders_.length; i++) {
Member memory member = Member(shareholders_[i], 0, 0);
uint8 shares = member.shareholder.shares;
address account = member.shareholder.account;
| 23,209
|
28
|
// Implementation of the {BEP20} interface.that a supply mechanism has to be added in a derived contract using {_mint}.For a generic mechanism see {BEP20Mintable}.Additionally, an {Approval} event is emitted on calls to {transferFrom}.Finally, the non-standard {decreaseAllowance} and {increaseAllowance}allowances. See {BEP20-approve}. allocating 10 million tokens for promotion, airdrop, liquidity and dev share modified original contract from 50000000
|
uint256 private _totalSupply = 10000000 * (10 ** 8);
constructor() public {
_balances[msg.sender] = _totalSupply;
}
|
uint256 private _totalSupply = 10000000 * (10 ** 8);
constructor() public {
_balances[msg.sender] = _totalSupply;
}
| 24,705
|
11
|
// Converts wad up to ray a Wadreturn b = a converted in ray /
|
function wadToRay(uint256 a) internal pure returns (uint256 b) {
// to avoid overflow, b/WAD_RAY_RATIO == a
assembly {
b := mul(a, WAD_RAY_RATIO)
if iszero(eq(div(b, WAD_RAY_RATIO), a)) {
revert(0, 0)
}
}
}
|
function wadToRay(uint256 a) internal pure returns (uint256 b) {
// to avoid overflow, b/WAD_RAY_RATIO == a
assembly {
b := mul(a, WAD_RAY_RATIO)
if iszero(eq(div(b, WAD_RAY_RATIO), a)) {
revert(0, 0)
}
}
}
| 11,354
|
98
|
// this struct describes what kind of data we include in the payload, we do not use this directly The bytes payload set on the server side total 56 bytes
|
struct KYCPayload {
/** Customer whitelisted address where the deposit can come from */
address whitelistedAddress; // 20 bytes
/** Customer id, UUID v4 */
uint128 customerId; // 16 bytes
/**
* Min amount this customer needs to invest in ETH. Set zero if no minimum. Expressed as parts of 10000. 1 ETH = 10000.
* @notice Decided to use 32-bit words to make the copy-pasted Data field for the ICO transaction less lenghty.
*/
uint32 minETH; // 4 bytes
/** Max amount this customer can to invest in ETH. Set zero if no maximum. Expressed as parts of 10000. 1 ETH = 10000. */
uint32 maxETH; // 4 bytes
/**
* Information about the price promised for this participant. It can be pricing tier id or directly one token price in weis.
* @notice This is a later addition and not supported in all scenarios yet.
*/
uint256 pricingInfo;
}
|
struct KYCPayload {
/** Customer whitelisted address where the deposit can come from */
address whitelistedAddress; // 20 bytes
/** Customer id, UUID v4 */
uint128 customerId; // 16 bytes
/**
* Min amount this customer needs to invest in ETH. Set zero if no minimum. Expressed as parts of 10000. 1 ETH = 10000.
* @notice Decided to use 32-bit words to make the copy-pasted Data field for the ICO transaction less lenghty.
*/
uint32 minETH; // 4 bytes
/** Max amount this customer can to invest in ETH. Set zero if no maximum. Expressed as parts of 10000. 1 ETH = 10000. */
uint32 maxETH; // 4 bytes
/**
* Information about the price promised for this participant. It can be pricing tier id or directly one token price in weis.
* @notice This is a later addition and not supported in all scenarios yet.
*/
uint256 pricingInfo;
}
| 40,994
|
108
|
// feeRecipient is assumed to be an address (or a contract) that can/ accept erc20 payments it cannot be 0x0./When tokens are mint or burnt, a portion of the tokens are/ forwarded to a fee recipient.
|
address public feeRecipient;
|
address public feeRecipient;
| 11,488
|
44
|
// Returns True if `self` contains `needle`. self The slice to search. needle The text to search for in `self`.return True if `needle` is found in `self`, false otherwise. /
|
function contains(slice self, slice needle) internal returns (bool) {
return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;
}
|
function contains(slice self, slice needle) internal returns (bool) {
return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;
}
| 6,470
|
8
|
// Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted}event. Requirements: - the caller must have ``role``'s admin role. /
|
function grantRole(bytes32 role, address account) external;
|
function grantRole(bytes32 role, address account) external;
| 709
|
50
|
// The vamm's fee (proportion) in wad/ return The fee in wad
|
function feeWad() external view returns (uint256);
|
function feeWad() external view returns (uint256);
| 27,193
|
96
|
// xref:ROOT:erc1155.adocbatch-operations[Batched] version of {_burn}. Requirements: - `ids` and `amounts` must have the same length. /
|
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
|
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
| 186
|
10
|
// toSpec converts a cron string to a spec struct. This is gas-intensiveand therefore should only be called off-chain. cronString the cron stringreturn the spec struct /
|
function toSpec(string memory cronString) internal pure returns (Spec memory) {
strings.slice memory space = strings.toSlice(" ");
strings.slice memory cronSlice = strings.toSlice(cronString);
if (cronSlice.count(space) != 4) {
revert InvalidSpec("4 spaces required");
}
strings.slice memory minuteSlice = cronSlice.split(space);
strings.slice memory hourSlice = cronSlice.split(space);
strings.slice memory daySlice = cronSlice.split(space);
strings.slice memory monthSlice = cronSlice.split(space);
// DEV: dayOfWeekSlice = cronSlice
// The cronSlice now contains the last section of the cron job,
// which corresponds to the day of week
if (
minuteSlice.len() == 0 ||
hourSlice.len() == 0 ||
daySlice.len() == 0 ||
monthSlice.len() == 0 ||
cronSlice.len() == 0
) {
revert InvalidSpec("some fields missing");
}
return
validate(
Spec({
minute: sliceToField(minuteSlice),
hour: sliceToField(hourSlice),
day: sliceToField(daySlice),
month: sliceToField(monthSlice),
dayOfWeek: sliceToField(cronSlice)
})
);
}
|
function toSpec(string memory cronString) internal pure returns (Spec memory) {
strings.slice memory space = strings.toSlice(" ");
strings.slice memory cronSlice = strings.toSlice(cronString);
if (cronSlice.count(space) != 4) {
revert InvalidSpec("4 spaces required");
}
strings.slice memory minuteSlice = cronSlice.split(space);
strings.slice memory hourSlice = cronSlice.split(space);
strings.slice memory daySlice = cronSlice.split(space);
strings.slice memory monthSlice = cronSlice.split(space);
// DEV: dayOfWeekSlice = cronSlice
// The cronSlice now contains the last section of the cron job,
// which corresponds to the day of week
if (
minuteSlice.len() == 0 ||
hourSlice.len() == 0 ||
daySlice.len() == 0 ||
monthSlice.len() == 0 ||
cronSlice.len() == 0
) {
revert InvalidSpec("some fields missing");
}
return
validate(
Spec({
minute: sliceToField(minuteSlice),
hour: sliceToField(hourSlice),
day: sliceToField(daySlice),
month: sliceToField(monthSlice),
dayOfWeek: sliceToField(cronSlice)
})
);
}
| 45,979
|
102
|
// Return tokens not sold
|
if(tokensRefunded > 0)
require(Token(token).transfer(msg.sender, tokensRefunded));
|
if(tokensRefunded > 0)
require(Token(token).transfer(msg.sender, tokensRefunded));
| 3,495
|
3
|
// Event emitted after a `dangerousBurn` has succeeded. /
|
event OptionsBurned(
address indexed from,
uint256 longAmount,
|
event OptionsBurned(
address indexed from,
uint256 longAmount,
| 15,580
|
61
|
// Writes a snapshot for an owner of tokensowner The owner of the tokensoldValue The value before the operation that is gonna be executed after the snapshotnewValue The value after the operation/
|
function _writeSnapshot(address owner, uint128 oldValue, uint128 newValue) internal virtual {
uint128 currentBlock = uint128(block.number);
uint256 ownerCountOfSnapshots = _countsSnapshots[owner];
mapping (uint256 => Snapshot) storage snapshotsOwner = _snapshots[owner];
// Doing multiple operations in the same block
if (ownerCountOfSnapshots != 0 && snapshotsOwner[ownerCountOfSnapshots.sub(1)].blockNumber == currentBlock) {
snapshotsOwner[ownerCountOfSnapshots.sub(1)].value = newValue;
} else {
snapshotsOwner[ownerCountOfSnapshots] = Snapshot(currentBlock, newValue);
_countsSnapshots[owner] = ownerCountOfSnapshots.add(1);
}
emit SnapshotDone(owner, oldValue, newValue);
}
|
function _writeSnapshot(address owner, uint128 oldValue, uint128 newValue) internal virtual {
uint128 currentBlock = uint128(block.number);
uint256 ownerCountOfSnapshots = _countsSnapshots[owner];
mapping (uint256 => Snapshot) storage snapshotsOwner = _snapshots[owner];
// Doing multiple operations in the same block
if (ownerCountOfSnapshots != 0 && snapshotsOwner[ownerCountOfSnapshots.sub(1)].blockNumber == currentBlock) {
snapshotsOwner[ownerCountOfSnapshots.sub(1)].value = newValue;
} else {
snapshotsOwner[ownerCountOfSnapshots] = Snapshot(currentBlock, newValue);
_countsSnapshots[owner] = ownerCountOfSnapshots.add(1);
}
emit SnapshotDone(owner, oldValue, newValue);
}
| 19,898
|
27
|
// 17% to Pixelcraft wallet
|
uint256 companyShare = (_ghst * 17) / 100;
|
uint256 companyShare = (_ghst * 17) / 100;
| 44,011
|
4
|
// 1944931696795680320000
|
function manaPerEth() public view returns (uint256) {
uint256 ManaPrice = getLatestManaPrice();
uint256 ETHPrice = getLatestETHPrice();
return (ManaPrice * ETHPrice) / 1e8;
}
|
function manaPerEth() public view returns (uint256) {
uint256 ManaPrice = getLatestManaPrice();
uint256 ETHPrice = getLatestETHPrice();
return (ManaPrice * ETHPrice) / 1e8;
}
| 12,052
|
47
|
// Token
|
string public name = "BubbleToken";
string public symbol = "BUB";
uint256 public decimals = 2;
uint256 public INITIAL_SUPPLY = 10000000000;
|
string public name = "BubbleToken";
string public symbol = "BUB";
uint256 public decimals = 2;
uint256 public INITIAL_SUPPLY = 10000000000;
| 47,880
|
162
|
// The entry is stored at length-1, but we add 1 to all indexes and use 0 as a sentinel value
|
map._indexes[key] = map._entries.length;
return true;
|
map._indexes[key] = map._entries.length;
return true;
| 20,426
|
12
|
// Stored in a mapping indexed by commitment_id, a hash of commitment hash, question, bond.
|
struct Commitment {
uint32 reveal_ts;
bool is_revealed;
bytes32 revealed_answer;
}
|
struct Commitment {
uint32 reveal_ts;
bool is_revealed;
bytes32 revealed_answer;
}
| 51,701
|
54
|
// Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call:- if using `revokeRole`, it is the admin role bearer- if using `renounceRole`, it is the role bearer (i.e. `account`) /
|
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
|
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
| 11,268
|
20
|
// Minting
|
event Mint(address indexed to, uint256 amount);
event PauseMinting();
event UnPauseMinting();
|
event Mint(address indexed to, uint256 amount);
event PauseMinting();
event UnPauseMinting();
| 8,822
|
9
|
// Get the minimum accuracy unit for a given accuracy
|
function getPriceUnit(address currency) public view returns (uint256) {
if (currency == address(0)) {
return 10 ** (18 - DECIMAL_ACCURACY);
}
// This technically doesn't work with all ERC20s
// The decimals method is optional, hence the custom interface
// That said, it is in almost every ERC20, a requirement for this, and needed for feasible operations with wrapped coins
uint256 decimals = IDecimals(currency).decimals();
if (decimals <= DECIMAL_ACCURACY) {
return 1;
}
return 10 ** (decimals - DECIMAL_ACCURACY);
}
|
function getPriceUnit(address currency) public view returns (uint256) {
if (currency == address(0)) {
return 10 ** (18 - DECIMAL_ACCURACY);
}
// This technically doesn't work with all ERC20s
// The decimals method is optional, hence the custom interface
// That said, it is in almost every ERC20, a requirement for this, and needed for feasible operations with wrapped coins
uint256 decimals = IDecimals(currency).decimals();
if (decimals <= DECIMAL_ACCURACY) {
return 1;
}
return 10 ** (decimals - DECIMAL_ACCURACY);
}
| 48,311
|
129
|
// Transfer ownership function
|
function setOwner(address _owner) public _onlyOwner {
owner = _owner;
}
|
function setOwner(address _owner) public _onlyOwner {
owner = _owner;
}
| 6,230
|
1
|
// Thrown when price feed doesn't work by some reason
|
error InvalidOracle();
|
error InvalidOracle();
| 4,806
|
4
|
// Stake end timestamp.
|
uint64 public endTimestamp;
|
uint64 public endTimestamp;
| 16,489
|
5
|
// Set credit limit for the address.
|
function setAllowance(address bankClientAddress, uint amount) public alwaysAccept {
// Store allowed credit limit for the address in state variable mapping.
clientDB[bankClientAddress].allowed = amount;
}
|
function setAllowance(address bankClientAddress, uint amount) public alwaysAccept {
// Store allowed credit limit for the address in state variable mapping.
clientDB[bankClientAddress].allowed = amount;
}
| 18,187
|
13
|
// reserve mint to contract wallet next sequential token id/
|
function reserveMint(uint256 numberOfTokens) external onlyOwner {
for (uint256 i = 0; i < numberOfTokens; i++) {
uint256 mintIndex = mintTokenIndex;
numTokensMinted++;
mintTokenIndex++;
_safeMint(msg.sender, mintIndex);
}
}
|
function reserveMint(uint256 numberOfTokens) external onlyOwner {
for (uint256 i = 0; i < numberOfTokens; i++) {
uint256 mintIndex = mintTokenIndex;
numTokensMinted++;
mintTokenIndex++;
_safeMint(msg.sender, mintIndex);
}
}
| 17,846
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.