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 |
|---|---|---|---|---|
38 | // Block / Unlock address handling tokens | function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
| function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
| 51,323 |
19 | // Collects SUSHI tokens | ISushiChef(masterChef).deposit(poolId, 0);
uint256 _sushi = IERC20(sushi).balanceOf(address(this));
if (_sushi > 0) {
| ISushiChef(masterChef).deposit(poolId, 0);
uint256 _sushi = IERC20(sushi).balanceOf(address(this));
if (_sushi > 0) {
| 13,517 |
142 | // Safe FRT transfer function, just in case if rounding error causes pool to not have enough Tokens. | function safeFRTTransfer(address _to, uint256 _amount) internal {
uint256 testBal = frt.balanceOf(address(this));
if (_amount > testBal) {
frt.safeTransfer(address(_to), testBal);
} else {
frt.safeTransfer(address(_to), _amount);
}
}
| function safeFRTTransfer(address _to, uint256 _amount) internal {
uint256 testBal = frt.balanceOf(address(this));
if (_amount > testBal) {
frt.safeTransfer(address(_to), testBal);
} else {
frt.safeTransfer(address(_to), _amount);
}
}
| 879 |
293 | // get position notional and unrealized Pnl without fee expense and funding payment _amm IAmm address _trader trader address _pnlCalcOption enum PnlCalcOption, SPOT_PRICE for spot price and TWAP for twap pricereturn positionNotional position notionalreturn unrealizedPnl unrealized Pnl / | function getPositionNotionalAndUnrealizedPnl(
IAmm _amm,
address _trader,
PnlCalcOption _pnlCalcOption
| function getPositionNotionalAndUnrealizedPnl(
IAmm _amm,
address _trader,
PnlCalcOption _pnlCalcOption
| 8,079 |
129 | // =================================================================================================================Constructors ================================================================================================================= |
function SirinCrowdsale(uint256 _startTime,
uint256 _endTime,
address _wallet,
address _walletTeam,
address _walletOEM,
address _walletBounties,
address _walletReserve,
SirinSmartToken _sirinSmartToken,
RefundVault _refundVault)
|
function SirinCrowdsale(uint256 _startTime,
uint256 _endTime,
address _wallet,
address _walletTeam,
address _walletOEM,
address _walletBounties,
address _walletReserve,
SirinSmartToken _sirinSmartToken,
RefundVault _refundVault)
| 44,419 |
4 | // Get Information | function getWalletBalance()
public
view
onlyOwner(msg.sender)
returns (uint256)
| function getWalletBalance()
public
view
onlyOwner(msg.sender)
returns (uint256)
| 29,063 |
17 | // Converts all incoming Ethereum to tokens for the caller, and passes down the referral address (if any) / | function buy(address _referredBy)
public
payable
returns(uint256)
| function buy(address _referredBy)
public
payable
returns(uint256)
| 19,756 |
77 | // if (curblk > (blk+2proposalExpiration)) { uint jump = (curblk-blk)/(2proposalExpirationnodeCount); if ((curblk-blk) > (2proposalExpirationnodeCountjump + proposalExpiration)) { blk = blk + (jump + 1)(2proposalExpirationnodeCount); } else { blk = blk + jump(2proposalExpirationnodeCount); } } | return blk;
| return blk;
| 1,568 |
0 | // ---------------------------------------------------------------------------------------------------------------------------EVENTS----------------------------------------------------------------------------------------------------------------------------- |
event EligibilityConfirmed(uint32 whitelistVersion, bytes32 hash, address user);
event EligibilityRemoved(uint32 whitelistVersion, address user);
event whitelistVersionIncreased(uint32 currentDeclaration);
|
event EligibilityConfirmed(uint32 whitelistVersion, bytes32 hash, address user);
event EligibilityRemoved(uint32 whitelistVersion, address user);
event whitelistVersionIncreased(uint32 currentDeclaration);
| 22,766 |
33 | // Returns global wallet limit. This is the max number of tokens can be minted by one wallet. / | function getGlobalWalletLimit() external view override returns (uint256) {
return _globalWalletLimit;
}
| function getGlobalWalletLimit() external view override returns (uint256) {
return _globalWalletLimit;
}
| 17,933 |
7 | // If not purchased, return true. If purchased demand, bought and timeover demand is true. | function _isBurnable(uint256 demand_id) private view returns(bool){
return _isPurchesed(demand_id) ? _isOwnBoughtDemand(demand_id)&&_isTimeOver(demand_id) : true;
}
| function _isBurnable(uint256 demand_id) private view returns(bool){
return _isPurchesed(demand_id) ? _isOwnBoughtDemand(demand_id)&&_isTimeOver(demand_id) : true;
}
| 53,342 |
77 | // Muldiv operation overflow. / | error MathOverflowedMulDiv();
| error MathOverflowedMulDiv();
| 38,498 |
1 | // Divides two numbers but checks for 0 in the divisor first./ Does not throw./a First number/b Second number/ return err False normally, or true if `b` is 0/ return res The quotient of a and b, or 0 if `b` is 0 | function dividedBy(uint256 a, uint256 b) public pure returns (bool err,uint256 i) {
uint256 res;
assembly{
switch iszero(b)
case 0 {
res := div(a,b)
let loc := mload(0x40)
mstore(add(loc,0x20),res)
i := mload(add(loc,0x20))
}
default {
err := 1
i := 0
}
}
}
| function dividedBy(uint256 a, uint256 b) public pure returns (bool err,uint256 i) {
uint256 res;
assembly{
switch iszero(b)
case 0 {
res := div(a,b)
let loc := mload(0x40)
mstore(add(loc,0x20),res)
i := mload(add(loc,0x20))
}
default {
err := 1
i := 0
}
}
}
| 73,673 |
37 | // @inheritdoc IUniswapV3PoolActions/not locked because it initializes unlocked | function initialize(uint160 sqrtPriceX96) external override {
require(slot0.sqrtPriceX96 == 0, 'AI');
int24 tick = TickMath.getTickAtSqrtRatio(sqrtPriceX96);
(uint16 cardinality, uint16 cardinalityNext) = observations.initialize(_blockTimestamp());
slot0 = Slot0({
sqrtPriceX96: sqrtPriceX96,
tick: tick,
observationIndex: 0,
observationCardinality: cardinality,
observationCardinalityNext: cardinalityNext,
feeProtocol: 0,
unlocked: true
});
emit Initialize(sqrtPriceX96, tick);
}
| function initialize(uint160 sqrtPriceX96) external override {
require(slot0.sqrtPriceX96 == 0, 'AI');
int24 tick = TickMath.getTickAtSqrtRatio(sqrtPriceX96);
(uint16 cardinality, uint16 cardinalityNext) = observations.initialize(_blockTimestamp());
slot0 = Slot0({
sqrtPriceX96: sqrtPriceX96,
tick: tick,
observationIndex: 0,
observationCardinality: cardinality,
observationCardinalityNext: cardinalityNext,
feeProtocol: 0,
unlocked: true
});
emit Initialize(sqrtPriceX96, tick);
}
| 3,377 |
75 | // Revert if flasher is not a valid flasher at {Chief}.flasher address to check / | function _checkValidFlasher(address flasher) internal view {
if (!chief.allowedFlasher(flasher)) {
revert BaseRouter__checkValidFlasher_notAllowedFlasher();
}
| function _checkValidFlasher(address flasher) internal view {
if (!chief.allowedFlasher(flasher)) {
revert BaseRouter__checkValidFlasher_notAllowedFlasher();
}
| 40,972 |
1 | // -------------------// MAPPINGS//-------------------//-------------------//EVENTS //-------------------//-------------------//CONSTRUCTOR//-------------------/ | {
Role[0x1A0a3E3AE390a0710f8A6d00587082273eA8F6C9] = true; // BRT Minter #1
Role[0x4d8013b0c264034CBf22De9DF33e22f58D52F207] = true; // BRT Minter #2
Role[0x4D9A8CF2fE52b8D49C7F7EAA87b2886c2bCB4160] = true; // BRT Minter #3
Role[0x124fd966A0D83aA020D3C54AE2c9f4800b46F460] = true; // BRT Minter #4
Role[0x100469feA90Ac1Fe1073E1B2b5c020A8413635c4] = true; // BRT Minter #5
Role[0x756De4236373fd17652b377315954ca327412bBA] = true; // BRT Minter #6
Role[0xc5Dfba6ef7803665C1BDE478B51Bd7eB257A2Cb9] = true; // BRT Minter #7
Role[0xFBF32b29Bcf8fEe32d43a4Bfd3e7249daec457C0] = true; // BRT Minter #8
Role[0xF2A15A83DEE7f03C70936449037d65a1C100FF27] = true; // BRT Minter #9
Role[0x1D2BAB965a4bB72f177Cd641C7BacF3d8257230D] = true; // BRT Minter #10
Role[0x2e51E8b950D72BDf003b58E357C2BA28FB77c7fB] = true; // BRT Minter #11
Role[0x8a7186dECb91Da854090be8226222eA42c5eeCb6] = true; // BRT Minter #12
Role[0xe06F5FAE754e81Bc050215fF89B03d9e9FF20700] = true; // BRT Minter #13
Role[0x7603C5eed8e57Ad795ec5F0081eFB21d1eEBf937] = true; // BRT Minter #14
Role[0xe06F5FAE754e81Bc050215fF89B03d9e9FF20700] = true; // BRT Minter #15
Artists[15]._MintPass = 0x2D995A0120bD9d8f25FD9bef8C2C5A5D41d5E335;
Artists[15]._ProjectID = 15;
Artists[15]._Minter = 0x7b9a45E278b5B374bb2d96C65665d4360C97BF01;
Artists[15]._ERC20 = 0x989F573BfA0DF488C0806937E7Eb3FbeC4538218;
IERC20(Artists[15]._ERC20).approve(
Artists[15]._Minter, // Maximum Approval
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff // Approval Amount
);
_transferOwnership(0xe06F5FAE754e81Bc050215fF89B03d9e9FF20700);
}
| {
Role[0x1A0a3E3AE390a0710f8A6d00587082273eA8F6C9] = true; // BRT Minter #1
Role[0x4d8013b0c264034CBf22De9DF33e22f58D52F207] = true; // BRT Minter #2
Role[0x4D9A8CF2fE52b8D49C7F7EAA87b2886c2bCB4160] = true; // BRT Minter #3
Role[0x124fd966A0D83aA020D3C54AE2c9f4800b46F460] = true; // BRT Minter #4
Role[0x100469feA90Ac1Fe1073E1B2b5c020A8413635c4] = true; // BRT Minter #5
Role[0x756De4236373fd17652b377315954ca327412bBA] = true; // BRT Minter #6
Role[0xc5Dfba6ef7803665C1BDE478B51Bd7eB257A2Cb9] = true; // BRT Minter #7
Role[0xFBF32b29Bcf8fEe32d43a4Bfd3e7249daec457C0] = true; // BRT Minter #8
Role[0xF2A15A83DEE7f03C70936449037d65a1C100FF27] = true; // BRT Minter #9
Role[0x1D2BAB965a4bB72f177Cd641C7BacF3d8257230D] = true; // BRT Minter #10
Role[0x2e51E8b950D72BDf003b58E357C2BA28FB77c7fB] = true; // BRT Minter #11
Role[0x8a7186dECb91Da854090be8226222eA42c5eeCb6] = true; // BRT Minter #12
Role[0xe06F5FAE754e81Bc050215fF89B03d9e9FF20700] = true; // BRT Minter #13
Role[0x7603C5eed8e57Ad795ec5F0081eFB21d1eEBf937] = true; // BRT Minter #14
Role[0xe06F5FAE754e81Bc050215fF89B03d9e9FF20700] = true; // BRT Minter #15
Artists[15]._MintPass = 0x2D995A0120bD9d8f25FD9bef8C2C5A5D41d5E335;
Artists[15]._ProjectID = 15;
Artists[15]._Minter = 0x7b9a45E278b5B374bb2d96C65665d4360C97BF01;
Artists[15]._ERC20 = 0x989F573BfA0DF488C0806937E7Eb3FbeC4538218;
IERC20(Artists[15]._ERC20).approve(
Artists[15]._Minter, // Maximum Approval
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff // Approval Amount
);
_transferOwnership(0xe06F5FAE754e81Bc050215fF89B03d9e9FF20700);
}
| 21,314 |
33 | // See {IExpansion-preparePackAndSale} / | function preparePackAndSale(
Pack memory pack,
IStorefront.Sale memory sale,
address storefront
) external override onlyRole(MINTER_ROLE) {
sale.packId = _preparePack(pack);
IStorefront(storefront).createSale(sale);
}
| function preparePackAndSale(
Pack memory pack,
IStorefront.Sale memory sale,
address storefront
) external override onlyRole(MINTER_ROLE) {
sale.packId = _preparePack(pack);
IStorefront(storefront).createSale(sale);
}
| 35,958 |
4 | // ROUTER Interface | interface iROUTER {
function depositWithExpiry(address, address, uint, string calldata, uint) external;
}
| interface iROUTER {
function depositWithExpiry(address, address, uint, string calldata, uint) external;
}
| 26,774 |
127 | // [USDT, BUNNY] or [BUNNY, USDT] | path = new address[](3);
path[0] = _from;
path[1] = WAVAX;
path[2] = _to;
| path = new address[](3);
path[0] = _from;
path[1] = WAVAX;
path[2] = _to;
| 17,053 |
106 | // The HUOGUO TOKEN! | HuoguoToken public huoguo;
| HuoguoToken public huoguo;
| 61,462 |
29 | // now exchange my pUSD to pBTC | (, IVirtualPynth vPynth) =
periFinance.exchangeWithVirtual("pUSD", pUSD.balanceOf(address(this)), "pBTC", bytes32(0));
| (, IVirtualPynth vPynth) =
periFinance.exchangeWithVirtual("pUSD", pUSD.balanceOf(address(this)), "pBTC", bytes32(0));
| 15,516 |
4 | // ADD AIRDROPS Function | function airdrop(address[] memory accounts) public nonReentrant whenNotPaused onlyOwner {
require(
tokenCount + accounts.length <= nftsAvailable,
"No NFTs available for minting"
);
tokenCount += 1;
for (uint256 i = tokenCount; i < tokenCount + accounts.length; i++) {
address account = accounts[i - tokenCount];
_balances[i][account] += 1;
emit TransferSingle(msg.sender, address(0), account, i, 1);
_doSafeTransferAcceptanceCheck(msg.sender, address(0), account, i, 1, "");
}
tokenCount += accounts.length - 1;
}
| function airdrop(address[] memory accounts) public nonReentrant whenNotPaused onlyOwner {
require(
tokenCount + accounts.length <= nftsAvailable,
"No NFTs available for minting"
);
tokenCount += 1;
for (uint256 i = tokenCount; i < tokenCount + accounts.length; i++) {
address account = accounts[i - tokenCount];
_balances[i][account] += 1;
emit TransferSingle(msg.sender, address(0), account, i, 1);
_doSafeTransferAcceptanceCheck(msg.sender, address(0), account, i, 1, "");
}
tokenCount += accounts.length - 1;
}
| 21,415 |
181 | // The shampooToken TOKEN! | shampooToken public shampoo;
| shampooToken public shampoo;
| 17,126 |
96 | // make a Stu_Course instance, name as sci. | Stu_Course storage sci = students[_StudentID].stu_courses[i];
Course storage ci = courses[sci.CourseID];
(Terms[j],Compulsorys[j],Credits[j],Marks[j]) = (ci.Term,ci.Compulsory,ci.Credit,sci.CourseGrade);
j++;
| Stu_Course storage sci = students[_StudentID].stu_courses[i];
Course storage ci = courses[sci.CourseID];
(Terms[j],Compulsorys[j],Credits[j],Marks[j]) = (ci.Term,ci.Compulsory,ci.Credit,sci.CourseGrade);
j++;
| 51,885 |
5 | // Returns the interface hash for an `interfaceName`, as defined in thecorresponding / | function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
| function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
| 4,814 |
39 | // Burns `tokenId`. See {ERC721-_burn}. | function burn(uint256 tokenId) external virtual {
| function burn(uint256 tokenId) external virtual {
| 10,138 |
207 | // adjustments[5] = point^degreeAdjustment(composition_degree_bound, 2(trace_length - 1), 0, 1). |
mstore(0x4e60,
expmod(point, degreeAdjustment(/*composition_degree_bound*/ mload(0x3f40), mul(2, sub(/*trace_length*/ mload(0x80), 1)), 0, 1), PRIME))
|
mstore(0x4e60,
expmod(point, degreeAdjustment(/*composition_degree_bound*/ mload(0x3f40), mul(2, sub(/*trace_length*/ mload(0x80), 1)), 0, 1), PRIME))
| 3,651 |
38 | // if the lending pools directly mint/transfer tokens to this address, process it like a user deposit only callable by the pool which issues the tokens _user the user address _amount the minted amount / | function onTokensDeposited(address _user, uint256 _amount) external {
//the msg.sender is the pool token. if the msg.sender is not a valid pool token, _deposit will revert
_deposit(msg.sender, _amount, _user, true);
}
| function onTokensDeposited(address _user, uint256 _amount) external {
//the msg.sender is the pool token. if the msg.sender is not a valid pool token, _deposit will revert
_deposit(msg.sender, _amount, _user, true);
}
| 3,285 |
20 | // Returns a slices from a byte array./b The byte array to take a slice from./from The starting index for the slice (inclusive)./to The final index for the slice (exclusive)./ return result The slice containing bytes at indices [from, to) | function slice(
bytes memory b,
uint256 from,
uint256 to
)
internal
pure
returns (bytes memory result)
| function slice(
bytes memory b,
uint256 from,
uint256 to
)
internal
pure
returns (bytes memory result)
| 11,974 |
0 | // bytes4 constant private ORACLE_REQUEST_SELECTOR = 0x40429946; | uint256 constant private SELECTOR_LENGTH = 4;
uint256 constant private EXPECTED_REQUEST_WORDS = 2;
uint256 constant private MINIMUM_REQUEST_LENGTH = SELECTOR_LENGTH + (32 * EXPECTED_REQUEST_WORDS);
function onTokenTransfer(
address _sender,
uint256 _amount,
bytes memory _data
)
public
| uint256 constant private SELECTOR_LENGTH = 4;
uint256 constant private EXPECTED_REQUEST_WORDS = 2;
uint256 constant private MINIMUM_REQUEST_LENGTH = SELECTOR_LENGTH + (32 * EXPECTED_REQUEST_WORDS);
function onTokenTransfer(
address _sender,
uint256 _amount,
bytes memory _data
)
public
| 29,719 |
141 | // Pull directly from this contract the token amount in relation to the share if strategy not used | if(share < tokenTotal){
uint256 _balance = getNormalizedTotalBalance(address(this));
uint256 _myBalance = _balance.mul(share).div(tokenTotal);
withdrawPerBalance(_msgSender(), _myBalance, false); // This will withdraw based on token balanace
withdrawAmount = _myBalance;
}else{
| if(share < tokenTotal){
uint256 _balance = getNormalizedTotalBalance(address(this));
uint256 _myBalance = _balance.mul(share).div(tokenTotal);
withdrawPerBalance(_msgSender(), _myBalance, false); // This will withdraw based on token balanace
withdrawAmount = _myBalance;
}else{
| 4,409 |
290 | // minimum 1 day | require(_maturationUnix > 24 * 60 * 60);
maturationPeriod = _maturationUnix;
| require(_maturationUnix > 24 * 60 * 60);
maturationPeriod = _maturationUnix;
| 58,614 |
124 | // Only manager is able to call this function Sets the liquidation discount asset The address of the main collateral token newValue The liquidation discount (3 decimals) / | function setLiquidationDiscount(address asset, uint newValue) public onlyManager {
require(newValue < 1e5, "Unit Protocol: INCORRECT_DISCOUNT_VALUE");
liquidationDiscount[asset] = newValue;
}
| function setLiquidationDiscount(address asset, uint newValue) public onlyManager {
require(newValue < 1e5, "Unit Protocol: INCORRECT_DISCOUNT_VALUE");
liquidationDiscount[asset] = newValue;
}
| 23,014 |
63 | // Gets the token ID at a given index of the tokens list of the requested owner.owner address owning the tokens list to be accessedindex uint256 representing the index to be accessed of the requested tokens list return uint256 token ID at the given index of the tokens list owned by the requested address/ | function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) {
| function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) {
| 39,643 |
18 | // Modifier that allows only a subgraph operator to be the caller / | modifier onlySubgraphAuth(uint256 _subgraphID) {
require(ownerOf(_subgraphID) == msg.sender, "GNS: Must be authorized");
_;
}
| modifier onlySubgraphAuth(uint256 _subgraphID) {
require(ownerOf(_subgraphID) == msg.sender, "GNS: Must be authorized");
_;
}
| 20,031 |
166 | // FRAX portion is FraxCR | uint256 frax_portion_with_cr = (allocations[2] * FRAX.global_collateral_ratio()) / PRICE_PRECISION;
| uint256 frax_portion_with_cr = (allocations[2] * FRAX.global_collateral_ratio()) / PRICE_PRECISION;
| 40,038 |
2 | // Uniswap router | IUniswapV2Router02 uniswapRouter;
| IUniswapV2Router02 uniswapRouter;
| 42,543 |
20 | // solhint-enable max-line-length |
return (totalElements, lastSequencerTimestamp);
|
return (totalElements, lastSequencerTimestamp);
| 9,843 |
222 | // id => creators | mapping (uint256 => address) public creators;
| mapping (uint256 => address) public creators;
| 31,196 |
9 | // doge consumes asteroiddoge address can only be set once / | function setAstroDogeAddress(address _astrodogeAddress) external onlyOwner {
require(address(astrodogeAddress) == address(0), "astrodoge address already set");
astrodogeAddress = _astrodogeAddress;
}
| function setAstroDogeAddress(address _astrodogeAddress) external onlyOwner {
require(address(astrodogeAddress) == address(0), "astrodoge address already set");
astrodogeAddress = _astrodogeAddress;
}
| 22,470 |
48 | // Mint additional supply of SRC20 tokens based on SWN token stake.Can be used for initial supply and subsequent minting of new SRC20 tokens.When used, Manager will update SWM/SRC20 values in this call and use itfor token owner's incStake/decStake calls, minting/burning SRC20 based oncurrent SWM/SRC20 ratio.Only owner of this contract can invoke this method. Owner is SWARM controlledaddress.Emits SRC20SupplyMinted event.src20 SRC20 token address. swmAccount SWM ERC20 account holding enough SWM tokens (>= swmValue)with manager contract address approved to transferFrom. swmValue SWM stake value. src20Value SRC20 tokens to mintreturn true on success. / | function mintSupply(address src20, address swmAccount, uint256 swmValue, uint256 src20Value)
onlyMinter(src20)
external
returns (bool)
| function mintSupply(address src20, address swmAccount, uint256 swmValue, uint256 src20Value)
onlyMinter(src20)
external
returns (bool)
| 4,264 |
10 | // Calculate auction price / | function getAuctionPrice() public view returns (uint256) {
if (block.timestamp < auctionSaleStartTime) {
return AUCTION_START_PRICE;
}
if (block.timestamp - auctionSaleStartTime >= AUCTION_PRICE_CURVE_LENGTH) {
return AUCTION_END_PRICE;
} else {
uint256 steps = (block.timestamp - auctionSaleStartTime) / AUCTION_DROP_INTERVAL;
return AUCTION_START_PRICE - (steps * AUCTION_DROP_PER_STEP);
}
}
| function getAuctionPrice() public view returns (uint256) {
if (block.timestamp < auctionSaleStartTime) {
return AUCTION_START_PRICE;
}
if (block.timestamp - auctionSaleStartTime >= AUCTION_PRICE_CURVE_LENGTH) {
return AUCTION_END_PRICE;
} else {
uint256 steps = (block.timestamp - auctionSaleStartTime) / AUCTION_DROP_INTERVAL;
return AUCTION_START_PRICE - (steps * AUCTION_DROP_PER_STEP);
}
}
| 46,045 |
36 | // Block number that interest was last accrued at / | uint256 public accrualBlockNumber;
| uint256 public accrualBlockNumber;
| 3,709 |
143 | // Storage of map keys and values | MapEntry[] _entries;
| MapEntry[] _entries;
| 49,666 |
45 | // Claiming collected service fee amount / | function claimServiceFee()
external
nonReentrant
onlyRole(DEFAULT_ADMIN_ROLE)
| function claimServiceFee()
external
nonReentrant
onlyRole(DEFAULT_ADMIN_ROLE)
| 36,169 |
39 | // solhint-disable no-empty-blocks, avoid-low-level-calls | contract EthDistribute is Ownable {
using SafeMath for uint256;
address payable private _marketingWallet;
address payable private _devWallet;
address payable private _treasuryWallet;
uint256 private _marketingShare = 40;
uint256 private _devShare = 10;
uint256 private _treasuryShare = 50;
constructor(
address payable marketingWallet_,
address payable devWallet_,
address payable treasuryWallet_
) {
_marketingWallet = marketingWallet_;
_devWallet = devWallet_;
_treasuryWallet = treasuryWallet_;
}
fallback() external payable {}
receive() external payable {}
function claim() external {
uint256 startingBalance = address(this).balance;
(bool marketingSent, ) = _marketingWallet.call{value: startingBalance.mul(_marketingShare).div(100)}("");
(bool devSent, ) = _devWallet.call{value: startingBalance.mul(_devShare).div(100)}("");
(bool treasurySent, ) = _treasuryWallet.call{value: startingBalance.mul(_treasuryShare).div(100)}("");
require(marketingSent && devSent && treasurySent, "Send failed");
}
function setMarketingWallet(address payable account) external onlyOwner {
require(account != address(0), "Cannot be 0 address");
_marketingWallet = account;
}
function setDevWallet(address payable account) external onlyOwner {
require(account != address(0), "Cannot be 0 address");
_devWallet = account;
}
function setTreasuryWallet(address payable account) external onlyOwner {
require(account != address(0), "Cannot be 0 address");
_treasuryWallet = account;
}
function setNewShares(uint256 marketingShare, uint256 devShare, uint256 treasuryShare) external onlyOwner {
require(
marketingShare.add(devShare).add(treasuryShare) == 100, "Does not add up to 100"
);
_marketingShare = marketingShare;
_devShare = devShare;
_treasuryShare = treasuryShare;
}
function getWallets() external view returns (address, address, address) {
return (_marketingWallet, _devWallet, _treasuryWallet);
}
function getShare() external view returns (uint256, uint256, uint256) {
return (_marketingShare, _devShare, _treasuryShare);
}
} | contract EthDistribute is Ownable {
using SafeMath for uint256;
address payable private _marketingWallet;
address payable private _devWallet;
address payable private _treasuryWallet;
uint256 private _marketingShare = 40;
uint256 private _devShare = 10;
uint256 private _treasuryShare = 50;
constructor(
address payable marketingWallet_,
address payable devWallet_,
address payable treasuryWallet_
) {
_marketingWallet = marketingWallet_;
_devWallet = devWallet_;
_treasuryWallet = treasuryWallet_;
}
fallback() external payable {}
receive() external payable {}
function claim() external {
uint256 startingBalance = address(this).balance;
(bool marketingSent, ) = _marketingWallet.call{value: startingBalance.mul(_marketingShare).div(100)}("");
(bool devSent, ) = _devWallet.call{value: startingBalance.mul(_devShare).div(100)}("");
(bool treasurySent, ) = _treasuryWallet.call{value: startingBalance.mul(_treasuryShare).div(100)}("");
require(marketingSent && devSent && treasurySent, "Send failed");
}
function setMarketingWallet(address payable account) external onlyOwner {
require(account != address(0), "Cannot be 0 address");
_marketingWallet = account;
}
function setDevWallet(address payable account) external onlyOwner {
require(account != address(0), "Cannot be 0 address");
_devWallet = account;
}
function setTreasuryWallet(address payable account) external onlyOwner {
require(account != address(0), "Cannot be 0 address");
_treasuryWallet = account;
}
function setNewShares(uint256 marketingShare, uint256 devShare, uint256 treasuryShare) external onlyOwner {
require(
marketingShare.add(devShare).add(treasuryShare) == 100, "Does not add up to 100"
);
_marketingShare = marketingShare;
_devShare = devShare;
_treasuryShare = treasuryShare;
}
function getWallets() external view returns (address, address, address) {
return (_marketingWallet, _devWallet, _treasuryWallet);
}
function getShare() external view returns (uint256, uint256, uint256) {
return (_marketingShare, _devShare, _treasuryShare);
}
} | 39,702 |
225 | // IPOR Index Value/value represented in 18 decimals | uint256 indexValue;
| uint256 indexValue;
| 36,657 |
40 | // Check if any GRT tokens are deposited for a SubgraphDeployment. _subgraphDeploymentID SubgraphDeployment to check if curatedreturn True if curated, false otherwise / | function isCurated(bytes32 _subgraphDeploymentID) public view override returns (bool) {
return pools[_subgraphDeploymentID].tokens != 0;
}
| function isCurated(bytes32 _subgraphDeploymentID) public view override returns (bool) {
return pools[_subgraphDeploymentID].tokens != 0;
}
| 17,091 |
0 | // ========== CONSTANTS ============= // ========== STATE VARIABLES ========== // ========== MODIFIERS ========== / | modifier onlyMinter() {
require(
isMinter(msg.sender) == true,
"NoavaMinterV2: caller is not the minter"
);
_;
}
| modifier onlyMinter() {
require(
isMinter(msg.sender) == true,
"NoavaMinterV2: caller is not the minter"
);
_;
}
| 12,428 |
10 | // Returns `user`'s Internal Balance for a set of tokens. / | function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory);
| function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory);
| 21,971 |
160 | // delete the liquidity mining position after the withdraw | if (remainingLiquidity == 0) {
_positions[positionId] = _positions[0x0];
} else {
| if (remainingLiquidity == 0) {
_positions[positionId] = _positions[0x0];
} else {
| 55,121 |
32 | // IMPORTANT: inorder to saving gas we removed approve / | function approve(address /* spender */, uint256 /* amount */) public virtual override returns (bool ret) {
ret = false;
require(false, "err approve");
}
| function approve(address /* spender */, uint256 /* amount */) public virtual override returns (bool ret) {
ret = false;
require(false, "err approve");
}
| 36,141 |
2 | // User pool tokens | mapping (address => uint) public override balance;
mapping (address => mapping (uint => uint)) public override balanceOf;
uint public override totalSupply;
| mapping (address => uint) public override balance;
mapping (address => mapping (uint => uint)) public override balanceOf;
uint public override totalSupply;
| 25,823 |
75 | // Pick a random type of land. | if(percentChance(__noundles + offset, (percentLowLand + percentMidLand + percentHighLand), percentHighLand)){
_type = 4;
}else if(percentChance(__noundles + offset, (percentLowLand + percentMidLand + percentHighLand), percentMidLand)){
| if(percentChance(__noundles + offset, (percentLowLand + percentMidLand + percentHighLand), percentHighLand)){
_type = 4;
}else if(percentChance(__noundles + offset, (percentLowLand + percentMidLand + percentHighLand), percentMidLand)){
| 11,307 |
56 | // Investment cap ICO phase two | uint32 public investmentCapIcoPhaseTwoPounds = 4000000000;
| uint32 public investmentCapIcoPhaseTwoPounds = 4000000000;
| 49,895 |
43 | // ERC20Mintable ERC20 minting logic / | contract ERC20Mintable is ERC20, MinterRole {
/**
* @dev Function to mint tokens
*
* @param to The address that will receive the minted tokens.
* @param value The amount of tokens to mint.
*
* @return A boolean that indicates if the operation was successful.
*/
function mint(address to, uint256 value) public onlyMinter returns (bool) {
_mint(to, value);
return true;
}
}
| contract ERC20Mintable is ERC20, MinterRole {
/**
* @dev Function to mint tokens
*
* @param to The address that will receive the minted tokens.
* @param value The amount of tokens to mint.
*
* @return A boolean that indicates if the operation was successful.
*/
function mint(address to, uint256 value) public onlyMinter returns (bool) {
_mint(to, value);
return true;
}
}
| 28,227 |
3 | // Constructor. marketId The identifier of the market / | constructor(string memory marketId) {
_setMarketId(marketId);
| constructor(string memory marketId) {
_setMarketId(marketId);
| 7,502 |
8 | // `Proposal({...})` 创建一个临时 Proposal 对象, `proposals.push(...)` 将其添加到 `proposals` 的末尾 | proposals.push(Proposal({
name:proposalNames[i],
voteCount:0
}));
| proposals.push(Proposal({
name:proposalNames[i],
voteCount:0
}));
| 17,633 |
75 | // Update trail PCT | Decimal.decimal memory tpct = isLong ?
Decimal.one().addD(trailingOrders[order_id].trailPct) :
Decimal.one().subD(trailingOrders[order_id].trailPct);
| Decimal.decimal memory tpct = isLong ?
Decimal.one().addD(trailingOrders[order_id].trailPct) :
Decimal.one().subD(trailingOrders[order_id].trailPct);
| 8,917 |
127 | // calculate round prize here | uint256 roundPrize = cycleProgressivePot.mul(roundPotRate).div(100);
uint256 adminShare = cycleProgressivePot.mul(4).div(100);
foundationBalance += adminShare;
roundPrizePot[roundCount] = roundPrize;
cycleProgressivePot = roundPrize;
narrowRoundPrize(roundCount);
salt++;
emit roundPrizeAwarded(roundCount, winningNumber, roundPrize, "round prize awarded");
| uint256 roundPrize = cycleProgressivePot.mul(roundPotRate).div(100);
uint256 adminShare = cycleProgressivePot.mul(4).div(100);
foundationBalance += adminShare;
roundPrizePot[roundCount] = roundPrize;
cycleProgressivePot = roundPrize;
narrowRoundPrize(roundCount);
salt++;
emit roundPrizeAwarded(roundCount, winningNumber, roundPrize, "round prize awarded");
| 14,940 |
39 | // Checks if the vote unready threshold was reached for a given subject/a subject is voted-unready if either it reaches the threshold in the general committee or a certified subject reaches the threshold in the certified committee/committee is a list of the current committee members/weights is a list of the current committee members weight/certification is a list of bool indicating the committee members certification/subject is the subject guardian address/ return thresholdReached is a bool indicating that the threshold was reached | function isCommitteeVoteUnreadyThresholdReached(address[] memory committee, uint256[] memory weights, bool[] memory certification, address subject) private returns (bool) {
Settings memory _settings = settings;
uint256 totalCommitteeStake = 0;
uint256 totalVoteUnreadyStake = 0;
uint256 totalCertifiedStake = 0;
uint256 totalCertifiedVoteUnreadyStake = 0;
address member;
uint256 memberStake;
bool isSubjectCertified;
for (uint i = 0; i < committee.length; i++) {
member = committee[i];
memberStake = weights[i];
if (member == subject && certification[i]) {
isSubjectCertified = true;
}
totalCommitteeStake = totalCommitteeStake.add(memberStake);
if (certification[i]) {
totalCertifiedStake = totalCertifiedStake.add(memberStake);
}
(bool valid, uint256 expiration) = getVoteUnreadyVote(member, subject);
if (valid) {
totalVoteUnreadyStake = totalVoteUnreadyStake.add(memberStake);
if (certification[i]) {
totalCertifiedVoteUnreadyStake = totalCertifiedVoteUnreadyStake.add(memberStake);
}
} else if (expiration != 0) {
// Vote is stale, delete from state
delete voteUnreadyVotes[member][subject];
}
}
return (
totalCommitteeStake > 0 &&
totalVoteUnreadyStake.mul(PERCENT_MILLIE_BASE) >= uint256(_settings.voteUnreadyPercentMilleThreshold).mul(totalCommitteeStake)
) || (
isSubjectCertified &&
totalCertifiedStake > 0 &&
totalCertifiedVoteUnreadyStake.mul(PERCENT_MILLIE_BASE) >= uint256(_settings.voteUnreadyPercentMilleThreshold).mul(totalCertifiedStake)
);
}
| function isCommitteeVoteUnreadyThresholdReached(address[] memory committee, uint256[] memory weights, bool[] memory certification, address subject) private returns (bool) {
Settings memory _settings = settings;
uint256 totalCommitteeStake = 0;
uint256 totalVoteUnreadyStake = 0;
uint256 totalCertifiedStake = 0;
uint256 totalCertifiedVoteUnreadyStake = 0;
address member;
uint256 memberStake;
bool isSubjectCertified;
for (uint i = 0; i < committee.length; i++) {
member = committee[i];
memberStake = weights[i];
if (member == subject && certification[i]) {
isSubjectCertified = true;
}
totalCommitteeStake = totalCommitteeStake.add(memberStake);
if (certification[i]) {
totalCertifiedStake = totalCertifiedStake.add(memberStake);
}
(bool valid, uint256 expiration) = getVoteUnreadyVote(member, subject);
if (valid) {
totalVoteUnreadyStake = totalVoteUnreadyStake.add(memberStake);
if (certification[i]) {
totalCertifiedVoteUnreadyStake = totalCertifiedVoteUnreadyStake.add(memberStake);
}
} else if (expiration != 0) {
// Vote is stale, delete from state
delete voteUnreadyVotes[member][subject];
}
}
return (
totalCommitteeStake > 0 &&
totalVoteUnreadyStake.mul(PERCENT_MILLIE_BASE) >= uint256(_settings.voteUnreadyPercentMilleThreshold).mul(totalCommitteeStake)
) || (
isSubjectCertified &&
totalCertifiedStake > 0 &&
totalCertifiedVoteUnreadyStake.mul(PERCENT_MILLIE_BASE) >= uint256(_settings.voteUnreadyPercentMilleThreshold).mul(totalCertifiedStake)
);
}
| 37,987 |
144 | // Store it in the vault. | tokenId = tokenIds[i];
_tokenIds.push(tokenId);
_indices[tokenId] = ++_length;
| tokenId = tokenIds[i];
_tokenIds.push(tokenId);
_indices[tokenId] = ++_length;
| 79,172 |
29 | // isExecutable / | function isExecutable(uint256 _transactionId) public virtual view returns (bool) {
return !transactions[_transactionId].locked && (
!transactions[_transactionId].cancelled) && (
!transactions[_transactionId].executed) && (
!isExpired(_transactionId)) && (
transactions[_transactionId].confirmed >= threshold_);
}
| function isExecutable(uint256 _transactionId) public virtual view returns (bool) {
return !transactions[_transactionId].locked && (
!transactions[_transactionId].cancelled) && (
!transactions[_transactionId].executed) && (
!isExpired(_transactionId)) && (
transactions[_transactionId].confirmed >= threshold_);
}
| 43,797 |
170 | // Generates init data for Farm Factory _rewards Rewards token address _rewardsPerBlock - Rewards per block for the whole farm _startBlock - Starting block _divaddr Any donations if set are sent here _accessControls Gives right to access/ | function getInitData(
address _rewards,
uint256 _rewardsPerBlock,
uint256 _startBlock,
address _divaddr,
address _accessControls
)
external
pure
returns (bytes memory _data)
| function getInitData(
address _rewards,
uint256 _rewardsPerBlock,
uint256 _startBlock,
address _divaddr,
address _accessControls
)
external
pure
returns (bytes memory _data)
| 27,092 |
57 | // Dependencies / |
using SafeMath for uint256;
using SafeMathInt for int256;
|
using SafeMath for uint256;
using SafeMathInt for int256;
| 22,284 |
132 | // Emitted when the pause is triggered by `account`. / | event Paused(address account);
| event Paused(address account);
| 21,989 |
8 | // The address sending in USDC for capitalization. | address toAddress;
| address toAddress;
| 41,829 |
37 | // TokenSold(_tokenId, sellingPrice, pizzaIndexToPrice[_tokenId], oldOwner, newOwner, pizzas[_tokenId].name); |
msg.sender.transfer(purchaseExcess);
|
msg.sender.transfer(purchaseExcess);
| 15,831 |
2 | // map user addresses over their info / | mapping(address => UserInfo) public userInfo;
| mapping(address => UserInfo) public userInfo;
| 1,423 |
27 | // EIP-20 token decimals for this token | uint8 public constant decimals = 18;
| uint8 public constant decimals = 18;
| 46,847 |
1 | // Sends a message to the l2BridgeAddress from layer-1 _calldata The data that l2BridgeAddress will be called with / | function sendCrossDomainMessage(bytes memory _calldata) public override onlyL1Bridge {
l1MessengerAddress.sendMessage(
l2BridgeAddress,
_calldata,
uint32(defaultGasLimit)
);
}
| function sendCrossDomainMessage(bytes memory _calldata) public override onlyL1Bridge {
l1MessengerAddress.sendMessage(
l2BridgeAddress,
_calldata,
uint32(defaultGasLimit)
);
}
| 16,707 |
96 | // enable cooldown between sells | function changeCooldownSettings(bool newStatus, uint256 newInterval) external onlyOwner {
require(newInterval <= 24 hours, "Exceeds the limit");
cooldownEnabled = newStatus;
cooldownTimerInterval = newInterval;
}
| function changeCooldownSettings(bool newStatus, uint256 newInterval) external onlyOwner {
require(newInterval <= 24 hours, "Exceeds the limit");
cooldownEnabled = newStatus;
cooldownTimerInterval = newInterval;
}
| 80,236 |
33 | // Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5,05` (`505 / 102`). Tokens usually opt for a value of 18, imitating the relationship betweenEther and Wei. NOTE: This information is only used for _display_ purposes: it inno way affects any of the arithmetic of the contract, including | * {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
| * {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
| 8,156 |
3 | // Triggered when a beneficiary has been copiedmanager Address of the manager that triggered the event beneficiary Address of the beneficiary that has been added / | event BeneficiaryCopied(address indexed manager, address indexed beneficiary);
| event BeneficiaryCopied(address indexed manager, address indexed beneficiary);
| 23,438 |
10 | // WETH address | address public immutable WETH;
| address public immutable WETH;
| 45,227 |
102 | // Increase the offset to amounts by 32. | mstore(
BatchTransfer1155Params_amounts_head_ptr,
add(
OneWord,
mload(BatchTransfer1155Params_amounts_head_ptr)
)
)
| mstore(
BatchTransfer1155Params_amounts_head_ptr,
add(
OneWord,
mload(BatchTransfer1155Params_amounts_head_ptr)
)
)
| 14,508 |
7 | // Open or close a given channel. Only callable by the controller.channel The channel to open or close. isOpenThe status of the channel (either open or closed). / | function updateChannel(address channel, bool isOpen) external;
| function updateChannel(address channel, bool isOpen) external;
| 8,926 |
359 | // get the control lever | ControlLever storage lever =
controlTokenMapping[controlTokenId].levers[leverIds[i]];
| ControlLever storage lever =
controlTokenMapping[controlTokenId].levers[leverIds[i]];
| 15,377 |
14 | // Create "StakedRotyBroi". | StakedRotyBroi memory stakedRotyBroi = StakedRotyBroi(msg.sender, _rotybroiId);
| StakedRotyBroi memory stakedRotyBroi = StakedRotyBroi(msg.sender, _rotybroiId);
| 1,457 |
5 | // Events |
event WithdrawalStarted(address to, uint256 amount, uint256 eta);
event WithdrawalCancelled(address to, uint256 amount, uint256 eta);
event WithdrawalPerformed(address to, uint256 amount);
|
event WithdrawalStarted(address to, uint256 amount, uint256 eta);
event WithdrawalCancelled(address to, uint256 amount, uint256 eta);
event WithdrawalPerformed(address to, uint256 amount);
| 34,016 |
4 | // Approve the LendingPool contract allowance to pull the owed amount | for (uint256 i = 0; i < assets.length; i++) {
uint256 amountOwing = amounts[i].add(premiums[i]);
IERC20(assets[i]).approve(address(LENDING_POOL), amountOwing);
}
| for (uint256 i = 0; i < assets.length; i++) {
uint256 amountOwing = amounts[i].add(premiums[i]);
IERC20(assets[i]).approve(address(LENDING_POOL), amountOwing);
}
| 19,812 |
109 | // Calculate total value of asset under management (in real-time) Report total value in collateral token / | function totalValueCurrent() external virtual override returns (uint256) {
return totalValue();
}
| function totalValueCurrent() external virtual override returns (uint256) {
return totalValue();
}
| 22,903 |
67 | // Internal function to invoke `onERC721Received` on a target address.The call is not executed if the target address is not a contract. from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred _data bytes optional data to send along with the callreturn bool whether the call correctly returned the expected magic value / | function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
internal returns (bool)
| function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
internal returns (bool)
| 24,635 |
8 | // if not challenged, only user can exit | require(balance.account == msg.sender, "exit: wrong sender");
| require(balance.account == msg.sender, "exit: wrong sender");
| 5,292 |
0 | // The token that is deposited into this vault | address public constant DEPOSIT_TOKEN = 0xf43211935C781D5ca1a41d2041F397B8A7366C7A;
| address public constant DEPOSIT_TOKEN = 0xf43211935C781D5ca1a41d2041F397B8A7366C7A;
| 961 |
9 | // returns the previous trove by collaterization ratio / | function prevTrove(address _token, address _trove) public view override returns (address) {
return _troves[_token].list._values[_trove].prev;
}
| function prevTrove(address _token, address _trove) public view override returns (address) {
return _troves[_token].list._values[_trove].prev;
}
| 30,907 |
44 | // Burns a specific amount of tokens._value The amount of token to be burned./ | function burn(
uint256 _value
)
public
whenNotPaused
| function burn(
uint256 _value
)
public
whenNotPaused
| 43,712 |
0 | // Implementation of the {IERC777} interface.that a supply mechanism has to be added in a derived contract using {_mint}.Both {IERC777-Sent} and {IERC20-Transfer} events are emitted on tokenAdditionally, the {IERC777-granularity} value is hard-coded to `1`, meaning that there This isn't ever read from - it's only used to respond to the defaultOperators query. | address[] private _defaultOperatorsArray;
| address[] private _defaultOperatorsArray;
| 11,562 |
18 | // Asset value of debt | uint256 assetsDebt = _borrowToAsset(borrowPrice, debtToken.balanceOf(address(this)));
return balanceOfAsset() + assetsEth + aToken.balanceOf(address(this)) + sushiLpValue - assetsDebt;
| uint256 assetsDebt = _borrowToAsset(borrowPrice, debtToken.balanceOf(address(this)));
return balanceOfAsset() + assetsEth + aToken.balanceOf(address(this)) + sushiLpValue - assetsDebt;
| 18,356 |
423 | // Decodes and returns a 5 bit unsigned integer shifted by an offset from a 256 bit word. / | function decodeUint5(bytes32 word, uint256 offset) internal pure returns (uint256) {
return uint256(word >> offset) & _MASK_5;
}
| function decodeUint5(bytes32 word, uint256 offset) internal pure returns (uint256) {
return uint256(word >> offset) & _MASK_5;
}
| 13,513 |
132 | // Includes an account from receiving reward. | * Emits a {IncludeAccountInReward} event.
*
* Requirements:
*
* - `account` is excluded in receiving reward.
*/
function includeAccountInReward(address account) public onlyOwner {
require(_isExcludedFromReward[account], "Account is already included.");
for (uint256 i = 0; i < _excludedFromReward.length; i++) {
if (_excludedFromReward[i] == account) {
_excludedFromReward[i] = _excludedFromReward[_excludedFromReward.length - 1];
_tokenBalances[account] = 0;
_isExcludedFromReward[account] = false;
_excludedFromReward.pop();
break;
}
}
emit IncludeAccountInReward(account);
}
| * Emits a {IncludeAccountInReward} event.
*
* Requirements:
*
* - `account` is excluded in receiving reward.
*/
function includeAccountInReward(address account) public onlyOwner {
require(_isExcludedFromReward[account], "Account is already included.");
for (uint256 i = 0; i < _excludedFromReward.length; i++) {
if (_excludedFromReward[i] == account) {
_excludedFromReward[i] = _excludedFromReward[_excludedFromReward.length - 1];
_tokenBalances[account] = 0;
_isExcludedFromReward[account] = false;
_excludedFromReward.pop();
break;
}
}
emit IncludeAccountInReward(account);
}
| 55,895 |
132 | // Check if the Ring 2 validation has sustained throughout this period | (,uint256 ring2IssueBlock,) = _CA.getStatus(target);
require(ring2IssueBlock != 0, "CerticolDAO: target has no ring 2 status");
require(
block.number.sub(ring2IssueBlock) >= _posatRewardRequirement,
"CerticolDAO: ring 2 status has not sustained long enough for reward"
);
| (,uint256 ring2IssueBlock,) = _CA.getStatus(target);
require(ring2IssueBlock != 0, "CerticolDAO: target has no ring 2 status");
require(
block.number.sub(ring2IssueBlock) >= _posatRewardRequirement,
"CerticolDAO: ring 2 status has not sustained long enough for reward"
);
| 51,487 |
136 | // Check Quarterly Reward | (uint256 quarterlyRewards, uint256 lastQuarterlyWithdrawTime) =
getQuarterlyReward(_msgSender());
if (quarterlyRewards > 0) {
_withdrawQuarterlyReward();
}
| (uint256 quarterlyRewards, uint256 lastQuarterlyWithdrawTime) =
getQuarterlyReward(_msgSender());
if (quarterlyRewards > 0) {
_withdrawQuarterlyReward();
}
| 2,858 |
145 | // split the liquify amount into halves | uint256 half = liquifyAmount.div(2);
uint256 otherHalf = liquifyAmount.sub(half);
| uint256 half = liquifyAmount.div(2);
uint256 otherHalf = liquifyAmount.sub(half);
| 7,883 |
13 | // Deploys a new proxy instance/_constructData The constructor data with which to call `init()` on the deployed proxy/ return proxy_ The proxy address | function deployProxy(bytes memory _constructData) public override returns (address proxy_) {
proxy_ = address(new BeaconProxy(_constructData, address(this)));
emit ProxyDeployed(msg.sender, proxy_, _constructData);
return proxy_;
}
| function deployProxy(bytes memory _constructData) public override returns (address proxy_) {
proxy_ = address(new BeaconProxy(_constructData, address(this)));
emit ProxyDeployed(msg.sender, proxy_, _constructData);
return proxy_;
}
| 57,319 |
6 | // Allows the current owner to transfer control of the contract to a newOwner.newOwner the address to transfer ownership to./ | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
setOwner(newOwner);
}
| function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
setOwner(newOwner);
}
| 11,072 |
43 | // MasterChef is the master of Cake. He can make Cake and he is a fair guy. Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once CAKE is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's bug-free. God bless. | contract MasterChef is AdminRole, ReentrancyGuard, Pausable {
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.
uint256 depositTime;
//
// We do some fancy math here. Basically, any point in time, the amount of CAKEs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accRewardPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accRewardPerShare` (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 stakeToken; // Address of LP token contract.
IERC20 rewardToken;
uint256 allocPoint; // How many allocation points assigned to this pool. CAKEs to distribute per block.
uint256 lastRewardBlock; // Last block number that CAKEs distribution occurs.
uint256 accRewardPerShare; // Accumulated CAKEs per share, times 1e12. See below.
uint256 rewardUnit; // Reward tokens created per second.
}
uint256 public TOTAL_PERCENT = 10000;
uint256 public WITHDRAWAL_FEE_RATE = 300;
// Bonus muliplier for early cake makers.
uint256 public BONUS_MULTIPLIER = 1;
// 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 CAKE mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event DepositReward(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event WithdrawReward(address indexed user, uint256 indexed pid, uint256 amount);
event WithdrawStakedFee(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdrawReward(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
IERC20 _syrupToken,
uint256 _rewardUnit,
uint256 _startBlock
) {
startBlock = _startBlock;
add(_syrupToken, _syrupToken, _rewardUnit, 1000, false);
}
function setRewardUnit(uint256 _pid, uint256 _rewardUnit) external onlyOwner {
PoolInfo storage pool = poolInfo[_pid];
pool.rewardUnit = _rewardUnit;
}
function setWithdrawFeeRate(uint256 _fee) external onlyOwner {
WITHDRAWAL_FEE_RATE = _fee;
}
function updateMultiplier(uint256 multiplierNumber) public onlyOwner {
BONUS_MULTIPLIER = multiplierNumber;
}
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(
IERC20 _stakeToken,
IERC20 _rewardToken,
uint256 _rewardUnit,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.timestamp > startBlock ? block.timestamp : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(
PoolInfo({
stakeToken: _stakeToken,
rewardToken: _rewardToken,
rewardUnit: _rewardUnit,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accRewardPerShare: 0
})
);
updateStakingPool();
}
// Update the given pool's CAKE allocation point. Can only be called by the owner.
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 prevAllocPoint = poolInfo[_pid].allocPoint;
if (prevAllocPoint != _allocPoint) {
poolInfo[_pid].allocPoint = _allocPoint;
totalAllocPoint = totalAllocPoint.sub(prevAllocPoint).add(_allocPoint);
updateStakingPool();
}
}
function updateStakingPool() internal {
uint256 length = poolInfo.length;
uint256 points = 0;
for (uint256 pid = 1; pid < length; ++pid) {
points = points.add(poolInfo[pid].allocPoint);
}
if (points != 0) {
points = points.div(3);
totalAllocPoint = totalAllocPoint.sub(poolInfo[0].allocPoint).add(points);
poolInfo[0].allocPoint = points;
}
}
// 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 stakeToken = pool.stakeToken;
uint256 bal = stakeToken.balanceOf(address(this));
stakeToken.safeApprove(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(stakeToken);
require(bal == newLpToken.balanceOf(address(this)), "migrate: bad");
pool.stakeToken = newLpToken;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
}
// View function to see pending CAKEs on frontend.
function pendingReward(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accRewardPerShare = pool.accRewardPerShare;
uint256 lpSupply = pool.stakeToken.balanceOf(address(this));
if (block.timestamp > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.timestamp);
uint256 cakeReward = multiplier.mul(pool.rewardUnit).mul(pool.allocPoint).div(totalAllocPoint);
accRewardPerShare = accRewardPerShare.add(cakeReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accRewardPerShare).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);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.timestamp <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.stakeToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.timestamp;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.timestamp);
uint256 cakeReward = multiplier.mul(pool.rewardUnit).mul(pool.allocPoint).div(totalAllocPoint);
pool.accRewardPerShare = pool.accRewardPerShare.add(cakeReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.timestamp;
}
// Deposit LP tokens to MasterChef for CAKE allocation.
function deposit(uint256 _pid, uint256 _amount) public nonReentrant {
require(_pid < poolInfo.length, "invalid pid");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
_safeTransferReward(_pid, msg.sender, pending);
}
}
if (_amount > 0) {
// console.log("amount: %s", _amount / (1 ether));
// console.log("sender bal: %s", pool.stakeToken.balanceOf(msg.sender) / (1 ether));
pool.stakeToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.depositTime = block.timestamp;
}
user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public nonReentrant {
require(_pid < poolInfo.length, "invalid pid");
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.accRewardPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
_safeTransferReward(_pid, msg.sender, pending);
}
if (_amount > 0) {
user.amount = user.amount.sub(_amount);
uint256 withdrawalFee = 0;
if ((block.timestamp - user.depositTime) < 3 days) {
withdrawalFee = (_amount * WITHDRAWAL_FEE_RATE) / TOTAL_PERCENT;
}
// console.log("withdrawal fee: %s", withdrawalFee);
// console.log("withdraw amount: %s", _amount - withdrawalFee);
pool.stakeToken.safeTransfer(address(msg.sender), _amount - withdrawalFee);
pool.stakeToken.safeTransfer(owner, withdrawalFee);
}
user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
// Stake CAKE tokens to MasterChef
function enterStaking(uint256 _amount) public {
deposit(0, _amount);
}
// Withdraw CAKE tokens from STAKING.
function leaveStaking(uint256 _amount) public {
withdraw(0, _amount);
}
// 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.stakeToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
function depositReward(uint256 _pid, uint256 _amount) external payable {
require(_pid < poolInfo.length, "invalid pool id");
require(_amount > 0, "invalid amount");
poolInfo[_pid].rewardToken.safeTransferFrom(address(msg.sender), address(this), _amount);
emit DepositReward(msg.sender, _pid, _amount);
}
function _safeTransferReward(
uint256 _pid,
address _to,
uint256 _amount
) internal {
require(_pid < poolInfo.length, "invalid pool id");
require(_amount > 0, "invalid amount");
poolInfo[_pid].rewardToken.safeTransfer(_to, _amount);
emit WithdrawReward(_to, _pid, _amount);
}
function withdrawReward(uint256 _pid, uint256 _amount) external onlyOwner {
_safeTransferReward(_pid, msg.sender, _amount);
}
// Withdraw reward. EMERGENCY ONLY.
function emergencyWithdrawReward(uint256 _pid) external onlyOwner {
uint256 _amount = rewardBalanceOfPool(_pid);
_safeTransferReward(_pid, address(msg.sender), _amount);
emit EmergencyWithdrawReward(msg.sender, _pid, _amount);
}
/* View Functions */
function isValidPool(uint256 _pid) public view returns (bool) {
PoolInfo memory pool = poolInfo[_pid];
return pool.rewardUnit > 0;
}
function stakedBalanceOfUser(uint256 _pid, address _user) public view returns (uint256) {
return userInfo[_pid][_user].amount;
}
function stakedBalanceOfPool(uint256 _pid) public view returns (uint256) {
return poolInfo[_pid].stakeToken.balanceOf(address(this));
}
function rewardBalanceOfPool(uint256 _pid) public view returns (uint256) {
return poolInfo[_pid].rewardToken.balanceOf(address(this));
}
}
| contract MasterChef is AdminRole, ReentrancyGuard, Pausable {
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.
uint256 depositTime;
//
// We do some fancy math here. Basically, any point in time, the amount of CAKEs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accRewardPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accRewardPerShare` (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 stakeToken; // Address of LP token contract.
IERC20 rewardToken;
uint256 allocPoint; // How many allocation points assigned to this pool. CAKEs to distribute per block.
uint256 lastRewardBlock; // Last block number that CAKEs distribution occurs.
uint256 accRewardPerShare; // Accumulated CAKEs per share, times 1e12. See below.
uint256 rewardUnit; // Reward tokens created per second.
}
uint256 public TOTAL_PERCENT = 10000;
uint256 public WITHDRAWAL_FEE_RATE = 300;
// Bonus muliplier for early cake makers.
uint256 public BONUS_MULTIPLIER = 1;
// 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 CAKE mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event DepositReward(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event WithdrawReward(address indexed user, uint256 indexed pid, uint256 amount);
event WithdrawStakedFee(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdrawReward(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
IERC20 _syrupToken,
uint256 _rewardUnit,
uint256 _startBlock
) {
startBlock = _startBlock;
add(_syrupToken, _syrupToken, _rewardUnit, 1000, false);
}
function setRewardUnit(uint256 _pid, uint256 _rewardUnit) external onlyOwner {
PoolInfo storage pool = poolInfo[_pid];
pool.rewardUnit = _rewardUnit;
}
function setWithdrawFeeRate(uint256 _fee) external onlyOwner {
WITHDRAWAL_FEE_RATE = _fee;
}
function updateMultiplier(uint256 multiplierNumber) public onlyOwner {
BONUS_MULTIPLIER = multiplierNumber;
}
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(
IERC20 _stakeToken,
IERC20 _rewardToken,
uint256 _rewardUnit,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.timestamp > startBlock ? block.timestamp : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(
PoolInfo({
stakeToken: _stakeToken,
rewardToken: _rewardToken,
rewardUnit: _rewardUnit,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accRewardPerShare: 0
})
);
updateStakingPool();
}
// Update the given pool's CAKE allocation point. Can only be called by the owner.
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 prevAllocPoint = poolInfo[_pid].allocPoint;
if (prevAllocPoint != _allocPoint) {
poolInfo[_pid].allocPoint = _allocPoint;
totalAllocPoint = totalAllocPoint.sub(prevAllocPoint).add(_allocPoint);
updateStakingPool();
}
}
function updateStakingPool() internal {
uint256 length = poolInfo.length;
uint256 points = 0;
for (uint256 pid = 1; pid < length; ++pid) {
points = points.add(poolInfo[pid].allocPoint);
}
if (points != 0) {
points = points.div(3);
totalAllocPoint = totalAllocPoint.sub(poolInfo[0].allocPoint).add(points);
poolInfo[0].allocPoint = points;
}
}
// 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 stakeToken = pool.stakeToken;
uint256 bal = stakeToken.balanceOf(address(this));
stakeToken.safeApprove(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(stakeToken);
require(bal == newLpToken.balanceOf(address(this)), "migrate: bad");
pool.stakeToken = newLpToken;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
}
// View function to see pending CAKEs on frontend.
function pendingReward(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accRewardPerShare = pool.accRewardPerShare;
uint256 lpSupply = pool.stakeToken.balanceOf(address(this));
if (block.timestamp > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.timestamp);
uint256 cakeReward = multiplier.mul(pool.rewardUnit).mul(pool.allocPoint).div(totalAllocPoint);
accRewardPerShare = accRewardPerShare.add(cakeReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accRewardPerShare).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);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.timestamp <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.stakeToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.timestamp;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.timestamp);
uint256 cakeReward = multiplier.mul(pool.rewardUnit).mul(pool.allocPoint).div(totalAllocPoint);
pool.accRewardPerShare = pool.accRewardPerShare.add(cakeReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.timestamp;
}
// Deposit LP tokens to MasterChef for CAKE allocation.
function deposit(uint256 _pid, uint256 _amount) public nonReentrant {
require(_pid < poolInfo.length, "invalid pid");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
_safeTransferReward(_pid, msg.sender, pending);
}
}
if (_amount > 0) {
// console.log("amount: %s", _amount / (1 ether));
// console.log("sender bal: %s", pool.stakeToken.balanceOf(msg.sender) / (1 ether));
pool.stakeToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.depositTime = block.timestamp;
}
user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public nonReentrant {
require(_pid < poolInfo.length, "invalid pid");
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.accRewardPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
_safeTransferReward(_pid, msg.sender, pending);
}
if (_amount > 0) {
user.amount = user.amount.sub(_amount);
uint256 withdrawalFee = 0;
if ((block.timestamp - user.depositTime) < 3 days) {
withdrawalFee = (_amount * WITHDRAWAL_FEE_RATE) / TOTAL_PERCENT;
}
// console.log("withdrawal fee: %s", withdrawalFee);
// console.log("withdraw amount: %s", _amount - withdrawalFee);
pool.stakeToken.safeTransfer(address(msg.sender), _amount - withdrawalFee);
pool.stakeToken.safeTransfer(owner, withdrawalFee);
}
user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
// Stake CAKE tokens to MasterChef
function enterStaking(uint256 _amount) public {
deposit(0, _amount);
}
// Withdraw CAKE tokens from STAKING.
function leaveStaking(uint256 _amount) public {
withdraw(0, _amount);
}
// 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.stakeToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
function depositReward(uint256 _pid, uint256 _amount) external payable {
require(_pid < poolInfo.length, "invalid pool id");
require(_amount > 0, "invalid amount");
poolInfo[_pid].rewardToken.safeTransferFrom(address(msg.sender), address(this), _amount);
emit DepositReward(msg.sender, _pid, _amount);
}
function _safeTransferReward(
uint256 _pid,
address _to,
uint256 _amount
) internal {
require(_pid < poolInfo.length, "invalid pool id");
require(_amount > 0, "invalid amount");
poolInfo[_pid].rewardToken.safeTransfer(_to, _amount);
emit WithdrawReward(_to, _pid, _amount);
}
function withdrawReward(uint256 _pid, uint256 _amount) external onlyOwner {
_safeTransferReward(_pid, msg.sender, _amount);
}
// Withdraw reward. EMERGENCY ONLY.
function emergencyWithdrawReward(uint256 _pid) external onlyOwner {
uint256 _amount = rewardBalanceOfPool(_pid);
_safeTransferReward(_pid, address(msg.sender), _amount);
emit EmergencyWithdrawReward(msg.sender, _pid, _amount);
}
/* View Functions */
function isValidPool(uint256 _pid) public view returns (bool) {
PoolInfo memory pool = poolInfo[_pid];
return pool.rewardUnit > 0;
}
function stakedBalanceOfUser(uint256 _pid, address _user) public view returns (uint256) {
return userInfo[_pid][_user].amount;
}
function stakedBalanceOfPool(uint256 _pid) public view returns (uint256) {
return poolInfo[_pid].stakeToken.balanceOf(address(this));
}
function rewardBalanceOfPool(uint256 _pid) public view returns (uint256) {
return poolInfo[_pid].rewardToken.balanceOf(address(this));
}
}
| 29,576 |
63 | // REGISTER DIRECT MINT CONTRACT// Register Contract. / | contract RegisterDirectMint {
using SafeMath for uint256;
// Account with the right to adjust the set of minters.
address public _owner;
// Address of the Kong ERC20 account.
address public _kongERC20Address;
// Sum of Kong amounts marked as mintable for registered devices.
uint256 public _totalMintable;
// Minters.
mapping (address => bool) public _minters;
// Minting caps.
mapping (address => uint256) public _mintingCaps;
//
struct Device {
uint256 kongAmount;
uint256 mintableTime;
bool mintable;
}
// Registered devices.
mapping(bytes32 => Device) internal _devices;
/**
* @dev Emit when device is registered.
*/
event Registration(
bytes32 hardwareHash,
bytes32 primaryPublicKeyHash,
bytes32 secondaryPublicKeyHash,
bytes32 tertiaryPublicKeyHash,
bytes32 hardwareManufacturer,
bytes32 hardwareModel,
bytes32 hardwareSerial,
bytes32 hardwareConfig,
uint256 kongAmount,
uint256 mintableTime,
bool mintable
);
/**
* @dev Emit when minting rights are delegated / removed.
*/
event MinterAddition (
address minter,
uint256 mintingCap
);
event MinterRemoval (
address minter
);
/**
* @dev Constructor.
*/
constructor(address owner, address kongAddress) public {
// Set address of owner.
_owner = owner;
// Set address of Kong ERC20 contract.
_kongERC20Address = kongAddress;
// Set minting cap of owner account.
_mintingCaps[_owner] = (2 ** 25 + 2 ** 24 + 2 ** 23 + 2 ** 22) * 10 ** 18;
}
/**
* @dev Throws if called by any account but owner.
*/
modifier onlyOwner() {
require(_owner == msg.sender, 'Can only be called by owner.');
_;
}
/**
* @dev Throws if called by any account but owner or registered minter.
*/
modifier onlyOwnerOrMinter() {
require(_owner == msg.sender || _minters[msg.sender] == true, 'Can only be called by owner or minter.');
_;
}
/**
* @dev Endow `newMinter` with right to add mintable devices up to `mintingCap`.
*/
function delegateMintingRights(
address newMinter,
uint256 mintingCap
)
public
onlyOwner
{
// Delegate minting rights.
_mintingCaps[_owner] = _mintingCaps[_owner].sub(mintingCap);
_mintingCaps[newMinter] = _mintingCaps[newMinter].add(mintingCap);
// Add newMinter to dictionary of minters.
_minters[newMinter] = true;
// Emit event.
emit MinterAddition(newMinter, _mintingCaps[newMinter]);
}
/**
* @dev Remove address from the mapping of _minters.
*/
function removeMintingRights(
address minter
)
public
onlyOwner
{
// Cannot remove rights from _owner.
require(_owner != minter, 'Cannot remove owner from minters.');
// Adjust minting rights.
_mintingCaps[_owner] = _mintingCaps[_owner].add(_mintingCaps[minter]);
_mintingCaps[minter] = 0;
// Deactivate minter.
_minters[minter] = false;
// Emit event.
emit MinterRemoval(minter);
}
/**
* @dev Register a new device.
*/
function registerDevice(
bytes32 hardwareHash,
bytes32 primaryPublicKeyHash,
bytes32 secondaryPublicKeyHash,
bytes32 tertiaryPublicKeyHash,
bytes32 hardwareManufacturer,
bytes32 hardwareModel,
bytes32 hardwareSerial,
bytes32 hardwareConfig,
uint256 kongAmount,
uint256 mintableTime,
bool mintable
)
public
onlyOwnerOrMinter
{
// Verify that this device has not been registered yet.
require(_devices[hardwareHash].kongAmount == 0, 'Already registered.');
// Verify the cumulative limit for mintable Kong has not been exceeded.
if (mintable) {
uint256 _maxMinted = KongERC20Interface(_kongERC20Address).getMintingLimit();
require(_totalMintable.add(kongAmount) <= _maxMinted, 'Exceeds cumulative limit.');
// Increment _totalMintable.
_totalMintable += kongAmount;
// Adjust minting cap. Throws on underflow / Guarantees minter does not exceed its limit.
_mintingCaps[msg.sender] = _mintingCaps[msg.sender].sub(kongAmount);
}
// Create device struct.
_devices[hardwareHash] = Device(
kongAmount,
mintableTime,
mintable
);
// Emit event.
emit Registration(
hardwareHash,
primaryPublicKeyHash,
secondaryPublicKeyHash,
tertiaryPublicKeyHash,
hardwareManufacturer,
hardwareModel,
hardwareSerial,
hardwareConfig,
kongAmount,
mintableTime,
mintable
);
}
/**
* @dev Mint registered `kongAmount` for `_devices[hardwareHash]` to `recipient`.
*/
function mintKong(
bytes32 hardwareHash,
address recipient
)
external
onlyOwnerOrMinter
{
// Get Kong details.
Device memory d = _devices[hardwareHash];
// Verify that Kong is mintable.
require(d.mintable, 'Not mintable / already minted.');
require(block.timestamp >= d.mintableTime, 'Cannot mint yet.');
// Set status to minted.
_devices[hardwareHash].mintable = false;
// Mint.
KongERC20Interface(_kongERC20Address).mint(d.kongAmount, recipient);
}
/**
* @dev Return the stored details for a registered device.
*/
function getRegistrationDetails(
bytes32 hardwareHash
)
external
view
returns (uint256, uint256, bool)
{
Device memory d = _devices[hardwareHash];
return (
d.kongAmount,
d.mintableTime,
d.mintable
);
}
/**
* @dev Return the hashed minting key for a registered device.
*/
function verifyMintableHardwareHash(
bytes32 primaryPublicKeyHash,
bytes32 secondaryPublicKeyHash,
bytes32 tertiaryPublicKeyHash,
bytes32 hardwareSerial
)
external
view
returns (bytes32)
{
bytes32 hashedKey = sha256(abi.encodePacked(primaryPublicKeyHash, secondaryPublicKeyHash, tertiaryPublicKeyHash, hardwareSerial));
Device memory d = _devices[hashedKey];
require(d.mintable == true, 'Not mintable.');
require(d.kongAmount > 0, 'No KONG amount to be minted.');
return hashedKey;
}
/**
* @dev Return Kong amount for a registered device.
*/
function getKongAmount(
bytes32 hardwareHash
)
external
view
returns (uint)
{
Device memory d = _devices[hardwareHash];
return d.kongAmount;
}
} | contract RegisterDirectMint {
using SafeMath for uint256;
// Account with the right to adjust the set of minters.
address public _owner;
// Address of the Kong ERC20 account.
address public _kongERC20Address;
// Sum of Kong amounts marked as mintable for registered devices.
uint256 public _totalMintable;
// Minters.
mapping (address => bool) public _minters;
// Minting caps.
mapping (address => uint256) public _mintingCaps;
//
struct Device {
uint256 kongAmount;
uint256 mintableTime;
bool mintable;
}
// Registered devices.
mapping(bytes32 => Device) internal _devices;
/**
* @dev Emit when device is registered.
*/
event Registration(
bytes32 hardwareHash,
bytes32 primaryPublicKeyHash,
bytes32 secondaryPublicKeyHash,
bytes32 tertiaryPublicKeyHash,
bytes32 hardwareManufacturer,
bytes32 hardwareModel,
bytes32 hardwareSerial,
bytes32 hardwareConfig,
uint256 kongAmount,
uint256 mintableTime,
bool mintable
);
/**
* @dev Emit when minting rights are delegated / removed.
*/
event MinterAddition (
address minter,
uint256 mintingCap
);
event MinterRemoval (
address minter
);
/**
* @dev Constructor.
*/
constructor(address owner, address kongAddress) public {
// Set address of owner.
_owner = owner;
// Set address of Kong ERC20 contract.
_kongERC20Address = kongAddress;
// Set minting cap of owner account.
_mintingCaps[_owner] = (2 ** 25 + 2 ** 24 + 2 ** 23 + 2 ** 22) * 10 ** 18;
}
/**
* @dev Throws if called by any account but owner.
*/
modifier onlyOwner() {
require(_owner == msg.sender, 'Can only be called by owner.');
_;
}
/**
* @dev Throws if called by any account but owner or registered minter.
*/
modifier onlyOwnerOrMinter() {
require(_owner == msg.sender || _minters[msg.sender] == true, 'Can only be called by owner or minter.');
_;
}
/**
* @dev Endow `newMinter` with right to add mintable devices up to `mintingCap`.
*/
function delegateMintingRights(
address newMinter,
uint256 mintingCap
)
public
onlyOwner
{
// Delegate minting rights.
_mintingCaps[_owner] = _mintingCaps[_owner].sub(mintingCap);
_mintingCaps[newMinter] = _mintingCaps[newMinter].add(mintingCap);
// Add newMinter to dictionary of minters.
_minters[newMinter] = true;
// Emit event.
emit MinterAddition(newMinter, _mintingCaps[newMinter]);
}
/**
* @dev Remove address from the mapping of _minters.
*/
function removeMintingRights(
address minter
)
public
onlyOwner
{
// Cannot remove rights from _owner.
require(_owner != minter, 'Cannot remove owner from minters.');
// Adjust minting rights.
_mintingCaps[_owner] = _mintingCaps[_owner].add(_mintingCaps[minter]);
_mintingCaps[minter] = 0;
// Deactivate minter.
_minters[minter] = false;
// Emit event.
emit MinterRemoval(minter);
}
/**
* @dev Register a new device.
*/
function registerDevice(
bytes32 hardwareHash,
bytes32 primaryPublicKeyHash,
bytes32 secondaryPublicKeyHash,
bytes32 tertiaryPublicKeyHash,
bytes32 hardwareManufacturer,
bytes32 hardwareModel,
bytes32 hardwareSerial,
bytes32 hardwareConfig,
uint256 kongAmount,
uint256 mintableTime,
bool mintable
)
public
onlyOwnerOrMinter
{
// Verify that this device has not been registered yet.
require(_devices[hardwareHash].kongAmount == 0, 'Already registered.');
// Verify the cumulative limit for mintable Kong has not been exceeded.
if (mintable) {
uint256 _maxMinted = KongERC20Interface(_kongERC20Address).getMintingLimit();
require(_totalMintable.add(kongAmount) <= _maxMinted, 'Exceeds cumulative limit.');
// Increment _totalMintable.
_totalMintable += kongAmount;
// Adjust minting cap. Throws on underflow / Guarantees minter does not exceed its limit.
_mintingCaps[msg.sender] = _mintingCaps[msg.sender].sub(kongAmount);
}
// Create device struct.
_devices[hardwareHash] = Device(
kongAmount,
mintableTime,
mintable
);
// Emit event.
emit Registration(
hardwareHash,
primaryPublicKeyHash,
secondaryPublicKeyHash,
tertiaryPublicKeyHash,
hardwareManufacturer,
hardwareModel,
hardwareSerial,
hardwareConfig,
kongAmount,
mintableTime,
mintable
);
}
/**
* @dev Mint registered `kongAmount` for `_devices[hardwareHash]` to `recipient`.
*/
function mintKong(
bytes32 hardwareHash,
address recipient
)
external
onlyOwnerOrMinter
{
// Get Kong details.
Device memory d = _devices[hardwareHash];
// Verify that Kong is mintable.
require(d.mintable, 'Not mintable / already minted.');
require(block.timestamp >= d.mintableTime, 'Cannot mint yet.');
// Set status to minted.
_devices[hardwareHash].mintable = false;
// Mint.
KongERC20Interface(_kongERC20Address).mint(d.kongAmount, recipient);
}
/**
* @dev Return the stored details for a registered device.
*/
function getRegistrationDetails(
bytes32 hardwareHash
)
external
view
returns (uint256, uint256, bool)
{
Device memory d = _devices[hardwareHash];
return (
d.kongAmount,
d.mintableTime,
d.mintable
);
}
/**
* @dev Return the hashed minting key for a registered device.
*/
function verifyMintableHardwareHash(
bytes32 primaryPublicKeyHash,
bytes32 secondaryPublicKeyHash,
bytes32 tertiaryPublicKeyHash,
bytes32 hardwareSerial
)
external
view
returns (bytes32)
{
bytes32 hashedKey = sha256(abi.encodePacked(primaryPublicKeyHash, secondaryPublicKeyHash, tertiaryPublicKeyHash, hardwareSerial));
Device memory d = _devices[hashedKey];
require(d.mintable == true, 'Not mintable.');
require(d.kongAmount > 0, 'No KONG amount to be minted.');
return hashedKey;
}
/**
* @dev Return Kong amount for a registered device.
*/
function getKongAmount(
bytes32 hardwareHash
)
external
view
returns (uint)
{
Device memory d = _devices[hardwareHash];
return d.kongAmount;
}
} | 38,859 |
404 | // Whitelist of users being able to convert tokens.user_ address is candidate to be whitelisted (if whitelist is enabled)allowed_ bool set if user should be allowed (uf true), or denied using system/ | function setKyc(address user_, bool allowed_) public auth {
require(user_ != address(0), "asm-kyc-user-can-not-be-zero");
kyc[user_] = allowed_;
}
| function setKyc(address user_, bool allowed_) public auth {
require(user_ != address(0), "asm-kyc-user-can-not-be-zero");
kyc[user_] = allowed_;
}
| 26,914 |
33 | // Function to get global item via the Association Struct (IceGlobal library) self is the GlobalRecord Struct (IceGlobal library) which contains the indexes used for storing an item _globalItems is the entire array of global itemsreturn association is the Association Struct which contains properties of the specific item in question / | function getGlobalItemViaRecord(
GlobalRecord storage self,
mapping (uint => mapping(uint => Association)) storage _globalItems
)
internal view
| function getGlobalItemViaRecord(
GlobalRecord storage self,
mapping (uint => mapping(uint => Association)) storage _globalItems
)
internal view
| 24,482 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.