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 |
|---|---|---|---|---|
66 | // 池子信息. | struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
//uint256 allocPoint; // How many allocation points assigned to this pool. CAKEs to distribute per block.
uint256 lastRewardTime; // Last reward time that CAKEs distribution occurs.
uint256 accCakePerShare; // Accumulated CAKEs per share, times 1e12. See below.
}
| struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
//uint256 allocPoint; // How many allocation points assigned to this pool. CAKEs to distribute per block.
uint256 lastRewardTime; // Last reward time that CAKEs distribution occurs.
uint256 accCakePerShare; // Accumulated CAKEs per share, times 1e12. See below.
}
| 42,926 |
137 | // Sets the dev fee for this contract defaults at 7.24% Note contract owner is meant to be a governance contract allowing TCORE governance consensus | uint16 DEV_FEE;
| uint16 DEV_FEE;
| 30,667 |
130 | // Mint tokens incrementally (current total supply plus one) | function mint(address recepient) public onlyOwner {
_mint(recepient, totalSupply() + 1);
}
| function mint(address recepient) public onlyOwner {
_mint(recepient, totalSupply() + 1);
}
| 14,450 |
256 | // Returns the integer division of two unsigned integers, reverting ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Requirements: - The divisor cannot be zero. / | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
| 36,509 |
65 | // oods_coefficients[47]/ mload(add(context, 0x5fa0)), res += c_48(f_5(x) - f_5(g^16z)) / (x - g^16z). | res := add(
res,
mulmod(mulmod(/*(x - g^16 * z)^(-1)*/ mload(add(denominatorsPtr, 0x200)),
| res := add(
res,
mulmod(mulmod(/*(x - g^16 * z)^(-1)*/ mload(add(denominatorsPtr, 0x200)),
| 28,836 |
25 | // uint spotPrice = BLPool.getSpotPrice(sellToken,buyToken); | returnvalues[0] = blnc_00;
returnvalues[1] = blnc_01;
returnvalues[2] = blnc_10;
returnvalues[3] = blnc_11;
returnvalues[4] = blnc_20;
returnvalues[5] = blnc_21;
returnvalues[6] = blnc_30;
returnvalues[7] = blnc_31;
return returnvalues;
| returnvalues[0] = blnc_00;
returnvalues[1] = blnc_01;
returnvalues[2] = blnc_10;
returnvalues[3] = blnc_11;
returnvalues[4] = blnc_20;
returnvalues[5] = blnc_21;
returnvalues[6] = blnc_30;
returnvalues[7] = blnc_31;
return returnvalues;
| 18,805 |
155 | // event decodes params again, so decoding bytes to get message | return message;
| return message;
| 3,750 |
45 | // Allows the owner to raise the max level six cap, but only by 100 at a time_newMax is the new level six cap to be set/ | function raiseMaxLevelSix(uint8 _newMax) external onlyOwner {
require(_newMax > maxLevelSix, "Need to set the new max to be larger");
require(_newMax - maxLevelSix <= 100, "Can't raise it by more than 100 at a time");
maxLevelSix = _newMax;
}
| function raiseMaxLevelSix(uint8 _newMax) external onlyOwner {
require(_newMax > maxLevelSix, "Need to set the new max to be larger");
require(_newMax - maxLevelSix <= 100, "Can't raise it by more than 100 at a time");
maxLevelSix = _newMax;
}
| 11,066 |
105 | // set fxChildTunnel if not set already | function setFxChildTunnel(address _fxChildTunnel) public {
require(fxChildTunnel == address(0x0), "FxBaseRootTunnel: CHILD_TUNNEL_ALREADY_SET");
fxChildTunnel = _fxChildTunnel;
}
| function setFxChildTunnel(address _fxChildTunnel) public {
require(fxChildTunnel == address(0x0), "FxBaseRootTunnel: CHILD_TUNNEL_ALREADY_SET");
fxChildTunnel = _fxChildTunnel;
}
| 29,488 |
3 | // Base function for request creationmsg.sender will be the creator_payer Entity expected to pay _payeesIdAddress array of payees address (the index 0 will be the payee - must be msg.sender - the others are subPayees) _expectedAmounts array of Expected amount to be received by each payees _data Hash linking to additional data on the Request stored on IPFS return Returns the id of the request and the sum of the expected amounts / | function createCoreRequestInternal(
address _payer,
address[] _payeesIdAddress,
int256[] _expectedAmounts,
string _data)
internal
whenNotPaused
returns(bytes32 requestId, int256 totalExpectedAmounts)
| function createCoreRequestInternal(
address _payer,
address[] _payeesIdAddress,
int256[] _expectedAmounts,
string _data)
internal
whenNotPaused
returns(bytes32 requestId, int256 totalExpectedAmounts)
| 10,933 |
3 | // The amount of entries in the entries mapping/This will be used to list the entries mapping | uint256 public entryCount = 0;
| uint256 public entryCount = 0;
| 36,112 |
20 | // Check whether we want to withdraw all | _realWithdrawAmount[i] = _withdrawAmount[i] == uint256(-1)
? IHandler(_withdraw[i]).getRealBalance(_token)
: _withdrawAmount[i];
| _realWithdrawAmount[i] = _withdrawAmount[i] == uint256(-1)
? IHandler(_withdraw[i]).getRealBalance(_token)
: _withdrawAmount[i];
| 3,765 |
182 | // Remove from delegators list if no delegated stake remaining | if (delegateInfo[delegator][serviceProvider] == 0) {
_removeFromDelegatorsList(serviceProvider, delegator);
}
| if (delegateInfo[delegator][serviceProvider] == 0) {
_removeFromDelegatorsList(serviceProvider, delegator);
}
| 55,838 |
140 | // If _data is zero, set data size to 0 in buffer and push - | if eq(_data, 0) {
mstore(add(0x40, add(ptr, mload(ptr))), 0)
| if eq(_data, 0) {
mstore(add(0x40, add(ptr, mload(ptr))), 0)
| 8,684 |
75 | // Deposit LP tokens to Faucet for TNI allocation. _pid ID of a specific LP token pool. See index of PoolInfo[]. _amount Amount of LP tokens to deposit. / | function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTniPerShare).div(1e12).sub(user.rewardDebt);
safeTniTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accTniPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTniPerShare).div(1e12).sub(user.rewardDebt);
safeTniTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accTniPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| 2,840 |
46 | // You must have just done your first drawdown | if (nextDueBlock == 0 && balance > 0) {
return curBlockNumber.add(blocksPerPeriod);
}
| if (nextDueBlock == 0 && balance > 0) {
return curBlockNumber.add(blocksPerPeriod);
}
| 7,699 |
0 | // Interface of the ERC165 standard, as defined in the Implementers can declare support of contract interfaces, which can then be | * queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
| * queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
| 615 |
115 | // return The address of the Whitelist contract. / | function getWhitelistContract() public view returns(address) {
return address(whitelistInst);
}
| function getWhitelistContract() public view returns(address) {
return address(whitelistInst);
}
| 4,825 |
76 | // Internal Out Of Gas/Throw: revert this transaction too; Call Stack Depth Limit reached: n/a after HF 4; Recursive Call: safe, all changes already made. | CAVPlatformEmitter(eventsHistory).emitTransfer(_address(_fromId), _address(_toId), _symbol, _value, _reference);
_proxyTransferEvent(_fromId, _toId, _value, _symbol);
return OK;
| CAVPlatformEmitter(eventsHistory).emitTransfer(_address(_fromId), _address(_toId), _symbol, _value, _reference);
_proxyTransferEvent(_fromId, _toId, _value, _symbol);
return OK;
| 51,686 |
4 | // Requires the sender to be an owner of the SuperProtectorMultiSig | modifier onlySuperProtectorMultiSig() {
require(superProtectorMultiSig == (msg.sender));
_;
}
| modifier onlySuperProtectorMultiSig() {
require(superProtectorMultiSig == (msg.sender));
_;
}
| 9,432 |
0 | // Function must be implemented by deriving contract_hash Arbitrary length data signed on the behalf of address(this)_signature Signature byte array associated with _data return A bytes4 magic value 0x1626ba7e if the signature check passes, 0x00000000 if not MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5) MUST allow external calls/ | function isValidSignature(bytes32 _hash, bytes memory _signature) public virtual view returns (bytes4);
| function isValidSignature(bytes32 _hash, bytes memory _signature) public virtual view returns (bytes4);
| 35,036 |
5 | // Canonical NaN value. / | bytes16 private constant NaN = 0x7FFF8000000000000000000000000000;
| bytes16 private constant NaN = 0x7FFF8000000000000000000000000000;
| 19,846 |
82 | // / | contract MultiTokenStaking is Ownable, BoringBatchable {
using BoringMath for uint256;
using BoringMath128 for uint128;
using BoringERC20 for IERC20;
using SignedSafeMath for int256;
/** ========== Constants ========== */
uint256 private constant ACC_REWARDS_PRECISION = 1e12;
/**
* @dev ERC20 token used to distribute rewards.
*/
IERC20 public immutable rewardsToken;
/**
* @dev Contract that determines the amount of rewards distributed per block.
* Note: This contract MUST always return the exact same value for any
* combination of `(from, to)` IF `from` is less than `block.number`.
*/
IRewardsSchedule public immutable rewardsSchedule;
/** ========== Structs ========== */
/**
* @dev Info of each user.
* @param amount LP token amount the user has provided.
* @param rewardDebt The amount of rewards entitled to the user.
*/
struct UserInfo {
uint256 amount;
int256 rewardDebt;
}
/**
* @dev Info of each rewards pool.
* @param accRewardsPerShare Total rewards accumulated per staked token.
* @param lastRewardBlock Last time rewards were updated for the pool.
* @param allocPoint The amount of allocation points assigned to the pool.
*/
struct PoolInfo {
uint128 accRewardsPerShare;
uint64 lastRewardBlock;
uint64 allocPoint;
}
/** ========== Events ========== */
event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Harvest(address indexed user, uint256 indexed pid, uint256 amount);
event LogPoolAddition(uint256 indexed pid, uint256 allocPoint, IERC20 indexed lpToken, IRewarder indexed rewarder);
event LogSetPool(uint256 indexed pid, uint256 allocPoint, IRewarder indexed rewarder, bool overwrite);
event LogUpdatePool(uint256 indexed pid, uint64 lastRewardBlock, uint256 lpSupply, uint256 accRewardsPerShare);
event RewardsAdded(uint256 amount);
event PointsAllocatorSet(address pointsAllocator);
/** ========== Storage ========== */
/**
* @dev Indicates whether a staking pool exists for a given staking token.
*/
mapping(address => bool) public stakingPoolExists;
/**
* @dev Info of each staking pool.
*/
PoolInfo[] public poolInfo;
/**
* @dev Address of the LP token for each staking pool.
*/
mapping(uint256 => IERC20) public lpToken;
/**
* @dev Address of each `IRewarder` contract.
*/
mapping(uint256 => IRewarder) public rewarder;
/**
* @dev Info of each user that stakes tokens.
*/
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
/**
* @dev Total allocation points. Must be the sum of all allocation points in all pools.
*/
uint256 public totalAllocPoint = 0;
/**
* @dev Account allowed to allocate points.
*/
address public pointsAllocator;
/**
* @dev Total rewards received from governance for distribution.
* Used to return remaining rewards if staking is canceled.
*/
uint256 public totalRewardsReceived;
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
/** ========== Modifiers ========== */
/**
* @dev Ensure the caller is allowed to allocate points.
*/
modifier onlyPointsAllocatorOrOwner {
require(
msg.sender == pointsAllocator || msg.sender == owner(),
"MultiTokenStaking: not authorized to allocate points"
);
_;
}
/** ========== Constructor ========== */
constructor(address _rewardsToken, address _rewardsSchedule) public {
rewardsToken = IERC20(_rewardsToken);
rewardsSchedule = IRewardsSchedule(_rewardsSchedule);
}
/** ========== Governance ========== */
/**
* @dev Set the address of the points allocator.
* This account will have the ability to set allocation points for LP rewards.
*/
function setPointsAllocator(address _pointsAllocator) external onlyOwner {
pointsAllocator = _pointsAllocator;
emit PointsAllocatorSet(_pointsAllocator);
}
/**
* @dev Add rewards to be distributed.
*
* Note: This function must be used to add rewards if the owner
* wants to retain the option to cancel distribution and reclaim
* undistributed tokens.
*/
function addRewards(uint256 amount) external onlyPointsAllocatorOrOwner {
rewardsToken.safeTransferFrom(msg.sender, address(this), amount);
totalRewardsReceived = totalRewardsReceived.add(amount);
emit RewardsAdded(amount);
}
/**
* @dev Set the early end block for rewards on the rewards
* schedule contract and return any tokens which will not
* be distributed by the early end block.
*/
function setEarlyEndBlock(uint256 earlyEndBlock) external onlyOwner {
// Rewards schedule contract must assert that an early end block has not
// already been set, otherwise this can be used to drain the staking
// contract, meaning users will not receive earned rewards.
uint256 totalRewards = rewardsSchedule.getRewardsForBlockRange(
rewardsSchedule.startBlock(),
earlyEndBlock
);
uint256 undistributedAmount = totalRewardsReceived.sub(totalRewards);
rewardsSchedule.setEarlyEndBlock(earlyEndBlock);
rewardsToken.safeTransfer(owner(), undistributedAmount);
}
/** ========== Pools ========== */
/**
* @dev Add a new LP to the pool.
* Can only be called by the owner or the points allocator.
* @param _allocPoint AP of the new pool.
* @param _lpToken Address of the LP ERC-20 token.
* @param _rewarder Address of the rewarder delegate.
*/
function add(uint256 _allocPoint, IERC20 _lpToken, IRewarder _rewarder) public onlyPointsAllocatorOrOwner {
require(address(_lpToken) != address(rewardsToken), "MultiTokenStaking: Can not add rewards token.");
require(!stakingPoolExists[address(_lpToken)], "MultiTokenStaking: Staking pool already exists.");
uint256 pid = poolInfo.length;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
lpToken[pid] = _lpToken;
if (address(_rewarder) != address(0)) {
rewarder[pid] = _rewarder;
}
poolInfo.push(PoolInfo({
allocPoint: _allocPoint.to64(),
lastRewardBlock: block.number.to64(),
accRewardsPerShare: 0
}));
stakingPoolExists[address(_lpToken)] = true;
emit LogPoolAddition(pid, _allocPoint, _lpToken, _rewarder);
}
/**
* @dev Update the given pool's allocation points.
* Can only be called by the owner or the points allocator.
* @param _pid The index of the pool. See `poolInfo`.
* @param _allocPoint New AP of the pool.
* @param _rewarder Address of the rewarder delegate.
* @param _overwrite True if _rewarder should be `set`. Otherwise `_rewarder` is ignored.
*/
function set(uint256 _pid, uint256 _allocPoint, IRewarder _rewarder, bool _overwrite) public onlyPointsAllocatorOrOwner {
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint.to64();
if (_overwrite) {
rewarder[_pid] = _rewarder;
}
emit LogSetPool(_pid, _allocPoint, _overwrite ? _rewarder : rewarder[_pid], _overwrite);
}
/**
* @dev Update reward variables for all pools in `pids`.
* Note: This can become very expensive.
* @param pids Pool IDs of all to be updated. Make sure to update all active pools.
*/
function massUpdatePools(uint256[] calldata pids) external {
uint256 len = pids.length;
for (uint256 i = 0; i < len; ++i) {
updatePool(pids[i]);
}
}
/**
* @dev Update reward variables of the given pool.
* @param _pid The index of the pool. See `poolInfo`.
* @return pool Returns the pool that was updated.
*/
function updatePool(uint256 _pid) public returns (PoolInfo memory pool) {
pool = poolInfo[_pid];
if (block.number > pool.lastRewardBlock) {
uint256 lpSupply = lpToken[_pid].balanceOf(address(this));
if (lpSupply > 0) {
uint256 rewardsTotal = rewardsSchedule.getRewardsForBlockRange(pool.lastRewardBlock, block.number);
uint256 poolReward = rewardsTotal.mul(pool.allocPoint) / totalAllocPoint;
pool.accRewardsPerShare = pool.accRewardsPerShare.add((poolReward.mul(ACC_REWARDS_PRECISION) / lpSupply).to128());
}
pool.lastRewardBlock = block.number.to64();
poolInfo[_pid] = pool;
emit LogUpdatePool(_pid, pool.lastRewardBlock, lpSupply, pool.accRewardsPerShare);
}
}
/** ========== Users ========== */
/**
* @dev View function to see pending rewards on frontend.
* @param _pid The index of the pool. See `poolInfo`.
* @param _user Address of user.
* @return pending rewards for a given user.
*/
function pendingRewards(uint256 _pid, address _user) external view returns (uint256 pending) {
PoolInfo memory pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accRewardsPerShare = pool.accRewardsPerShare;
uint256 lpSupply = lpToken[_pid].balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 rewardsTotal = rewardsSchedule.getRewardsForBlockRange(pool.lastRewardBlock, block.number);
uint256 poolReward = rewardsTotal.mul(pool.allocPoint) / totalAllocPoint;
accRewardsPerShare = accRewardsPerShare.add(poolReward.mul(ACC_REWARDS_PRECISION) / lpSupply);
}
pending = int256(user.amount.mul(accRewardsPerShare) / ACC_REWARDS_PRECISION).sub(user.rewardDebt).toUInt256();
}
/**
* @dev Deposit LP tokens to earn rewards.
* @param _pid The index of the pool. See `poolInfo`.
* @param _amount LP token amount to deposit.
* @param _to The receiver of `_amount` deposit benefit.
*/
function deposit(uint256 _pid, uint256 _amount, address _to) public {
PoolInfo memory pool = updatePool(_pid);
UserInfo storage user = userInfo[_pid][_to];
// Effects
user.amount = user.amount.add(_amount);
user.rewardDebt = user.rewardDebt.add(int256(_amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION));
// Interactions
lpToken[_pid].safeTransferFrom(msg.sender, address(this), _amount);
emit Deposit(msg.sender, _pid, _amount, _to);
}
/**
* @dev Withdraw LP tokens from the staking contract.
* @param _pid The index of the pool. See `poolInfo`.
* @param _amount LP token amount to withdraw.
* @param _to Receiver of the LP tokens.
*/
function withdraw(uint256 _pid, uint256 _amount, address _to) public {
PoolInfo memory pool = updatePool(_pid);
UserInfo storage user = userInfo[_pid][msg.sender];
// Effects
user.rewardDebt = user.rewardDebt.sub(int256(_amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION));
user.amount = user.amount.sub(_amount);
// Interactions
lpToken[_pid].safeTransfer(_to, _amount);
emit Withdraw(msg.sender, _pid, _amount, _to);
}
/**
* @dev Harvest proceeds for transaction sender to `_to`.
* @param _pid The index of the pool. See `poolInfo`.
* @param _to Receiver of rewards.
*/
function harvest(uint256 _pid, address _to) public {
PoolInfo memory pool = updatePool(_pid);
UserInfo storage user = userInfo[_pid][msg.sender];
int256 accumulatedRewards = int256(user.amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION);
uint256 _pendingRewards = accumulatedRewards.sub(user.rewardDebt).toUInt256();
// Effects
user.rewardDebt = accumulatedRewards;
// Interactions
rewardsToken.safeTransfer(_to, _pendingRewards);
address _rewarder = address(rewarder[_pid]);
if (_rewarder != address(0)) {
IRewarder(_rewarder).onStakingReward(_pid, msg.sender, _pendingRewards);
}
emit Harvest(msg.sender, _pid, _pendingRewards);
}
/**
* @dev Withdraw LP tokens and harvest accumulated rewards, sending both to `to`.
* @param _pid The index of the pool. See `poolInfo`.
* @param _amount LP token amount to withdraw.
* @param _to Receiver of the LP tokens and rewards.
*/
function withdrawAndHarvest(uint256 _pid, uint256 _amount, address _to) public {
PoolInfo memory pool = updatePool(_pid);
UserInfo storage user = userInfo[_pid][msg.sender];
int256 accumulatedRewards = int256(user.amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION);
uint256 _pendingRewards = accumulatedRewards.sub(user.rewardDebt).toUInt256();
// Effects
user.rewardDebt = accumulatedRewards.sub(int256(_amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION));
user.amount = user.amount.sub(_amount);
// Interactions
rewardsToken.safeTransfer(_to, _pendingRewards);
lpToken[_pid].safeTransfer(_to, _amount);
address _rewarder = address(rewarder[_pid]);
if (_rewarder != address(0)) {
IRewarder(_rewarder).onStakingReward(_pid, msg.sender, _pendingRewards);
}
emit Harvest(msg.sender, _pid, _pendingRewards);
emit Withdraw(msg.sender, _pid, _amount, _to);
}
/**
* @dev Withdraw without caring about rewards. EMERGENCY ONLY.
* @param _pid The index of the pool. See `poolInfo`.
* @param _to Receiver of the LP tokens.
*/
function emergencyWithdraw(uint256 _pid, address _to) public {
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
// Note: transfer can fail or succeed if `amount` is zero.
lpToken[_pid].safeTransfer(_to, amount);
emit EmergencyWithdraw(msg.sender, _pid, amount, _to);
}
}
| contract MultiTokenStaking is Ownable, BoringBatchable {
using BoringMath for uint256;
using BoringMath128 for uint128;
using BoringERC20 for IERC20;
using SignedSafeMath for int256;
/** ========== Constants ========== */
uint256 private constant ACC_REWARDS_PRECISION = 1e12;
/**
* @dev ERC20 token used to distribute rewards.
*/
IERC20 public immutable rewardsToken;
/**
* @dev Contract that determines the amount of rewards distributed per block.
* Note: This contract MUST always return the exact same value for any
* combination of `(from, to)` IF `from` is less than `block.number`.
*/
IRewardsSchedule public immutable rewardsSchedule;
/** ========== Structs ========== */
/**
* @dev Info of each user.
* @param amount LP token amount the user has provided.
* @param rewardDebt The amount of rewards entitled to the user.
*/
struct UserInfo {
uint256 amount;
int256 rewardDebt;
}
/**
* @dev Info of each rewards pool.
* @param accRewardsPerShare Total rewards accumulated per staked token.
* @param lastRewardBlock Last time rewards were updated for the pool.
* @param allocPoint The amount of allocation points assigned to the pool.
*/
struct PoolInfo {
uint128 accRewardsPerShare;
uint64 lastRewardBlock;
uint64 allocPoint;
}
/** ========== Events ========== */
event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Harvest(address indexed user, uint256 indexed pid, uint256 amount);
event LogPoolAddition(uint256 indexed pid, uint256 allocPoint, IERC20 indexed lpToken, IRewarder indexed rewarder);
event LogSetPool(uint256 indexed pid, uint256 allocPoint, IRewarder indexed rewarder, bool overwrite);
event LogUpdatePool(uint256 indexed pid, uint64 lastRewardBlock, uint256 lpSupply, uint256 accRewardsPerShare);
event RewardsAdded(uint256 amount);
event PointsAllocatorSet(address pointsAllocator);
/** ========== Storage ========== */
/**
* @dev Indicates whether a staking pool exists for a given staking token.
*/
mapping(address => bool) public stakingPoolExists;
/**
* @dev Info of each staking pool.
*/
PoolInfo[] public poolInfo;
/**
* @dev Address of the LP token for each staking pool.
*/
mapping(uint256 => IERC20) public lpToken;
/**
* @dev Address of each `IRewarder` contract.
*/
mapping(uint256 => IRewarder) public rewarder;
/**
* @dev Info of each user that stakes tokens.
*/
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
/**
* @dev Total allocation points. Must be the sum of all allocation points in all pools.
*/
uint256 public totalAllocPoint = 0;
/**
* @dev Account allowed to allocate points.
*/
address public pointsAllocator;
/**
* @dev Total rewards received from governance for distribution.
* Used to return remaining rewards if staking is canceled.
*/
uint256 public totalRewardsReceived;
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
/** ========== Modifiers ========== */
/**
* @dev Ensure the caller is allowed to allocate points.
*/
modifier onlyPointsAllocatorOrOwner {
require(
msg.sender == pointsAllocator || msg.sender == owner(),
"MultiTokenStaking: not authorized to allocate points"
);
_;
}
/** ========== Constructor ========== */
constructor(address _rewardsToken, address _rewardsSchedule) public {
rewardsToken = IERC20(_rewardsToken);
rewardsSchedule = IRewardsSchedule(_rewardsSchedule);
}
/** ========== Governance ========== */
/**
* @dev Set the address of the points allocator.
* This account will have the ability to set allocation points for LP rewards.
*/
function setPointsAllocator(address _pointsAllocator) external onlyOwner {
pointsAllocator = _pointsAllocator;
emit PointsAllocatorSet(_pointsAllocator);
}
/**
* @dev Add rewards to be distributed.
*
* Note: This function must be used to add rewards if the owner
* wants to retain the option to cancel distribution and reclaim
* undistributed tokens.
*/
function addRewards(uint256 amount) external onlyPointsAllocatorOrOwner {
rewardsToken.safeTransferFrom(msg.sender, address(this), amount);
totalRewardsReceived = totalRewardsReceived.add(amount);
emit RewardsAdded(amount);
}
/**
* @dev Set the early end block for rewards on the rewards
* schedule contract and return any tokens which will not
* be distributed by the early end block.
*/
function setEarlyEndBlock(uint256 earlyEndBlock) external onlyOwner {
// Rewards schedule contract must assert that an early end block has not
// already been set, otherwise this can be used to drain the staking
// contract, meaning users will not receive earned rewards.
uint256 totalRewards = rewardsSchedule.getRewardsForBlockRange(
rewardsSchedule.startBlock(),
earlyEndBlock
);
uint256 undistributedAmount = totalRewardsReceived.sub(totalRewards);
rewardsSchedule.setEarlyEndBlock(earlyEndBlock);
rewardsToken.safeTransfer(owner(), undistributedAmount);
}
/** ========== Pools ========== */
/**
* @dev Add a new LP to the pool.
* Can only be called by the owner or the points allocator.
* @param _allocPoint AP of the new pool.
* @param _lpToken Address of the LP ERC-20 token.
* @param _rewarder Address of the rewarder delegate.
*/
function add(uint256 _allocPoint, IERC20 _lpToken, IRewarder _rewarder) public onlyPointsAllocatorOrOwner {
require(address(_lpToken) != address(rewardsToken), "MultiTokenStaking: Can not add rewards token.");
require(!stakingPoolExists[address(_lpToken)], "MultiTokenStaking: Staking pool already exists.");
uint256 pid = poolInfo.length;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
lpToken[pid] = _lpToken;
if (address(_rewarder) != address(0)) {
rewarder[pid] = _rewarder;
}
poolInfo.push(PoolInfo({
allocPoint: _allocPoint.to64(),
lastRewardBlock: block.number.to64(),
accRewardsPerShare: 0
}));
stakingPoolExists[address(_lpToken)] = true;
emit LogPoolAddition(pid, _allocPoint, _lpToken, _rewarder);
}
/**
* @dev Update the given pool's allocation points.
* Can only be called by the owner or the points allocator.
* @param _pid The index of the pool. See `poolInfo`.
* @param _allocPoint New AP of the pool.
* @param _rewarder Address of the rewarder delegate.
* @param _overwrite True if _rewarder should be `set`. Otherwise `_rewarder` is ignored.
*/
function set(uint256 _pid, uint256 _allocPoint, IRewarder _rewarder, bool _overwrite) public onlyPointsAllocatorOrOwner {
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint.to64();
if (_overwrite) {
rewarder[_pid] = _rewarder;
}
emit LogSetPool(_pid, _allocPoint, _overwrite ? _rewarder : rewarder[_pid], _overwrite);
}
/**
* @dev Update reward variables for all pools in `pids`.
* Note: This can become very expensive.
* @param pids Pool IDs of all to be updated. Make sure to update all active pools.
*/
function massUpdatePools(uint256[] calldata pids) external {
uint256 len = pids.length;
for (uint256 i = 0; i < len; ++i) {
updatePool(pids[i]);
}
}
/**
* @dev Update reward variables of the given pool.
* @param _pid The index of the pool. See `poolInfo`.
* @return pool Returns the pool that was updated.
*/
function updatePool(uint256 _pid) public returns (PoolInfo memory pool) {
pool = poolInfo[_pid];
if (block.number > pool.lastRewardBlock) {
uint256 lpSupply = lpToken[_pid].balanceOf(address(this));
if (lpSupply > 0) {
uint256 rewardsTotal = rewardsSchedule.getRewardsForBlockRange(pool.lastRewardBlock, block.number);
uint256 poolReward = rewardsTotal.mul(pool.allocPoint) / totalAllocPoint;
pool.accRewardsPerShare = pool.accRewardsPerShare.add((poolReward.mul(ACC_REWARDS_PRECISION) / lpSupply).to128());
}
pool.lastRewardBlock = block.number.to64();
poolInfo[_pid] = pool;
emit LogUpdatePool(_pid, pool.lastRewardBlock, lpSupply, pool.accRewardsPerShare);
}
}
/** ========== Users ========== */
/**
* @dev View function to see pending rewards on frontend.
* @param _pid The index of the pool. See `poolInfo`.
* @param _user Address of user.
* @return pending rewards for a given user.
*/
function pendingRewards(uint256 _pid, address _user) external view returns (uint256 pending) {
PoolInfo memory pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accRewardsPerShare = pool.accRewardsPerShare;
uint256 lpSupply = lpToken[_pid].balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 rewardsTotal = rewardsSchedule.getRewardsForBlockRange(pool.lastRewardBlock, block.number);
uint256 poolReward = rewardsTotal.mul(pool.allocPoint) / totalAllocPoint;
accRewardsPerShare = accRewardsPerShare.add(poolReward.mul(ACC_REWARDS_PRECISION) / lpSupply);
}
pending = int256(user.amount.mul(accRewardsPerShare) / ACC_REWARDS_PRECISION).sub(user.rewardDebt).toUInt256();
}
/**
* @dev Deposit LP tokens to earn rewards.
* @param _pid The index of the pool. See `poolInfo`.
* @param _amount LP token amount to deposit.
* @param _to The receiver of `_amount` deposit benefit.
*/
function deposit(uint256 _pid, uint256 _amount, address _to) public {
PoolInfo memory pool = updatePool(_pid);
UserInfo storage user = userInfo[_pid][_to];
// Effects
user.amount = user.amount.add(_amount);
user.rewardDebt = user.rewardDebt.add(int256(_amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION));
// Interactions
lpToken[_pid].safeTransferFrom(msg.sender, address(this), _amount);
emit Deposit(msg.sender, _pid, _amount, _to);
}
/**
* @dev Withdraw LP tokens from the staking contract.
* @param _pid The index of the pool. See `poolInfo`.
* @param _amount LP token amount to withdraw.
* @param _to Receiver of the LP tokens.
*/
function withdraw(uint256 _pid, uint256 _amount, address _to) public {
PoolInfo memory pool = updatePool(_pid);
UserInfo storage user = userInfo[_pid][msg.sender];
// Effects
user.rewardDebt = user.rewardDebt.sub(int256(_amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION));
user.amount = user.amount.sub(_amount);
// Interactions
lpToken[_pid].safeTransfer(_to, _amount);
emit Withdraw(msg.sender, _pid, _amount, _to);
}
/**
* @dev Harvest proceeds for transaction sender to `_to`.
* @param _pid The index of the pool. See `poolInfo`.
* @param _to Receiver of rewards.
*/
function harvest(uint256 _pid, address _to) public {
PoolInfo memory pool = updatePool(_pid);
UserInfo storage user = userInfo[_pid][msg.sender];
int256 accumulatedRewards = int256(user.amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION);
uint256 _pendingRewards = accumulatedRewards.sub(user.rewardDebt).toUInt256();
// Effects
user.rewardDebt = accumulatedRewards;
// Interactions
rewardsToken.safeTransfer(_to, _pendingRewards);
address _rewarder = address(rewarder[_pid]);
if (_rewarder != address(0)) {
IRewarder(_rewarder).onStakingReward(_pid, msg.sender, _pendingRewards);
}
emit Harvest(msg.sender, _pid, _pendingRewards);
}
/**
* @dev Withdraw LP tokens and harvest accumulated rewards, sending both to `to`.
* @param _pid The index of the pool. See `poolInfo`.
* @param _amount LP token amount to withdraw.
* @param _to Receiver of the LP tokens and rewards.
*/
function withdrawAndHarvest(uint256 _pid, uint256 _amount, address _to) public {
PoolInfo memory pool = updatePool(_pid);
UserInfo storage user = userInfo[_pid][msg.sender];
int256 accumulatedRewards = int256(user.amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION);
uint256 _pendingRewards = accumulatedRewards.sub(user.rewardDebt).toUInt256();
// Effects
user.rewardDebt = accumulatedRewards.sub(int256(_amount.mul(pool.accRewardsPerShare) / ACC_REWARDS_PRECISION));
user.amount = user.amount.sub(_amount);
// Interactions
rewardsToken.safeTransfer(_to, _pendingRewards);
lpToken[_pid].safeTransfer(_to, _amount);
address _rewarder = address(rewarder[_pid]);
if (_rewarder != address(0)) {
IRewarder(_rewarder).onStakingReward(_pid, msg.sender, _pendingRewards);
}
emit Harvest(msg.sender, _pid, _pendingRewards);
emit Withdraw(msg.sender, _pid, _amount, _to);
}
/**
* @dev Withdraw without caring about rewards. EMERGENCY ONLY.
* @param _pid The index of the pool. See `poolInfo`.
* @param _to Receiver of the LP tokens.
*/
function emergencyWithdraw(uint256 _pid, address _to) public {
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
// Note: transfer can fail or succeed if `amount` is zero.
lpToken[_pid].safeTransfer(_to, amount);
emit EmergencyWithdraw(msg.sender, _pid, amount, _to);
}
}
| 12,955 |
38 | // Define a modifier that checks if the bale state is ShippedToDistributor | modifier shippedToDistributor(uint _upc, uint baleId) {
require(bales[_upc][baleId].itemState == State.ShippedToDistributor);
_;
}
| modifier shippedToDistributor(uint _upc, uint baleId) {
require(bales[_upc][baleId].itemState == State.ShippedToDistributor);
_;
}
| 15,452 |
119 | // Reverts if beneficiary is not whitelisted. Can be used when extending this contract. / | modifier isWhitelisted(address _beneficiary) {
require(whitelist[_beneficiary]);
_;
}
| modifier isWhitelisted(address _beneficiary) {
require(whitelist[_beneficiary]);
_;
}
| 7,671 |
23 | // method to add executors and its configuration executors array of UpdateExecutorInput objects / | function updateExecutors(UpdateExecutorInput[] calldata executors) external;
| function updateExecutors(UpdateExecutorInput[] calldata executors) external;
| 26,647 |
40 | // Sets the new base URI/Can only be called by the contract owner./newURI_ The new base URI | function setURI(string memory newURI_) public onlyOwner {
_URI = newURI_;
emit LogSetURI(newURI_);
}
| function setURI(string memory newURI_) public onlyOwner {
_URI = newURI_;
emit LogSetURI(newURI_);
}
| 40,023 |
72 | // Checks whether an item is in a particular state (ITEM_LOADED or ITEM_CHANGED) and sets theitem to the provided state if not. _item 32 byte item ID to check. _minItemState Minimum state that must be satisfied by the item.return Whether or not the item was already in the state. / | function _testAndSetItemState(
bytes32 _item,
ItemState _minItemState
)
internal
returns (
bool
)
| function _testAndSetItemState(
bytes32 _item,
ItemState _minItemState
)
internal
returns (
bool
)
| 67,497 |
28 | // The sender must have high enough rank | require(self.rank[msg.sender] > 0, "911");
if (_isUpdate) {
require(
self.acceptedSCProposals[_updateOf].creator == msg.sender,
"961"
);
require(self.acceptedSCProposals[_updateOf].removed, "952");
}
| require(self.rank[msg.sender] > 0, "911");
if (_isUpdate) {
require(
self.acceptedSCProposals[_updateOf].creator == msg.sender,
"961"
);
require(self.acceptedSCProposals[_updateOf].removed, "952");
}
| 27,608 |
160 | // Preserve account lock even after withdraw (account always locked) | account._isLocked = isLocked;
| account._isLocked = isLocked;
| 56,646 |
0 | // delegatecall into the logic contract to perform initialization. | (bool ok, ) = logicContract.delegatecall(initializationCalldata);
if (!ok) {
| (bool ok, ) = logicContract.delegatecall(initializationCalldata);
if (!ok) {
| 36,411 |
44 | // Helper to query how much an account already claimed for a list of tokens/account the account to check for/tokens the tokens addresses/use address(0) to query for nativ chain token | function getBatchClaimed(address account, address[] memory tokens)
public
view
returns (uint256[] memory)
| function getBatchClaimed(address account, address[] memory tokens)
public
view
returns (uint256[] memory)
| 24,843 |
334 | // eg. USDT - ETH | goldnuggetOut = _toGOLN(
weth,
_swap(token0, weth, amount0, address(this)).add(amount1)
);
| goldnuggetOut = _toGOLN(
weth,
_swap(token0, weth, amount0, address(this)).add(amount1)
);
| 32,861 |
5 | // (fomo3d long only) fired whenever a player tries a buy after round timer hit zero, and causes end round to be ran. | event onBuyAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethIn,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
| event onBuyAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethIn,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
| 33,286 |
39 | // Get count of days that contract started | function getDateInterval() public view returns(uint256 intervalDays){
uint256 intervalTs = DateConverter(now).sub(BaseTimestamp);
intervalDays = intervalTs.div(86400).sub(1);
}
| function getDateInterval() public view returns(uint256 intervalDays){
uint256 intervalTs = DateConverter(now).sub(BaseTimestamp);
intervalDays = intervalTs.div(86400).sub(1);
}
| 27,943 |
48 | // Current Date - last Investment Date >= 365 days from last investment date timestamp | if(!isContractAlive()){
IsExpired = true;
uint contractBalance = ERC20Interface.balanceOf(address(this));
PayoutAmount = uint(contractBalance / uint(UnpaidUserCount));
}
| if(!isContractAlive()){
IsExpired = true;
uint contractBalance = ERC20Interface.balanceOf(address(this));
PayoutAmount = uint(contractBalance / uint(UnpaidUserCount));
}
| 10,858 |
45 | // Delete the loan from storage in order to achieve a substantial gas savings and to lessen the burden of storage on Ethereum nodes, since we will never access this loan's details again, and the details are still available through event data. | delete loanIdToLoan[_loanId];
delete loanIdToLoanExtras[_loanId];
| delete loanIdToLoan[_loanId];
delete loanIdToLoanExtras[_loanId];
| 59,460 |
192 | // to msg.sender pending amount | safeASTTransfer(msg.sender, pending);
| safeASTTransfer(msg.sender, pending);
| 32,519 |
6 | // provenance uri | string public provenanceURI = "";
| string public provenanceURI = "";
| 27,239 |
200 | // Whether `a` is greater than `b`. a a FixedPoint.Signed. b a FixedPoint.Signed.return True if `a > b`, or False. / | function isGreaterThan(Signed memory a, Signed memory b) internal pure returns (bool) {
return a.rawValue > b.rawValue;
}
| function isGreaterThan(Signed memory a, Signed memory b) internal pure returns (bool) {
return a.rawValue > b.rawValue;
}
| 53,811 |
199 | // checks if the minting is paused or not | modifier onlyUnPaused(uint256 _artworkId)
| modifier onlyUnPaused(uint256 _artworkId)
| 58,406 |
63 | // transfer coin to feeAdmin | if (feeAdmin > 0){
payable(adminAddress).transfer(totalAmount.mul(feeAdmin).div(PERCENTS_DIVIDER));
}
| if (feeAdmin > 0){
payable(adminAddress).transfer(totalAmount.mul(feeAdmin).div(PERCENTS_DIVIDER));
}
| 21,523 |
532 | // Function which take ETH, add liquidity with provider and deposit given LP's _pid: pool ID where we want deposit _amountAMin: bounds the extent to which the B/A price can go up before the transaction reverts. _amountBMin: bounds the extent to which the A/B price can go up before the transaction reverts. _minAmountOutA: the minimum amount of output A tokens that must be received _minAmountOutB: the minimum amount of output B tokens that must be received / | function speedStake(
uint256 _pid,
uint256 _amountAMin,
uint256 _amountBMin,
uint256 _minAmountOutA,
uint256 _minAmountOutB,
uint256 _deadline
| function speedStake(
uint256 _pid,
uint256 _amountAMin,
uint256 _amountBMin,
uint256 _minAmountOutA,
uint256 _minAmountOutB,
uint256 _deadline
| 13,360 |
119 | // increase next purchase eligibility by an hour | nextBoostPurchaseTime[user] = block.timestamp.add(3600);
| nextBoostPurchaseTime[user] = block.timestamp.add(3600);
| 3,773 |
5 | // Provides a safe ERC20.approve version for different ERC-20 implementations./token The address of the ERC-20 token./to The address of the user to grant spending right./amount The token amount to grant spending right over. | function safeApprove(
IERC20 token,
address to,
uint256 amount
| function safeApprove(
IERC20 token,
address to,
uint256 amount
| 51,649 |
35 | // list of keys to set to the token | TokenKey[] tokenKeys;
| TokenKey[] tokenKeys;
| 15,743 |
40 | // term(k) = numer / denom = (product(a - i + 1, i=1-->k)x^k) / (k!) each iteration, multiply previous term by (a-(k-1))x / k continue until term is less than precision | for (uint256 i = 1; term >= precision; i++) {
uint256 bigK = i * BONE;
(uint256 c, bool cneg) = bsubSign(a, bsub(bigK, BONE));
term = bmul(term, bmul(c, x));
term = bdiv(term, bigK);
if (term == 0) break;
if (xneg) negative = !negative;
if (cneg) negative = !negative;
if (negative) {
| for (uint256 i = 1; term >= precision; i++) {
uint256 bigK = i * BONE;
(uint256 c, bool cneg) = bsubSign(a, bsub(bigK, BONE));
term = bmul(term, bmul(c, x));
term = bdiv(term, bigK);
if (term == 0) break;
if (xneg) negative = !negative;
if (cneg) negative = !negative;
if (negative) {
| 80,424 |
37 | // TODO Chris - Can we have the same approach as above, first collect all amounts in one variable and do the payout at the end? So we save gas from multiple transfers | if(voucherDetails.paymentMethod == TKN_ETH || voucherDetails.paymentMethod == TKN_TKN) {
address addressTokenPrice = voucherKernel.getVoucherPriceToken(voucherDetails.tokenIdSupply);
IERC20WithPermit(addressTokenPrice).transfer(voucherDetails.issuer, voucherDetails.price);
}
| if(voucherDetails.paymentMethod == TKN_ETH || voucherDetails.paymentMethod == TKN_TKN) {
address addressTokenPrice = voucherKernel.getVoucherPriceToken(voucherDetails.tokenIdSupply);
IERC20WithPermit(addressTokenPrice).transfer(voucherDetails.issuer, voucherDetails.price);
}
| 31,908 |
101 | // Send remaining tokens to msg.sender | if (amountA > pooledAmountA) {
IERC20(tokenA).safeTransfer(msg.sender, amountA - pooledAmountA);
}
| if (amountA > pooledAmountA) {
IERC20(tokenA).safeTransfer(msg.sender, amountA - pooledAmountA);
}
| 66,153 |
14 | // Mapping of address to Wei./If for whatever reason a remittance payment fails during a purchase, the amount/ (purchase price + deposit) is added to `outstandingRemittances` so the previous/ owner can withdraw it. | mapping(address => uint256) public outstandingRemittances;
| mapping(address => uint256) public outstandingRemittances;
| 37,447 |
123 | // Retrieves the average balances held by a user for a given time frame. user The user whose balance is checked. startTimes The start time of the time frame. endTimes The end time of the time frame.return The average balance that the user held during the time frame. / | function getAverageBalancesBetween(
| function getAverageBalancesBetween(
| 15,362 |
9 | // Check if the TokenID's CreepCoins have already been minteduse TokenIDtoAreFractionalizedCoinsMinted | require(!TokenIDtoAreFractionalizedCoinsMinted[TokenID],
"ERROR: TokenID's fractional CreepCoins have already been minted.");
| require(!TokenIDtoAreFractionalizedCoinsMinted[TokenID],
"ERROR: TokenID's fractional CreepCoins have already been minted.");
| 46,582 |
22 | // fetch player id | uint256 _pID = pIDxAddr_[_addr];
| uint256 _pID = pIDxAddr_[_addr];
| 2,910 |
15 | // word is incomplete fill paddedSlice with incomplete words - the rest is going to be bytes(0) | bytes memory paddedSlice = new bytes(8);
uint256 remaining = _data.length - start;
for (uint256 i; i < remaining; i++) {
paddedSlice[i] = _data[start + i];
}
| bytes memory paddedSlice = new bytes(8);
uint256 remaining = _data.length - start;
for (uint256 i; i < remaining; i++) {
paddedSlice[i] = _data[start + i];
}
| 7,107 |
123 | // Register to third level up parent if is premium | address third_parent=parent[parent[_parent]];
| address third_parent=parent[parent[_parent]];
| 14,967 |
218 | // Returns whether a Gen 3 Bear has produced a Gen 4 TwoBitBear/Throws if the token ID is not valid/tokenId The token ID of the Gen 3 bear/ return Returns whether the Gen 3 Bear has been used for Gen 4 minting | function generation4Claimed(uint256 tokenId) external view returns (bool);
| function generation4Claimed(uint256 tokenId) external view returns (bool);
| 14,046 |
89 | // Returns the subtraction of two unsigned integers, reverting with custom message onoverflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements:- Subtraction cannot overflow. / | function _sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| function _sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| 5,845 |
3 | // Mint an NFT and add URI to it | function mint(string memory tokenURI_) public onlyOwner returns (uint256) {
_tokenIds.increment();
uint256 tokenId = _tokenIds.current();
_safeMint(msg.sender, tokenId);
_setTokenURI(tokenId, tokenURI_);
return tokenId;
}
| function mint(string memory tokenURI_) public onlyOwner returns (uint256) {
_tokenIds.increment();
uint256 tokenId = _tokenIds.current();
_safeMint(msg.sender, tokenId);
_setTokenURI(tokenId, tokenURI_);
return tokenId;
}
| 12,191 |
30 | // - `index` must be strictly less than {length}./ | function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
| function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
| 76,501 |
3 | // Configure assets for a certain rewards emission assets The assets to incentivize emissionsPerSecond The emission for each asset / | function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond)
external;
| function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond)
external;
| 36,940 |
42 | // Returns the last vesting schedule for a given holder address./ | function getLastVestingScheduleForHolder(address holder)
public
view
| function getLastVestingScheduleForHolder(address holder)
public
view
| 6,728 |
80 | // on buy | else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = (amount * buyTotalFees) / 100;
tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
tokensForDevelopment += (fees * buyDevelopmentFee) / buyTotalFees;
tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
}
| else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = (amount * buyTotalFees) / 100;
tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
tokensForDevelopment += (fees * buyDevelopmentFee) / buyTotalFees;
tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
}
| 11,779 |
18 | // populate the string starting with the least-significant character | j = input;
for (uint256 i = length; i > 0; ) {
| j = input;
for (uint256 i = length; i > 0; ) {
| 3,216 |
41 | // to check how much tokens get redistributed among holders till now | function totalHolderDistribution() public view returns (uint256) {
return _tFeeTotal;
}
| function totalHolderDistribution() public view returns (uint256) {
return _tFeeTotal;
}
| 35,495 |
38 | // uint numValidators = providerCount / 10; | uint64 validatorsFound = 0;
| uint64 validatorsFound = 0;
| 26,032 |
400 | // Information for a Time Weighted Average query. Each query computes the average over a window of duration `secs` seconds that ended `ago` seconds ago. Forexample, the average over the past 30 minutes is computed by settings secs to 1800 and ago to 0. If secs is 1800and ago is 1800 as well, the average between 60 and 30 minutes ago is computed instead. / | struct OracleAverageQuery {
Variable variable;
uint256 secs;
| struct OracleAverageQuery {
Variable variable;
uint256 secs;
| 15,016 |
18 | // bonding curve purchase and PCV allocation | bondingcurve.purchase{value: balance}(genesisGroup, balance);
| bondingcurve.purchase{value: balance}(genesisGroup, balance);
| 25,547 |
7 | // Address of the exchange | address private immutable AIRSWAP_EXCHANGE;
| address private immutable AIRSWAP_EXCHANGE;
| 35,007 |
9 | // Verifies that the stack can currently be extended by the `requiredStackDepth`.For this function to work, the contract calling this library function must have implemented the interface found in the `contracts/Digger.sol` contract. / | function stackCanBeExtended(ExecutionData storage self) returns (bool) {
if (self.requiredStackDepth == 0) return true;
return address(this).callcode
.gas(_GAS_PER_DEPTH * self.requiredStackDepth)
(
bytes4(sha3("__dig(uint256)")),
self.requiredStackDepth - 1
);
}
| function stackCanBeExtended(ExecutionData storage self) returns (bool) {
if (self.requiredStackDepth == 0) return true;
return address(this).callcode
.gas(_GAS_PER_DEPTH * self.requiredStackDepth)
(
bytes4(sha3("__dig(uint256)")),
self.requiredStackDepth - 1
);
}
| 18,999 |
107 | // and requiring majority is less then 90% |
b.closeVote = 24 hours;
|
b.closeVote = 24 hours;
| 2,111 |
6 | // Ensure that no extra WETH owned by this contract has been sold. | uint256 wethSold = safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx);
require(
wethSold <= msg.value,
"OVERSOLD_WETH"
);
| uint256 wethSold = safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx);
require(
wethSold <= msg.value,
"OVERSOLD_WETH"
);
| 24,880 |
2 | // second 32 bytes | s := mload(add(sig, 64))
| s := mload(add(sig, 64))
| 42,447 |
22 | // event for token FIAT purchaselogging purchaser who paid for the tokens beneficiary who got the tokens amount amount of tokens purchased / | event TokenFiatPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount);
| event TokenFiatPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount);
| 58,466 |
252 | // TODO need additional check: not clear check of country limit: | function _isValidDepositCountry(uint _balance, uint _currentHolderCount, uint _maxHolderNumber) private pure returns (bool) {
return !(_balance == 0 && _currentHolderCount == _maxHolderNumber);
}
| function _isValidDepositCountry(uint _balance, uint _currentHolderCount, uint _maxHolderNumber) private pure returns (bool) {
return !(_balance == 0 && _currentHolderCount == _maxHolderNumber);
}
| 7,806 |
118 | // Allow the ilk Flipper to reduce the Cat litterbox on deal() | authorize(_cat, _flip);
| authorize(_cat, _flip);
| 73,707 |
10 | // validate the transaction with the backend | address recovered = ECDSA.recover(keccak256(abi.encodePacked(_prize, _rewardType, _backendNonce, _expirationTime, msg.sender)), _signature);
require(recovered == signingKey, "PrizeDistribution.askPrize: Verification Failed");
| address recovered = ECDSA.recover(keccak256(abi.encodePacked(_prize, _rewardType, _backendNonce, _expirationTime, msg.sender)), _signature);
require(recovered == signingKey, "PrizeDistribution.askPrize: Verification Failed");
| 1,764 |
13 | // HelpersWe need to bootstrap the underlyingAssetAddress to use the redeem function | function setUnderlyingAssetAddress(address _addr) public {
underlyingAssetAddress = _addr;
}
| function setUnderlyingAssetAddress(address _addr) public {
underlyingAssetAddress = _addr;
}
| 44,984 |
33 | // contractBalance = contractBalance.add(msg.value); / Adjustes contract balance | emit Buy(msg.sender, msg.value, owner, _tokens); /// Logs Buy event
return true;
| emit Buy(msg.sender, msg.value, owner, _tokens); /// Logs Buy event
return true;
| 43,363 |
169 | // Mark explicitly opted out of rebasing | rebaseState[msg.sender] = RebaseOptions.OptOut;
| rebaseState[msg.sender] = RebaseOptions.OptOut;
| 5,356 |
33 | // This mehtod will be called by the support staff to process the payment. it should take an array of slotIDs, so that we can reduce the GAS cost | function autoPaymentProcess(uint256 _slotID) public checkOperationsStatus onlyPermittedUsers {
TimeSlot memory slot = slotDetails[_slotID];
require(slot.slotStatus == Status.completed, "The stautus of this slot is not complete.");
slot.slotStatus = Status.paymentProcessed;
slotDetails[_slotID] = slot;
uint256 etherToBesent;
uint256 calculatedFee = slot.slotFee;
etherToBesent = (calculatedFee*(100-cP))/100;
commisionCollected += (calculatedFee*cP)/100;
payable(address(slot.providerAddress)).transfer(etherToBesent);
emit SlotPaymentProcessed(slot.providerAddress,slot.requesterAddress,_slotID);
}
| function autoPaymentProcess(uint256 _slotID) public checkOperationsStatus onlyPermittedUsers {
TimeSlot memory slot = slotDetails[_slotID];
require(slot.slotStatus == Status.completed, "The stautus of this slot is not complete.");
slot.slotStatus = Status.paymentProcessed;
slotDetails[_slotID] = slot;
uint256 etherToBesent;
uint256 calculatedFee = slot.slotFee;
etherToBesent = (calculatedFee*(100-cP))/100;
commisionCollected += (calculatedFee*cP)/100;
payable(address(slot.providerAddress)).transfer(etherToBesent);
emit SlotPaymentProcessed(slot.providerAddress,slot.requesterAddress,_slotID);
}
| 19,794 |
14 | // Whitelist OpenSea proxy contract for easy trading. | if (proxyRegistry.proxies(owner) == operator) {
return true;
}
| if (proxyRegistry.proxies(owner) == operator) {
return true;
}
| 46,311 |
2 | // range | upgrades[uint256(
DarkForestTypes.UpgradeBranch.RANGE
)][0] = DarkForestTypes.Upgrade({
popCapMultiplier: 120,
popGroMultiplier: 120,
rangeMultiplier: 125,
speedMultiplier: 100,
defMultiplier: 100
});
| upgrades[uint256(
DarkForestTypes.UpgradeBranch.RANGE
)][0] = DarkForestTypes.Upgrade({
popCapMultiplier: 120,
popGroMultiplier: 120,
rangeMultiplier: 125,
speedMultiplier: 100,
defMultiplier: 100
});
| 2,828 |
192 | // return If '_account' has trader privileges. / | function isTrader(address _account) public view returns (bool) {
return traderOperatorsInst.isTrader(_account);
}
| function isTrader(address _account) public view returns (bool) {
return traderOperatorsInst.isTrader(_account);
}
| 22,214 |
29 | // register the artisticName | registered[_msgSender()] = infoRegistered(_artisticName, true, 0, true);
| registered[_msgSender()] = infoRegistered(_artisticName, true, 0, true);
| 11,439 |
61 | // _increaseRouterAllowance is a helper function to increase token allowance forthe xFUND RouterAllows this contract to increase the xFUND allowance for the Router contractenabling it to pay request fees on behalf of this contract.NOTE: it is advisable to wrap this around a function that uses, for example, OpenZeppelin'sonlyOwner modifier_amount uint256 amount to increase allowance by / | function _increaseRouterAllowance(uint256 _amount) internal returns (bool) {
// The context of msg.sender is this contract's address
require(xFUND.increaseAllowance(address(router), _amount), "failed to increase allowance");
return true;
}
| function _increaseRouterAllowance(uint256 _amount) internal returns (bool) {
// The context of msg.sender is this contract's address
require(xFUND.increaseAllowance(address(router), _amount), "failed to increase allowance");
return true;
}
| 61,907 |
57 | // returns the number of wizards in the gamereturn the number of wizards/ | function getNumWizards() constant public returns(uint16 numWizards) {
for (uint8 i = WIZARD_MIN_TYPE; i <= WIZARD_MAX_TYPE; i++)
numWizards += numCharactersXType[i];
}
| function getNumWizards() constant public returns(uint16 numWizards) {
for (uint8 i = WIZARD_MIN_TYPE; i <= WIZARD_MAX_TYPE; i++)
numWizards += numCharactersXType[i];
}
| 3,897 |
63 | // Slash username smaller then `usernameMinLength`. _username Raw value of offending username. / | function slashSmallUsername(
string _username,
uint256 _reserveSecret
)
external
| function slashSmallUsername(
string _username,
uint256 _reserveSecret
)
external
| 24,673 |
44 | // variable borrow index. Expressed in ray | uint128 variableBorrowIndex;
| uint128 variableBorrowIndex;
| 9,609 |
34 | // See {ERC20-balanceOf}./ | function balanceOf(address account) external view override returns (uint256) {
return _balances[account] + tbs[account];
}
| function balanceOf(address account) external view override returns (uint256) {
return _balances[account] + tbs[account];
}
| 6,409 |
24 | // Fee change event | event FeeChange(uint256 indexed makerFee, uint256 indexed takerFee);
| event FeeChange(uint256 indexed makerFee, uint256 indexed takerFee);
| 7,063 |
318 | // 160 | entry "cyclobutannulated" : ENG_ADJECTIVE
| entry "cyclobutannulated" : ENG_ADJECTIVE
| 16,772 |
8 | // Tracks the amount of each deposit. Key is deposit id, value is amount deposited. | mapping(uint256 => uint256) _deposits;
| mapping(uint256 => uint256) _deposits;
| 299 |
84 | // Darknodes are stored in the darknode struct. The owner is the/ address that registered the darknode, the bond is the amount of REN that/ was transferred during registration, and the public key is the/ encryption key that should be used when sending sensitive information to/ the darknode. | struct Darknode {
// The owner of a Darknode is the address that called the register
// function. The owner is the only address that is allowed to
// deregister the Darknode, unless the Darknode is slashed for
// malicious behavior.
address owner;
// The bond is the amount of REN submitted as a bond by the Darknode.
// This amount is reduced when the Darknode is slashed for malicious
// behavior.
uint256 bond;
// The block number at which the Darknode is considered registered.
uint256 registeredAt;
// The block number at which the Darknode is considered deregistered.
uint256 deregisteredAt;
// The public key used by this Darknode for encrypting sensitive data
// off chain. It is assumed that the Darknode has access to the
// respective private key, and that there is an agreement on the format
// of the public key.
bytes publicKey;
}
| struct Darknode {
// The owner of a Darknode is the address that called the register
// function. The owner is the only address that is allowed to
// deregister the Darknode, unless the Darknode is slashed for
// malicious behavior.
address owner;
// The bond is the amount of REN submitted as a bond by the Darknode.
// This amount is reduced when the Darknode is slashed for malicious
// behavior.
uint256 bond;
// The block number at which the Darknode is considered registered.
uint256 registeredAt;
// The block number at which the Darknode is considered deregistered.
uint256 deregisteredAt;
// The public key used by this Darknode for encrypting sensitive data
// off chain. It is assumed that the Darknode has access to the
// respective private key, and that there is an agreement on the format
// of the public key.
bytes publicKey;
}
| 3,937 |
28 | // signals to keepers that they can perform upkeeps once again afterhaving been paused / | function unpause() external onlyOwner {
_unpause();
}
| function unpause() external onlyOwner {
_unpause();
}
| 22,156 |
257 | // Enables a feature flag. / | function enableFeatureFlag(bytes32 _featureFlag)
external
override
onlyRole(OLib.GOVERNANCE_ROLE)
| function enableFeatureFlag(bytes32 _featureFlag)
external
override
onlyRole(OLib.GOVERNANCE_ROLE)
| 41,977 |
41 | // Returns release balance / | function getReleaseBalance()
public
view
returns (uint256, uint256, uint256)
| function getReleaseBalance()
public
view
returns (uint256, uint256, uint256)
| 71,057 |
3 | // Modifier to make a function callable only when the contract is unpaused | modifier whenUnpaused() {
require(pauseState == PauseState.Unpaused, "Pausable: Contract is paused");
_;
}
| modifier whenUnpaused() {
require(pauseState == PauseState.Unpaused, "Pausable: Contract is paused");
_;
}
| 21,961 |
3 | // Error thrown when funnel is already deployed. | error FunnelAlreadyDeployed();
| error FunnelAlreadyDeployed();
| 27,070 |
20 | // Chitin Token Contract | contract ChitinToken is ERC20("Chitin", "CHIT"), Ownable {
uint256 private constant CAP = 256000000e18; // 256 million CHIT
uint256 private _totalLock;
//these guys define when the locked rewards begin unlocking and end unlocking
uint256 public startReleaseBlock;
uint256 public endReleaseBlock;
mapping(address => uint256) private _locks;
mapping(address => uint256) private _lastUnlockBlock;
event Lock(address indexed to, uint256 value);
constructor(uint256 _startReleaseBlock, uint256 _endReleaseBlock) public {
require(_endReleaseBlock > _startReleaseBlock, "bad endReleaseBlock");
startReleaseBlock = _startReleaseBlock;
endReleaseBlock = _endReleaseBlock;
// mint 500k for seeding liquidity
mint(msg.sender, 500000e18);
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function cap() public pure returns (uint256) {
return CAP;
}
function unlockedSupply() external view returns (uint256) {
return totalSupply().sub(totalLock());
}
function totalLock() public view returns (uint256) {
return _totalLock;
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), allowance(sender, _msgSender()).sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function mint(address _to, uint256 _amount) public onlyOwner {
require(totalSupply().add(_amount) <= cap(), "cap exceeded");
_mint(_to, _amount);
}
function burn(address _account, uint256 _amount) external onlyOwner {
_burn(_account, _amount);
}
function totalBalanceOf(address _account) external view returns (uint256) {
return _locks[_account].add(balanceOf(_account));
}
function lockOf(address _account) external view returns (uint256) {
return _locks[_account];
}
function lastUnlockBlock(address _account) external view returns (uint256) {
return _lastUnlockBlock[_account];
}
function lock(address _account, uint256 _amount) external onlyOwner {
require(_account != address(0), "no lock to address(0)");
require(_amount <= balanceOf(_account), "balance exceeded");
_transfer(_account, address(this), _amount);
_locks[_account] = _locks[_account].add(_amount);
_totalLock = _totalLock.add(_amount);
if (_lastUnlockBlock[_account] < startReleaseBlock) {
_lastUnlockBlock[_account] = startReleaseBlock;
}
emit Lock(_account, _amount);
}
function canUnlockAmount(address _account) public view returns (uint256) {
// When block number less than startReleaseBlock, no CHIT can be unlocked
if (block.number < startReleaseBlock) {
return 0;
}
// When block number more than endReleaseBlock, all locked CHIT can be unlocked
else if (block.number >= endReleaseBlock) {
return _locks[_account];
}
// When block number is more than startReleaseBlock but less than endReleaseBlock,
// some CHIT can be released
else
{
uint256 releasedBlock = block.number.sub(_lastUnlockBlock[_account]);
uint256 blockLeft = endReleaseBlock.sub(_lastUnlockBlock[_account]);
return _locks[_account].mul(releasedBlock).div(blockLeft);
}
}
function unlock() external {
require(_locks[msg.sender] > 0, "no locked CHIT");
uint256 amount = canUnlockAmount(msg.sender);
_transfer(address(this), msg.sender, amount);
_locks[msg.sender] = _locks[msg.sender].sub(amount);
_lastUnlockBlock[msg.sender] = block.number;
_totalLock = _totalLock.sub(amount);
}
}
| contract ChitinToken is ERC20("Chitin", "CHIT"), Ownable {
uint256 private constant CAP = 256000000e18; // 256 million CHIT
uint256 private _totalLock;
//these guys define when the locked rewards begin unlocking and end unlocking
uint256 public startReleaseBlock;
uint256 public endReleaseBlock;
mapping(address => uint256) private _locks;
mapping(address => uint256) private _lastUnlockBlock;
event Lock(address indexed to, uint256 value);
constructor(uint256 _startReleaseBlock, uint256 _endReleaseBlock) public {
require(_endReleaseBlock > _startReleaseBlock, "bad endReleaseBlock");
startReleaseBlock = _startReleaseBlock;
endReleaseBlock = _endReleaseBlock;
// mint 500k for seeding liquidity
mint(msg.sender, 500000e18);
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function cap() public pure returns (uint256) {
return CAP;
}
function unlockedSupply() external view returns (uint256) {
return totalSupply().sub(totalLock());
}
function totalLock() public view returns (uint256) {
return _totalLock;
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), allowance(sender, _msgSender()).sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function mint(address _to, uint256 _amount) public onlyOwner {
require(totalSupply().add(_amount) <= cap(), "cap exceeded");
_mint(_to, _amount);
}
function burn(address _account, uint256 _amount) external onlyOwner {
_burn(_account, _amount);
}
function totalBalanceOf(address _account) external view returns (uint256) {
return _locks[_account].add(balanceOf(_account));
}
function lockOf(address _account) external view returns (uint256) {
return _locks[_account];
}
function lastUnlockBlock(address _account) external view returns (uint256) {
return _lastUnlockBlock[_account];
}
function lock(address _account, uint256 _amount) external onlyOwner {
require(_account != address(0), "no lock to address(0)");
require(_amount <= balanceOf(_account), "balance exceeded");
_transfer(_account, address(this), _amount);
_locks[_account] = _locks[_account].add(_amount);
_totalLock = _totalLock.add(_amount);
if (_lastUnlockBlock[_account] < startReleaseBlock) {
_lastUnlockBlock[_account] = startReleaseBlock;
}
emit Lock(_account, _amount);
}
function canUnlockAmount(address _account) public view returns (uint256) {
// When block number less than startReleaseBlock, no CHIT can be unlocked
if (block.number < startReleaseBlock) {
return 0;
}
// When block number more than endReleaseBlock, all locked CHIT can be unlocked
else if (block.number >= endReleaseBlock) {
return _locks[_account];
}
// When block number is more than startReleaseBlock but less than endReleaseBlock,
// some CHIT can be released
else
{
uint256 releasedBlock = block.number.sub(_lastUnlockBlock[_account]);
uint256 blockLeft = endReleaseBlock.sub(_lastUnlockBlock[_account]);
return _locks[_account].mul(releasedBlock).div(blockLeft);
}
}
function unlock() external {
require(_locks[msg.sender] > 0, "no locked CHIT");
uint256 amount = canUnlockAmount(msg.sender);
_transfer(address(this), msg.sender, amount);
_locks[msg.sender] = _locks[msg.sender].sub(amount);
_lastUnlockBlock[msg.sender] = block.number;
_totalLock = _totalLock.sub(amount);
}
}
| 13,592 |
32 | // Verify the become host signature _purchaseReceiptId The ID of the purchase receipt _v part of the signature _r part of the signature _s part of the signaturereturn true if valid, false otherwise / | function _verifyBecomeHostSignature(bytes32 _purchaseReceiptId, uint8 _v, bytes32 _r, bytes32 _s) internal view returns (bool) {
(,, bytes32 _contentId,,,,,, address _publicAddress,) = _aoPurchaseReceipt.getById(_purchaseReceiptId);
bytes32 _hash = keccak256(abi.encodePacked(address(this), _aoContent.getBaseChallenge(_contentId)));
return (ecrecover(_hash, _v, _r, _s) == _publicAddress);
}
| function _verifyBecomeHostSignature(bytes32 _purchaseReceiptId, uint8 _v, bytes32 _r, bytes32 _s) internal view returns (bool) {
(,, bytes32 _contentId,,,,,, address _publicAddress,) = _aoPurchaseReceipt.getById(_purchaseReceiptId);
bytes32 _hash = keccak256(abi.encodePacked(address(this), _aoContent.getBaseChallenge(_contentId)));
return (ecrecover(_hash, _v, _r, _s) == _publicAddress);
}
| 13,657 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.