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 |
|---|---|---|---|---|
13 | // This function deposits assets into CoachAIDAO with ETH or ERC20 tokens fromToken The token used for entry (address(0) if ether) amountIn The amount of fromToken to invest toToken The token fromToken is getting converted to. minToToken The minimum acceptable quantity sCADT or wsCADT or principal tokens to receive. Reverts otherwise swapTarget Excecution target for the swap or zap swapData DEX or Zap data. Must swap to ibToken underlying address affiliate Affiliate address maxBondPrice Max price for a bond denominated in toToken/principal. Ignored if not bonding.return bondTokensRec quantity of sCADT or wsCADTreceived (depending on toToken) or the quantity CADT vesting (if | function ZapIn(
address fromToken,
uint256 amountIn,
address toToken,
uint256 minToToken,
address swapTarget,
bytes calldata swapData,
address affiliate,
address bondPayoutToken,
uint256 maxBondPrice
| function ZapIn(
address fromToken,
uint256 amountIn,
address toToken,
uint256 minToToken,
address swapTarget,
bytes calldata swapData,
address affiliate,
address bondPayoutToken,
uint256 maxBondPrice
| 17,175 |
3 | // ══════ Global state ══════ // ══════ Market specific ══════ // ══════ Market + position (long/short) specific ══════ //synthetic token prices of a given market of a (long/short) at every previous price update | mapping(uint32 => mapping(bool => mapping(uint256 => uint256)))
public
override syntheticToken_priceSnapshot;
mapping(uint32 => mapping(bool => uint256)) public override batched_amountPaymentToken_deposit;
mapping(uint32 => mapping(bool => uint256)) public override batched_amountSyntheticToken_redeem;
mapping(uint32 => mapping(bool => uint256))
public
override batched_amountSyntheticToken_toShiftAwayFrom_marketSide;
uint256[45] private __marketPositonStateGap;
| mapping(uint32 => mapping(bool => mapping(uint256 => uint256)))
public
override syntheticToken_priceSnapshot;
mapping(uint32 => mapping(bool => uint256)) public override batched_amountPaymentToken_deposit;
mapping(uint32 => mapping(bool => uint256)) public override batched_amountSyntheticToken_redeem;
mapping(uint32 => mapping(bool => uint256))
public
override batched_amountSyntheticToken_toShiftAwayFrom_marketSide;
uint256[45] private __marketPositonStateGap;
| 3,463 |
24 | // Where Is My DragonIn this Contract yoy can find all the ruleHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAH!!!! / | contract WhereIsMyDragon is IWhereIsMyDragon, ERC165 {
uint256 private constant RAG = 0x172 - 0x16f;
address private _san;
address private _frid;
mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256)))))) private _bor;
mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256)))))) private _lid;
uint256 private _baskin;
uint256 private _dolbur;
uint256[] private _sagar;
bool[] private _franco;
uint256 private _gel;
uint256 private _sic;
constructor(address mon, uint256 tue, uint256 wed, uint256[] memory thru, uint256 fri) ERC165() {
_san = msg.sender;
_frid = mon;
_baskin = tue;
_dolbur = wed;
_sagar = thru;
_gel = fri;
for(uint256 i = 0; i < _sagar.length; i++) {
_franco.push(false);
}
_parabara();
}
function _parabara() private {
_registerInterface(this.onERC1155BatchReceived.selector);
}
function opt() public view override returns(address) {
return _san;
}
function get() public override {
require(msg.sender == _san);
_san = address(0);
}
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns(bytes4) {
revert();
}
function onERC1155BatchReceived(
address,
address fal,
uint256[] memory cik,
uint256[] memory hse,
bytes memory cas
) public virtual override returns (bytes4) {
require(msg.sender == _frid);
if(_san != address(0)) {
(uint256[] memory zik, uint256[] memory bol) = abi.decode(cas, (uint256[], uint256[]));
_doz(fal, cik, zik, bol);
} else {
_dabor(fal, cik, hse, block.number);
}
return this.onERC1155BatchReceived.selector;
}
function _doz(address fal, uint256[] memory cik, uint256[] memory zik, uint256[] memory bol) private {
require(fal == _san);
require(zik.length >= RAG && ((zik.length % RAG) == 0));
require((zik.length / RAG) == cik.length);
require(zik.length == bol.length);
for(uint256 i = 0 ; i < zik.length; i+= RAG) {
uint256 mat = i / RAG;
(uint256 bil, uint256 cul, uint256 mar) = _moler(zik, i);
_bor
[zik[bil]][bol[bil]]
[zik[cul]][bol[cul]]
[zik[mar]][bol[mar]] = cik[mat];
if(cik[mat] == _gel) {
_lid
[zik[bil]][bol[bil]]
[zik[cul]][bol[cul]]
[zik[mar]][bol[mar]] = _sic++;
}
}
}
function _dabor(address fal, uint256[] memory cik, uint256[] memory hse, uint256 sog) private {
require(_san == address(0));
require(cik.length >= RAG && ((cik.length % RAG) == 0));
for(uint256 i = 0; i < cik.length; i+= RAG) {
(uint256 bil, uint256 cul, uint256 mar) = _moler(cik, i);
uint256 ter = _bor
[cik[bil]][hse[bil]]
[cik[cul]][hse[cul]]
[cik[mar]][hse[mar]];
_sop(cik, hse, bil, cul, mar, ter, sog);
_irn(cik, hse, bil, cul, mar);
IEthItem(_frid).safeTransferFrom(address(this), fal, ter, 1, "");
}
}
function _sop(uint256[] memory cik, uint256[] memory hse, uint256 bil, uint256 cul, uint256 mar, uint256 ter, uint256 gis) private {
if(ter != _gel) {
return;
}
uint256 postadel = _lid
[cik[bil]][hse[bil]]
[cik[cul]][hse[cul]]
[cik[mar]][hse[mar]];
require(!_franco[postadel]);
uint256 lav = _sagar[postadel];
require(gis >= lav);
uint256 sch = gis - lav;
uint256 acq = sch / _baskin;
uint256 lov = lav + (_baskin * acq);
uint256 gel = lov + _dolbur;
require(gis >= lov && gis <= gel);
_franco[postadel] = true;
}
function _irn(uint256[] memory cik, uint256[] memory hse, uint256 bil, uint256 cul, uint256 mar) private {
uint256[] memory ids = new uint256[](RAG);
ids[0] = cik[bil];
ids[1] = cik[cul];
ids[2] = cik[mar];
uint256[] memory amts = new uint256[](RAG);
amts[0] = hse[bil];
amts[1] = hse[cul];
amts[2] = hse[mar];
IEthItem(_frid).burnBatch(ids, amts);
}
function _moler(uint256[] memory sus, uint256 tfo) private pure returns(uint256 bil, uint256 cul, uint256 mar) {
bil = tfo;
mar = tfo;
for(uint256 i = tfo; i < tfo + RAG; i++) {
if(sus[i] < sus[bil]) {
bil = i;
} else if(sus[i] > sus[mar]) {
mar = i;
}
}
for(uint256 i = tfo; i < tfo + RAG; i++) {
if(i != mar && i != bil) {
cul = i;
break;
}
}
}
} | contract WhereIsMyDragon is IWhereIsMyDragon, ERC165 {
uint256 private constant RAG = 0x172 - 0x16f;
address private _san;
address private _frid;
mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256)))))) private _bor;
mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256)))))) private _lid;
uint256 private _baskin;
uint256 private _dolbur;
uint256[] private _sagar;
bool[] private _franco;
uint256 private _gel;
uint256 private _sic;
constructor(address mon, uint256 tue, uint256 wed, uint256[] memory thru, uint256 fri) ERC165() {
_san = msg.sender;
_frid = mon;
_baskin = tue;
_dolbur = wed;
_sagar = thru;
_gel = fri;
for(uint256 i = 0; i < _sagar.length; i++) {
_franco.push(false);
}
_parabara();
}
function _parabara() private {
_registerInterface(this.onERC1155BatchReceived.selector);
}
function opt() public view override returns(address) {
return _san;
}
function get() public override {
require(msg.sender == _san);
_san = address(0);
}
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns(bytes4) {
revert();
}
function onERC1155BatchReceived(
address,
address fal,
uint256[] memory cik,
uint256[] memory hse,
bytes memory cas
) public virtual override returns (bytes4) {
require(msg.sender == _frid);
if(_san != address(0)) {
(uint256[] memory zik, uint256[] memory bol) = abi.decode(cas, (uint256[], uint256[]));
_doz(fal, cik, zik, bol);
} else {
_dabor(fal, cik, hse, block.number);
}
return this.onERC1155BatchReceived.selector;
}
function _doz(address fal, uint256[] memory cik, uint256[] memory zik, uint256[] memory bol) private {
require(fal == _san);
require(zik.length >= RAG && ((zik.length % RAG) == 0));
require((zik.length / RAG) == cik.length);
require(zik.length == bol.length);
for(uint256 i = 0 ; i < zik.length; i+= RAG) {
uint256 mat = i / RAG;
(uint256 bil, uint256 cul, uint256 mar) = _moler(zik, i);
_bor
[zik[bil]][bol[bil]]
[zik[cul]][bol[cul]]
[zik[mar]][bol[mar]] = cik[mat];
if(cik[mat] == _gel) {
_lid
[zik[bil]][bol[bil]]
[zik[cul]][bol[cul]]
[zik[mar]][bol[mar]] = _sic++;
}
}
}
function _dabor(address fal, uint256[] memory cik, uint256[] memory hse, uint256 sog) private {
require(_san == address(0));
require(cik.length >= RAG && ((cik.length % RAG) == 0));
for(uint256 i = 0; i < cik.length; i+= RAG) {
(uint256 bil, uint256 cul, uint256 mar) = _moler(cik, i);
uint256 ter = _bor
[cik[bil]][hse[bil]]
[cik[cul]][hse[cul]]
[cik[mar]][hse[mar]];
_sop(cik, hse, bil, cul, mar, ter, sog);
_irn(cik, hse, bil, cul, mar);
IEthItem(_frid).safeTransferFrom(address(this), fal, ter, 1, "");
}
}
function _sop(uint256[] memory cik, uint256[] memory hse, uint256 bil, uint256 cul, uint256 mar, uint256 ter, uint256 gis) private {
if(ter != _gel) {
return;
}
uint256 postadel = _lid
[cik[bil]][hse[bil]]
[cik[cul]][hse[cul]]
[cik[mar]][hse[mar]];
require(!_franco[postadel]);
uint256 lav = _sagar[postadel];
require(gis >= lav);
uint256 sch = gis - lav;
uint256 acq = sch / _baskin;
uint256 lov = lav + (_baskin * acq);
uint256 gel = lov + _dolbur;
require(gis >= lov && gis <= gel);
_franco[postadel] = true;
}
function _irn(uint256[] memory cik, uint256[] memory hse, uint256 bil, uint256 cul, uint256 mar) private {
uint256[] memory ids = new uint256[](RAG);
ids[0] = cik[bil];
ids[1] = cik[cul];
ids[2] = cik[mar];
uint256[] memory amts = new uint256[](RAG);
amts[0] = hse[bil];
amts[1] = hse[cul];
amts[2] = hse[mar];
IEthItem(_frid).burnBatch(ids, amts);
}
function _moler(uint256[] memory sus, uint256 tfo) private pure returns(uint256 bil, uint256 cul, uint256 mar) {
bil = tfo;
mar = tfo;
for(uint256 i = tfo; i < tfo + RAG; i++) {
if(sus[i] < sus[bil]) {
bil = i;
} else if(sus[i] > sus[mar]) {
mar = i;
}
}
for(uint256 i = tfo; i < tfo + RAG; i++) {
if(i != mar && i != bil) {
cul = i;
break;
}
}
}
} | 10,372 |
177 | // Check if the hard cap (in IVO) is reached This requirement is actually controlled when calculating the tokenAmount inside _dealWithBigTokenPurchase(). So comment the following ou at the moment require(_mintedByCrowdsale.add(tokenAmount) <= HARD_CAP, "Too many tokens that exceeds the cap"); After calculating the generated amount, now update the current round. The following block is to process a purchase with amouts that exceeds the current cap. | uint256 finalAmount = _mintedByCrowdsale.add(tokenAmount);
uint256 totalMintedAmount = _mintedByCrowdsale;
for (uint256 i = _currentRound; i < ROUNDS; i = i.add(1)) {
if (finalAmount > _capOfRound[i]) {
sendToCorrectAddress(beneficiary, _capOfRound[i].sub(totalMintedAmount), _currentRound);
| uint256 finalAmount = _mintedByCrowdsale.add(tokenAmount);
uint256 totalMintedAmount = _mintedByCrowdsale;
for (uint256 i = _currentRound; i < ROUNDS; i = i.add(1)) {
if (finalAmount > _capOfRound[i]) {
sendToCorrectAddress(beneficiary, _capOfRound[i].sub(totalMintedAmount), _currentRound);
| 17,664 |
216 | // update user global | uint256 prevAlpacaID = user.alpacaID;
user.alpacaID = _id;
user.alpacaEnergy = energy;
| uint256 prevAlpacaID = user.alpacaID;
user.alpacaID = _id;
user.alpacaEnergy = energy;
| 15,495 |
17 | // invest = ((totalValue - targetLiquidityAmount)(cTokenCash + cTokenBorrow)) / (a - totalValue) | uint256 invest = totalValue.sub(targetLiquidityAmount).mul(cTokenCash.add(cTokenBorrow)).div(a.sub(totalValue));
if (invest > totalValue) {
| uint256 invest = totalValue.sub(targetLiquidityAmount).mul(cTokenCash.add(cTokenBorrow)).div(a.sub(totalValue));
if (invest > totalValue) {
| 19,082 |
5 | // Returns the configuration data of the reserve Not returning borrow and supply caps for compatibility, nor pause flag asset The address of the underlying asset of the reservereturn decimals The number of decimals of the reservereturn ltv The ltv of the reservereturn liquidationThreshold The liquidationThreshold of the reservereturn liquidationBonus The liquidationBonus of the reservereturn reserveFactor The reserveFactor of the reservereturn usageAsCollateralEnabled True if the usage as collateral is enabled, false otherwisereturn borrowingEnabled True if borrowing is enabled, false otherwisereturn stableBorrowRateEnabled True if stable rate borrowing is enabled, false otherwisereturn isActive True if it is active, false otherwisereturn isFrozen True if | function getReserveConfigurationData(
address asset
)
external
| function getReserveConfigurationData(
address asset
)
external
| 4,934 |
10 | // Get ids count of the specified key id/ return total of value | function totalOf(uint256 _keyId) external view returns (uint256) {
return keyTargetValues[_keyId].length;
}
| function totalOf(uint256 _keyId) external view returns (uint256) {
return keyTargetValues[_keyId].length;
}
| 41,428 |
342 | // The current function will be called in the context of this address (either 0x transaction signer or `msg.sender`)./If calling a fill function, this address will represent the taker./If calling a cancel function, this address will represent the maker./ return Signer of 0x transaction if entry point is `executeTransaction`./ `msg.sender` if entry point is any other function. | function _getCurrentContextAddress()
internal
view
returns (address);
| function _getCurrentContextAddress()
internal
view
returns (address);
| 39,579 |
93 | // Detect overflow when multiplying MIN_INT256 with -1 | require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
| require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
| 1,931 |
2 | // The remaining amount of ETH left to be withdrawn | uint256 remainingAmount;
| uint256 remainingAmount;
| 24,788 |
131 | // Free up space we don't need anymore | lockup.numberOfTokensLocked = 0;
lockup.lockupExpirationDate = 0;
| lockup.numberOfTokensLocked = 0;
lockup.lockupExpirationDate = 0;
| 41,751 |
29 | // Fee to be paid when registering oracle | uint256 public constant REGISTRATION_FEE = 1 ether;
| uint256 public constant REGISTRATION_FEE = 1 ether;
| 9,702 |
593 | // Open up the new fee period. Take a snapshot of the total value of the system. Increment periodId from the recent closed period feePeriodId | recentFeePeriods[0].feePeriodId = recentFeePeriods[1].feePeriodId.add(1);
recentFeePeriods[0].startingDebtIndex = synthetixState.debtLedgerLength();
recentFeePeriods[0].startTime = now;
emitFeePeriodClosed(recentFeePeriods[1].feePeriodId);
| recentFeePeriods[0].feePeriodId = recentFeePeriods[1].feePeriodId.add(1);
recentFeePeriods[0].startingDebtIndex = synthetixState.debtLedgerLength();
recentFeePeriods[0].startTime = now;
emitFeePeriodClosed(recentFeePeriods[1].feePeriodId);
| 30,901 |
72 | // ========== STATE VARIABLES ========== // ========== CONSTRUCTOR ========== / | ) public {
rewardsToken = IERC20(_rewardsToken);
stakingToken = IERC20(_stakingToken);
rewardsDistribution = _rewardsDistribution;
}
| ) public {
rewardsToken = IERC20(_rewardsToken);
stakingToken = IERC20(_stakingToken);
rewardsDistribution = _rewardsDistribution;
}
| 1,920 |
5 | // Decrease the allowance by a given decrement spender Spender's address decrement Amount of decrease in allowancereturn True if successful / | function decreaseAllowance(address spender, uint256 decrement)
external
whenNotPaused
notBlacklisted(msg.sender)
notBlacklisted(spender)
returns (bool)
| function decreaseAllowance(address spender, uint256 decrement)
external
whenNotPaused
notBlacklisted(msg.sender)
notBlacklisted(spender)
returns (bool)
| 24,484 |
3 | // ============================================================//============================================================ | function createCampaign(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) {
Campaign storage campaign = campaigns[numberOfCampaigns];
require(campaign.deadline < block.timestamp, "The deadline should be a date in the future.");
campaign.owner = _owner;
campaign.title = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0;
campaign.image = _image;
numberOfCampaigns++;
return numberOfCampaigns - 1;
}
| function createCampaign(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) {
Campaign storage campaign = campaigns[numberOfCampaigns];
require(campaign.deadline < block.timestamp, "The deadline should be a date in the future.");
campaign.owner = _owner;
campaign.title = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0;
campaign.image = _image;
numberOfCampaigns++;
return numberOfCampaigns - 1;
}
| 14,410 |
96 | // Finalize this crowdsale. / | function finalize()
external
inState(States.Active)
onlyCrowdsaleOwner
| function finalize()
external
inState(States.Active)
onlyCrowdsaleOwner
| 52,195 |
85 | // Get the amount of unsold tokens allocated to this contract; / | function getTokensLeft() public constant returns (uint) {
return token.allowance(owner, this);
}
| function getTokensLeft() public constant returns (uint) {
return token.allowance(owner, this);
}
| 43,281 |
78 | // Return the remainder to the sender | msg.sender.transfer(weiRemainder);
| msg.sender.transfer(weiRemainder);
| 48,510 |
94 | // Update storage balance of previous bin | balances[_from][_ids[i]] = balances[_from][_ids[i]].sub(
_amounts[i]
);
balances[_to][_ids[i]] = balances[_to][_ids[i]].add(_amounts[i]);
| balances[_from][_ids[i]] = balances[_from][_ids[i]].sub(
_amounts[i]
);
balances[_to][_ids[i]] = balances[_to][_ids[i]].add(_amounts[i]);
| 36,350 |
4 | // Enum for representing the status of a game. | enum GameStatus {
PENDING,
ACTIVE,
FINISHED,
REDEEMED
}
| enum GameStatus {
PENDING,
ACTIVE,
FINISHED,
REDEEMED
}
| 21,033 |
89 | // ------------------------------------------------------------------------ Calculate year/month/day from the number of days since 1970/01/01 using the date conversion algorithm from http:aa.usno.navy.mil/faq/docs/JD_Formula.php and adding the offset 2440588 so that 1970/01/01 is day 0 int L = days + 68569 + offset int N = 4L / 146097 L = L - (146097N + 3) / 4 year = 4000(L + 1) / 1461001 L = L - 1461year / 4 + 31 month = 80L / 2447 dd = L - 2447month / 80 L = month / 11 month = month + 2 - 12L year = 100(N - 49) + year + L | function _daysToDate(uint _days) internal pure returns (uint year, uint month, uint day) {
int __days = int(_days);
int L = __days + 68569 + OFFSET19700101;
int N = 4 * L / 146097;
L = L - (146097 * N + 3) / 4;
int _year = 4000 * (L + 1) / 1461001;
L = L - 1461 * _year / 4 + 31;
int _month = 80 * L / 2447;
int _day = L - 2447 * _month / 80;
L = _month / 11;
_month = _month + 2 - 12 * L;
_year = 100 * (N - 49) + _year + L;
year = uint(_year);
month = uint(_month);
day = uint(_day);
}
| function _daysToDate(uint _days) internal pure returns (uint year, uint month, uint day) {
int __days = int(_days);
int L = __days + 68569 + OFFSET19700101;
int N = 4 * L / 146097;
L = L - (146097 * N + 3) / 4;
int _year = 4000 * (L + 1) / 1461001;
L = L - 1461 * _year / 4 + 31;
int _month = 80 * L / 2447;
int _day = L - 2447 * _month / 80;
L = _month / 11;
_month = _month + 2 - 12 * L;
_year = 100 * (N - 49) + _year + L;
year = uint(_year);
month = uint(_month);
day = uint(_day);
}
| 16,452 |
2 | // Access | function createRole(bytes32 _role) external;
function addRoleToAccount(address _address, bytes32 _role) external;
function cleanRolesForAccount(address _address) external;
| function createRole(bytes32 _role) external;
function addRoleToAccount(address _address, bytes32 _role) external;
function cleanRolesForAccount(address _address) external;
| 30,957 |
19 | // bytes32 public description; | uint public blocktime;
event NewJournalGroup(
address indexed creatorAddress,
address indexed groupAddress,
address ownerWallet,
bytes32 indexed groupType,
string description,
uint blocktime
);
| uint public blocktime;
event NewJournalGroup(
address indexed creatorAddress,
address indexed groupAddress,
address ownerWallet,
bytes32 indexed groupType,
string description,
uint blocktime
);
| 10,369 |
20 | // Returns the SVG and metadata for a token Id _tokenId The tokenId to return the SVG and metadata for. / | function tokenURI(uint256 _tokenId)
public
view
override
returns (string memory)
| function tokenURI(uint256 _tokenId)
public
view
override
returns (string memory)
| 111 |
117 | // Transfer equal tokens amount to multiple addresses | contract MultiTransferTokenEqual is Pausable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/// @notice Send equal ERC20 tokens amount to multiple contracts
///
/// @param _token The token to send
/// @param _addresses Array of addresses to send to
/// @param _amount Tokens amount to send to each address
function multiTransferTokenEqual_71p(
address _token,
address[] calldata _addresses,
uint256 _amount
) payable external whenNotPaused
{
// assert(_addresses.length <= 255);
uint256 _amountSum = _amount.mul(_addresses.length);
IERC20 token = IERC20(_token);
token.safeTransferFrom(msg.sender, address(this), _amountSum);
for (uint8 i; i < _addresses.length; i++) {
token.transfer(_addresses[i], _amount);
}
}
}
| contract MultiTransferTokenEqual is Pausable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/// @notice Send equal ERC20 tokens amount to multiple contracts
///
/// @param _token The token to send
/// @param _addresses Array of addresses to send to
/// @param _amount Tokens amount to send to each address
function multiTransferTokenEqual_71p(
address _token,
address[] calldata _addresses,
uint256 _amount
) payable external whenNotPaused
{
// assert(_addresses.length <= 255);
uint256 _amountSum = _amount.mul(_addresses.length);
IERC20 token = IERC20(_token);
token.safeTransferFrom(msg.sender, address(this), _amountSum);
for (uint8 i; i < _addresses.length; i++) {
token.transfer(_addresses[i], _amount);
}
}
}
| 21,461 |
95 | // OPERATOR | function setArbiters(address _icoRoundAddress, address[] _arbiters) only(owner) public {
for (uint i = 0; i < _arbiters.length ; i++) {
arbiterPool[_icoRoundAddress][_arbiters[i]] = true;
}
}
| function setArbiters(address _icoRoundAddress, address[] _arbiters) only(owner) public {
for (uint i = 0; i < _arbiters.length ; i++) {
arbiterPool[_icoRoundAddress][_arbiters[i]] = true;
}
}
| 49,975 |
73 | // Pick out the remaining bytes. | uint256 mask;
unchecked {
mask = 256**(32 - (_length % 32)) - 1;
}
| uint256 mask;
unchecked {
mask = 256**(32 - (_length % 32)) - 1;
}
| 23,782 |
6 | // Every bottle of wine increases the grapes to make next by 10 | grapesToProduceBottle = SafeMath.add(SafeMath.mul(864000, wineBottles), grapesToProduceBottle);
wineInCellar[msg.sender] = SafeMath.add(wineInCellar[msg.sender],wineBottles);
| grapesToProduceBottle = SafeMath.add(SafeMath.mul(864000, wineBottles), grapesToProduceBottle);
wineInCellar[msg.sender] = SafeMath.add(wineInCellar[msg.sender],wineBottles);
| 36,581 |
83 | // //Migrate AAVE `aToken` underlying `amount` into COMP/CREAM `cToken` for benefit of `to` by batching calls to `aave` and `cToken`. | function aaveToCompound(address aToken, address cToken, address to, uint256 amount) external {
IERC20(aToken).safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` `aToken` `amount` into this contract
address underlying = IAaveBridge(aToken).UNDERLYING_ASSET_ADDRESS(); // sanity check for `underlying` token
aave.withdraw(underlying, amount, address(this)); // burn deposited `aToken` from `aave` into `underlying`
ICompoundBridge(cToken).mint(amount); // stake `underlying` into `cToken`
IERC20(cToken).safeTransfer(to, IERC20(cToken).balanceOf(address(this))); // transfer resulting `cToken` to `to`
}
| function aaveToCompound(address aToken, address cToken, address to, uint256 amount) external {
IERC20(aToken).safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` `aToken` `amount` into this contract
address underlying = IAaveBridge(aToken).UNDERLYING_ASSET_ADDRESS(); // sanity check for `underlying` token
aave.withdraw(underlying, amount, address(this)); // burn deposited `aToken` from `aave` into `underlying`
ICompoundBridge(cToken).mint(amount); // stake `underlying` into `cToken`
IERC20(cToken).safeTransfer(to, IERC20(cToken).balanceOf(address(this))); // transfer resulting `cToken` to `to`
}
| 28,455 |
6 | // Set LenderPoolAddress linked to the contract to a new lenderPoolAddressCan only be called by the owner / | function setLenderPoolAddress(
address stableAddress,
address lenderPoolAddress
| function setLenderPoolAddress(
address stableAddress,
address lenderPoolAddress
| 17,155 |
26 | // to affiliates / | function set_new_affiliateSplit(uint256 _new_affiliateSplit) external onlyOwner {
require(_new_affiliateSplit <= 100, "Affiliate Split Value not allowed");
affiliateSplit = _new_affiliateSplit;
}
| function set_new_affiliateSplit(uint256 _new_affiliateSplit) external onlyOwner {
require(_new_affiliateSplit <= 100, "Affiliate Split Value not allowed");
affiliateSplit = _new_affiliateSplit;
}
| 24,690 |
229 | // Deposit NFT tokens to Interstellar for MILK allocation. | function depositFarmingToken(uint256 _pid, uint256 _amount) public {
require(lpToken.balanceOf(msg.sender) > 0); // todo - сделать проверку что пользователь залочил LP токены Shake/ETH - pid 10
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accMilkPerShare).div(1e12).sub(user.rewardDebt);
safeMilkTransfer(msg.sender, pending);
}
NFTToken.safeTransferFrom(address(msg.sender), address(this), pool.nftId, _amount, ""); //
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accMilkPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| function depositFarmingToken(uint256 _pid, uint256 _amount) public {
require(lpToken.balanceOf(msg.sender) > 0); // todo - сделать проверку что пользователь залочил LP токены Shake/ETH - pid 10
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accMilkPerShare).div(1e12).sub(user.rewardDebt);
safeMilkTransfer(msg.sender, pending);
}
NFTToken.safeTransferFrom(address(msg.sender), address(this), pool.nftId, _amount, ""); //
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accMilkPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| 23,245 |
35 | // transferWithLock is only for airdrop or marketing purpose |
function transferWithLock(address _to, uint256 _value, uint256 _time) onlyOwner transferParamsValidation(msg.sender, _to, _value) external returns (bool)
|
function transferWithLock(address _to, uint256 _value, uint256 _time) onlyOwner transferParamsValidation(msg.sender, _to, _value) external returns (bool)
| 6,454 |
119 | // - _id - multiplier's id (0-4)- return value of multiplier/ | function getValueMultiplier(uint256 _id) public view returns(uint256) {
return multipliers[_id];
}
| function getValueMultiplier(uint256 _id) public view returns(uint256) {
return multipliers[_id];
}
| 31,108 |
108 | // Amount of tokens available, in EXTwei | uint256 public remainingSupply;
| uint256 public remainingSupply;
| 14,104 |
71 | // Approve or remove `operator` as an operator for the caller.Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. Requirements: - The `operator` cannot be the caller. Emits an {ApprovalForAll} event. / | function setApprovalForAll(address operator, bool _approved) external;
| function setApprovalForAll(address operator, bool _approved) external;
| 33,410 |
3 | // Replaces any existing stored metadata.To expose the setter externally with modifier access control, create a new method invoking _setMetaData. / | function _setMetaData(string calldata data) internal {
_metaData = data;
emit MetaDataUpdate(data, _msgSender());
}
| function _setMetaData(string calldata data) internal {
_metaData = data;
emit MetaDataUpdate(data, _msgSender());
}
| 46,298 |
220 | // transfer interest in tokens | _token.safeTransfer(to, tokens);
emit InterestPaid(to, depositId, tokens);
| _token.safeTransfer(to, tokens);
emit InterestPaid(to, depositId, tokens);
| 22,155 |
84 | // Max tx, dividend threshold and tax variables | uint256 public maxWallet;
uint256 public swapTokensAtAmount;
uint256 public sellRewardsFee;
uint256 public sellDeadFees;
uint256 public sellMarketingFees;
uint256 public sellLiquidityFee;
uint256 public buyDeadFees;
uint256 public buyMarketingFees;
uint256 public buyLiquidityFee;
uint256 public buyRewardsFee;
| uint256 public maxWallet;
uint256 public swapTokensAtAmount;
uint256 public sellRewardsFee;
uint256 public sellDeadFees;
uint256 public sellMarketingFees;
uint256 public sellLiquidityFee;
uint256 public buyDeadFees;
uint256 public buyMarketingFees;
uint256 public buyLiquidityFee;
uint256 public buyRewardsFee;
| 31,415 |
57 | // View how much the Vault would increase this Strategy's borrow limit,based on its present performance (since its last report). Can be used todetermine expectedReturn in your Strategy. / | function creditAvailable() external view returns (uint256);
| function creditAvailable() external view returns (uint256);
| 15,603 |
5 | // initializes bond parameters_controlVariable uint_vestingTerm uint_minimumPrice uint_maxPayout uint_fee uint_maxDebt uint_initialDebt uint / | function initializeBondTerms(
uint _controlVariable,
uint _vestingTerm,
uint _minimumPrice,
uint _maxPayout,
uint _fee,
uint _maxDebt,
uint _initialDebt
| function initializeBondTerms(
uint _controlVariable,
uint _vestingTerm,
uint _minimumPrice,
uint _maxPayout,
uint _fee,
uint _maxDebt,
uint _initialDebt
| 37,165 |
17 | // Contains 512-bit math functions/Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision/Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits/Adapted to pragma solidity 0.8 from https:github.com/Uniswap/v3-core/blob/main/contracts/libraries/FullMath.sol | library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = (0 - denominator) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
| library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = (0 - denominator) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
| 19,478 |
15 | // An event emitted when a proposal has been executed in the NounsDAOExecutor | event ProposalExecuted(uint256 id);
| event ProposalExecuted(uint256 id);
| 41,583 |
4 | // https:github.com/makerdao/dss/blob/master/src/jug.sol | interface JugAbstract {
function wards(address) external view returns (uint256);
function rely(address) external;
function deny(address) external;
function ilks(bytes32) external view returns (uint256, uint256);
function vat() external view returns (address);
function vow() external view returns (address);
function base() external view returns (address);
function init(bytes32) external;
function file(bytes32, bytes32, uint256) external;
function file(bytes32, uint256) external;
function file(bytes32, address) external;
function drip(bytes32) external returns (uint256);
}
| interface JugAbstract {
function wards(address) external view returns (uint256);
function rely(address) external;
function deny(address) external;
function ilks(bytes32) external view returns (uint256, uint256);
function vat() external view returns (address);
function vow() external view returns (address);
function base() external view returns (address);
function init(bytes32) external;
function file(bytes32, bytes32, uint256) external;
function file(bytes32, uint256) external;
function file(bytes32, address) external;
function drip(bytes32) external returns (uint256);
}
| 22,612 |
8 | // SafeMath Unsigned math operations with safety checks that revert on error. / | library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @dev Adds two unsigned integers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
| library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @dev Adds two unsigned integers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
| 7,818 |
27 | // add lpToken to the lpTokens enumerable set | lpTokens.add(address(_lpToken));
emit Add(pid, _lpToken, _boostedRewarder);
| lpTokens.add(address(_lpToken));
emit Add(pid, _lpToken, _boostedRewarder);
| 30,292 |
54 | // Adds the vesting id corresponding to the receiver | receiverIDs[_receiver].push(totalVestings);
require(_transfer(msg.sender, address(this), _amount));
return true;
| receiverIDs[_receiver].push(totalVestings);
require(_transfer(msg.sender, address(this), _amount));
return true;
| 32,015 |
12 | // Fetches the current token/eth price accumulator from uniswap. / | // function currentCumulativePrice(TokenConfig memory config) internal view returns (uint) {
// (uint cumulativePrice0, uint cumulativePrice1,) = UniswapV2OracleLibrary.currentCumulativePrices(config.uniswapMarket);
// if (config.isUniswapReversed) {
// return cumulativePrice1;
// } else {
// return cumulativePrice0;
// }
// }
| // function currentCumulativePrice(TokenConfig memory config) internal view returns (uint) {
// (uint cumulativePrice0, uint cumulativePrice1,) = UniswapV2OracleLibrary.currentCumulativePrices(config.uniswapMarket);
// if (config.isUniswapReversed) {
// return cumulativePrice1;
// } else {
// return cumulativePrice0;
// }
// }
| 54,835 |
143 | // Configurable address for defaultOwner. defaultOwner account to which newly minted tokens are allocated. / | function setDefaultOwner(address defaultOwner) onlyValidSender external {
_defaultOwner = defaultOwner;
}
| function setDefaultOwner(address defaultOwner) onlyValidSender external {
_defaultOwner = defaultOwner;
}
| 8,412 |
337 | // assign the new Lock | locks[newLock] = LockBalances({
deployed: true,
totalSales: 0,
yieldedDiscountTokens: 0
});
| locks[newLock] = LockBalances({
deployed: true,
totalSales: 0,
yieldedDiscountTokens: 0
});
| 13,546 |
16 | // In case of an attmept to delete a non-existent outflow, we should just do nothing. | if (oldFlowRate == int96(0) && newFlowRate == int96(0)) return;
| if (oldFlowRate == int96(0) && newFlowRate == int96(0)) return;
| 988 |
297 | // CryptoFlyz contract Extends ERC721 Non-Fungible Token Standard basic implementation / | contract CryptoFlyz is ERC721, Ownable, PaymentSplitter {
bool public mintIsActive = true;
uint256 public tokenPrice = 0;
uint256 public publicTokenPrice = 42000000000000000;
uint256 public constant maxTokens = 7025;
uint256 public constant maxMintsPerTx = 10;
string private _contractURI;
uint256 public tokenCount=1;
bool public devMintLocked = false;
bool private initialized = false;
bool public publicMintLocked = true;
//Parent NFT Contract
//mainnet address
//address public nftAddress = 0x1cb1a5e65610aeff2551a50f76a87a7d3fb649c6;
//rinkeby address
address public nftAddress = 0x70BC4cCb9bC9eF1B7E9dc465a38EEbc5d73740FB;
nftInterface nftContract = nftInterface(nftAddress);
constructor() public ERC721("CryptoFlyz", "FLYZ") {}
function initializePaymentSplitter (address[] memory payees, uint256[] memory shares_) external onlyOwner {
require (!initialized, "Payment Split Already Initialized!");
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
initialized=true;
}
//Set Base URI
function setBaseURI(string memory _baseURI) external onlyOwner {
_setBaseURI(_baseURI);
}
function flipMintState() public onlyOwner {
mintIsActive = !mintIsActive;
}
function setContractURI(string memory contractURI_) external onlyOwner {
_contractURI = contractURI_;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
//Private sale minting (reserved for Toadz)
function mintWithToad(uint256 nftId) external {
require(mintIsActive, "CryptoFlyz must be active to mint");
require(tokenCount - 1 + 1 <= maxTokens, "Minting would exceed supply");
require(nftContract.ownerOf(nftId) == msg.sender, "Not the owner of this Toad");
if (nftId >= 1000000) {
uint256 newID = SafeMath.div(nftId, 1000000);
newID = SafeMath.add(newID, 6969);
require(!_exists(newID), "This Toad has already been used.");
_safeMint(msg.sender, newID);
tokenCount++;
} else {
require(!_exists(nftId), "This Toad has already been used.");
_safeMint(msg.sender, nftId);
tokenCount++;
}
}
function multiMintWithnft(uint256 [] memory nftIds) public {
require(mintIsActive, "CryptoFlyz must be active to mint");
for (uint i=0; i< nftIds.length; i++) {
require(nftContract.ownerOf(nftIds[i]) == msg.sender, "Not the owner of this Toad");
if (nftIds[i] >= 1000000) {
uint256 newID = SafeMath.div(nftIds[i], 1000000);
newID = SafeMath.add(newID, 6969);
if(_exists(newID)) {
continue;
} else {
_mint(msg.sender, newID);
tokenCount++;
}
} else {
if(_exists(nftIds[i])) {
continue;
} else {
_mint(msg.sender, nftIds[i]);
tokenCount++;
}
}
}
}
function mintAllToadz() external {
require(mintIsActive, "CryptoFlyz must be active to mint");
uint256 balance = nftContract.balanceOf(msg.sender);
uint256 [] storage lot;
for (uint i = 0; i < balance; i++) {
lot.push(nftContract.tokenOfOwnerByIndex(msg.sender, i));
}
multiMintWithnft(lot);
}
//Dev mint special tokens
function mintSpecial(uint256 [] memory specialId) external onlyOwner {
require (!devMintLocked, "Dev Mint Permanently Locked");
for (uint256 i = 0; i < specialId.length; i++) {
require (specialId[i]!=0);
_mint(msg.sender,specialId[i]);
}
}
function lockDevMint() public onlyOwner {
devMintLocked = true;
}
function unlockPublicMint() public onlyOwner {
publicMintLocked = false;
}
function updatePublicPrice(uint256 newPrice) public onlyOwner {
publicTokenPrice = newPrice;
}
function mintPublic(uint256 quantity) external payable {
require(quantity <= maxMintsPerTx, "trying to mint too many at a time!");
require(tokenCount - 1 + quantity <= maxTokens, "minting this many would exceed supply");
require(msg.value >= publicTokenPrice * quantity, "not enough ether sent!");
require(msg.sender == tx.origin, "no contracts please!");
require(!publicMintLocked, "minting is not open to the public yet!");
uint256 i = 0;
for (uint256 j = 1; j < maxTokens + 1; j++) {
if (i == quantity) {
break;
}
else {
if (!_exists(j) && i < quantity) {
_safeMint(msg.sender, j);
i++;
tokenCount++;
}
}
}
}
function multiMintPublic(uint256 [] memory nftIds, uint256 quantity) external payable {
require(quantity <= maxMintsPerTx, "trying to mint too many at a time!");
require(tokenCount - 1 + quantity <= maxTokens, "minting this many would exceed supply");
require(msg.value >= publicTokenPrice * quantity, "not enough ether sent!");
require(msg.sender == tx.origin, "no contracts please!");
require(!publicMintLocked, "minting is not open to the public yet!");
for (uint i=0; i< nftIds.length; i++) {
if (nftIds[i] >= 1000000) {
uint256 newID = SafeMath.div(nftIds[i], 1000000);
newID = SafeMath.add(newID, 6969);
if(_exists(newID)) {
continue;
} else {
_safeMint(msg.sender, newID);
tokenCount++;
}
} else {
if(_exists(nftIds[i])) {
continue;
} else {
_safeMint(msg.sender, nftIds[i]);
tokenCount++;
}
}
}
}
} | contract CryptoFlyz is ERC721, Ownable, PaymentSplitter {
bool public mintIsActive = true;
uint256 public tokenPrice = 0;
uint256 public publicTokenPrice = 42000000000000000;
uint256 public constant maxTokens = 7025;
uint256 public constant maxMintsPerTx = 10;
string private _contractURI;
uint256 public tokenCount=1;
bool public devMintLocked = false;
bool private initialized = false;
bool public publicMintLocked = true;
//Parent NFT Contract
//mainnet address
//address public nftAddress = 0x1cb1a5e65610aeff2551a50f76a87a7d3fb649c6;
//rinkeby address
address public nftAddress = 0x70BC4cCb9bC9eF1B7E9dc465a38EEbc5d73740FB;
nftInterface nftContract = nftInterface(nftAddress);
constructor() public ERC721("CryptoFlyz", "FLYZ") {}
function initializePaymentSplitter (address[] memory payees, uint256[] memory shares_) external onlyOwner {
require (!initialized, "Payment Split Already Initialized!");
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
initialized=true;
}
//Set Base URI
function setBaseURI(string memory _baseURI) external onlyOwner {
_setBaseURI(_baseURI);
}
function flipMintState() public onlyOwner {
mintIsActive = !mintIsActive;
}
function setContractURI(string memory contractURI_) external onlyOwner {
_contractURI = contractURI_;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
//Private sale minting (reserved for Toadz)
function mintWithToad(uint256 nftId) external {
require(mintIsActive, "CryptoFlyz must be active to mint");
require(tokenCount - 1 + 1 <= maxTokens, "Minting would exceed supply");
require(nftContract.ownerOf(nftId) == msg.sender, "Not the owner of this Toad");
if (nftId >= 1000000) {
uint256 newID = SafeMath.div(nftId, 1000000);
newID = SafeMath.add(newID, 6969);
require(!_exists(newID), "This Toad has already been used.");
_safeMint(msg.sender, newID);
tokenCount++;
} else {
require(!_exists(nftId), "This Toad has already been used.");
_safeMint(msg.sender, nftId);
tokenCount++;
}
}
function multiMintWithnft(uint256 [] memory nftIds) public {
require(mintIsActive, "CryptoFlyz must be active to mint");
for (uint i=0; i< nftIds.length; i++) {
require(nftContract.ownerOf(nftIds[i]) == msg.sender, "Not the owner of this Toad");
if (nftIds[i] >= 1000000) {
uint256 newID = SafeMath.div(nftIds[i], 1000000);
newID = SafeMath.add(newID, 6969);
if(_exists(newID)) {
continue;
} else {
_mint(msg.sender, newID);
tokenCount++;
}
} else {
if(_exists(nftIds[i])) {
continue;
} else {
_mint(msg.sender, nftIds[i]);
tokenCount++;
}
}
}
}
function mintAllToadz() external {
require(mintIsActive, "CryptoFlyz must be active to mint");
uint256 balance = nftContract.balanceOf(msg.sender);
uint256 [] storage lot;
for (uint i = 0; i < balance; i++) {
lot.push(nftContract.tokenOfOwnerByIndex(msg.sender, i));
}
multiMintWithnft(lot);
}
//Dev mint special tokens
function mintSpecial(uint256 [] memory specialId) external onlyOwner {
require (!devMintLocked, "Dev Mint Permanently Locked");
for (uint256 i = 0; i < specialId.length; i++) {
require (specialId[i]!=0);
_mint(msg.sender,specialId[i]);
}
}
function lockDevMint() public onlyOwner {
devMintLocked = true;
}
function unlockPublicMint() public onlyOwner {
publicMintLocked = false;
}
function updatePublicPrice(uint256 newPrice) public onlyOwner {
publicTokenPrice = newPrice;
}
function mintPublic(uint256 quantity) external payable {
require(quantity <= maxMintsPerTx, "trying to mint too many at a time!");
require(tokenCount - 1 + quantity <= maxTokens, "minting this many would exceed supply");
require(msg.value >= publicTokenPrice * quantity, "not enough ether sent!");
require(msg.sender == tx.origin, "no contracts please!");
require(!publicMintLocked, "minting is not open to the public yet!");
uint256 i = 0;
for (uint256 j = 1; j < maxTokens + 1; j++) {
if (i == quantity) {
break;
}
else {
if (!_exists(j) && i < quantity) {
_safeMint(msg.sender, j);
i++;
tokenCount++;
}
}
}
}
function multiMintPublic(uint256 [] memory nftIds, uint256 quantity) external payable {
require(quantity <= maxMintsPerTx, "trying to mint too many at a time!");
require(tokenCount - 1 + quantity <= maxTokens, "minting this many would exceed supply");
require(msg.value >= publicTokenPrice * quantity, "not enough ether sent!");
require(msg.sender == tx.origin, "no contracts please!");
require(!publicMintLocked, "minting is not open to the public yet!");
for (uint i=0; i< nftIds.length; i++) {
if (nftIds[i] >= 1000000) {
uint256 newID = SafeMath.div(nftIds[i], 1000000);
newID = SafeMath.add(newID, 6969);
if(_exists(newID)) {
continue;
} else {
_safeMint(msg.sender, newID);
tokenCount++;
}
} else {
if(_exists(nftIds[i])) {
continue;
} else {
_safeMint(msg.sender, nftIds[i]);
tokenCount++;
}
}
}
}
} | 72,352 |
36 | // Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once FATE is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's bug-free. God bless. | contract FateRewardController is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of FATEs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accumulatedFatePerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accumulatedFatePerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. FATEs to distribute per block.
uint256 lastRewardBlock; // Last block number that FATEs distribution occurs.
uint256 accumulatedFatePerShare; // Accumulated FATEs per share, times 1e12. See below.
}
FateToken public fate;
address public vault;
// The emission scheduler that calculates fate per block over a given period
RewardSchedule public emissionSchedule;
// Bonus multiplier for early fate LP deposits.
uint256 public constant BONUS_MULTIPLIER = 10;
// The migrator contract. It has a lot of power. Can only be set through governance (owner).
IMigratorChef public migrator;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when FATE mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event ClaimRewards(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmissionScheduleSet(address indexed emissionSchedule);
event VaultSet(address indexed emissionSchedule);
constructor(
FateToken _fate,
RewardSchedule _emissionSchedule,
address _vault
) public {
fate = _fate;
emissionSchedule = _emissionSchedule;
vault = _vault;
startBlock = block.number;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(
uint256 _allocPoint,
IERC20 _lpToken,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(
PoolInfo({
lpToken : _lpToken,
allocPoint : _allocPoint,
lastRewardBlock : lastRewardBlock,
accumulatedFatePerShare : 0
})
);
}
// Update the given pool's FATE allocation point. Can only be called by the owner.
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Set the migrator contract. Can only be called by the owner.
function setMigrator(IMigratorChef _migrator) public onlyOwner {
migrator = _migrator;
}
// Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
function migrate(uint256 _pid) public {
require(address(migrator) != address(0), "migrate: no migrator");
PoolInfo storage pool = poolInfo[_pid];
IERC20 lpToken = pool.lpToken;
uint256 bal = lpToken.balanceOf(address(this));
lpToken.safeApprove(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(lpToken);
require(bal == newLpToken.balanceOf(address(this)), "migrate: bad");
pool.lpToken = newLpToken;
}
// View function to see pending FATE tokens on frontend.
function pendingFate(uint256 _pid, address _user)
external
view
returns (uint256)
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accumulatedFatePerShare = pool.accumulatedFatePerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 fatePerBlock = emissionSchedule.getFatePerBlock(startBlock, pool.lastRewardBlock, block.number);
uint256 fateReward = fatePerBlock.mul(pool.allocPoint).div(totalAllocPoint);
accumulatedFatePerShare = accumulatedFatePerShare.add(fateReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accumulatedFatePerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward variables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
function getNewRewardPerBlock(uint pid1) public view returns (uint) {
uint256 fatePerBlock = emissionSchedule.getFatePerBlock(startBlock, block.number - 1, block.number);
if (pid1 == 0) {
return fatePerBlock;
} else {
return fatePerBlock.mul(poolInfo[pid1 - 1].allocPoint).div(totalAllocPoint);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 fatePerBlock = emissionSchedule.getFatePerBlock(startBlock, pool.lastRewardBlock, block.number);
uint256 fateReward = fatePerBlock.mul(pool.allocPoint).div(totalAllocPoint);
if (fateReward > 0) {
fate.transferFrom(vault, address(this), fateReward);
pool.accumulatedFatePerShare = pool.accumulatedFatePerShare.add(fateReward.mul(1e12).div(lpSupply));
}
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for FATE allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accumulatedFatePerShare).div(1e12).sub(user.rewardDebt);
safeFateTransfer(msg.sender, pending);
emit ClaimRewards(msg.sender, _pid, pending);
}
pool.lpToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accumulatedFatePerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accumulatedFatePerShare).div(1e12).sub(user.rewardDebt);
safeFateTransfer(msg.sender, pending);
emit ClaimRewards(msg.sender, _pid, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accumulatedFatePerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// claim any pending rewards from this pool, from msg.sender
function claimReward(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accumulatedFatePerShare).div(1e12).sub(user.rewardDebt);
safeFateTransfer(msg.sender, pending);
emit ClaimRewards(msg.sender, _pid, pending);
user.rewardDebt = user.amount.mul(pool.accumulatedFatePerShare).div(1e12);
}
// claim any pending rewards from this pool, from msg.sender
function claimRewards(uint256[] calldata _pids) external {
for (uint i = 0; i < _pids.length; i++) {
claimReward(_pids[i]);
}
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe fate transfer function, just in case if rounding error causes pool to not have enough FATEs.
function safeFateTransfer(address _to, uint256 _amount) internal {
uint256 fateBal = fate.balanceOf(address(this));
if (_amount > fateBal) {
fate.transfer(_to, fateBal);
} else {
fate.transfer(_to, _amount);
}
}
function setEmissionSchedule(
RewardSchedule _emissionSchedule
)
public
onlyOwner {
// pro-rate the pools to the current block, before changing the schedule
massUpdatePools();
emissionSchedule = _emissionSchedule;
emit EmissionScheduleSet(address(_emissionSchedule));
}
function setVault(
address _vault
)
public
onlyOwner {
// pro-rate the pools to the current block, before changing the schedule
vault = _vault;
emit VaultSet(_vault);
}
}
| contract FateRewardController is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of FATEs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accumulatedFatePerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accumulatedFatePerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. FATEs to distribute per block.
uint256 lastRewardBlock; // Last block number that FATEs distribution occurs.
uint256 accumulatedFatePerShare; // Accumulated FATEs per share, times 1e12. See below.
}
FateToken public fate;
address public vault;
// The emission scheduler that calculates fate per block over a given period
RewardSchedule public emissionSchedule;
// Bonus multiplier for early fate LP deposits.
uint256 public constant BONUS_MULTIPLIER = 10;
// The migrator contract. It has a lot of power. Can only be set through governance (owner).
IMigratorChef public migrator;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when FATE mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event ClaimRewards(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmissionScheduleSet(address indexed emissionSchedule);
event VaultSet(address indexed emissionSchedule);
constructor(
FateToken _fate,
RewardSchedule _emissionSchedule,
address _vault
) public {
fate = _fate;
emissionSchedule = _emissionSchedule;
vault = _vault;
startBlock = block.number;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(
uint256 _allocPoint,
IERC20 _lpToken,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(
PoolInfo({
lpToken : _lpToken,
allocPoint : _allocPoint,
lastRewardBlock : lastRewardBlock,
accumulatedFatePerShare : 0
})
);
}
// Update the given pool's FATE allocation point. Can only be called by the owner.
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Set the migrator contract. Can only be called by the owner.
function setMigrator(IMigratorChef _migrator) public onlyOwner {
migrator = _migrator;
}
// Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
function migrate(uint256 _pid) public {
require(address(migrator) != address(0), "migrate: no migrator");
PoolInfo storage pool = poolInfo[_pid];
IERC20 lpToken = pool.lpToken;
uint256 bal = lpToken.balanceOf(address(this));
lpToken.safeApprove(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(lpToken);
require(bal == newLpToken.balanceOf(address(this)), "migrate: bad");
pool.lpToken = newLpToken;
}
// View function to see pending FATE tokens on frontend.
function pendingFate(uint256 _pid, address _user)
external
view
returns (uint256)
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accumulatedFatePerShare = pool.accumulatedFatePerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 fatePerBlock = emissionSchedule.getFatePerBlock(startBlock, pool.lastRewardBlock, block.number);
uint256 fateReward = fatePerBlock.mul(pool.allocPoint).div(totalAllocPoint);
accumulatedFatePerShare = accumulatedFatePerShare.add(fateReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accumulatedFatePerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward variables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
function getNewRewardPerBlock(uint pid1) public view returns (uint) {
uint256 fatePerBlock = emissionSchedule.getFatePerBlock(startBlock, block.number - 1, block.number);
if (pid1 == 0) {
return fatePerBlock;
} else {
return fatePerBlock.mul(poolInfo[pid1 - 1].allocPoint).div(totalAllocPoint);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 fatePerBlock = emissionSchedule.getFatePerBlock(startBlock, pool.lastRewardBlock, block.number);
uint256 fateReward = fatePerBlock.mul(pool.allocPoint).div(totalAllocPoint);
if (fateReward > 0) {
fate.transferFrom(vault, address(this), fateReward);
pool.accumulatedFatePerShare = pool.accumulatedFatePerShare.add(fateReward.mul(1e12).div(lpSupply));
}
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for FATE allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accumulatedFatePerShare).div(1e12).sub(user.rewardDebt);
safeFateTransfer(msg.sender, pending);
emit ClaimRewards(msg.sender, _pid, pending);
}
pool.lpToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accumulatedFatePerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accumulatedFatePerShare).div(1e12).sub(user.rewardDebt);
safeFateTransfer(msg.sender, pending);
emit ClaimRewards(msg.sender, _pid, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accumulatedFatePerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// claim any pending rewards from this pool, from msg.sender
function claimReward(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accumulatedFatePerShare).div(1e12).sub(user.rewardDebt);
safeFateTransfer(msg.sender, pending);
emit ClaimRewards(msg.sender, _pid, pending);
user.rewardDebt = user.amount.mul(pool.accumulatedFatePerShare).div(1e12);
}
// claim any pending rewards from this pool, from msg.sender
function claimRewards(uint256[] calldata _pids) external {
for (uint i = 0; i < _pids.length; i++) {
claimReward(_pids[i]);
}
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe fate transfer function, just in case if rounding error causes pool to not have enough FATEs.
function safeFateTransfer(address _to, uint256 _amount) internal {
uint256 fateBal = fate.balanceOf(address(this));
if (_amount > fateBal) {
fate.transfer(_to, fateBal);
} else {
fate.transfer(_to, _amount);
}
}
function setEmissionSchedule(
RewardSchedule _emissionSchedule
)
public
onlyOwner {
// pro-rate the pools to the current block, before changing the schedule
massUpdatePools();
emissionSchedule = _emissionSchedule;
emit EmissionScheduleSet(address(_emissionSchedule));
}
function setVault(
address _vault
)
public
onlyOwner {
// pro-rate the pools to the current block, before changing the schedule
vault = _vault;
emit VaultSet(_vault);
}
}
| 37,159 |
88 | // The pulled forward user's total investment amount | uint256 allPrevInvestmentTotals = currentUser
.epochTotals[currentUser.lastEpochUpdate]
.allPrevInvestmentTotals;
| uint256 allPrevInvestmentTotals = currentUser
.epochTotals[currentUser.lastEpochUpdate]
.allPrevInvestmentTotals;
| 46,437 |
550 | // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag Check setRebaseLag comments for more details. Natural number, no decimal places. | uint256 public rebaseLag;
| uint256 public rebaseLag;
| 5,988 |
37 | // The Smart Contract which stores the addresses of all the authorized Converts portal | PermittedConvertsInterface public permittedConverts;
| PermittedConvertsInterface public permittedConverts;
| 9,978 |
127 | // Convert signed 64.64 fixed point number into signed 128.128 fixed pointnumber.x signed 64.64-bit fixed point numberreturn signed 128.128 fixed point number / | function to128x128 (int128 x) internal pure returns (int256) {
return int256 (x) << 64;
}
| function to128x128 (int128 x) internal pure returns (int256) {
return int256 (x) << 64;
}
| 10,731 |
91 | // Multisignature wallet - Allows multiple parties to agree on proposals beforeexecution. Stefan George - <stefan.george@consensys.net> NOTE: This contract has its limitations and is not viable for everymulti-signature setup. On a case by case basis, evaluate whether this is thecorrect contract for your use case.In particular, this contract doesn't have an atomic "add owners and increaserequirement" operation.This can be tricky, for example, in a situation where a MultiSig starts outowned by a single owner. Safely increasing the owner set and requirement atthe same time is not trivial. One way to work around this situation is tofirst add a second address controlled | contract MultiSig is Initializable, UUPSUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @notice The maximum number of multisig owners.
*/
uint256 public constant MAX_OWNER_COUNT = 50;
/**
* @notice The minimum time in seconds that must elapse before a proposal is executable.
*/
uint256 public immutable minDelay;
/**
* @notice The value used to mark a proposal as executed.
*/
uint256 internal constant DONE_TIMESTAMP = uint256(1);
/**
* @notice Used to keep track of a proposal.
* @param destinations The addresses at which the proposal is directed to.
* @param values The amounts of CELO involved.
* @param payloads The payloads of the proposal.
* @param timestampExecutable The timestamp at which a proposal becomes executable.
* @dev timestampExecutable is 0 if proposal is not yet scheduled or 1 if the proposal
* is executed.
* @param confirmations The list of confirmations. Keyed by the address that
* confirmed the proposal, whether or not the proposal is confirmed.
*/
struct Proposal {
address[] destinations;
uint256[] values;
bytes[] payloads;
uint256 timestampExecutable;
mapping(address => bool) confirmations;
}
/**
* @notice The delay that must elapse to be able to execute a proposal.
*/
uint256 public delay;
/**
* @notice Keyed by proposal ID, the Proposal record.
*/
mapping(uint256 => Proposal) public proposals;
/**
* @notice The set of addresses which are owners of the multisig.
*/
EnumerableSet.AddressSet private owners;
/**
* @notice The amount of confirmations required
* for a proposal to be fully confirmed.
*/
uint256 public required;
/**
* @notice The total count of proposals.
*/
uint256 public proposalCount;
/**
* @notice Used when a proposal is successfully confirmed.
* @param sender The address of the sender.
* @param proposalId The ID of the proposal.
*/
event ProposalConfirmed(address indexed sender, uint256 indexed proposalId);
/**
* @notice Used when a confirmation is successfully revoked.
* @param sender The address of the sender.
* @param proposalId The ID of the proposal.
*/
event ConfirmationRevoked(address indexed sender, uint256 indexed proposalId);
/**
* @notice Used when a proposal is successfully added.
* @param proposalId The ID of the proposal that was added.
*/
event ProposalAdded(uint256 indexed proposalId);
/**
* @notice Emitted when a confirmed proposal is successfully executed.
* @param proposalId The ID of the proposal that was executed.
* @param returnData The response that was recieved from the external call.
*/
event ProposalExecuted(uint256 indexed proposalId, bytes returnData);
/**
* @notice Emitted when one of the transactions that make up a proposal is successfully
* executed.
* @param index The index of the transaction within the proposal.
* @param proposalId The ID of the proposal.
* @param returnData The response that was recieved from the external call.
*/
event TransactionExecuted(uint256 index, uint256 indexed proposalId, bytes returnData);
/**
* @notice Emitted when CELO is sent to this contract.
* @param sender The account which sent the CELO.
* @param value The amount of CELO sent.
*/
event CeloDeposited(address indexed sender, uint256 value);
/**
* @notice Emitted when an Owner is successfully added as part of the multisig.
* @param owner The added owner.
*/
event OwnerAdded(address indexed owner);
/**
* @notice Emitted when an Owner is successfully removed from the multisig.
* @param owner The removed owner.
*/
event OwnerRemoved(address indexed owner);
/**
* @notice Emitted when the minimum amount of required confirmations is
* successfully changed.
* @param required The new required amount.
*/
event RequirementChanged(uint256 required);
/**
* @notice Emitted when a proposal is scheduled.
* @param proposalId The ID of the proposal that is scheduled.
*/
event ProposalScheduled(uint256 indexed proposalId);
/**
* @notice Used when `delay` is changed.
* @param delay The current delay value.
* @param newDelay The new delay value.
*/
event DelayChanged(uint256 delay, uint256 newDelay);
/**
* @notice Used when sender is not this contract in an `onlyWallet` function.
* @param account The sender which triggered the function.
*/
error SenderMustBeMultisigWallet(address account);
/**
* @notice Used when attempting to add an already existing owner.
* @param owner The address of the owner.
*/
error OwnerAlreadyExists(address owner);
/**
* @notice Used when an owner does not exist.
* @param owner The address of the owner.
*/
error OwnerDoesNotExist(address owner);
/**
* @notice Used when a proposal does not exist.
* @param proposalId The ID of the non-existent proposal.
*/
error ProposalDoesNotExist(uint256 proposalId);
/**
* @notice Used when a proposal is not confirmed by a given owner.
* @param proposalId The ID of the proposal that is not confirmed.
* @param owner The address of the owner which did not confirm the proposal.
*/
error ProposalNotConfirmed(uint256 proposalId, address owner);
/**
* @notice Used when a proposal is not fully confirmed.
* @dev A proposal is fully confirmed when the `required` threshold
* of confirmations has been met.
* @param proposalId The ID of the proposal that is not fully confirmed.
*/
error ProposalNotFullyConfirmed(uint256 proposalId);
/**
* @notice Used when a proposal is already confirmed by an owner.
* @param proposalId The ID of the proposal that is already confirmed.
* @param owner The address of the owner which confirmed the proposal.
*/
error ProposalAlreadyConfirmed(uint256 proposalId, address owner);
/**
* @notice Used when a proposal has been executed.
* @param proposalId The ID of the proposal that is already executed.
*/
error ProposalAlreadyExecuted(uint256 proposalId);
/**
* @notice Used when a passed address is address(0).
*/
error NullAddress();
/**
* @notice Used when the set threshold values for owner and minimum
* required confirmations are not met.
* @param ownerCount The count of owners.
* @param required The number of required confirmations.
*/
error InvalidRequirement(uint256 ownerCount, uint256 required);
/**
* @notice Used when attempting to remove the last owner.
* @param owner The last owner.
*/
error CannotRemoveLastOwner(address owner);
/**
* @notice Used when attempting to schedule an already scheduled proposal.
* @param proposalId The ID of the proposal which is already scheduled.
*/
error ProposalAlreadyScheduled(uint256 proposalId);
/**
* @notice Used when a proposal is not scheduled.
* @param proposalId The ID of the proposal which is not scheduled.
*/
error ProposalNotScheduled(uint256 proposalId);
/**
* @notice Used when a time lock delay is not reached.
* @param proposalId The ID of the proposal whose time lock has not been reached yet.
*/
error ProposalTimelockNotReached(uint256 proposalId);
/**
* @notice Used when a provided value is less than the minimum time lock delay.
* @param delay The insufficient delay.
*/
error InsufficientDelay(uint256 delay);
/**
* @notice Used when the sizes of the provided arrays params do not match
* when submitting a proposal.
*/
error ParamLengthsMismatch();
/**
* @notice Checks that only the multisig contract can execute a function.
*/
modifier onlyWallet() {
if (msg.sender != address(this)) {
revert SenderMustBeMultisigWallet(msg.sender);
}
_;
}
/**
* @notice Checks that an address is not a multisig owner.
* @param owner The address to check.
*/
modifier ownerDoesNotExist(address owner) {
if (owners.contains(owner)) {
revert OwnerAlreadyExists(owner);
}
_;
}
/**
* @notice Checks that an address is a multisig owner.
* @param owner The address to check.
*/
modifier ownerExists(address owner) {
if (!owners.contains(owner)) {
revert OwnerDoesNotExist(owner);
}
_;
}
/**
* @notice Checks that a proposal exists.
* @param proposalId The proposal ID to check.
*/
modifier proposalExists(uint256 proposalId) {
if (proposals[proposalId].destinations.length == 0) {
revert ProposalDoesNotExist(proposalId);
}
_;
}
/**
* @notice Checks that a proposal has been confirmed by a multisig owner.
* @param proposalId The proposal ID to check.
* @param owner The owner to check.
*/
modifier confirmed(uint256 proposalId, address owner) {
if (!proposals[proposalId].confirmations[owner]) {
revert ProposalNotConfirmed(proposalId, owner);
}
_;
}
/**
* @notice Checks that a proposal has not been confirmed by a multisig owner.
* @param proposalId The proposal ID to check.
* @param owner The owner to check.
*/
modifier notConfirmed(uint256 proposalId, address owner) {
if (proposals[proposalId].confirmations[owner]) {
revert ProposalAlreadyConfirmed(proposalId, owner);
}
_;
}
/**
* @notice Checks that a proposal has not been executed.
* @dev A proposal can only be executed after it is fully confirmed.
* @param proposalId The proposal ID to check.
*/
modifier notExecuted(uint256 proposalId) {
if (proposals[proposalId].timestampExecutable == DONE_TIMESTAMP) {
revert ProposalAlreadyExecuted(proposalId);
}
_;
}
/**
* @notice Checks that an address is not address(0).
* @param addr The address to check.
*/
modifier notNull(address addr) {
if (addr == address(0)) {
revert NullAddress();
}
_;
}
/**
* @notice Checks that each address in a batch of addresses are not address(0).
* @param _addresses The addresses to check.
*/
modifier notNullBatch(address[] memory _addresses) {
for (uint256 i = 0; i < _addresses.length; i++) {
if (_addresses[i] == address(0)) {
revert NullAddress();
}
}
_;
}
/**
* @notice Checks that the values passed for number of multisig owners and required
* confirmation are valid in comparison with the configured thresholds.
* @param ownerCount The owners count to check.
* @param requiredConfirmations The minimum number of confirmations required to consider
* a proposal as fully confirmed.
*/
modifier validRequirement(uint256 ownerCount, uint256 requiredConfirmations) {
if (
ownerCount > MAX_OWNER_COUNT ||
requiredConfirmations > ownerCount ||
requiredConfirmations == 0 ||
ownerCount == 0
) {
revert InvalidRequirement(ownerCount, requiredConfirmations);
}
_;
}
/**
* @notice Checks that a proposal is scheduled.
* @param proposalId The ID of the proposal to check.
*/
modifier scheduled(uint256 proposalId) {
if (!isScheduled(proposalId)) {
revert ProposalNotScheduled(proposalId);
}
_;
}
/**
* @notice Checks that a proposal is not scheduled.
* @param proposalId The ID of the proposal to check.
*/
modifier notScheduled(uint256 proposalId) {
if (isScheduled(proposalId)) {
revert ProposalAlreadyScheduled(proposalId);
}
_;
}
/**
* @notice Checks that a proposal's time lock has elapsed.
* @param proposalId The ID of the proposal to check.
*/
modifier timeLockReached(uint256 proposalId) {
if (!isProposalTimelockReached(proposalId)) {
revert ProposalTimelockNotReached(proposalId);
}
_;
}
/**
* @notice Checks that a proposal is fully confirmed.
* @param proposalId The ID of the proposal to check.
*/
modifier fullyConfirmed(uint256 proposalId) {
if (!isFullyConfirmed(proposalId)) {
revert ProposalNotFullyConfirmed(proposalId);
}
_;
}
/**
* @notice Sets `initialized` to true on implementation contracts.
* @param _minDelay The minimum time in seconds that must elapse before a
* proposal is executable.
*/
// solhint-disable-next-line no-empty-blocks
constructor(uint256 _minDelay) initializer {
minDelay = _minDelay;
}
receive() external payable {
if (msg.value > 0) {
emit CeloDeposited(msg.sender, msg.value);
}
}
/**
* @notice Bootstraps this contract with initial data.
* @dev This plays the role of a typical contract constructor. Sets initial owners and
* required number of confirmations. The initializer modifier ensures that this function
* is ONLY callable once.
* @param initialOwners The list of initial owners.
* @param requiredConfirmations The number of required confirmations for a proposal
* to be fully confirmed.
* @param _delay The delay that must elapse to be able to execute a proposal.
*/
function initialize(
address[] calldata initialOwners,
uint256 requiredConfirmations,
uint256 _delay
) external initializer validRequirement(initialOwners.length, requiredConfirmations) {
for (uint256 i = 0; i < initialOwners.length; i++) {
if (owners.contains(initialOwners[i])) {
revert OwnerAlreadyExists(initialOwners[i]);
}
if (initialOwners[i] == address(0)) {
revert NullAddress();
}
owners.add(initialOwners[i]);
emit OwnerAdded(initialOwners[i]);
}
_changeRequirement(requiredConfirmations);
_changeDelay(_delay);
}
/**
* @notice Adds a new multisig owner.
* @dev This call can only be made by this contract.
* @param owner The owner to add.
*/
function addOwner(address owner)
external
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length() + 1, required)
{
owners.add(owner);
emit OwnerAdded(owner);
}
/**
* @notice Removes an existing owner.
* @dev This call can only be made by this contract.
* @param owner The owner to remove.
*/
function removeOwner(address owner) external onlyWallet ownerExists(owner) {
if (owners.length() == 1) {
revert CannotRemoveLastOwner(owner);
}
owners.remove(owner);
if (required > owners.length()) {
// Readjust the required amount, since the list of total owners has reduced.
changeRequirement(owners.length());
}
emit OwnerRemoved(owner);
}
/**
* @notice Replaces an existing owner with a new owner.
* @dev This call can only be made by this contract.
* @param owner The owner to be replaced.
*/
function replaceOwner(address owner, address newOwner)
external
onlyWallet
ownerExists(owner)
notNull(newOwner)
ownerDoesNotExist(newOwner)
{
owners.remove(owner);
owners.add(newOwner);
emit OwnerRemoved(owner);
emit OwnerAdded(newOwner);
}
/**
* @notice Void a confirmation for a previously confirmed proposal.
* @param proposalId The ID of the proposal to be revoked.
*/
function revokeConfirmation(uint256 proposalId)
external
ownerExists(msg.sender)
confirmed(proposalId, msg.sender)
notExecuted(proposalId)
{
proposals[proposalId].confirmations[msg.sender] = false;
emit ConfirmationRevoked(msg.sender, proposalId);
}
/**
* @notice Creates a proposal and triggers the first confirmation on behalf of the
* proposal creator.
* @param destinations The addresses at which the proposal is target at.
* @param values The CELO values involved in the proposal if any.
* @param payloads The payloads of the proposal.
* @return proposalId Returns the ID of the proposal that gets generated.
*/
function submitProposal(
address[] calldata destinations,
uint256[] calldata values,
bytes[] calldata payloads
) external returns (uint256 proposalId) {
if (destinations.length != values.length) {
revert ParamLengthsMismatch();
}
if (destinations.length != payloads.length) {
revert ParamLengthsMismatch();
}
proposalId = addProposal(destinations, values, payloads);
confirmProposal(proposalId);
}
/**
* @notice Get the list of multisig owners.
* @return The list of owner addresses.
*/
function getOwners() external view returns (address[] memory) {
return owners.values();
}
/**
* @notice Gets the list of owners' addresses which have confirmed a given proposal.
* @param proposalId The ID of the proposal.
* @return The list of owner addresses.
*/
function getConfirmations(uint256 proposalId) external view returns (address[] memory) {
address[] memory confirmationsTemp = new address[](owners.length());
uint256 count = 0;
for (uint256 i = 0; i < owners.length(); i++) {
if (proposals[proposalId].confirmations[owners.at(i)]) {
confirmationsTemp[count] = owners.at(i);
count++;
}
}
address[] memory confirmingOwners = new address[](count);
for (uint256 i = 0; i < count; i++) {
confirmingOwners[i] = confirmationsTemp[i];
}
return confirmingOwners;
}
/**
* @notice Gets the destinations, values and payloads of a proposal.
* @param proposalId The ID of the proposal.
* @param destinations The addresses at which the proposal is target at.
* @param values The CELO values involved in the proposal if any.
* @param payloads The payloads of the proposal.
*/
function getProposal(uint256 proposalId)
external
view
returns (
address[] memory destinations,
uint256[] memory values,
bytes[] memory payloads
)
{
Proposal storage proposal = proposals[proposalId];
return (proposal.destinations, proposal.values, proposal.payloads);
}
/**
* @notice Changes the number of confirmations required to consider a proposal
* fully confirmed.
* @dev Proposal has to be sent by wallet.
* @param newRequired The new number of confirmations required.
*/
function changeRequirement(uint256 newRequired)
public
onlyWallet
validRequirement(owners.length(), newRequired)
{
_changeRequirement(newRequired);
}
/**
* @notice Changes the value of the delay that must
* elapse before a proposal can become executable.
* @dev Proposal has to be sent by wallet.
* @param newDelay The new delay value.
*/
function changeDelay(uint256 newDelay) public onlyWallet {
_changeDelay(newDelay);
}
/**
* @notice Confirms a proposal. A proposal is executed if this confirmation
* makes it fully confirmed.
* @param proposalId The ID of the proposal to confirm.
*/
function confirmProposal(uint256 proposalId)
public
ownerExists(msg.sender)
proposalExists(proposalId)
notConfirmed(proposalId, msg.sender)
{
proposals[proposalId].confirmations[msg.sender] = true;
emit ProposalConfirmed(msg.sender, proposalId);
if (isFullyConfirmed(proposalId)) {
scheduleProposal(proposalId);
}
}
/**
* @notice Schedules a proposal with a time lock.
* @param proposalId The ID of the proposal to confirm.
*/
function scheduleProposal(uint256 proposalId)
public
ownerExists(msg.sender)
notExecuted(proposalId)
{
schedule(proposalId);
emit ProposalScheduled(proposalId);
}
/**
* @notice Executes a proposal. A proposal is only executetable if it is fully confirmed,
* scheduled and the set delay has elapsed.
* @dev Any of the multisig owners can execute a given proposal, even though they may
* not have participated in its confirmation process.
*/
function executeProposal(uint256 proposalId)
public
scheduled(proposalId)
notExecuted(proposalId)
timeLockReached(proposalId)
{
Proposal storage proposal = proposals[proposalId];
proposal.timestampExecutable = DONE_TIMESTAMP;
for (uint256 i = 0; i < proposals[proposalId].destinations.length; i++) {
bytes memory returnData = ExternalCall.execute(
proposal.destinations[i],
proposal.values[i],
proposal.payloads[i]
);
emit TransactionExecuted(i, proposalId, returnData);
}
}
/**
* @notice Returns the timestamp at which a proposal becomes executable.
* @param proposalId The ID of the proposal.
* @return The timestamp at which the proposal becomes executable.
*/
function getTimestamp(uint256 proposalId) public view returns (uint256) {
return proposals[proposalId].timestampExecutable;
}
/**
* @notice Returns whether a proposal is scheduled.
* @param proposalId The ID of the proposal to check.
* @return Whether or not the proposal is scheduled.
*/
function isScheduled(uint256 proposalId) public view returns (bool) {
return getTimestamp(proposalId) > DONE_TIMESTAMP;
}
/**
* @notice Returns whether a proposal is executable or not.
* A proposal is executable if it is scheduled, the delay has elapsed
* and it is not yet executed.
* @param proposalId The ID of the proposal to check.
* @return Whether or not the time lock is reached.
*/
function isProposalTimelockReached(uint256 proposalId) public view returns (bool) {
uint256 timestamp = getTimestamp(proposalId);
return
timestamp <= block.timestamp &&
proposals[proposalId].timestampExecutable > DONE_TIMESTAMP;
}
/**
* @notice Checks that a proposal has been confirmed by at least the `required`
* number of owners.
* @param proposalId The ID of the proposal to check.
* @return Whether or not the proposal is confirmed by the minimum set of owners.
*/
function isFullyConfirmed(uint256 proposalId) public view returns (bool) {
uint256 count = 0;
for (uint256 i = 0; i < owners.length(); i++) {
if (proposals[proposalId].confirmations[owners.at(i)]) {
count++;
}
if (count == required) {
return true;
}
}
return false;
}
/**
* @notice Checks that a proposal is confirmed by an owner.
* @param proposalId The ID of the proposal to check.
* @param owner The address to check.
* @return Whether or not the proposal is confirmed by the given owner.
*/
function isConfirmedBy(uint256 proposalId, address owner) public view returns (bool) {
return proposals[proposalId].confirmations[owner];
}
/**
* @notice Checks that an address is a multisig owner.
* @param owner The address to check.
* @return Whether or not the address is a multisig owner.
*/
function isOwner(address owner) public view returns (bool) {
return owners.contains(owner);
}
/**
* @notice Adds a new proposal to the proposals list.
* @param destinations The addresses at which the proposal is directed to.
* @param values The CELO valuse involved in the proposal if any.
* @param payloads The payloads of the proposal.
* @return proposalId Returns the ID of the proposal that gets generated.
*/
function addProposal(
address[] memory destinations,
uint256[] memory values,
bytes[] memory payloads
) internal notNullBatch(destinations) returns (uint256 proposalId) {
proposalId = proposalCount;
Proposal storage proposal = proposals[proposalId];
proposal.destinations = destinations;
proposal.values = values;
proposal.payloads = payloads;
proposalCount++;
emit ProposalAdded(proposalId);
}
/**
* @notice Schedules a proposal with a time lock.
* @param proposalId The ID of the proposal to schedule.
*/
function schedule(uint256 proposalId)
internal
notScheduled(proposalId)
fullyConfirmed(proposalId)
{
proposals[proposalId].timestampExecutable = block.timestamp + delay;
}
/**
* @notice Changes the value of the delay that must
* elapse before a proposal can become executable.
* @param newDelay The new delay value.
*/
function _changeDelay(uint256 newDelay) internal {
if (newDelay < minDelay) {
revert InsufficientDelay(newDelay);
}
delay = newDelay;
emit DelayChanged(delay, newDelay);
}
/**
* @notice Changes the number of confirmations required to consider a proposal
* fully confirmed.
* @dev This method does not do any validation, see `changeRequirement`
* for how it is used with the requirement validation modifier.
* @param newRequired The new number of confirmations required.
*/
function _changeRequirement(uint256 newRequired) internal {
required = newRequired;
emit RequirementChanged(newRequired);
}
/**
* @notice Guard method for UUPS (Universal Upgradable Proxy Standard)
* See: https://docs.openzeppelin.com/contracts/4.x/api/proxy#transparent-vs-uups
* @dev This methods overrides the virtual one in UUPSUpgradeable and
* adds the onlyWallet modifer.
*/
// solhint-disable-next-line no-empty-blocks
function _authorizeUpgrade(address) internal override onlyWallet {}
/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return Storage version of the contract.
* @return Major version of the contract.
* @return Minor version of the contract.
* @return Patch version of the contract.
*/
function getVersionNumber()
external
pure
returns (
uint256,
uint256,
uint256,
uint256
)
{
return (1, 1, 1, 0);
}
}
| contract MultiSig is Initializable, UUPSUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @notice The maximum number of multisig owners.
*/
uint256 public constant MAX_OWNER_COUNT = 50;
/**
* @notice The minimum time in seconds that must elapse before a proposal is executable.
*/
uint256 public immutable minDelay;
/**
* @notice The value used to mark a proposal as executed.
*/
uint256 internal constant DONE_TIMESTAMP = uint256(1);
/**
* @notice Used to keep track of a proposal.
* @param destinations The addresses at which the proposal is directed to.
* @param values The amounts of CELO involved.
* @param payloads The payloads of the proposal.
* @param timestampExecutable The timestamp at which a proposal becomes executable.
* @dev timestampExecutable is 0 if proposal is not yet scheduled or 1 if the proposal
* is executed.
* @param confirmations The list of confirmations. Keyed by the address that
* confirmed the proposal, whether or not the proposal is confirmed.
*/
struct Proposal {
address[] destinations;
uint256[] values;
bytes[] payloads;
uint256 timestampExecutable;
mapping(address => bool) confirmations;
}
/**
* @notice The delay that must elapse to be able to execute a proposal.
*/
uint256 public delay;
/**
* @notice Keyed by proposal ID, the Proposal record.
*/
mapping(uint256 => Proposal) public proposals;
/**
* @notice The set of addresses which are owners of the multisig.
*/
EnumerableSet.AddressSet private owners;
/**
* @notice The amount of confirmations required
* for a proposal to be fully confirmed.
*/
uint256 public required;
/**
* @notice The total count of proposals.
*/
uint256 public proposalCount;
/**
* @notice Used when a proposal is successfully confirmed.
* @param sender The address of the sender.
* @param proposalId The ID of the proposal.
*/
event ProposalConfirmed(address indexed sender, uint256 indexed proposalId);
/**
* @notice Used when a confirmation is successfully revoked.
* @param sender The address of the sender.
* @param proposalId The ID of the proposal.
*/
event ConfirmationRevoked(address indexed sender, uint256 indexed proposalId);
/**
* @notice Used when a proposal is successfully added.
* @param proposalId The ID of the proposal that was added.
*/
event ProposalAdded(uint256 indexed proposalId);
/**
* @notice Emitted when a confirmed proposal is successfully executed.
* @param proposalId The ID of the proposal that was executed.
* @param returnData The response that was recieved from the external call.
*/
event ProposalExecuted(uint256 indexed proposalId, bytes returnData);
/**
* @notice Emitted when one of the transactions that make up a proposal is successfully
* executed.
* @param index The index of the transaction within the proposal.
* @param proposalId The ID of the proposal.
* @param returnData The response that was recieved from the external call.
*/
event TransactionExecuted(uint256 index, uint256 indexed proposalId, bytes returnData);
/**
* @notice Emitted when CELO is sent to this contract.
* @param sender The account which sent the CELO.
* @param value The amount of CELO sent.
*/
event CeloDeposited(address indexed sender, uint256 value);
/**
* @notice Emitted when an Owner is successfully added as part of the multisig.
* @param owner The added owner.
*/
event OwnerAdded(address indexed owner);
/**
* @notice Emitted when an Owner is successfully removed from the multisig.
* @param owner The removed owner.
*/
event OwnerRemoved(address indexed owner);
/**
* @notice Emitted when the minimum amount of required confirmations is
* successfully changed.
* @param required The new required amount.
*/
event RequirementChanged(uint256 required);
/**
* @notice Emitted when a proposal is scheduled.
* @param proposalId The ID of the proposal that is scheduled.
*/
event ProposalScheduled(uint256 indexed proposalId);
/**
* @notice Used when `delay` is changed.
* @param delay The current delay value.
* @param newDelay The new delay value.
*/
event DelayChanged(uint256 delay, uint256 newDelay);
/**
* @notice Used when sender is not this contract in an `onlyWallet` function.
* @param account The sender which triggered the function.
*/
error SenderMustBeMultisigWallet(address account);
/**
* @notice Used when attempting to add an already existing owner.
* @param owner The address of the owner.
*/
error OwnerAlreadyExists(address owner);
/**
* @notice Used when an owner does not exist.
* @param owner The address of the owner.
*/
error OwnerDoesNotExist(address owner);
/**
* @notice Used when a proposal does not exist.
* @param proposalId The ID of the non-existent proposal.
*/
error ProposalDoesNotExist(uint256 proposalId);
/**
* @notice Used when a proposal is not confirmed by a given owner.
* @param proposalId The ID of the proposal that is not confirmed.
* @param owner The address of the owner which did not confirm the proposal.
*/
error ProposalNotConfirmed(uint256 proposalId, address owner);
/**
* @notice Used when a proposal is not fully confirmed.
* @dev A proposal is fully confirmed when the `required` threshold
* of confirmations has been met.
* @param proposalId The ID of the proposal that is not fully confirmed.
*/
error ProposalNotFullyConfirmed(uint256 proposalId);
/**
* @notice Used when a proposal is already confirmed by an owner.
* @param proposalId The ID of the proposal that is already confirmed.
* @param owner The address of the owner which confirmed the proposal.
*/
error ProposalAlreadyConfirmed(uint256 proposalId, address owner);
/**
* @notice Used when a proposal has been executed.
* @param proposalId The ID of the proposal that is already executed.
*/
error ProposalAlreadyExecuted(uint256 proposalId);
/**
* @notice Used when a passed address is address(0).
*/
error NullAddress();
/**
* @notice Used when the set threshold values for owner and minimum
* required confirmations are not met.
* @param ownerCount The count of owners.
* @param required The number of required confirmations.
*/
error InvalidRequirement(uint256 ownerCount, uint256 required);
/**
* @notice Used when attempting to remove the last owner.
* @param owner The last owner.
*/
error CannotRemoveLastOwner(address owner);
/**
* @notice Used when attempting to schedule an already scheduled proposal.
* @param proposalId The ID of the proposal which is already scheduled.
*/
error ProposalAlreadyScheduled(uint256 proposalId);
/**
* @notice Used when a proposal is not scheduled.
* @param proposalId The ID of the proposal which is not scheduled.
*/
error ProposalNotScheduled(uint256 proposalId);
/**
* @notice Used when a time lock delay is not reached.
* @param proposalId The ID of the proposal whose time lock has not been reached yet.
*/
error ProposalTimelockNotReached(uint256 proposalId);
/**
* @notice Used when a provided value is less than the minimum time lock delay.
* @param delay The insufficient delay.
*/
error InsufficientDelay(uint256 delay);
/**
* @notice Used when the sizes of the provided arrays params do not match
* when submitting a proposal.
*/
error ParamLengthsMismatch();
/**
* @notice Checks that only the multisig contract can execute a function.
*/
modifier onlyWallet() {
if (msg.sender != address(this)) {
revert SenderMustBeMultisigWallet(msg.sender);
}
_;
}
/**
* @notice Checks that an address is not a multisig owner.
* @param owner The address to check.
*/
modifier ownerDoesNotExist(address owner) {
if (owners.contains(owner)) {
revert OwnerAlreadyExists(owner);
}
_;
}
/**
* @notice Checks that an address is a multisig owner.
* @param owner The address to check.
*/
modifier ownerExists(address owner) {
if (!owners.contains(owner)) {
revert OwnerDoesNotExist(owner);
}
_;
}
/**
* @notice Checks that a proposal exists.
* @param proposalId The proposal ID to check.
*/
modifier proposalExists(uint256 proposalId) {
if (proposals[proposalId].destinations.length == 0) {
revert ProposalDoesNotExist(proposalId);
}
_;
}
/**
* @notice Checks that a proposal has been confirmed by a multisig owner.
* @param proposalId The proposal ID to check.
* @param owner The owner to check.
*/
modifier confirmed(uint256 proposalId, address owner) {
if (!proposals[proposalId].confirmations[owner]) {
revert ProposalNotConfirmed(proposalId, owner);
}
_;
}
/**
* @notice Checks that a proposal has not been confirmed by a multisig owner.
* @param proposalId The proposal ID to check.
* @param owner The owner to check.
*/
modifier notConfirmed(uint256 proposalId, address owner) {
if (proposals[proposalId].confirmations[owner]) {
revert ProposalAlreadyConfirmed(proposalId, owner);
}
_;
}
/**
* @notice Checks that a proposal has not been executed.
* @dev A proposal can only be executed after it is fully confirmed.
* @param proposalId The proposal ID to check.
*/
modifier notExecuted(uint256 proposalId) {
if (proposals[proposalId].timestampExecutable == DONE_TIMESTAMP) {
revert ProposalAlreadyExecuted(proposalId);
}
_;
}
/**
* @notice Checks that an address is not address(0).
* @param addr The address to check.
*/
modifier notNull(address addr) {
if (addr == address(0)) {
revert NullAddress();
}
_;
}
/**
* @notice Checks that each address in a batch of addresses are not address(0).
* @param _addresses The addresses to check.
*/
modifier notNullBatch(address[] memory _addresses) {
for (uint256 i = 0; i < _addresses.length; i++) {
if (_addresses[i] == address(0)) {
revert NullAddress();
}
}
_;
}
/**
* @notice Checks that the values passed for number of multisig owners and required
* confirmation are valid in comparison with the configured thresholds.
* @param ownerCount The owners count to check.
* @param requiredConfirmations The minimum number of confirmations required to consider
* a proposal as fully confirmed.
*/
modifier validRequirement(uint256 ownerCount, uint256 requiredConfirmations) {
if (
ownerCount > MAX_OWNER_COUNT ||
requiredConfirmations > ownerCount ||
requiredConfirmations == 0 ||
ownerCount == 0
) {
revert InvalidRequirement(ownerCount, requiredConfirmations);
}
_;
}
/**
* @notice Checks that a proposal is scheduled.
* @param proposalId The ID of the proposal to check.
*/
modifier scheduled(uint256 proposalId) {
if (!isScheduled(proposalId)) {
revert ProposalNotScheduled(proposalId);
}
_;
}
/**
* @notice Checks that a proposal is not scheduled.
* @param proposalId The ID of the proposal to check.
*/
modifier notScheduled(uint256 proposalId) {
if (isScheduled(proposalId)) {
revert ProposalAlreadyScheduled(proposalId);
}
_;
}
/**
* @notice Checks that a proposal's time lock has elapsed.
* @param proposalId The ID of the proposal to check.
*/
modifier timeLockReached(uint256 proposalId) {
if (!isProposalTimelockReached(proposalId)) {
revert ProposalTimelockNotReached(proposalId);
}
_;
}
/**
* @notice Checks that a proposal is fully confirmed.
* @param proposalId The ID of the proposal to check.
*/
modifier fullyConfirmed(uint256 proposalId) {
if (!isFullyConfirmed(proposalId)) {
revert ProposalNotFullyConfirmed(proposalId);
}
_;
}
/**
* @notice Sets `initialized` to true on implementation contracts.
* @param _minDelay The minimum time in seconds that must elapse before a
* proposal is executable.
*/
// solhint-disable-next-line no-empty-blocks
constructor(uint256 _minDelay) initializer {
minDelay = _minDelay;
}
receive() external payable {
if (msg.value > 0) {
emit CeloDeposited(msg.sender, msg.value);
}
}
/**
* @notice Bootstraps this contract with initial data.
* @dev This plays the role of a typical contract constructor. Sets initial owners and
* required number of confirmations. The initializer modifier ensures that this function
* is ONLY callable once.
* @param initialOwners The list of initial owners.
* @param requiredConfirmations The number of required confirmations for a proposal
* to be fully confirmed.
* @param _delay The delay that must elapse to be able to execute a proposal.
*/
function initialize(
address[] calldata initialOwners,
uint256 requiredConfirmations,
uint256 _delay
) external initializer validRequirement(initialOwners.length, requiredConfirmations) {
for (uint256 i = 0; i < initialOwners.length; i++) {
if (owners.contains(initialOwners[i])) {
revert OwnerAlreadyExists(initialOwners[i]);
}
if (initialOwners[i] == address(0)) {
revert NullAddress();
}
owners.add(initialOwners[i]);
emit OwnerAdded(initialOwners[i]);
}
_changeRequirement(requiredConfirmations);
_changeDelay(_delay);
}
/**
* @notice Adds a new multisig owner.
* @dev This call can only be made by this contract.
* @param owner The owner to add.
*/
function addOwner(address owner)
external
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length() + 1, required)
{
owners.add(owner);
emit OwnerAdded(owner);
}
/**
* @notice Removes an existing owner.
* @dev This call can only be made by this contract.
* @param owner The owner to remove.
*/
function removeOwner(address owner) external onlyWallet ownerExists(owner) {
if (owners.length() == 1) {
revert CannotRemoveLastOwner(owner);
}
owners.remove(owner);
if (required > owners.length()) {
// Readjust the required amount, since the list of total owners has reduced.
changeRequirement(owners.length());
}
emit OwnerRemoved(owner);
}
/**
* @notice Replaces an existing owner with a new owner.
* @dev This call can only be made by this contract.
* @param owner The owner to be replaced.
*/
function replaceOwner(address owner, address newOwner)
external
onlyWallet
ownerExists(owner)
notNull(newOwner)
ownerDoesNotExist(newOwner)
{
owners.remove(owner);
owners.add(newOwner);
emit OwnerRemoved(owner);
emit OwnerAdded(newOwner);
}
/**
* @notice Void a confirmation for a previously confirmed proposal.
* @param proposalId The ID of the proposal to be revoked.
*/
function revokeConfirmation(uint256 proposalId)
external
ownerExists(msg.sender)
confirmed(proposalId, msg.sender)
notExecuted(proposalId)
{
proposals[proposalId].confirmations[msg.sender] = false;
emit ConfirmationRevoked(msg.sender, proposalId);
}
/**
* @notice Creates a proposal and triggers the first confirmation on behalf of the
* proposal creator.
* @param destinations The addresses at which the proposal is target at.
* @param values The CELO values involved in the proposal if any.
* @param payloads The payloads of the proposal.
* @return proposalId Returns the ID of the proposal that gets generated.
*/
function submitProposal(
address[] calldata destinations,
uint256[] calldata values,
bytes[] calldata payloads
) external returns (uint256 proposalId) {
if (destinations.length != values.length) {
revert ParamLengthsMismatch();
}
if (destinations.length != payloads.length) {
revert ParamLengthsMismatch();
}
proposalId = addProposal(destinations, values, payloads);
confirmProposal(proposalId);
}
/**
* @notice Get the list of multisig owners.
* @return The list of owner addresses.
*/
function getOwners() external view returns (address[] memory) {
return owners.values();
}
/**
* @notice Gets the list of owners' addresses which have confirmed a given proposal.
* @param proposalId The ID of the proposal.
* @return The list of owner addresses.
*/
function getConfirmations(uint256 proposalId) external view returns (address[] memory) {
address[] memory confirmationsTemp = new address[](owners.length());
uint256 count = 0;
for (uint256 i = 0; i < owners.length(); i++) {
if (proposals[proposalId].confirmations[owners.at(i)]) {
confirmationsTemp[count] = owners.at(i);
count++;
}
}
address[] memory confirmingOwners = new address[](count);
for (uint256 i = 0; i < count; i++) {
confirmingOwners[i] = confirmationsTemp[i];
}
return confirmingOwners;
}
/**
* @notice Gets the destinations, values and payloads of a proposal.
* @param proposalId The ID of the proposal.
* @param destinations The addresses at which the proposal is target at.
* @param values The CELO values involved in the proposal if any.
* @param payloads The payloads of the proposal.
*/
function getProposal(uint256 proposalId)
external
view
returns (
address[] memory destinations,
uint256[] memory values,
bytes[] memory payloads
)
{
Proposal storage proposal = proposals[proposalId];
return (proposal.destinations, proposal.values, proposal.payloads);
}
/**
* @notice Changes the number of confirmations required to consider a proposal
* fully confirmed.
* @dev Proposal has to be sent by wallet.
* @param newRequired The new number of confirmations required.
*/
function changeRequirement(uint256 newRequired)
public
onlyWallet
validRequirement(owners.length(), newRequired)
{
_changeRequirement(newRequired);
}
/**
* @notice Changes the value of the delay that must
* elapse before a proposal can become executable.
* @dev Proposal has to be sent by wallet.
* @param newDelay The new delay value.
*/
function changeDelay(uint256 newDelay) public onlyWallet {
_changeDelay(newDelay);
}
/**
* @notice Confirms a proposal. A proposal is executed if this confirmation
* makes it fully confirmed.
* @param proposalId The ID of the proposal to confirm.
*/
function confirmProposal(uint256 proposalId)
public
ownerExists(msg.sender)
proposalExists(proposalId)
notConfirmed(proposalId, msg.sender)
{
proposals[proposalId].confirmations[msg.sender] = true;
emit ProposalConfirmed(msg.sender, proposalId);
if (isFullyConfirmed(proposalId)) {
scheduleProposal(proposalId);
}
}
/**
* @notice Schedules a proposal with a time lock.
* @param proposalId The ID of the proposal to confirm.
*/
function scheduleProposal(uint256 proposalId)
public
ownerExists(msg.sender)
notExecuted(proposalId)
{
schedule(proposalId);
emit ProposalScheduled(proposalId);
}
/**
* @notice Executes a proposal. A proposal is only executetable if it is fully confirmed,
* scheduled and the set delay has elapsed.
* @dev Any of the multisig owners can execute a given proposal, even though they may
* not have participated in its confirmation process.
*/
function executeProposal(uint256 proposalId)
public
scheduled(proposalId)
notExecuted(proposalId)
timeLockReached(proposalId)
{
Proposal storage proposal = proposals[proposalId];
proposal.timestampExecutable = DONE_TIMESTAMP;
for (uint256 i = 0; i < proposals[proposalId].destinations.length; i++) {
bytes memory returnData = ExternalCall.execute(
proposal.destinations[i],
proposal.values[i],
proposal.payloads[i]
);
emit TransactionExecuted(i, proposalId, returnData);
}
}
/**
* @notice Returns the timestamp at which a proposal becomes executable.
* @param proposalId The ID of the proposal.
* @return The timestamp at which the proposal becomes executable.
*/
function getTimestamp(uint256 proposalId) public view returns (uint256) {
return proposals[proposalId].timestampExecutable;
}
/**
* @notice Returns whether a proposal is scheduled.
* @param proposalId The ID of the proposal to check.
* @return Whether or not the proposal is scheduled.
*/
function isScheduled(uint256 proposalId) public view returns (bool) {
return getTimestamp(proposalId) > DONE_TIMESTAMP;
}
/**
* @notice Returns whether a proposal is executable or not.
* A proposal is executable if it is scheduled, the delay has elapsed
* and it is not yet executed.
* @param proposalId The ID of the proposal to check.
* @return Whether or not the time lock is reached.
*/
function isProposalTimelockReached(uint256 proposalId) public view returns (bool) {
uint256 timestamp = getTimestamp(proposalId);
return
timestamp <= block.timestamp &&
proposals[proposalId].timestampExecutable > DONE_TIMESTAMP;
}
/**
* @notice Checks that a proposal has been confirmed by at least the `required`
* number of owners.
* @param proposalId The ID of the proposal to check.
* @return Whether or not the proposal is confirmed by the minimum set of owners.
*/
function isFullyConfirmed(uint256 proposalId) public view returns (bool) {
uint256 count = 0;
for (uint256 i = 0; i < owners.length(); i++) {
if (proposals[proposalId].confirmations[owners.at(i)]) {
count++;
}
if (count == required) {
return true;
}
}
return false;
}
/**
* @notice Checks that a proposal is confirmed by an owner.
* @param proposalId The ID of the proposal to check.
* @param owner The address to check.
* @return Whether or not the proposal is confirmed by the given owner.
*/
function isConfirmedBy(uint256 proposalId, address owner) public view returns (bool) {
return proposals[proposalId].confirmations[owner];
}
/**
* @notice Checks that an address is a multisig owner.
* @param owner The address to check.
* @return Whether or not the address is a multisig owner.
*/
function isOwner(address owner) public view returns (bool) {
return owners.contains(owner);
}
/**
* @notice Adds a new proposal to the proposals list.
* @param destinations The addresses at which the proposal is directed to.
* @param values The CELO valuse involved in the proposal if any.
* @param payloads The payloads of the proposal.
* @return proposalId Returns the ID of the proposal that gets generated.
*/
function addProposal(
address[] memory destinations,
uint256[] memory values,
bytes[] memory payloads
) internal notNullBatch(destinations) returns (uint256 proposalId) {
proposalId = proposalCount;
Proposal storage proposal = proposals[proposalId];
proposal.destinations = destinations;
proposal.values = values;
proposal.payloads = payloads;
proposalCount++;
emit ProposalAdded(proposalId);
}
/**
* @notice Schedules a proposal with a time lock.
* @param proposalId The ID of the proposal to schedule.
*/
function schedule(uint256 proposalId)
internal
notScheduled(proposalId)
fullyConfirmed(proposalId)
{
proposals[proposalId].timestampExecutable = block.timestamp + delay;
}
/**
* @notice Changes the value of the delay that must
* elapse before a proposal can become executable.
* @param newDelay The new delay value.
*/
function _changeDelay(uint256 newDelay) internal {
if (newDelay < minDelay) {
revert InsufficientDelay(newDelay);
}
delay = newDelay;
emit DelayChanged(delay, newDelay);
}
/**
* @notice Changes the number of confirmations required to consider a proposal
* fully confirmed.
* @dev This method does not do any validation, see `changeRequirement`
* for how it is used with the requirement validation modifier.
* @param newRequired The new number of confirmations required.
*/
function _changeRequirement(uint256 newRequired) internal {
required = newRequired;
emit RequirementChanged(newRequired);
}
/**
* @notice Guard method for UUPS (Universal Upgradable Proxy Standard)
* See: https://docs.openzeppelin.com/contracts/4.x/api/proxy#transparent-vs-uups
* @dev This methods overrides the virtual one in UUPSUpgradeable and
* adds the onlyWallet modifer.
*/
// solhint-disable-next-line no-empty-blocks
function _authorizeUpgrade(address) internal override onlyWallet {}
/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return Storage version of the contract.
* @return Major version of the contract.
* @return Minor version of the contract.
* @return Patch version of the contract.
*/
function getVersionNumber()
external
pure
returns (
uint256,
uint256,
uint256,
uint256
)
{
return (1, 1, 1, 0);
}
}
| 23,429 |
33 | // only two roles at this point, admin and moderator if admin is the account to change, then decrement if moderator is the count to change, then increment | if(isAdmin(_groupId, _accountToChange) == true)
{
require(getAdminCount(_groupId) > 1);
storageContract.decrementUintValue(keccak256(
abi.encodePacked(GROUP_KEY, _groupId, "adminCount")),
1
);
} else {
| if(isAdmin(_groupId, _accountToChange) == true)
{
require(getAdminCount(_groupId) > 1);
storageContract.decrementUintValue(keccak256(
abi.encodePacked(GROUP_KEY, _groupId, "adminCount")),
1
);
} else {
| 31,070 |
152 | // The block number when WOLF mining starts. | uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
WOLFToken _WOLF,
address _devaddr,
uint256 _WOLFPerBlock,
| uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
WOLFToken _WOLF,
address _devaddr,
uint256 _WOLFPerBlock,
| 45,591 |
0 | // Proof of Performance Interface - Allows interaction with the PoP contract./Gabriele Rigo - <gab@rigoblock.com> | interface ProofOfPerformanceFace {
// CORE FUNCTIONS
function claimPop(uint _ofPool) external;
function setRegistry(address _dragoRegistry) external;
function setRigoblockDao(address _rigoblockDao) external;
function setRatio(address _ofGroup, uint _ratio) external;
function setMinimumRigo(uint256 _amount) external;
// CONSTANT PUBLIC FUNCTIONS
function getPoolData(uint _ofPool)
external view
returns (
bool active,
address thePoolAddress,
address thePoolGroup,
uint thePoolPrice,
uint thePoolSupply,
uint poolValue,
uint epochReward,
uint ratio,
uint pop
);
function getHwm(uint _ofPool) external view returns (uint);
function getPoolPrices() external view returns (address[] pools, uint[] poolPrices, uint[] totalTokens);
function calcNetworkValue() external view returns (uint networkValue, uint numberOfFunds);
}
| interface ProofOfPerformanceFace {
// CORE FUNCTIONS
function claimPop(uint _ofPool) external;
function setRegistry(address _dragoRegistry) external;
function setRigoblockDao(address _rigoblockDao) external;
function setRatio(address _ofGroup, uint _ratio) external;
function setMinimumRigo(uint256 _amount) external;
// CONSTANT PUBLIC FUNCTIONS
function getPoolData(uint _ofPool)
external view
returns (
bool active,
address thePoolAddress,
address thePoolGroup,
uint thePoolPrice,
uint thePoolSupply,
uint poolValue,
uint epochReward,
uint ratio,
uint pop
);
function getHwm(uint _ofPool) external view returns (uint);
function getPoolPrices() external view returns (address[] pools, uint[] poolPrices, uint[] totalTokens);
function calcNetworkValue() external view returns (uint networkValue, uint numberOfFunds);
}
| 40,439 |
2 | // Проверяет что тот кто перевел владелец кошелька | modifier onlyOwner {
require (msg.sender == ownerAddress, "Only owner");
_;
}
| modifier onlyOwner {
require (msg.sender == ownerAddress, "Only owner");
_;
}
| 42,829 |
28 | // Unmarshals a point on G2 from bytes in an uncompressed form. / | function g2Unmarshal(bytes memory m)
internal
pure
returns (G2Point memory)
| function g2Unmarshal(bytes memory m)
internal
pure
returns (G2Point memory)
| 7,303 |
139 | // Set the token address./newTokenAddress Token adddress | function setTokenAddress(address newTokenAddress)
public
onlyOwner
| function setTokenAddress(address newTokenAddress)
public
onlyOwner
| 15,256 |
3 | // Returns the number of decimals used to get its user representation. / | uint256 public immutable decimals = 18;
| uint256 public immutable decimals = 18;
| 2,696 |
161 | // Withdraw specified amount and collect rewards | function unstake(uint256 amount) external {
withdraw(amount);
getReward();
}
| function unstake(uint256 amount) external {
withdraw(amount);
getReward();
}
| 34,232 |
105 | // Transfers `tokenId` token from `from` to `to`. WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `tokenId` token must be owned by `from`.- If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. Emits a {Transfer} event. / | function transferFrom(address from, address to, uint256 tokenId) external;
| function transferFrom(address from, address to, uint256 tokenId) external;
| 928 |
24 | // Guardamos en una variable string los candidatos con sus respectivos votos | string memory resultados = "";
| string memory resultados = "";
| 29,843 |
18 | // emit an event first - to log both old and new values | emit BaseURIUpdated(_msgSender(), baseURI, __baseURI);
| emit BaseURIUpdated(_msgSender(), baseURI, __baseURI);
| 34,733 |
31 | // set raffle_state to TICKET_SALE_OPEN | raffleState = RAFFLE_STATE.TICKET_SALE_OPEN;
| raffleState = RAFFLE_STATE.TICKET_SALE_OPEN;
| 28,199 |
10 | // Events //A default version was set.version_ The default version. / | event DefaultVersionSet(uint256 indexed version_);
| event DefaultVersionSet(uint256 indexed version_);
| 79,280 |
31 | // Store the bid details. | auctionDetails.reservePriceOrHighestBid = actualBid;
auctionDetails.highestBidder = payable(msg.sender);
| auctionDetails.reservePriceOrHighestBid = actualBid;
auctionDetails.highestBidder = payable(msg.sender);
| 29,172 |
4 | // max quota (per user, per direction) | uint256 public userQuota;
| uint256 public userQuota;
| 14,631 |
104 | // ERC20_utils | function withdrawAnyToken(address _token) external onlyAllowed returns (bool) {
uint256 _amount = IERC20(_token).balanceOf(address(this));
_withdrawAnyToken(_msgSender(), _token, _amount);
return true;
} //get tokens sent by error to contract
| function withdrawAnyToken(address _token) external onlyAllowed returns (bool) {
uint256 _amount = IERC20(_token).balanceOf(address(this));
_withdrawAnyToken(_msgSender(), _token, _amount);
return true;
} //get tokens sent by error to contract
| 7,495 |
30 | // If claim hasn't been done before for the index, add initial allotment | if (lastClaimed == _emissionStart) {
totalAccumulated = totalAccumulated + INITIAL_ALLOTMENT;
}
| if (lastClaimed == _emissionStart) {
totalAccumulated = totalAccumulated + INITIAL_ALLOTMENT;
}
| 37,418 |
3 | // Make a golem for one addressthe required runes will not be consumed / | function makeGolem() external {
require(userMinted[msg.sender] == 0, "already minted");
require(tokenIdCounter < maxCountId, "cannot mint anymore");
uint256 runeSum;
uint256[] memory runes = _tokenProvider.userRunes(msg.sender);
for (uint256 index = 9; index > 0; ) {
runeSum += runes[--index];
if (runeSum >= runesRequirement) {
userMinted[msg.sender] = tokenIdCounter;
_mint(msg.sender);
return;
}
}
revert("not enought runes");
}
| function makeGolem() external {
require(userMinted[msg.sender] == 0, "already minted");
require(tokenIdCounter < maxCountId, "cannot mint anymore");
uint256 runeSum;
uint256[] memory runes = _tokenProvider.userRunes(msg.sender);
for (uint256 index = 9; index > 0; ) {
runeSum += runes[--index];
if (runeSum >= runesRequirement) {
userMinted[msg.sender] = tokenIdCounter;
_mint(msg.sender);
return;
}
}
revert("not enought runes");
}
| 40,084 |
63 | // @contract TradeJPY / | contract TradeJPY is StandardToken, Ownable, HasNoTokens, BurnableToken, MintableToken{
string public name = "TradeJPY";
string public symbol = "TJPY";
uint public decimals = 8;
event Transfer(address indexed from, address indexed to, uint value, bytes data);
constructor(uint256 initialSupply) public {
totalSupply_ = initialSupply;
owner = msg.sender;
balances[msg.sender] = initialSupply;
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) public {
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
HasNoTokens receiver = HasNoTokens(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
}
} | contract TradeJPY is StandardToken, Ownable, HasNoTokens, BurnableToken, MintableToken{
string public name = "TradeJPY";
string public symbol = "TJPY";
uint public decimals = 8;
event Transfer(address indexed from, address indexed to, uint value, bytes data);
constructor(uint256 initialSupply) public {
totalSupply_ = initialSupply;
owner = msg.sender;
balances[msg.sender] = initialSupply;
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) public {
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
HasNoTokens receiver = HasNoTokens(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
}
} | 21,353 |
0 | // Emitted when the stored value changes | event ValueChanged(uint256 value);
| event ValueChanged(uint256 value);
| 9,289 |
132 | // Mouth N°1 => Neutral | function item_1() public pure returns (string memory) {
return
base(
string(
abi.encodePacked(
'<path d="M178.3,262.7c3.3-0.2,6.6-0.1,9.9,0c3.3,0.1,6.6,0.3,9.8,0.8c-3.3,0.3-6.6,0.3-9.9,0.2C184.8,263.6,181.5,263.3,178.3,262.7z"/>',
'<path d="M201.9,263.4c1.2-0.1,2.3-0.1,3.5-0.2l3.5-0.2l6.9-0.3c2.3-0.1,4.6-0.2,6.9-0.4c1.2-0.1,2.3-0.2,3.5-0.3l1.7-0.2c0.6-0.1,1.1-0.2,1.7-0.2c-2.2,0.8-4.5,1.1-6.8,1.4s-4.6,0.5-7,0.6c-2.3,0.1-4.6,0.2-7,0.1C206.6,263.7,204.3,263.6,201.9,263.4z"/>',
'<path d="M195.8,271.8c0.8,0.5,1.8,0.8,2.7,1s1.8,0.4,2.7,0.5s1.8,0,2.8-0.1c0.9-0.1,1.8-0.5,2.8-0.8c-0.7,0.7-1.6,1.3-2.6,1.6c-1,0.3-2,0.5-3,0.4s-2-0.3-2.9-0.8C197.3,273.2,196.4,272.7,195.8,271.8z"/>'
)
)
);
}
| function item_1() public pure returns (string memory) {
return
base(
string(
abi.encodePacked(
'<path d="M178.3,262.7c3.3-0.2,6.6-0.1,9.9,0c3.3,0.1,6.6,0.3,9.8,0.8c-3.3,0.3-6.6,0.3-9.9,0.2C184.8,263.6,181.5,263.3,178.3,262.7z"/>',
'<path d="M201.9,263.4c1.2-0.1,2.3-0.1,3.5-0.2l3.5-0.2l6.9-0.3c2.3-0.1,4.6-0.2,6.9-0.4c1.2-0.1,2.3-0.2,3.5-0.3l1.7-0.2c0.6-0.1,1.1-0.2,1.7-0.2c-2.2,0.8-4.5,1.1-6.8,1.4s-4.6,0.5-7,0.6c-2.3,0.1-4.6,0.2-7,0.1C206.6,263.7,204.3,263.6,201.9,263.4z"/>',
'<path d="M195.8,271.8c0.8,0.5,1.8,0.8,2.7,1s1.8,0.4,2.7,0.5s1.8,0,2.8-0.1c0.9-0.1,1.8-0.5,2.8-0.8c-0.7,0.7-1.6,1.3-2.6,1.6c-1,0.3-2,0.5-3,0.4s-2-0.3-2.9-0.8C197.3,273.2,196.4,272.7,195.8,271.8z"/>'
)
)
);
}
| 33,920 |
10 | // Contract constructor | constructor() public {
rootAddress = msg.sender;
Owner = msg.sender;
// Addresses
tokenAdd = address(0x9da0D98c9d051c594038eb3267fBd0FAf3Da9e48);
tokenSpender = address(0xAd50cACa8cD726600840E745D0AE6B6E78861dBc);
token = TokenWithDates(tokenAdd);
initialDate = now;
yearlyInterest.push(70); // Yearly interest for first year: 70%
yearlyInterest.push(50); // For second year: 50%
yearlyInterest.push(20); // And so on: 20%
yearlyInterest.push(10); // 10%
}
| constructor() public {
rootAddress = msg.sender;
Owner = msg.sender;
// Addresses
tokenAdd = address(0x9da0D98c9d051c594038eb3267fBd0FAf3Da9e48);
tokenSpender = address(0xAd50cACa8cD726600840E745D0AE6B6E78861dBc);
token = TokenWithDates(tokenAdd);
initialDate = now;
yearlyInterest.push(70); // Yearly interest for first year: 70%
yearlyInterest.push(50); // For second year: 50%
yearlyInterest.push(20); // And so on: 20%
yearlyInterest.push(10); // 10%
}
| 21,522 |
86 | // Check if sale is made within the listing window. | require(block.timestamp < _listing.endTime && block.timestamp > _listing.startTime, "not within sale window.");
| require(block.timestamp < _listing.endTime && block.timestamp > _listing.startTime, "not within sale window.");
| 23,949 |
21 | // @validate: signature-of-intent from target signer. | _validateSignature(messageHash, _signature, _params.signer);
| _validateSignature(messageHash, _signature, _params.signer);
| 11,805 |
2 | // Returns the latest price / | function getPriceDolarperMaticLink() public view returns (int256) {
(
/*uint80 roundID*/,
int256 _price,
/*uint startedAt*/,
/*uint timeStamp*/,
/*uint80 answeredInRound*/
) = priceFeed.latestRoundData();
return _price;
}
| function getPriceDolarperMaticLink() public view returns (int256) {
(
/*uint80 roundID*/,
int256 _price,
/*uint startedAt*/,
/*uint timeStamp*/,
/*uint80 answeredInRound*/
) = priceFeed.latestRoundData();
return _price;
}
| 18,354 |
77 | // Return the merged Merkle root of all the leaves at a desired depth.merge() or merged(_depth) must be called first. _depth The depth of the main tree. It must first be computedusing mergeSubRoots() and merge()./ | function getMainRoot(uint256 _depth) public view returns (uint256) {
require(
hashLength ** _depth >= numLeaves,
"AccQueue: getMainRoot: _depth must be high enough"
);
return mainRoots[_depth];
}
| function getMainRoot(uint256 _depth) public view returns (uint256) {
require(
hashLength ** _depth >= numLeaves,
"AccQueue: getMainRoot: _depth must be high enough"
);
return mainRoots[_depth];
}
| 37,597 |
65 | // Provides a descriptive tag for bot consumption This should be modified weekly to provide a summary of the actions Hash: seth keccak -- "$(wget https:raw.githubusercontent.com/makerdao/community/989a2ee92df41ef7aee75a1ccdbedbe6071e28a7/governance/votes/Executive%20vote%20-%20October%201%2C%202021.md -q -O - 2>/dev/null)" | string public constant override description =
"2021-10-01 MakerDAO Executive Spell | Hash: 0x240a8946c4c5f2463a1fcd6c7036409087af1c2407d502330e27c9149bfa7ed7";
| string public constant override description =
"2021-10-01 MakerDAO Executive Spell | Hash: 0x240a8946c4c5f2463a1fcd6c7036409087af1c2407d502330e27c9149bfa7ed7";
| 51,423 |
1 | // tokenAmount is to 18 dp, usdAmount is to 8 dp token must be LINK / WETH / YFL | function calculateTokenAmountFromUsdAmount(address token, uint256 usdAmount)
external
view
returns (uint256 tokenAmount);
| function calculateTokenAmountFromUsdAmount(address token, uint256 usdAmount)
external
view
returns (uint256 tokenAmount);
| 3,138 |
0 | // fee for primary sales/ return uint256 of primary sale fee | uint256 public protocolFeePrimary;
| uint256 public protocolFeePrimary;
| 16,467 |
4 | // Emitted when a transaction is executed | event TransactionExecuted(bytes32 proposalId, address[] targets, uint256[] values, bytes[] payloads);
| event TransactionExecuted(bytes32 proposalId, address[] targets, uint256[] values, bytes[] payloads);
| 16,417 |
6 | // Modifier that restricts a function only for vault address | modifier onlyVault {
require(_msgSender() == blackHoleVaultAddress);
_;
}
| modifier onlyVault {
require(_msgSender() == blackHoleVaultAddress);
_;
}
| 43,305 |
0 | // ============ State Variables ============ // ============ Constructor ============ / | {
price = _startingPrice;
}
| {
price = _startingPrice;
}
| 992 |
82 | // clear any previously approved ownership exchange | delete villainIndexToApproved[_tokenId];
| delete villainIndexToApproved[_tokenId];
| 28,182 |
234 | // SET MANAGER ONLY. Initialize module with SetToken and set the fee state for the SetToken. Passed_settings will have lastStreamingFeeTimestamp over-written._setToken Address of SetToken _settings FeeState struct defining fee parameters / | function initialize(
ISetToken _setToken,
FeeState memory _settings
)
external
onlySetManager(_setToken, msg.sender)
onlyValidAndPendingSet(_setToken)
| function initialize(
ISetToken _setToken,
FeeState memory _settings
)
external
onlySetManager(_setToken, msg.sender)
onlyValidAndPendingSet(_setToken)
| 66,970 |
344 | // Get tier total supplys and counts | uint256 tierSupply = tierInfo.totalSupply;
uint256 tierCount = tierCounts[tier.id];
return tierSupply.sub(tierCount);
| uint256 tierSupply = tierInfo.totalSupply;
uint256 tierCount = tierCounts[tier.id];
return tierSupply.sub(tierCount);
| 29,824 |
3 | // what the eth to usd conversion rate | }
| }
| 8,688 |
10 | // Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). CAUTION: This function is deprecated because it requires allocating memory for the error | * message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
| * message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
| 84,074 |
18 | // Mints the below-mentioned amount of tokens allocated to Vibeo user adoption. The tokens are immediately available once the softcap is reached and ICO end date is specified. | function mintUserAdoptionTokens() public onlyWhitelisted {
require(softCapReached);
if(icoEndDate == 0) {
revert();
}
mintOnce("useradoption", msg.sender, 95000000);
}
| function mintUserAdoptionTokens() public onlyWhitelisted {
require(softCapReached);
if(icoEndDate == 0) {
revert();
}
mintOnce("useradoption", msg.sender, 95000000);
}
| 16,112 |
2 | // Write / | {
require(hasRole(FACTORY_ADMIN, msg.sender), "WINToken: Restricted to FACTORY_ADMIN role");
collectionName[_id] = _name;
collectionMaxSupply[_id] = _maxSupply;
}
| {
require(hasRole(FACTORY_ADMIN, msg.sender), "WINToken: Restricted to FACTORY_ADMIN role");
collectionName[_id] = _name;
collectionMaxSupply[_id] = _maxSupply;
}
| 14,212 |
60 | // Sets new fee recipient address/newFeeRecipient Address of the new fee recipient. | function setFeeRecipient(address newFeeRecipient) external;
| function setFeeRecipient(address newFeeRecipient) external;
| 17,655 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.