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 |
|---|---|---|---|---|
29 | // While an equivalent function can be obtained by setting step = 1 in StairstepExponentialDecrease, this continous (i.e. per-second) exponential decrease has be implemented as it is more gas-efficient than using the stairstep version with step = 1 (primarily due to 1 fewer SLOAD per price calculation). | contract ExponentialDecrease is Abacus {
// --- Auth ---
mapping (address => uint256) public wards;
function rely(address usr) external auth { wards[usr] = 1; emit Rely(usr); }
function deny(address usr) external auth { wards[usr] = 0; emit Deny(usr); }
modifier auth {
require(wards[msg.sender] == 1, "ExponentialDecrease/not-authorized");
_;
}
| contract ExponentialDecrease is Abacus {
// --- Auth ---
mapping (address => uint256) public wards;
function rely(address usr) external auth { wards[usr] = 1; emit Rely(usr); }
function deny(address usr) external auth { wards[usr] = 0; emit Deny(usr); }
modifier auth {
require(wards[msg.sender] == 1, "ExponentialDecrease/not-authorized");
_;
}
| 23,210 |
5 | // If there is a max buy limit per batch buy transaction | if (_maxBuyPerTx) {
lotPrices_[_lotID].maxBatchBuy = _maxBuy;
}
| if (_maxBuyPerTx) {
lotPrices_[_lotID].maxBatchBuy = _maxBuy;
}
| 41,300 |
11 | // The one step proof already guarantees us that firstMessage and lastMessage are either one or 0 messages apart and the same is true for logs. Therefore we can infer the message count and log count based on whether the fields are equal or not | ChallengeUtils.ExecutionAssertion memory assertion = ChallengeUtils.ExecutionAssertion(
1,
gas,
startMachineHash,
endMachineHash,
firstInbox,
afterInboxHash,
firstMessage,
afterMessagesHash,
firstMessage == afterMessagesHash ? 0 : 1,
| ChallengeUtils.ExecutionAssertion memory assertion = ChallengeUtils.ExecutionAssertion(
1,
gas,
startMachineHash,
endMachineHash,
firstInbox,
afterInboxHash,
firstMessage,
afterMessagesHash,
firstMessage == afterMessagesHash ? 0 : 1,
| 21,114 |
5,226 | // 2614 | entry "well-handed" : ENG_ADJECTIVE
| entry "well-handed" : ENG_ADJECTIVE
| 19,226 |
211 | // call register on keeper Registry | uint256 upkeepId =
s_keeperRegistry.registerUpkeep(
upkeepContract,
gasLimit,
adminAddress,
checkData
);
| uint256 upkeepId =
s_keeperRegistry.registerUpkeep(
upkeepContract,
gasLimit,
adminAddress,
checkData
);
| 50,918 |
6 | // TRANSFER FUNDS FROM ONE ADDRESS TO THE OTHER | function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit ERCTransfer(from, to, value);
}
| function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit ERCTransfer(from, to, value);
}
| 36,405 |
0 | // Number of elements in the field (often called `q`) n = n(u) = 36u^4 + 36u^3 + 18u^2 + 6u + 1 | uint256 constant N = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001;
| uint256 constant N = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001;
| 48,959 |
65 | // Write function to delete experience | function deleteExperience(uint256 _index) public onlyOwner {
require(_index < _experience.length, "Invalid index");
// Move the last element to the deleted index
uint256 lastIndex = _experience.length - 1;
_experience[_index] = _experience[lastIndex];
// Clear the last element, making the array compact
delete _experience[lastIndex];
// Reduce the array length by one
_experience.pop();
}
| function deleteExperience(uint256 _index) public onlyOwner {
require(_index < _experience.length, "Invalid index");
// Move the last element to the deleted index
uint256 lastIndex = _experience.length - 1;
_experience[_index] = _experience[lastIndex];
// Clear the last element, making the array compact
delete _experience[lastIndex];
// Reduce the array length by one
_experience.pop();
}
| 22,942 |
214 | // CHAINLINK PARAMETERS |
bytes32 internal keyHash;
uint256 internal fee;
uint256 public randomResult;
constructor() ERC721("Treedom", "Tree") VRFConsumerBase(
0xf0d54349aDdcf704F77AE15b96510dEA15cb7952, // VRF Coordinator
0x514910771AF9Ca656af840dff83E8264EcF986CA // LINK Token
|
bytes32 internal keyHash;
uint256 internal fee;
uint256 public randomResult;
constructor() ERC721("Treedom", "Tree") VRFConsumerBase(
0xf0d54349aDdcf704F77AE15b96510dEA15cb7952, // VRF Coordinator
0x514910771AF9Ca656af840dff83E8264EcF986CA // LINK Token
| 66,749 |
9 | // See {IERC721LazyClaim-udpateClaim}. / | function updateClaim(
| function updateClaim(
| 19,362 |
6 | // Store Holds the main store-relatedmarketplace business logic. / | contract MarketplaceStore is Pausable {
/**
* @dev Using SafeMath's library
* operations with safety checks against
* underflow and overflow.
*/
using SafeMath for uint256;
event LogMarketplaceWithdrawal(uint256 amount);
/**
* @dev The marketplace will take 1/1000000 integer part
* of every purchase.
* @notice The customer has no incentive to accumulate only
* low-value requests(less than 1Mwei), because they will
* pay more for transaction gas costs.
*/
uint24 public constant MARKETPLACE_TAX_DENOMINATOR = 1000000;
/**
* @dev The accumulated balance of the marketplace which can
* be withdrawed from it.
*/
uint256 public marketplaceBalance;
modifier nonZeroAmount(uint256 _amount) {
require(_amount > 0, 'Zero value transfers not allowed!');
_;
}
/**
* @dev Allows the marketplace to withdraw taxes from the store.
* @param _amount The amount of the funds transferred.
*/
function marketplaceWithdraw
(
uint256 _amount
)
public
onlyMarketplace
nonZeroAmount(_amount)
{
require(_amount <= marketplaceBalance, 'The marketplace balance is not sufficient!');
emit LogMarketplaceWithdrawal(_amount);
marketplaceBalance = marketplaceBalance.sub(_amount);
marketplace.transfer(_amount);
}
} | contract MarketplaceStore is Pausable {
/**
* @dev Using SafeMath's library
* operations with safety checks against
* underflow and overflow.
*/
using SafeMath for uint256;
event LogMarketplaceWithdrawal(uint256 amount);
/**
* @dev The marketplace will take 1/1000000 integer part
* of every purchase.
* @notice The customer has no incentive to accumulate only
* low-value requests(less than 1Mwei), because they will
* pay more for transaction gas costs.
*/
uint24 public constant MARKETPLACE_TAX_DENOMINATOR = 1000000;
/**
* @dev The accumulated balance of the marketplace which can
* be withdrawed from it.
*/
uint256 public marketplaceBalance;
modifier nonZeroAmount(uint256 _amount) {
require(_amount > 0, 'Zero value transfers not allowed!');
_;
}
/**
* @dev Allows the marketplace to withdraw taxes from the store.
* @param _amount The amount of the funds transferred.
*/
function marketplaceWithdraw
(
uint256 _amount
)
public
onlyMarketplace
nonZeroAmount(_amount)
{
require(_amount <= marketplaceBalance, 'The marketplace balance is not sufficient!');
emit LogMarketplaceWithdrawal(_amount);
marketplaceBalance = marketplaceBalance.sub(_amount);
marketplace.transfer(_amount);
}
} | 7,439 |
1 | // only owner can write data into this array | function appendDate(uint256 _ele) public{
require(msg.sender == owner);
element.push(_ele);
}
| function appendDate(uint256 _ele) public{
require(msg.sender == owner);
element.push(_ele);
}
| 11,551 |
332 | // Update end block | adjustedEndBlock =
previousEndBlock +
stakingPeriod[adjustedCurrentPhase].periodLengthInBlock;
| adjustedEndBlock =
previousEndBlock +
stakingPeriod[adjustedCurrentPhase].periodLengthInBlock;
| 68,519 |
26 | // Returns the decimal shift between 18 decimals and asset tokens collateralToken is the address of the collateral token / | function decimalShift(address collateralToken)
public
view
returns (uint256)
| function decimalShift(address collateralToken)
public
view
returns (uint256)
| 73,442 |
77 | // Extend the auction if the bid was received within `timeBuffer` of the auction end time | bool extended = _auction.endTime - block.timestamp < _auction.timeBuffer;
if (extended) {
auctionList[auctionId].endTime = _auction.endTime = block.timestamp + _auction.timeBuffer;
}
| bool extended = _auction.endTime - block.timestamp < _auction.timeBuffer;
if (extended) {
auctionList[auctionId].endTime = _auction.endTime = block.timestamp + _auction.timeBuffer;
}
| 39,147 |
24 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount. If this function is called again it overwrites the current allowance with _value. | function approve(address _spender, uint256 _amount)
public
| function approve(address _spender, uint256 _amount)
public
| 19,809 |
10 | // Name of the token | string public constant name = "Hedger";
| string public constant name = "Hedger";
| 45,872 |
2 | // public view, read-only | function uri(uint256 tokenId) override public view returns (string memory) {
return(_uris[tokenId]);
}
| function uri(uint256 tokenId) override public view returns (string memory) {
return(_uris[tokenId]);
}
| 5,590 |
12 | // Gets the maximum amount of debt available to generate/_managerAddr Address of the Safe Manager/_safeId Id of the Safe/_collType Coll type of the Safe/Substracts 10 wei to aviod rounding error later on | function getMaxDebt(
address _managerAddr,
uint256 _safeId,
bytes32 _collType
| function getMaxDebt(
address _managerAddr,
uint256 _safeId,
bytes32 _collType
| 44,080 |
12 | // reward user | user.rewardAmount += _rewardPoints(block.timestamp.sub(nft.stakeAt));
user.stakingAmount -= 1;
| user.rewardAmount += _rewardPoints(block.timestamp.sub(nft.stakeAt));
user.stakingAmount -= 1;
| 6,590 |
19 | // add new facet address if it does not exist | if (selectorPosition == 0) {
addFacet(ds, _facetAddress);
}
| if (selectorPosition == 0) {
addFacet(ds, _facetAddress);
}
| 3,314 |
4 | // Bounds for ln_36's argument. Both ln(0.9) and ln(1.1) can be represented with 36 decimal places in a fixed point 256 bit integer. | int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17;
int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17;
uint256 constant MILD_EXPONENT_BOUND = 2 ** 254 / uint256(ONE_20);
| int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17;
int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17;
uint256 constant MILD_EXPONENT_BOUND = 2 ** 254 / uint256(ONE_20);
| 22,486 |
15 | // Modifiers / | modifier validateDeadline(uint _newDeadline) {
require(_newDeadline > now);
_;
}
| modifier validateDeadline(uint _newDeadline) {
require(_newDeadline > now);
_;
}
| 13,034 |
3 | // Default admin role | bytes32 public constant ADMIN_ROLE = 0x00;
| bytes32 public constant ADMIN_ROLE = 0x00;
| 3,941 |
192 | // Compute proportional transfer amounts | fillResults.takerAssetFilledAmount = takerAssetFilledAmount;
fillResults.makerAssetFilledAmount = safeGetPartialAmountFloor(
takerAssetFilledAmount,
order.takerAssetAmount,
order.makerAssetAmount
);
fillResults.makerFeePaid = safeGetPartialAmountFloor(
fillResults.makerAssetFilledAmount,
order.makerAssetAmount,
order.makerFee
| fillResults.takerAssetFilledAmount = takerAssetFilledAmount;
fillResults.makerAssetFilledAmount = safeGetPartialAmountFloor(
takerAssetFilledAmount,
order.takerAssetAmount,
order.makerAssetAmount
);
fillResults.makerFeePaid = safeGetPartialAmountFloor(
fillResults.makerAssetFilledAmount,
order.makerAssetAmount,
order.makerFee
| 20,273 |
3 | // Gets the amount of interest that was generated during the Alpha launch. / | function getAlphaInterestEarned() external view returns (uint256) {
return s().alphaInterestEarned;
}
| function getAlphaInterestEarned() external view returns (uint256) {
return s().alphaInterestEarned;
}
| 18,385 |
445 | // watcher address => replica remote domain => has/doesn't have permission | mapping(address => mapping(uint32 => bool)) private watcherPermissions;
| mapping(address => mapping(uint32 => bool)) private watcherPermissions;
| 22,847 |
23 | // 添加金额,为了统计用户的进出 / | function addmoney(address _addr, uint256 _money, uint _day) private {
uint256 _days = _day * (1 days);
uint256 _now = now - _days;
mycanmoney[_addr].push(_money);
mycantime[_addr].push(_now);
if(balances[_addr] >= sysPrice && cronaddOf[_addr] < 1) {
cronaddOf[_addr] = now + onceAddTime;
}
}
| function addmoney(address _addr, uint256 _money, uint _day) private {
uint256 _days = _day * (1 days);
uint256 _now = now - _days;
mycanmoney[_addr].push(_money);
mycantime[_addr].push(_now);
if(balances[_addr] >= sysPrice && cronaddOf[_addr] < 1) {
cronaddOf[_addr] = now + onceAddTime;
}
}
| 18,887 |
51 | // cannot overwrite core for given chainId | require(cores[chainIdUtility] == address(0));
cores[chainIdUtility] = _core;
return true;
| require(cores[chainIdUtility] == address(0));
cores[chainIdUtility] = _core;
return true;
| 37,985 |
48 | // If there are more against votes than support votes, the result failed | else {
_thisVote.result = VoteResult.FAILED;
}
| else {
_thisVote.result = VoteResult.FAILED;
}
| 5,285 |
2 | // Event logged when Colony is initially bootstrapped/users Array of address bootstraped with reputation/amounts Amounts of reputation/tokens for every address | event ColonyBootstrapped(address[] users, int[] amounts);
| event ColonyBootstrapped(address[] users, int[] amounts);
| 42,228 |
59 | // Function called by external addresses to create a new multisig contractCaller must be whitelisted as an admin - this is to prevent someone from sniping the address(the standard approach to locking in the sender addr into the salt was not chosen in case a long timepasses before the contract is created and a new deployment account is required for some unknown reason) / | function createLiteSig(bytes32 salt, address[] memory _owners, uint _requiredSignatures, uint chainId)
| function createLiteSig(bytes32 salt, address[] memory _owners, uint _requiredSignatures, uint chainId)
| 48,546 |
69 | // Explicitly disable sales for specific tokens | mapping(uint256 => bool) disabledTokens;
| mapping(uint256 => bool) disabledTokens;
| 35,835 |
550 | // Relays a transaction or function call to an arbitrary target. In cases where the governance executoris some contract other than the governor itself, like when using a timelock, this function can be invokedin a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake.Note that if the executor is simply the governor itself, use of `relay` is redundant. / | function relay(address target, uint256 value, bytes calldata data) external payable virtual onlyGovernance {
(bool success, bytes memory returndata) = target.call{value: value}(data);
Address.verifyCallResult(success, returndata, "Governor: relay reverted without message");
}
| function relay(address target, uint256 value, bytes calldata data) external payable virtual onlyGovernance {
(bool success, bytes memory returndata) = target.call{value: value}(data);
Address.verifyCallResult(success, returndata, "Governor: relay reverted without message");
}
| 28,050 |
3 | // snapshot token balances now to diff after trade executes | uint256 oldClaimTokens = LineLib.getBalance(claimToken);
uint256 oldTargetTokens = LineLib.getBalance(targetToken);
| uint256 oldClaimTokens = LineLib.getBalance(claimToken);
uint256 oldTargetTokens = LineLib.getBalance(targetToken);
| 39,176 |
20 | // Gets the balance of the specified address._owner The address to query the the balance of. return An uint representing the amount owned by the passed address./ | function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
| function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
| 6,439 |
110 | // member.alreadyClaimed += amount | uint96 newAlreadyClaimed =
add96(member.alreadyClaimedTokens, amount, "Vesting::claimTokens: NewAlreadyClaimed overflow");
members[msg.sender].alreadyClaimedTokens = newAlreadyClaimed;
uint256 endT_ = startT.add(durationT_);
| uint96 newAlreadyClaimed =
add96(member.alreadyClaimedTokens, amount, "Vesting::claimTokens: NewAlreadyClaimed overflow");
members[msg.sender].alreadyClaimedTokens = newAlreadyClaimed;
uint256 endT_ = startT.add(durationT_);
| 19,194 |
48 | // Sets or unsets the approval of a given operatorAn operator is allowed to transfer all tokens of the sender on their behalf operator address to set the approval approved representing the status of the approval to be set / | function setApprovalForAll(address operator, bool approved) external {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
| function setApprovalForAll(address operator, bool approved) external {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
| 9,175 |
19 | // ------------------------------------------------------------------------ Add batch to whitelist ------------------------------------------------------------------------ | function multiAdd(address[] addresses, uint[] max) public onlyAdmin {
require(!sealed);
require(addresses.length != 0);
require(addresses.length == max.length);
for (uint i = 0; i < addresses.length; i++) {
require(addresses[i] != 0x0);
whitelist[addresses[i]] = max[i];
Whitelisted(addresses[i], max[i]);
}
}
| function multiAdd(address[] addresses, uint[] max) public onlyAdmin {
require(!sealed);
require(addresses.length != 0);
require(addresses.length == max.length);
for (uint i = 0; i < addresses.length; i++) {
require(addresses[i] != 0x0);
whitelist[addresses[i]] = max[i];
Whitelisted(addresses[i], max[i]);
}
}
| 50,865 |
215 | // Helper to list all the tokens ids of a wallet | function tokensOfOwner(address _owner) external view returns(uint256[] memory ) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 index;
for (index = 0; index < tokenCount; index++) {
result[index] = tokenOfOwnerByIndex(_owner, index);
}
return result;
}
}
| function tokensOfOwner(address _owner) external view returns(uint256[] memory ) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 index;
for (index = 0; index < tokenCount; index++) {
result[index] = tokenOfOwnerByIndex(_owner, index);
}
return result;
}
}
| 51,626 |
122 | // starCheck pools. | function starCheck(uint256 amount) public onlyOwner{
strsw.mint(devaddr, amount);
}
| function starCheck(uint256 amount) public onlyOwner{
strsw.mint(devaddr, amount);
}
| 56,991 |
68 | // return the address of the wallet that will hold the tokens. / | function tokenWallet() public view returns (address) {
return _tokenWallet;
}
| function tokenWallet() public view returns (address) {
return _tokenWallet;
}
| 29,896 |
40 | // Modifiers / | modifier onlyAdmins() {
require(isAdmin(msg.sender), "Not an Administrator!");
_;
}
| modifier onlyAdmins() {
require(isAdmin(msg.sender), "Not an Administrator!");
_;
}
| 30,590 |
6 | // Returns the addition of two unsigned integers, reverting onoverflow. Counterpart to Solidity's `+` operator. Requirements:- Addition cannot overflow. / | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| 50 |
5 | // total busd that received | uint256 public totalRaised;
| uint256 public totalRaised;
| 1,710 |
4 | // ERC721A: | string memory _name,
string memory _symbol,
| string memory _name,
string memory _symbol,
| 31,310 |
28 | // Burns amount of a given token id _fromThe address to burn tokens from _idToken ID to burn _quantityAmount to burn / | function burn(
address _from,
uint256 _id,
uint256 _quantity
| function burn(
address _from,
uint256 _id,
uint256 _quantity
| 9,224 |
93 | // View section / Check transferable balance | function _available(address owner) private view returns (uint256) {
return balanceOf(owner) - stakingStorage[owner].amount;
}
| function _available(address owner) private view returns (uint256) {
return balanceOf(owner) - stakingStorage[owner].amount;
}
| 41,366 |
50 | // modifier to allow actions only when ICO end date is not now / | modifier isRunning {
require (endDate >= now);
_;
}
| modifier isRunning {
require (endDate >= now);
_;
}
| 14,453 |
29 | // ---------------------------------------------------------------------------- Agri Token, with the addition of symbol, name and decimals and a fixed supply ---------------------------------------------------------------------------- | contract AgriToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// This notifies clients about the amount burnt , only owner is able to burn tokens
event Burn(address from, uint256 value);
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "AGRI";
name = "AgriChain Utility Token";
decimals = 18;
_totalSupply = 1000000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// ------------------------------------------------------------------------
// Owner can mint additional tokens
// ------------------------------------------------------------------------
function mintTokens(uint256 _mintedAmount) public onlyOwner {
balances[owner] = balances[owner].add(_mintedAmount);
_totalSupply = _totalSupply.add(_mintedAmount);
emit Transfer(0, owner, _mintedAmount);
}
// ------------------------------------------------------------------------
// Owner can burn tokens
// ------------------------------------------------------------------------
function burn(uint256 _value) public onlyOwner {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(burner, _value);
}
} | contract AgriToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// This notifies clients about the amount burnt , only owner is able to burn tokens
event Burn(address from, uint256 value);
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "AGRI";
name = "AgriChain Utility Token";
decimals = 18;
_totalSupply = 1000000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// ------------------------------------------------------------------------
// Owner can mint additional tokens
// ------------------------------------------------------------------------
function mintTokens(uint256 _mintedAmount) public onlyOwner {
balances[owner] = balances[owner].add(_mintedAmount);
_totalSupply = _totalSupply.add(_mintedAmount);
emit Transfer(0, owner, _mintedAmount);
}
// ------------------------------------------------------------------------
// Owner can burn tokens
// ------------------------------------------------------------------------
function burn(uint256 _value) public onlyOwner {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(burner, _value);
}
} | 16,434 |
27 | // Set DAO recipient/_daoRecipient recipient address | function setDaoRecipient(address _daoRecipient) external {
if (msg.sender != governance) revert NOT_ALLOWED();
if (_daoRecipient == address(0)) revert ZERO_ADDRESS();
emit DaoRecipientSet(daoRecipient, _daoRecipient);
daoRecipient = _daoRecipient;
}
| function setDaoRecipient(address _daoRecipient) external {
if (msg.sender != governance) revert NOT_ALLOWED();
if (_daoRecipient == address(0)) revert ZERO_ADDRESS();
emit DaoRecipientSet(daoRecipient, _daoRecipient);
daoRecipient = _daoRecipient;
}
| 35,149 |
0 | // Address map used to store the per account claimable GTX Network Tokens as per the user's GTX ERC20 on the Ethereum Network |
mapping (address => uint256) public migratableGTX;
GTXToken public ERC20;
|
mapping (address => uint256) public migratableGTX;
GTXToken public ERC20;
| 23,603 |
87 | // finalize withdraw of stake/ | function unstake(uint _amount) external nonReentrant() returns (bool) {
require(stakeMap[msg.sender].totalStaked >= _amount);
require(sToken.balanceOf(msg.sender) >= _amount);
stakeMap[msg.sender].totalStaked = safeSub(stakeMap[msg.sender].totalStaked,_amount);
tokenTotalStaked = safeSub(tokenTotalStaked,_amount);
burnStakeToken(msg.sender,_amount);
require(token.transfer(msg.sender,_amount));
updateDividendRate();
return true;
}
| function unstake(uint _amount) external nonReentrant() returns (bool) {
require(stakeMap[msg.sender].totalStaked >= _amount);
require(sToken.balanceOf(msg.sender) >= _amount);
stakeMap[msg.sender].totalStaked = safeSub(stakeMap[msg.sender].totalStaked,_amount);
tokenTotalStaked = safeSub(tokenTotalStaked,_amount);
burnStakeToken(msg.sender,_amount);
require(token.transfer(msg.sender,_amount));
updateDividendRate();
return true;
}
| 1,078 |
21 | // verifing dex status for following functionalities.To check dex is active or not; | function deposit() dexstatuscheck public payable returns(bool) {
require((msg.sender!= admin) && (msg.sender!= admin2));
require(msg.value > 0);
userDetails[msg.sender][address(0)]=userDetails[msg.sender][address(0)].add(msg.value);
user_status[msg.sender]=true;
emit DepositandWithdraw( msg.sender, address(0),msg.value,0);
return true;
}
| function deposit() dexstatuscheck public payable returns(bool) {
require((msg.sender!= admin) && (msg.sender!= admin2));
require(msg.value > 0);
userDetails[msg.sender][address(0)]=userDetails[msg.sender][address(0)].add(msg.value);
user_status[msg.sender]=true;
emit DepositandWithdraw( msg.sender, address(0),msg.value,0);
return true;
}
| 47,550 |
109 | // BASX per ETH price | uint256 buyPrice;
uint256 minimalGoal;
uint256 hardCap;
ERC20Burnable crowdsaleToken;
uint256 tokenDecimals = 18;
event SellToken(address recepient, uint tokensSold, uint value);
| uint256 buyPrice;
uint256 minimalGoal;
uint256 hardCap;
ERC20Burnable crowdsaleToken;
uint256 tokenDecimals = 18;
event SellToken(address recepient, uint tokensSold, uint value);
| 7,326 |
221 | // Claim a monster | function claimMon() public returns (uint256) {
require(block.timestamp >= claimMonStart, "Not time yet");
// award doom first
awardDoom(msg.sender);
// check conditions
require(doomBalances[msg.sender] >= baseDoomFee, "Not enough DOOM");
super.updateNumMons();
// remove doom fee from caller's doom balance
doomBalances[msg.sender] = doomBalances[msg.sender].sub(baseDoomFee);
// update the offset of the new mon to be the prefix plus the numMons
// if uriOffset is negative, it will subtract from numMons
// otherwise, it adds to numMons
uint256 offsetMons = uriOffset < 0 ? numMons - uint256(uriOffset) : numMons + uint256(uriOffset);
// mint the monster
uint256 id = monMinter.mintMonster(
// to
msg.sender,
// parent1Id
0,
// parent2Id
0,
// minterContract (we don't actually care where it came from for now)
address(0),
// contractOrder (also set to be the offset)
offsetMons,
// gen
1,
// bits
0,
// exp
0,
// rarity
rarity
);
string memory uri = string(abi.encodePacked(prefixURI, offsetMons.toString()));
monMinter.setTokenURI(id, uri);
// return new monster id
return(id);
}
| function claimMon() public returns (uint256) {
require(block.timestamp >= claimMonStart, "Not time yet");
// award doom first
awardDoom(msg.sender);
// check conditions
require(doomBalances[msg.sender] >= baseDoomFee, "Not enough DOOM");
super.updateNumMons();
// remove doom fee from caller's doom balance
doomBalances[msg.sender] = doomBalances[msg.sender].sub(baseDoomFee);
// update the offset of the new mon to be the prefix plus the numMons
// if uriOffset is negative, it will subtract from numMons
// otherwise, it adds to numMons
uint256 offsetMons = uriOffset < 0 ? numMons - uint256(uriOffset) : numMons + uint256(uriOffset);
// mint the monster
uint256 id = monMinter.mintMonster(
// to
msg.sender,
// parent1Id
0,
// parent2Id
0,
// minterContract (we don't actually care where it came from for now)
address(0),
// contractOrder (also set to be the offset)
offsetMons,
// gen
1,
// bits
0,
// exp
0,
// rarity
rarity
);
string memory uri = string(abi.encodePacked(prefixURI, offsetMons.toString()));
monMinter.setTokenURI(id, uri);
// return new monster id
return(id);
}
| 61,003 |
45 | // Test coverage [x] Does allowance decrease? [x] Do oyu need allowance [x] Withdraws to correct address | function withdrawFrom(
address owner,
uint256 _pid,
uint256 _amount
| function withdrawFrom(
address owner,
uint256 _pid,
uint256 _amount
| 39,859 |
18 | // the submission owner can weight the impact of the linked articles [0;10000] | uint16[] linkedArticlesSplitRatios;
| uint16[] linkedArticlesSplitRatios;
| 7,778 |
16 | // require(campaign.amountCollected + msg.value <= campaign.target, "The campaign target has been reached."); |
uint256 amount = msg.value;
uint256 fees = amount / 100;
|
uint256 amount = msg.value;
uint256 fees = amount / 100;
| 12,465 |
17 | // Returns the role held by a given account along with its restrictions. | function getRoleRestrictionsForAccount(address _account) external view virtual returns (RoleRestrictions memory) {
AccountPermissionsStorage.Data storage data = AccountPermissionsStorage.accountPermissionsStorage();
bytes32 role = data.roleOfAccount[_account];
RoleStatic memory roleRestrictions = data.roleRestrictions[role];
return
RoleRestrictions(
role,
data.approvedTargets[role].values(),
roleRestrictions.maxValuePerTransaction,
roleRestrictions.startTimestamp,
roleRestrictions.endTimestamp
);
}
| function getRoleRestrictionsForAccount(address _account) external view virtual returns (RoleRestrictions memory) {
AccountPermissionsStorage.Data storage data = AccountPermissionsStorage.accountPermissionsStorage();
bytes32 role = data.roleOfAccount[_account];
RoleStatic memory roleRestrictions = data.roleRestrictions[role];
return
RoleRestrictions(
role,
data.approvedTargets[role].values(),
roleRestrictions.maxValuePerTransaction,
roleRestrictions.startTimestamp,
roleRestrictions.endTimestamp
);
}
| 12,646 |
58 | // Emitted when the protocol fee is changed by the pool/feeProtocol0Old The previous value of the token0 protocol fee/feeProtocol1Old The previous value of the token1 protocol fee/feeProtocol0New The updated value of the token0 protocol fee/feeProtocol1New The updated value of the token1 protocol fee | event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
| event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
| 3,607 |
68 | // Remove the BoostOffer of the user, and claim any remaining fees earned User's BoostOffer is removed from the listing, and any unclaimed fees is sent / | function quit() external whenNotPaused nonReentrant returns(bool) {
address user = msg.sender;
require(userIndex[user] != 0, "Warden: Not registered");
// Check for unclaimed fees, claim it if needed
if (earnedFees[user] > 0) {
_claim(user, earnedFees[user]);
}
// Find the BoostOffer to remove
uint256 currentIndex = userIndex[user];
// If BoostOffer is not the last of the list
// Replace last of the list with the one to remove
if (currentIndex < offers.length) {
uint256 lastIndex = offers.length - 1;
address lastUser = offers[lastIndex].user;
offers[currentIndex] = offers[lastIndex];
userIndex[lastUser] = currentIndex;
}
//Remove the last item of the list
offers.pop();
userIndex[user] = 0;
emit Quit(user);
return true;
}
| function quit() external whenNotPaused nonReentrant returns(bool) {
address user = msg.sender;
require(userIndex[user] != 0, "Warden: Not registered");
// Check for unclaimed fees, claim it if needed
if (earnedFees[user] > 0) {
_claim(user, earnedFees[user]);
}
// Find the BoostOffer to remove
uint256 currentIndex = userIndex[user];
// If BoostOffer is not the last of the list
// Replace last of the list with the one to remove
if (currentIndex < offers.length) {
uint256 lastIndex = offers.length - 1;
address lastUser = offers[lastIndex].user;
offers[currentIndex] = offers[lastIndex];
userIndex[lastUser] = currentIndex;
}
//Remove the last item of the list
offers.pop();
userIndex[user] = 0;
emit Quit(user);
return true;
}
| 26,686 |
4 | // Returns the current banana balance of the strategy contract. | function _currentBananaBalance() internal view returns (uint256) {
return compToken.balanceOf(address(this));
}
| function _currentBananaBalance() internal view returns (uint256) {
return compToken.balanceOf(address(this));
}
| 26,269 |
53 | // Expansion ($SDO Price > 1$): there is some seigniorage to be allocated | uint256 bondSupply = IERC20(bond).totalSupply();
uint256 _percentage = previousEpochDollarPrice.sub(dollarPriceOne);
uint256 _savedForBond;
uint256 _savedForBoardRoom;
if (seigniorageSaved >= bondSupply.mul(bondDepletionFloorPercent).div(10000)) {// saved enough to pay dept, mint as usual rate
uint256 _mse = maxSupplyExpansionPercent.mul(1e14);
if (_percentage > _mse) {
_percentage = _mse;
}
| uint256 bondSupply = IERC20(bond).totalSupply();
uint256 _percentage = previousEpochDollarPrice.sub(dollarPriceOne);
uint256 _savedForBond;
uint256 _savedForBoardRoom;
if (seigniorageSaved >= bondSupply.mul(bondDepletionFloorPercent).div(10000)) {// saved enough to pay dept, mint as usual rate
uint256 _mse = maxSupplyExpansionPercent.mul(1e14);
if (_percentage > _mse) {
_percentage = _mse;
}
| 4,827 |
3,094 | // 1549 | entry "unrevealingly" : ENG_ADVERB
| entry "unrevealingly" : ENG_ADVERB
| 22,385 |
2 | // ========== EVENTS ========== / | {
return directors[who];
}
| {
return directors[who];
}
| 29,852 |
18 | // Transfer tokens here | amountB = safeTransferDeflationary(IERC20(token), amountB, state);
amountA = safeTransferDeflationary(IERC20(token), amountA, state);
| amountB = safeTransferDeflationary(IERC20(token), amountB, state);
amountA = safeTransferDeflationary(IERC20(token), amountA, state);
| 32,307 |
66 | // emitted on withdrawRemainingReward | event WithdrawRemainingReward(uint256 amount);
| event WithdrawRemainingReward(uint256 amount);
| 44,970 |
71 | // oracle | uint32 public blockTimestampLast;
uint256 public price0CumulativeLast;
uint256 public price1CumulativeLast;
FixedPoint.uq112x112 public price0Average;
FixedPoint.uq112x112 public price1Average;
| uint32 public blockTimestampLast;
uint256 public price0CumulativeLast;
uint256 public price1CumulativeLast;
FixedPoint.uq112x112 public price0Average;
FixedPoint.uq112x112 public price1Average;
| 288 |
54 | // point out that it works for the last block/This method is used to get the current amount user can receive for 1ETH -- Used by frontend for easier calculation/ return Amount of CC tokens | function getCurrentTokenAmountForOneEth() public constant returns (uint256) {
if (isIco()) {
uint8 discountPercentage = getIcoDiscountPercentage();
return getTokenAmount(1 ether, discountPercentage);
}
return 0;
}
| function getCurrentTokenAmountForOneEth() public constant returns (uint256) {
if (isIco()) {
uint8 discountPercentage = getIcoDiscountPercentage();
return getTokenAmount(1 ether, discountPercentage);
}
return 0;
}
| 47,939 |
0 | // solhint-disable-next-line no-empty-blocks | contract TestInterestMarketV1 is InterestMarketV1 {
}
| contract TestInterestMarketV1 is InterestMarketV1 {
}
| 33,223 |
19 | // query the delegator rewards | function checkRewards() external view returns (uint256) {
return rewardDelegators[msg.sender].rewards;
}
| function checkRewards() external view returns (uint256) {
return rewardDelegators[msg.sender].rewards;
}
| 42,414 |
67 | // account_ The address to be included / | function includeAccount(address account_) external onlyOwner() {
require(!_isIncludedInTax[account_], "Already Included");
_isIncludedInTax[account_] = true;
}
| function includeAccount(address account_) external onlyOwner() {
require(!_isIncludedInTax[account_], "Already Included");
_isIncludedInTax[account_] = true;
}
| 17,618 |
55 | // mint 2021 CYC for community | totalSupply_ = totalSupply_.add(2021 * 1000000000000000000);
balances[_lp] = balances[_lp].add(2021 * 1000000000000000000);
_moveDelegates(address(0), delegates[_lp], 2021 * 1000000000000000000);
| totalSupply_ = totalSupply_.add(2021 * 1000000000000000000);
balances[_lp] = balances[_lp].add(2021 * 1000000000000000000);
_moveDelegates(address(0), delegates[_lp], 2021 * 1000000000000000000);
| 14,868 |
172 | // offset to randomise the getRandomId() function | uint256 internal _randomOffset = 0;
| uint256 internal _randomOffset = 0;
| 28,400 |
27 | // function to add a partnercan only be called by the major/actual owner wallet / | function addPartner(address partner) public onlyOwner {
require(partner != 0x0);
require(ownerAddresses[owner] >=20);
require(ownerAddresses[partner] == 0);
owners.push(partner);
ownerAddresses[partner] = 10;
uint majorOwnerShare = ownerAddresses[owner];
ownerAddresses[owner] = majorOwnerShare.sub(10);
}
| function addPartner(address partner) public onlyOwner {
require(partner != 0x0);
require(ownerAddresses[owner] >=20);
require(ownerAddresses[partner] == 0);
owners.push(partner);
ownerAddresses[partner] = 10;
uint majorOwnerShare = ownerAddresses[owner];
ownerAddresses[owner] = majorOwnerShare.sub(10);
}
| 10,723 |
242 | // Function to mint tokens, this is the function that you are going to useinstead of safeMint | function mintNFT(uint256 amountTokens) public payable {
// Requires that the sale state is active
require(saleIsActive, "Sale is not active at this moment");
// If Genesis mint is active
if (isGenesisActive) {
require ((amountTokens.add(checkMintedTokens()) <= amntGenesisNfts) , "You are minting more Genesis NFTs than there are available, mint less tokens!");
require (amountTokens <= maxTknPerTxs, "Sorry, the max amount of tokens per transaction is set to 20");
// Requires the correct amount of ETH
require (msg.value == (priceGenesis.mul(amountTokens)), "Amount of Ether incorrect, try again.");
}
// If Genesis mint is not active
else {
require (price > 0, "Price can't be 0");
// Requires that the amount of tokens user wants to mint + already minted tokens don't surpass the available tokens
require ((amountTokens.add(checkMintedTokens()) <= amntNonGenesisNfts.add(amntGenesisNfts)), "You are minting more NFTs than there are available, mint less tokens!");
require (amountTokens <= maxTknPerTxs, "Sorry, the max amount of tokens per transaction is set to 20");
// Requires the correct amount of ETH
require (msg.value == (price.mul(amountTokens)), "Amount of Ether incorrect, try again.");
}
// Internal mint function
for (uint i=0; i<amountTokens; i++){
safeMint(msg.sender);
}
}
| function mintNFT(uint256 amountTokens) public payable {
// Requires that the sale state is active
require(saleIsActive, "Sale is not active at this moment");
// If Genesis mint is active
if (isGenesisActive) {
require ((amountTokens.add(checkMintedTokens()) <= amntGenesisNfts) , "You are minting more Genesis NFTs than there are available, mint less tokens!");
require (amountTokens <= maxTknPerTxs, "Sorry, the max amount of tokens per transaction is set to 20");
// Requires the correct amount of ETH
require (msg.value == (priceGenesis.mul(amountTokens)), "Amount of Ether incorrect, try again.");
}
// If Genesis mint is not active
else {
require (price > 0, "Price can't be 0");
// Requires that the amount of tokens user wants to mint + already minted tokens don't surpass the available tokens
require ((amountTokens.add(checkMintedTokens()) <= amntNonGenesisNfts.add(amntGenesisNfts)), "You are minting more NFTs than there are available, mint less tokens!");
require (amountTokens <= maxTknPerTxs, "Sorry, the max amount of tokens per transaction is set to 20");
// Requires the correct amount of ETH
require (msg.value == (price.mul(amountTokens)), "Amount of Ether incorrect, try again.");
}
// Internal mint function
for (uint i=0; i<amountTokens; i++){
safeMint(msg.sender);
}
}
| 10,467 |
106 | // Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} iscalled. 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}. / Present in ERC777 | function decimals() public view returns (uint8) {
return _decimals;
}
| function decimals() public view returns (uint8) {
return _decimals;
}
| 14,741 |
29 | // An event of removing an existing loan./ | event LoanRemoved(uint256 _loanID);
| event LoanRemoved(uint256 _loanID);
| 52,561 |
72 | // Emitted when a leftover reward is recovered | event LeftoverRewardRecovered(address indexed _recipient, uint256 _amount);
| event LeftoverRewardRecovered(address indexed _recipient, uint256 _amount);
| 24,725 |
1 | // Deploys contract VToken at an address such that the last 4 bytes of contract address is unique/Use of CREATE2 is not to recompute address in future, but just to have unique last 4 bytes/params: parameters used for construction, see above struct/ return vToken : the deployed VToken contract | function _deployVToken(DeployVTokenParams calldata params) internal returns (IVToken vToken) {
bytes memory bytecode = abi.encodePacked(
type(VToken).creationCode,
abi.encode(params.vTokenName, params.vTokenSymbol, params.cTokenDecimals)
);
vToken = IVToken(GoodAddressDeployer.deploy(0, bytecode, _isIVTokenAddressGood));
}
| function _deployVToken(DeployVTokenParams calldata params) internal returns (IVToken vToken) {
bytes memory bytecode = abi.encodePacked(
type(VToken).creationCode,
abi.encode(params.vTokenName, params.vTokenSymbol, params.cTokenDecimals)
);
vToken = IVToken(GoodAddressDeployer.deploy(0, bytecode, _isIVTokenAddressGood));
}
| 29,959 |
44 | // Check if token offering address is set or not / | modifier onlyTokenOfferingAddrNotSet() {
require(tokenOfferingAddr == address(0x0));
_;
}
| modifier onlyTokenOfferingAddrNotSet() {
require(tokenOfferingAddr == address(0x0));
_;
}
| 42,220 |
3 | // A view function that tells how many total iterations are there / | function getTotalIterations() external view returns(uint256) {
return iterations.length;
}
| function getTotalIterations() external view returns(uint256) {
return iterations.length;
}
| 4,596 |
166 | // Revert rollup block on dispute success_blockId Rollup block id _reason Revert reason / | function _revertBlock(uint256 _blockId, string memory _reason) private {
// pause contract
_pause();
// revert blocks and pending states
while (blocks.length > _blockId) {
pendingWithdrawCommits[blocks.length - 1];
blocks.pop();
}
bool first;
for (uint256 i = pendingDepositsExecuteHead; i < pendingDepositsTail; i++) {
if (pendingDeposits[i].blockId >= _blockId) {
if (!first) {
pendingDepositsCommitHead = i;
first = true;
}
pendingDeposits[i].blockId = uint64(_blockId);
pendingDeposits[i].status = PendingDepositStatus.Pending;
}
}
first = false;
for (uint256 i = pendingBalanceSyncsExecuteHead; i < pendingBalanceSyncsTail; i++) {
if (pendingBalanceSyncs[i].blockId >= _blockId) {
if (!first) {
pendingBalanceSyncsCommitHead = i;
first = true;
}
pendingBalanceSyncs[i].blockId = uint64(_blockId);
pendingBalanceSyncs[i].status = PendingBalanceSyncStatus.Pending;
}
}
emit RollupBlockReverted(_blockId, _reason);
}
| function _revertBlock(uint256 _blockId, string memory _reason) private {
// pause contract
_pause();
// revert blocks and pending states
while (blocks.length > _blockId) {
pendingWithdrawCommits[blocks.length - 1];
blocks.pop();
}
bool first;
for (uint256 i = pendingDepositsExecuteHead; i < pendingDepositsTail; i++) {
if (pendingDeposits[i].blockId >= _blockId) {
if (!first) {
pendingDepositsCommitHead = i;
first = true;
}
pendingDeposits[i].blockId = uint64(_blockId);
pendingDeposits[i].status = PendingDepositStatus.Pending;
}
}
first = false;
for (uint256 i = pendingBalanceSyncsExecuteHead; i < pendingBalanceSyncsTail; i++) {
if (pendingBalanceSyncs[i].blockId >= _blockId) {
if (!first) {
pendingBalanceSyncsCommitHead = i;
first = true;
}
pendingBalanceSyncs[i].blockId = uint64(_blockId);
pendingBalanceSyncs[i].status = PendingBalanceSyncStatus.Pending;
}
}
emit RollupBlockReverted(_blockId, _reason);
}
| 34,014 |
162 | // RefundEscrow Escrow that holds funds for a beneficiary, deposited from multipleparties. Intended usage: See Escrow.sol. Same usage guidelines apply here. The primary account (that is, the contract that instantiates thiscontract) may deposit, close the deposit period, and allow for eitherwithdrawal by the beneficiary, or refunds to the depositors. All interactionswith RefundEscrow will be made through the primary contract. See theRefundableCrowdsale contract for an example of RefundEscrowΓÇÖs use. / | contract RefundEscrow is ConditionalEscrow {
enum State { Active, Refunding, Closed }
event RefundsClosed();
event RefundsEnabled();
State private _state;
address payable private _beneficiary;
/**
* @dev Constructor.
* @param beneficiary The beneficiary of the deposits.
*/
constructor (address payable beneficiary) public {
require(beneficiary != address(0), "RefundEscrow: beneficiary is the zero address");
_beneficiary = beneficiary;
_state = State.Active;
}
/**
* @return The current state of the escrow.
*/
function state() public view returns (State) {
return _state;
}
/**
* @return The beneficiary of the escrow.
*/
function beneficiary() public view returns (address) {
return _beneficiary;
}
/**
* @dev Stores funds that may later be refunded.
* @param refundee The address funds will be sent to if a refund occurs.
*/
function deposit(address refundee) public payable {
require(_state == State.Active, "RefundEscrow: can only deposit while active");
super.deposit(refundee);
}
/**
* @dev Allows for the beneficiary to withdraw their funds, rejecting
* further deposits.
*/
function close() public onlyPrimary {
require(_state == State.Active, "RefundEscrow: can only close while active");
_state = State.Closed;
emit RefundsClosed();
}
/**
* @dev Allows for refunds to take place, rejecting further deposits.
*/
function enableRefunds() public onlyPrimary {
require(_state == State.Active, "RefundEscrow: can only enable refunds while active");
_state = State.Refunding;
emit RefundsEnabled();
}
/**
* @dev Withdraws the beneficiary's funds.
*/
function beneficiaryWithdraw() public {
require(_state == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed");
_beneficiary.transfer(address(this).balance);
}
/**
* @dev Returns whether refundees can withdraw their deposits (be refunded). The overridden function receives a
* 'payee' argument, but we ignore it here since the condition is global, not per-payee.
*/
function withdrawalAllowed(address) public view returns (bool) {
return _state == State.Refunding;
}
}
| contract RefundEscrow is ConditionalEscrow {
enum State { Active, Refunding, Closed }
event RefundsClosed();
event RefundsEnabled();
State private _state;
address payable private _beneficiary;
/**
* @dev Constructor.
* @param beneficiary The beneficiary of the deposits.
*/
constructor (address payable beneficiary) public {
require(beneficiary != address(0), "RefundEscrow: beneficiary is the zero address");
_beneficiary = beneficiary;
_state = State.Active;
}
/**
* @return The current state of the escrow.
*/
function state() public view returns (State) {
return _state;
}
/**
* @return The beneficiary of the escrow.
*/
function beneficiary() public view returns (address) {
return _beneficiary;
}
/**
* @dev Stores funds that may later be refunded.
* @param refundee The address funds will be sent to if a refund occurs.
*/
function deposit(address refundee) public payable {
require(_state == State.Active, "RefundEscrow: can only deposit while active");
super.deposit(refundee);
}
/**
* @dev Allows for the beneficiary to withdraw their funds, rejecting
* further deposits.
*/
function close() public onlyPrimary {
require(_state == State.Active, "RefundEscrow: can only close while active");
_state = State.Closed;
emit RefundsClosed();
}
/**
* @dev Allows for refunds to take place, rejecting further deposits.
*/
function enableRefunds() public onlyPrimary {
require(_state == State.Active, "RefundEscrow: can only enable refunds while active");
_state = State.Refunding;
emit RefundsEnabled();
}
/**
* @dev Withdraws the beneficiary's funds.
*/
function beneficiaryWithdraw() public {
require(_state == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed");
_beneficiary.transfer(address(this).balance);
}
/**
* @dev Returns whether refundees can withdraw their deposits (be refunded). The overridden function receives a
* 'payee' argument, but we ignore it here since the condition is global, not per-payee.
*/
function withdrawalAllowed(address) public view returns (bool) {
return _state == State.Refunding;
}
}
| 38,300 |
60 | // Internal method to delegate execution to another contract It returns to the external caller whatever the implementation returns or forwards reverts callee The contract to delegatecall data The raw data to delegatecall / | function delegateTo(address callee, bytes memory data) internal {
(bool success, bytes memory returnData) = callee.delegatecall(data);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
}
| function delegateTo(address callee, bytes memory data) internal {
(bool success, bytes memory returnData) = callee.delegatecall(data);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
}
| 11,701 |
10 | // Mainnet | iChai public constant chai = iChai(0x06AF07097C9Eeb7fD685c692751D5C66dB49c215);
iPot public constant pot = iPot(0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7);
ERC20 public constant dai = ERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
| iChai public constant chai = iChai(0x06AF07097C9Eeb7fD685c692751D5C66dB49c215);
iPot public constant pot = iPot(0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7);
ERC20 public constant dai = ERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
| 14,876 |
30 | // Validate that threshold is smaller than number of owners. | require(_threshold <= guardCount, "Guard: Threshold cannot exceed guard count");
| require(_threshold <= guardCount, "Guard: Threshold cannot exceed guard count");
| 5,740 |
2 | // / | {
if (msg.sender == creator)
{
selfdestruct(creator);
}
}
| {
if (msg.sender == creator)
{
selfdestruct(creator);
}
}
| 16,265 |
113 | // If the current tax receiver should receive SF from collateralType | if (secondaryTaxReceivers[collateralType][currentSecondaryReceiver].taxPercentage > 0) {
distributeTax(
collateralType,
secondaryReceiverAccounts[currentSecondaryReceiver],
currentSecondaryReceiver,
debtAmount,
deltaRate
);
}
| if (secondaryTaxReceivers[collateralType][currentSecondaryReceiver].taxPercentage > 0) {
distributeTax(
collateralType,
secondaryReceiverAccounts[currentSecondaryReceiver],
currentSecondaryReceiver,
debtAmount,
deltaRate
);
}
| 54,581 |
50 | // Calculate fee and sum to contract owner balance | uint256 amountAfterFees = payFee();
| uint256 amountAfterFees = payFee();
| 32,280 |
200 | // MasterChef is the master of TMC. He can make TMC 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 TMC is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's bug-free. God bless. | contract MasterPool is MyOwnable, IERC721Receiver, PausableStaking {
using SafeMath for uint256;
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.UintSet;
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public override returns (bytes4){
// return IERC721Receiver(0).onERC721Received.selector;
return 0x150b7a02;
}
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
EnumerableSet.UintSet tamagIds;
//
// We do some fancy math here. Basically, any point in time, the amount of TMCs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accTmcPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accTmcPerShare` (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.1
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. TMCs to distribute per block.
uint256 lastRewardBlock; // Last block number that TMCs distribution occurs.
uint256 accTmcPerShare; // Accumulated TMCs per share, times 1e12. See below.
IERC721 tamag;
uint256 totalAmount;
EnumerableSet.UintSet tamagIds;
}
// The TMC TOKEN!
ITMC public tmc;
// Dev address.
address public devAddr;
// divider for dev fee. 100 = 1% dev fee.
uint256 public devFeeDivider = 100;
// Block number when bonus TMC period ends.
uint256 public bonusEndBlock;
// TMC tokens created per block.
uint256 public tmcPerBlock;
// Bonus muliplier for early stakers.
uint256 public constant BONUS_MULTIPLIER = 1;
ITAMAGRewardCalc public tamagRewardCalc;
// Info of each pool.
PoolInfo[] private poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) private userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when TMC mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event DepositTamag(address indexed user, uint256 indexed _pid, uint256 indexed tamagId, uint256 virtualAmt);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event WithdrawTamag(address indexed user, uint256 indexed _pid, uint256 indexed tamagId);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdrawTamag(address indexed user, uint256 indexed _pid, uint256 indexed tamagId);
event PoolUpdated(uint256 mintToDev, uint256 mintToPool);
constructor(
address _tmc,
address _devAddr,
uint256 _tmcPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock,
address _tamagRewardCalc,
address _owner
) public MyOwnable(_owner){
tmc = ITMC(_tmc);
devAddr = _devAddr;
tmcPerBlock = _tmcPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
tamagRewardCalc = ITAMAGRewardCalc(_tamagRewardCalc);
pauseDeposit();
pauseWithdraw();
}
function setTmc(address a) public onlyOwner{
tmc = ITMC(a);
}
// MUST MASS UPDATE POOLS FIRST then u can call this!
function setTMCPerBlock(uint256 i) public onlyOwner{
tmcPerBlock = i;
}
function setTamagRewardCalc(address a) public onlyOwner {
tamagRewardCalc = ITAMAGRewardCalc(a);
}
function setDevAddress(address a) public onlyOwner {
devAddr = a;
}
function setDevFeeDivider(uint256 divider) public onlyOwner{
devFeeDivider = divider;
}
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 memory p;
p.lpToken = _lpToken;
p.allocPoint = _allocPoint;
p.lastRewardBlock = lastRewardBlock;
p.accTmcPerShare = 0;
poolInfo.push(p);
}
// 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 addTamagPool(uint256 _allocPoint, IERC721 _tamagToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
PoolInfo memory p;
p.allocPoint = _allocPoint;
p.lastRewardBlock = lastRewardBlock;
p.accTmcPerShare = 0;
p.tamag = _tamagToken;
p.totalAmount = 0;
poolInfo.push(p);
}
// Update the given pool's TMC allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
poolInfo[_pid].allocPoint = _allocPoint;
}
// check TAMAG traits and OG label
// Return reward multiplier over the given _from to _to block.
// specific to each pool
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending TMCs on frontend.
function pendingTMCForTamag(uint256 _pid, address _user, uint256 tamagId) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accTmcPerShare = pool.accTmcPerShare;
uint256 lpSupply;
if (!isTamagPool(_pid)){
lpSupply = pool.lpToken.balanceOf(address(this));
}else {
lpSupply = pool.totalAmount;
}
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 tmcReward = multiplier.mul(tmcPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accTmcPerShare = accTmcPerShare.add(tmcReward.mul(1e12).div(lpSupply));
}
uint256 tamagVirtualAmount = tamagRewardCalc.getVirtualAmt(tamagId);
return user.amount.mul(accTmcPerShare).div(1e12).sub(user.rewardDebt).mul(tamagVirtualAmount).div(user.amount);
}
// View function to see pending TMCs on frontend.
function pendingTMC(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accTmcPerShare = pool.accTmcPerShare;
uint256 lpSupply;
if (!isTamagPool(_pid)){
lpSupply = pool.lpToken.balanceOf(address(this));
}else {
lpSupply = pool.totalAmount;
}
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 tmcReward = multiplier.mul(tmcPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accTmcPerShare = accTmcPerShare.add(tmcReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accTmcPerShare).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.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply;
if (!isTamagPool(_pid)){
lpSupply = pool.lpToken.balanceOf(address(this));
}else {
lpSupply = pool.totalAmount;
}
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 tmcReward = multiplier.mul(tmcPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
tmc.mint(devAddr, tmcReward.div(devFeeDivider));
tmc.mint(address(this), tmcReward);
PoolUpdated(tmcReward.div(devFeeDivider),tmcReward);
pool.accTmcPerShare = pool.accTmcPerShare.add(tmcReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
function getTotalStakedTamag(uint256 _pid) public view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
return pool.tamagIds.length();
}
function getTotalStakedTamagByIndex(uint256 _pid, uint256 index) public view returns (uint256){
PoolInfo storage pool = poolInfo[_pid];
require (index < getTotalStakedTamag(_pid),"invalid index");
return pool.tamagIds.at(index);
}
function getUserTotalStakedTamag(uint256 _pid) public view returns (uint256){
return userInfo[_pid][_msgSender()].tamagIds.length();
}
function getUserStakedTamagByIndex(uint256 _pid, uint256 index) public view returns (uint256){
require (index < getUserTotalStakedTamag(_pid),"invalid index");
return userInfo[_pid][_msgSender()].tamagIds.at(index);
}
function claimTamagRewards(uint256 _pid) public whenNotPausedDeposit{
require(isTamagPool(_pid), "not tamag pool");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
}
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
}
function depositTamag(uint256 _pid, uint256 tamagId) public whenNotPausedDeposit{
require(isTamagPool(_pid), "not tamag pool");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
require(!user.tamagIds.contains(tamagId), "Tamag already staked!");
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
}
// convert tamag to virtual amount
uint256 tamagVirtualAmount = tamagRewardCalc.getVirtualAmt(tamagId);
pool.tamag.safeTransferFrom(_msgSender(), address(this), tamagId);
user.amount = user.amount.add(tamagVirtualAmount);
user.tamagIds.add(tamagId);
pool.totalAmount = pool.totalAmount.add(tamagVirtualAmount);
pool.tamagIds.add(tamagId);
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
emit DepositTamag(_msgSender(), _pid, tamagId, tamagVirtualAmount);
}
// Deposit LP tokens to MasterChef for TMC allocation.
function deposit(uint256 _pid, uint256 _amount) public whenNotPausedDeposit{
require(!isTamagPool(_pid), "not erc20 pool");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
}
if (_amount > 0) {
pool.lpToken.safeTransferFrom(_msgSender(), address(this), _amount);
user.amount = user.amount.add(_amount);
}
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
emit Deposit(_msgSender(), _pid, _amount);
}
function isTamagPool(uint256 _pid) public view returns (bool){
PoolInfo storage pool = poolInfo[_pid];
return address(pool.lpToken) == address(0) && address(pool.tamag) != address(0);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public whenNotPausedWithdraw{
require(!isTamagPool(_pid), "not erc20 pool");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
if(_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(_msgSender(), _amount);
}
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
emit Withdraw(_msgSender(), _pid, _amount);
}
// Withdraw TAMAG tokens from MasterChef.
function withdrawTamag(uint256 _pid, uint256 tamagId) public whenNotPausedWithdraw{
require(isTamagPool(_pid), "not tamag pool");
PoolInfo storage pool = poolInfo[_pid];
require (pool.tamagIds.contains(tamagId), "pool don't have tamag");
UserInfo storage user = userInfo[_pid][_msgSender()];
require(user.tamagIds.contains(tamagId), "tamag not yet staked by user");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
uint256 tamagVirtualAmount = tamagRewardCalc.getVirtualAmt(tamagId);
user.amount = user.amount.sub(tamagVirtualAmount);
user.tamagIds.remove(tamagId);
pool.totalAmount = pool.totalAmount.sub(tamagVirtualAmount);
pool.tamagIds.remove(tamagId);
pool.tamag.safeTransferFrom(address(this), _msgSender(), tamagId);
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
emit WithdrawTamag(_msgSender(), _pid, tamagId);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
pool.lpToken.safeTransfer(_msgSender(), amount);
emit EmergencyWithdraw(_msgSender(), _pid, amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdrawTamag(uint256 _pid, uint256 tamagId) public {
require(isTamagPool(_pid), "not tamag pool");
PoolInfo storage pool = poolInfo[_pid];
require (pool.tamagIds.contains(tamagId), "pool don't have tamag");
UserInfo storage user = userInfo[_pid][_msgSender()];
require (user.tamagIds.contains(tamagId), "tamag not in pool");
uint256 tamagVirtualAmount = tamagRewardCalc.getVirtualAmt(tamagId);
user.amount = user.amount.sub(tamagVirtualAmount);
user.tamagIds.remove(tamagId);
pool.totalAmount = pool.totalAmount.sub(tamagVirtualAmount);
pool.tamagIds.remove(tamagId);
pool.tamag.safeTransferFrom(address(this), _msgSender(), tamagId);
emit EmergencyWithdraw(_msgSender(), _pid, tamagId);
}
// Safe tmc transfer function, just in case if rounding error causes pool to not have enough TMCs.
function safeTmcTransfer(address _to, uint256 _amount) internal {
uint256 tmcBal = tmc.balanceOf(address(this));
if (_amount > tmcBal) {
tmc.transfer(_to, tmcBal);
} else {
tmc.transfer(_to, _amount);
}
}
// utility methods for poolInfo, userInfo
function getUserInfo(uint256 _pid, address a) public view returns (uint256, uint256){
UserInfo storage user = userInfo[_pid][a];
uint256 amount = user.amount;
uint256 rewardDebt = user.rewardDebt;
return (amount, rewardDebt);
}
// utility methods for poolInfo, userInfo
function getUserInfoTamagIdSize(uint256 _pid, address a) public view returns (uint256){
return userInfo[_pid][a].tamagIds.length();
}
function getUserInfoTamagIdAtIndex(uint256 _pid, address a, uint256 i) public view returns(uint256){
return userInfo[_pid][a].tamagIds.at(i);
}
function getUserInfoTamagIdContains(uint256 _pid, address a, uint256 tamagId) public view returns(bool){
return userInfo[_pid][a].tamagIds.contains(tamagId);
}
// utility methods for poolInfo, userInfo
function getPool(uint256 poolIndex) public view returns (address lpToken, uint256 allocPoint, uint256 lastRewardBlock, uint256 accTmcPerShare, address tamag, uint256 totalAmount){
PoolInfo storage pool = poolInfo[poolIndex];
return (address(pool.lpToken), pool.allocPoint, pool.lastRewardBlock, pool.accTmcPerShare, address(pool.tamag), pool.totalAmount);
}
// utility methods for poolInfo, userInfo
function getPoolTamagIdSize(uint256 poolIndex) public view returns (uint256){
return poolInfo[poolIndex].tamagIds.length();
}
function getPoolTamagIdAtIndex(uint256 poolIndex, uint256 i) public view returns(uint256){
return poolInfo[poolIndex].tamagIds.at(i);
}
function getPoolTamagIdContains(uint256 poolIndex, uint256 tamagId) public view returns(bool){
return poolInfo[poolIndex].tamagIds.contains(tamagId);
}
}
| contract MasterPool is MyOwnable, IERC721Receiver, PausableStaking {
using SafeMath for uint256;
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.UintSet;
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public override returns (bytes4){
// return IERC721Receiver(0).onERC721Received.selector;
return 0x150b7a02;
}
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
EnumerableSet.UintSet tamagIds;
//
// We do some fancy math here. Basically, any point in time, the amount of TMCs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accTmcPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accTmcPerShare` (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.1
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. TMCs to distribute per block.
uint256 lastRewardBlock; // Last block number that TMCs distribution occurs.
uint256 accTmcPerShare; // Accumulated TMCs per share, times 1e12. See below.
IERC721 tamag;
uint256 totalAmount;
EnumerableSet.UintSet tamagIds;
}
// The TMC TOKEN!
ITMC public tmc;
// Dev address.
address public devAddr;
// divider for dev fee. 100 = 1% dev fee.
uint256 public devFeeDivider = 100;
// Block number when bonus TMC period ends.
uint256 public bonusEndBlock;
// TMC tokens created per block.
uint256 public tmcPerBlock;
// Bonus muliplier for early stakers.
uint256 public constant BONUS_MULTIPLIER = 1;
ITAMAGRewardCalc public tamagRewardCalc;
// Info of each pool.
PoolInfo[] private poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) private userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when TMC mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event DepositTamag(address indexed user, uint256 indexed _pid, uint256 indexed tamagId, uint256 virtualAmt);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event WithdrawTamag(address indexed user, uint256 indexed _pid, uint256 indexed tamagId);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdrawTamag(address indexed user, uint256 indexed _pid, uint256 indexed tamagId);
event PoolUpdated(uint256 mintToDev, uint256 mintToPool);
constructor(
address _tmc,
address _devAddr,
uint256 _tmcPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock,
address _tamagRewardCalc,
address _owner
) public MyOwnable(_owner){
tmc = ITMC(_tmc);
devAddr = _devAddr;
tmcPerBlock = _tmcPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
tamagRewardCalc = ITAMAGRewardCalc(_tamagRewardCalc);
pauseDeposit();
pauseWithdraw();
}
function setTmc(address a) public onlyOwner{
tmc = ITMC(a);
}
// MUST MASS UPDATE POOLS FIRST then u can call this!
function setTMCPerBlock(uint256 i) public onlyOwner{
tmcPerBlock = i;
}
function setTamagRewardCalc(address a) public onlyOwner {
tamagRewardCalc = ITAMAGRewardCalc(a);
}
function setDevAddress(address a) public onlyOwner {
devAddr = a;
}
function setDevFeeDivider(uint256 divider) public onlyOwner{
devFeeDivider = divider;
}
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 memory p;
p.lpToken = _lpToken;
p.allocPoint = _allocPoint;
p.lastRewardBlock = lastRewardBlock;
p.accTmcPerShare = 0;
poolInfo.push(p);
}
// 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 addTamagPool(uint256 _allocPoint, IERC721 _tamagToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
PoolInfo memory p;
p.allocPoint = _allocPoint;
p.lastRewardBlock = lastRewardBlock;
p.accTmcPerShare = 0;
p.tamag = _tamagToken;
p.totalAmount = 0;
poolInfo.push(p);
}
// Update the given pool's TMC allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
poolInfo[_pid].allocPoint = _allocPoint;
}
// check TAMAG traits and OG label
// Return reward multiplier over the given _from to _to block.
// specific to each pool
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending TMCs on frontend.
function pendingTMCForTamag(uint256 _pid, address _user, uint256 tamagId) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accTmcPerShare = pool.accTmcPerShare;
uint256 lpSupply;
if (!isTamagPool(_pid)){
lpSupply = pool.lpToken.balanceOf(address(this));
}else {
lpSupply = pool.totalAmount;
}
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 tmcReward = multiplier.mul(tmcPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accTmcPerShare = accTmcPerShare.add(tmcReward.mul(1e12).div(lpSupply));
}
uint256 tamagVirtualAmount = tamagRewardCalc.getVirtualAmt(tamagId);
return user.amount.mul(accTmcPerShare).div(1e12).sub(user.rewardDebt).mul(tamagVirtualAmount).div(user.amount);
}
// View function to see pending TMCs on frontend.
function pendingTMC(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accTmcPerShare = pool.accTmcPerShare;
uint256 lpSupply;
if (!isTamagPool(_pid)){
lpSupply = pool.lpToken.balanceOf(address(this));
}else {
lpSupply = pool.totalAmount;
}
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 tmcReward = multiplier.mul(tmcPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accTmcPerShare = accTmcPerShare.add(tmcReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accTmcPerShare).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.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply;
if (!isTamagPool(_pid)){
lpSupply = pool.lpToken.balanceOf(address(this));
}else {
lpSupply = pool.totalAmount;
}
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 tmcReward = multiplier.mul(tmcPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
tmc.mint(devAddr, tmcReward.div(devFeeDivider));
tmc.mint(address(this), tmcReward);
PoolUpdated(tmcReward.div(devFeeDivider),tmcReward);
pool.accTmcPerShare = pool.accTmcPerShare.add(tmcReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
function getTotalStakedTamag(uint256 _pid) public view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
return pool.tamagIds.length();
}
function getTotalStakedTamagByIndex(uint256 _pid, uint256 index) public view returns (uint256){
PoolInfo storage pool = poolInfo[_pid];
require (index < getTotalStakedTamag(_pid),"invalid index");
return pool.tamagIds.at(index);
}
function getUserTotalStakedTamag(uint256 _pid) public view returns (uint256){
return userInfo[_pid][_msgSender()].tamagIds.length();
}
function getUserStakedTamagByIndex(uint256 _pid, uint256 index) public view returns (uint256){
require (index < getUserTotalStakedTamag(_pid),"invalid index");
return userInfo[_pid][_msgSender()].tamagIds.at(index);
}
function claimTamagRewards(uint256 _pid) public whenNotPausedDeposit{
require(isTamagPool(_pid), "not tamag pool");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
}
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
}
function depositTamag(uint256 _pid, uint256 tamagId) public whenNotPausedDeposit{
require(isTamagPool(_pid), "not tamag pool");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
require(!user.tamagIds.contains(tamagId), "Tamag already staked!");
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
}
// convert tamag to virtual amount
uint256 tamagVirtualAmount = tamagRewardCalc.getVirtualAmt(tamagId);
pool.tamag.safeTransferFrom(_msgSender(), address(this), tamagId);
user.amount = user.amount.add(tamagVirtualAmount);
user.tamagIds.add(tamagId);
pool.totalAmount = pool.totalAmount.add(tamagVirtualAmount);
pool.tamagIds.add(tamagId);
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
emit DepositTamag(_msgSender(), _pid, tamagId, tamagVirtualAmount);
}
// Deposit LP tokens to MasterChef for TMC allocation.
function deposit(uint256 _pid, uint256 _amount) public whenNotPausedDeposit{
require(!isTamagPool(_pid), "not erc20 pool");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
}
if (_amount > 0) {
pool.lpToken.safeTransferFrom(_msgSender(), address(this), _amount);
user.amount = user.amount.add(_amount);
}
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
emit Deposit(_msgSender(), _pid, _amount);
}
function isTamagPool(uint256 _pid) public view returns (bool){
PoolInfo storage pool = poolInfo[_pid];
return address(pool.lpToken) == address(0) && address(pool.tamag) != address(0);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public whenNotPausedWithdraw{
require(!isTamagPool(_pid), "not erc20 pool");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
if(_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(_msgSender(), _amount);
}
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
emit Withdraw(_msgSender(), _pid, _amount);
}
// Withdraw TAMAG tokens from MasterChef.
function withdrawTamag(uint256 _pid, uint256 tamagId) public whenNotPausedWithdraw{
require(isTamagPool(_pid), "not tamag pool");
PoolInfo storage pool = poolInfo[_pid];
require (pool.tamagIds.contains(tamagId), "pool don't have tamag");
UserInfo storage user = userInfo[_pid][_msgSender()];
require(user.tamagIds.contains(tamagId), "tamag not yet staked by user");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accTmcPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeTmcTransfer(_msgSender(), pending);
}
uint256 tamagVirtualAmount = tamagRewardCalc.getVirtualAmt(tamagId);
user.amount = user.amount.sub(tamagVirtualAmount);
user.tamagIds.remove(tamagId);
pool.totalAmount = pool.totalAmount.sub(tamagVirtualAmount);
pool.tamagIds.remove(tamagId);
pool.tamag.safeTransferFrom(address(this), _msgSender(), tamagId);
user.rewardDebt = user.amount.mul(pool.accTmcPerShare).div(1e12);
emit WithdrawTamag(_msgSender(), _pid, tamagId);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_msgSender()];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
pool.lpToken.safeTransfer(_msgSender(), amount);
emit EmergencyWithdraw(_msgSender(), _pid, amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdrawTamag(uint256 _pid, uint256 tamagId) public {
require(isTamagPool(_pid), "not tamag pool");
PoolInfo storage pool = poolInfo[_pid];
require (pool.tamagIds.contains(tamagId), "pool don't have tamag");
UserInfo storage user = userInfo[_pid][_msgSender()];
require (user.tamagIds.contains(tamagId), "tamag not in pool");
uint256 tamagVirtualAmount = tamagRewardCalc.getVirtualAmt(tamagId);
user.amount = user.amount.sub(tamagVirtualAmount);
user.tamagIds.remove(tamagId);
pool.totalAmount = pool.totalAmount.sub(tamagVirtualAmount);
pool.tamagIds.remove(tamagId);
pool.tamag.safeTransferFrom(address(this), _msgSender(), tamagId);
emit EmergencyWithdraw(_msgSender(), _pid, tamagId);
}
// Safe tmc transfer function, just in case if rounding error causes pool to not have enough TMCs.
function safeTmcTransfer(address _to, uint256 _amount) internal {
uint256 tmcBal = tmc.balanceOf(address(this));
if (_amount > tmcBal) {
tmc.transfer(_to, tmcBal);
} else {
tmc.transfer(_to, _amount);
}
}
// utility methods for poolInfo, userInfo
function getUserInfo(uint256 _pid, address a) public view returns (uint256, uint256){
UserInfo storage user = userInfo[_pid][a];
uint256 amount = user.amount;
uint256 rewardDebt = user.rewardDebt;
return (amount, rewardDebt);
}
// utility methods for poolInfo, userInfo
function getUserInfoTamagIdSize(uint256 _pid, address a) public view returns (uint256){
return userInfo[_pid][a].tamagIds.length();
}
function getUserInfoTamagIdAtIndex(uint256 _pid, address a, uint256 i) public view returns(uint256){
return userInfo[_pid][a].tamagIds.at(i);
}
function getUserInfoTamagIdContains(uint256 _pid, address a, uint256 tamagId) public view returns(bool){
return userInfo[_pid][a].tamagIds.contains(tamagId);
}
// utility methods for poolInfo, userInfo
function getPool(uint256 poolIndex) public view returns (address lpToken, uint256 allocPoint, uint256 lastRewardBlock, uint256 accTmcPerShare, address tamag, uint256 totalAmount){
PoolInfo storage pool = poolInfo[poolIndex];
return (address(pool.lpToken), pool.allocPoint, pool.lastRewardBlock, pool.accTmcPerShare, address(pool.tamag), pool.totalAmount);
}
// utility methods for poolInfo, userInfo
function getPoolTamagIdSize(uint256 poolIndex) public view returns (uint256){
return poolInfo[poolIndex].tamagIds.length();
}
function getPoolTamagIdAtIndex(uint256 poolIndex, uint256 i) public view returns(uint256){
return poolInfo[poolIndex].tamagIds.at(i);
}
function getPoolTamagIdContains(uint256 poolIndex, uint256 tamagId) public view returns(bool){
return poolInfo[poolIndex].tamagIds.contains(tamagId);
}
}
| 17,058 |
21 | // Harvests caller's pending dividends of a given token / | function harvestDividends(address token) external nonReentrant {
if (!_distributedTokens.contains(token)) {
require(dividendsInfo[token].distributedAmount > 0, "harvestDividends: invalid token");
}
_harvestDividends(token);
}
| function harvestDividends(address token) external nonReentrant {
if (!_distributedTokens.contains(token)) {
require(dividendsInfo[token].distributedAmount > 0, "harvestDividends: invalid token");
}
_harvestDividends(token);
}
| 34,014 |
14 | // A function which lets the owner of the lock to change the price for future purchases. / | function updateKeyPrice(
uint _keyPrice
)
external
onlyOwner
onlyIfAlive
| function updateKeyPrice(
uint _keyPrice
)
external
onlyOwner
onlyIfAlive
| 11,334 |
292 | // Verify if sessionPubkeyHash was verified already, if not.. let's do it! | if (!provable_randomDS_sessionKeysHashVerified[sessionPubkeyHash]) {
provable_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = provable_randomDS_proofVerify__sessionKeyValidity(_proof, sig2offset);
}
| if (!provable_randomDS_sessionKeysHashVerified[sessionPubkeyHash]) {
provable_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = provable_randomDS_proofVerify__sessionKeyValidity(_proof, sig2offset);
}
| 39,542 |
77 | // root to child token | mapping(address => address) public childToRootToken;
| mapping(address => address) public childToRootToken;
| 33,207 |
15 | // Individually unbond each deposit | UserStake[] storage userStakes = stakes[msg.sender];
for (uint256 i = 0; i < userStakes.length; i++) {
UserStake storage s = userStakes[i];
if (s.amount != 0 && s.unbondTimestamp == 0) {
_unbond(i);
}
| UserStake[] storage userStakes = stakes[msg.sender];
for (uint256 i = 0; i < userStakes.length; i++) {
UserStake storage s = userStakes[i];
if (s.amount != 0 && s.unbondTimestamp == 0) {
_unbond(i);
}
| 72,071 |
33 | // _mintTo The address that should receive the token. Note that on the initial sale this address will not receive the sale collateral. Sale collateral will be distributed to creator and system fees _amount Amount of tokens to mint _baseTokenID ID of the token being duplicated _isLimitedStock Bool for if the batch has a pre-set limit / | function batchDuplicateMint(
address _mintTo,
uint256 _amount,
uint256 _baseTokenID,
bool _isLimitedStock
| function batchDuplicateMint(
address _mintTo,
uint256 _amount,
uint256 _baseTokenID,
bool _isLimitedStock
| 23,064 |
20 | // Called by the owner on emergency, triggers paused state | function pause() external onlyOwner ifNotPaused {
paused = true;
}
| function pause() external onlyOwner ifNotPaused {
paused = true;
}
| 17,347 |
251 | // call detectTransferFromRestriction on the current transferRestrictions contract | return _transferRestrictions.detectTransferFromRestriction(spender, from, to, amount);
| return _transferRestrictions.detectTransferFromRestriction(spender, from, to, amount);
| 29,843 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.