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
242
// TIGERMasterFarmer is the master of TIGER. He can make TIGER 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 TIGER is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's bug-free. God bless.
contract TIGERMasterFarmer is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. uint256 rewardDebtAtBlock; // the last block user stake // // We do some fancy math here. Basically, any point in time, the amount of TIGERs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accTIGERPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accTIGERPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. TIGERs to distribute per block. uint256 lastRewardBlock; // Last block number that TIGERs distribution occurs. uint256 accTIGERPerShare; // Accumulated TIGERs per share, times 1e12. See below. } uint256 private _totalLock; mapping(address => uint256) private _locks; mapping(address => uint256) private _lastUnlockBlock; // The TIGER TOKEN! TigerToken public tiger; // Dev address. address public devaddr; // TIGER tokens created per block. uint256 public REWARD_PER_BLOCK; // 1000000000000000000 // Bonus muliplier for early TIGER makers. uint256[] public REWARD_MULTIPLIER = [8, 8, 8, 4, 4, 4, 2, 2, 2, 1]; uint256[] public HALVING_AT_BLOCK; // init in constructor function uint256 public FINISH_BONUS_AT_BLOCK; // The block number when TIGER mining starts. uint256 public START_BLOCK; uint256 public constant PERCENT_LOCK_BONUS_REWARD = 60; // lock 60% of bounus reward in 1 year uint256 public constant PERCENT_FOR_DEV = 20; // 10% reward for dev uint256 public burnPercent = 0; // init 0% burn tiger uint256 public lockFromBlock; uint256 public lockToBlock; // The migrator contract. It has a lot of power. Can only be set through governance (owner). IMigratorToTIGERSwap public migrator; // Info of each pool. PoolInfo[] public poolInfo; mapping(address => uint256) public poolId1; // poolId1 count from 1, subtraction 1 before using with poolInfo // Info of each user that stakes LP tokens. pid => user address => info mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event SendTIGERReward(address indexed user, uint256 indexed pid, uint256 amount, uint256 lockAmount); event Lock(address indexed to, uint256 value); constructor( TigerToken _tiger, address _devaddr, uint256 _rewardPerBlock, uint256 _startBlock, uint256 _halvingAfterBlock ) public { tiger = _tiger; devaddr = _devaddr; REWARD_PER_BLOCK = _rewardPerBlock; START_BLOCK = _startBlock; for (uint256 i = 0; i < REWARD_MULTIPLIER.length - 1; i++) { uint256 halvingAtBlock = _halvingAfterBlock.mul(i + 1).add(_startBlock); HALVING_AT_BLOCK.push(halvingAtBlock); } FINISH_BONUS_AT_BLOCK = _halvingAfterBlock.mul(REWARD_MULTIPLIER.length - 1).add(_startBlock); HALVING_AT_BLOCK.push(uint256(-1)); lockFromBlock = block.number + 10512000; lockToBlock = lockFromBlock + 10512000; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { require(poolId1[address(_lpToken)] == 0, "TIGERMasterFarmer::add: lp is already in pool"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > START_BLOCK ? block.number : START_BLOCK; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolId1[address(_lpToken)] = poolInfo.length + 1; poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accTIGERPerShare: 0 })); } // Update the given pool's TIGER allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // Set the migrator contract. Can only be called by the owner. function setMigrator(IMigratorToTIGERSwap _migrator) public onlyOwner { migrator = _migrator; } // Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good. function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } // 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 = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 tigerForBurn; uint256 tigerForDev; uint256 tigerForFarmer; (tigerForBurn, tigerForDev, tigerForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); if (tigerForBurn > 0) { tiger.mint(address(this), tigerForBurn); tiger.burn(tigerForBurn); } if (tigerForDev > 0) { // Mint unlocked amount for Dev tiger.mint(devaddr, tigerForDev.mul(100 - PERCENT_LOCK_BONUS_REWARD).div(100)); // Mint locked amount for Dev //For more simple, I lock reward for dev if mint reward in bonus time tiger.mint(address(this), tigerForDev.mul(PERCENT_LOCK_BONUS_REWARD).div(100)); farmLock(devaddr, tigerForDev.mul(PERCENT_LOCK_BONUS_REWARD).div(100)); } tiger.mint(address(this), tigerForFarmer); pool.accTIGERPerShare = pool.accTIGERPerShare.add(tigerForFarmer.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // |--------------------------------------| // [20, 30, 40, 50, 60, 70, 80, 99999999] // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_BLOCK) return 0; for (uint256 i = 0; i < HALVING_AT_BLOCK.length; i++) { uint256 endBlock = HALVING_AT_BLOCK[i]; if (_to <= endBlock) { uint256 m = _to.sub(_from).mul(REWARD_MULTIPLIER[i]); return result.add(m); } if (_from < endBlock) { uint256 m = endBlock.sub(_from).mul(REWARD_MULTIPLIER[i]); _from = endBlock; result = result.add(m); } } return result; } function getPoolReward(uint256 _from, uint256 _to, uint256 _allocPoint) public view returns (uint256 forBurn, uint256 forDev, uint256 forFarmer) { uint256 multiplier = getMultiplier(_from, _to); uint256 amount = multiplier.mul(REWARD_PER_BLOCK).mul(_allocPoint).div(totalAllocPoint); uint256 tigerCanMint = tiger.cap().sub(tiger.totalSupply()); if (tigerCanMint < amount) { forBurn = 0; forDev = 0; forFarmer = tigerCanMint; } else { forBurn = amount.mul(burnPercent).div(100); forDev = amount.mul(PERCENT_FOR_DEV).div(100); forFarmer = amount.mul(100 - burnPercent - PERCENT_FOR_DEV).div(100); } } // View function to see pending TIGERs on frontend. function pendingReward(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accTIGERPerShare = pool.accTIGERPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply > 0) { uint256 tigerForFarmer; (, , tigerForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); accTIGERPerShare = accTIGERPerShare.add(tigerForFarmer.mul(1e12).div(lpSupply)); } return user.amount.mul(accTIGERPerShare).div(1e12).sub(user.rewardDebt); } function claimReward(uint256 _pid) public { updatePool(_pid); _harvest(_pid); } // lock 75% of reward if it come from bounus time function _harvest(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accTIGERPerShare).div(1e12).sub(user.rewardDebt); uint256 masterBal = tiger.balanceOf(address(this)); if (pending > masterBal) { pending = masterBal; } if(pending > 0) { tiger.transfer(msg.sender, pending.mul(100 - PERCENT_LOCK_BONUS_REWARD).div(100)); uint256 lockAmount = 0; if (user.rewardDebtAtBlock <= FINISH_BONUS_AT_BLOCK) { lockAmount = pending.mul(PERCENT_LOCK_BONUS_REWARD).div(100); farmLock(msg.sender, lockAmount); } user.rewardDebtAtBlock = block.number; emit SendTIGERReward(msg.sender, _pid, pending, lockAmount); } user.rewardDebt = user.amount.mul(pool.accTIGERPerShare).div(1e12); } } // Deposit LP tokens to TIGERMasterFarmer for TIGER allocation. function deposit(uint256 _pid, uint256 _amount) public { require(_amount > 0, "TIGERMasterFarmer::deposit: amount must be greater than 0"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); _harvest(_pid); pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); if (user.amount == 0) { user.rewardDebtAtBlock = block.number; } user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accTIGERPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from TIGERMasterFarmer. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "TIGERMasterFarmer::withdraw: not good"); updatePool(_pid); _harvest(_pid); if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.accTIGERPerShare).div(1e12); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe tiger transfer function, just in case if rounding error causes pool to not have enough TIGERs. function safeTIGERTransfer(address _to, uint256 _amount) internal { uint256 tigerBal = tiger.balanceOf(address(this)); if (_amount > tigerBal) { tiger.transfer(_to, tigerBal); } else { tiger.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; } function getNewRewardPerBlock(uint256 pid1) public view returns (uint256) { uint256 multiplier = getMultiplier(block.number -1, block.number); if (pid1 == 0) { return multiplier.mul(REWARD_PER_BLOCK); } else { return multiplier .mul(REWARD_PER_BLOCK) .mul(poolInfo[pid1 - 1].allocPoint) .div(totalAllocPoint); } } function setBurnPercent(uint256 _burnPercent) public onlyOwner { require(_burnPercent > burnPercent, "error: set burn percent"); burnPercent = _burnPercent; } function totalLock() public view returns (uint256) { return _totalLock; } function lockOf(address _holder) public view returns (uint256) { return _locks[_holder]; } function lastUnlockBlock(address _holder) public view returns (uint256) { return _lastUnlockBlock[_holder]; } function farmLock(address _holder, uint256 _amount) internal { require(_holder != address(0), "ERC20: lock to the zero address"); require(_amount <= tiger.balanceOf(address(this)), "ERC20: lock amount over blance"); _locks[_holder] = _locks[_holder].add(_amount); _totalLock = _totalLock.add(_amount); if (_lastUnlockBlock[_holder] < lockFromBlock) { _lastUnlockBlock[_holder] = lockFromBlock; } emit Lock(_holder, _amount); } function canUnlockAmount(address _holder) public view returns (uint256) { if (block.number < lockFromBlock) { return 0; } else if (block.number >= lockToBlock) { return _locks[_holder]; } else { uint256 releaseBlock = block.number.sub(_lastUnlockBlock[_holder]); uint256 numberLockBlock = lockToBlock.sub(_lastUnlockBlock[_holder]); return _locks[_holder].mul(releaseBlock).div(numberLockBlock); } } function unlock() public { require(_locks[msg.sender] > 0, "ERC20: cannot unlock"); uint256 amount = canUnlockAmount(msg.sender); // just for sure if (amount > tiger.balanceOf(address(this))) { amount = tiger.balanceOf(address(this)); } tiger.transfer(msg.sender, amount); _locks[msg.sender] = _locks[msg.sender].sub(amount); _lastUnlockBlock[msg.sender] = block.number; _totalLock = _totalLock.sub(amount); } function setTransferBurnRate(uint256 _tranferBurnRate) public onlyOwner { tiger.setTransferBurnRate(_tranferBurnRate); } // In some circumstance, we should not burn TIGER on transfer, eg: Transfer from owner to distribute bounty, from depositing to swap for liquidity function addTransferBurnExceptAddress(address _transferBurnExceptAddress) public onlyOwner { tiger.addTransferBurnExceptAddress(_transferBurnExceptAddress); } function removeTransferBurnExceptAddress(address _transferBurnExceptAddress) public onlyOwner { tiger.removeTransferBurnExceptAddress(_transferBurnExceptAddress); } }
contract TIGERMasterFarmer is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. uint256 rewardDebtAtBlock; // the last block user stake // // We do some fancy math here. Basically, any point in time, the amount of TIGERs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accTIGERPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accTIGERPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. TIGERs to distribute per block. uint256 lastRewardBlock; // Last block number that TIGERs distribution occurs. uint256 accTIGERPerShare; // Accumulated TIGERs per share, times 1e12. See below. } uint256 private _totalLock; mapping(address => uint256) private _locks; mapping(address => uint256) private _lastUnlockBlock; // The TIGER TOKEN! TigerToken public tiger; // Dev address. address public devaddr; // TIGER tokens created per block. uint256 public REWARD_PER_BLOCK; // 1000000000000000000 // Bonus muliplier for early TIGER makers. uint256[] public REWARD_MULTIPLIER = [8, 8, 8, 4, 4, 4, 2, 2, 2, 1]; uint256[] public HALVING_AT_BLOCK; // init in constructor function uint256 public FINISH_BONUS_AT_BLOCK; // The block number when TIGER mining starts. uint256 public START_BLOCK; uint256 public constant PERCENT_LOCK_BONUS_REWARD = 60; // lock 60% of bounus reward in 1 year uint256 public constant PERCENT_FOR_DEV = 20; // 10% reward for dev uint256 public burnPercent = 0; // init 0% burn tiger uint256 public lockFromBlock; uint256 public lockToBlock; // The migrator contract. It has a lot of power. Can only be set through governance (owner). IMigratorToTIGERSwap public migrator; // Info of each pool. PoolInfo[] public poolInfo; mapping(address => uint256) public poolId1; // poolId1 count from 1, subtraction 1 before using with poolInfo // Info of each user that stakes LP tokens. pid => user address => info mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event SendTIGERReward(address indexed user, uint256 indexed pid, uint256 amount, uint256 lockAmount); event Lock(address indexed to, uint256 value); constructor( TigerToken _tiger, address _devaddr, uint256 _rewardPerBlock, uint256 _startBlock, uint256 _halvingAfterBlock ) public { tiger = _tiger; devaddr = _devaddr; REWARD_PER_BLOCK = _rewardPerBlock; START_BLOCK = _startBlock; for (uint256 i = 0; i < REWARD_MULTIPLIER.length - 1; i++) { uint256 halvingAtBlock = _halvingAfterBlock.mul(i + 1).add(_startBlock); HALVING_AT_BLOCK.push(halvingAtBlock); } FINISH_BONUS_AT_BLOCK = _halvingAfterBlock.mul(REWARD_MULTIPLIER.length - 1).add(_startBlock); HALVING_AT_BLOCK.push(uint256(-1)); lockFromBlock = block.number + 10512000; lockToBlock = lockFromBlock + 10512000; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { require(poolId1[address(_lpToken)] == 0, "TIGERMasterFarmer::add: lp is already in pool"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > START_BLOCK ? block.number : START_BLOCK; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolId1[address(_lpToken)] = poolInfo.length + 1; poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accTIGERPerShare: 0 })); } // Update the given pool's TIGER allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // Set the migrator contract. Can only be called by the owner. function setMigrator(IMigratorToTIGERSwap _migrator) public onlyOwner { migrator = _migrator; } // Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good. function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } // 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 = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 tigerForBurn; uint256 tigerForDev; uint256 tigerForFarmer; (tigerForBurn, tigerForDev, tigerForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); if (tigerForBurn > 0) { tiger.mint(address(this), tigerForBurn); tiger.burn(tigerForBurn); } if (tigerForDev > 0) { // Mint unlocked amount for Dev tiger.mint(devaddr, tigerForDev.mul(100 - PERCENT_LOCK_BONUS_REWARD).div(100)); // Mint locked amount for Dev //For more simple, I lock reward for dev if mint reward in bonus time tiger.mint(address(this), tigerForDev.mul(PERCENT_LOCK_BONUS_REWARD).div(100)); farmLock(devaddr, tigerForDev.mul(PERCENT_LOCK_BONUS_REWARD).div(100)); } tiger.mint(address(this), tigerForFarmer); pool.accTIGERPerShare = pool.accTIGERPerShare.add(tigerForFarmer.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // |--------------------------------------| // [20, 30, 40, 50, 60, 70, 80, 99999999] // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_BLOCK) return 0; for (uint256 i = 0; i < HALVING_AT_BLOCK.length; i++) { uint256 endBlock = HALVING_AT_BLOCK[i]; if (_to <= endBlock) { uint256 m = _to.sub(_from).mul(REWARD_MULTIPLIER[i]); return result.add(m); } if (_from < endBlock) { uint256 m = endBlock.sub(_from).mul(REWARD_MULTIPLIER[i]); _from = endBlock; result = result.add(m); } } return result; } function getPoolReward(uint256 _from, uint256 _to, uint256 _allocPoint) public view returns (uint256 forBurn, uint256 forDev, uint256 forFarmer) { uint256 multiplier = getMultiplier(_from, _to); uint256 amount = multiplier.mul(REWARD_PER_BLOCK).mul(_allocPoint).div(totalAllocPoint); uint256 tigerCanMint = tiger.cap().sub(tiger.totalSupply()); if (tigerCanMint < amount) { forBurn = 0; forDev = 0; forFarmer = tigerCanMint; } else { forBurn = amount.mul(burnPercent).div(100); forDev = amount.mul(PERCENT_FOR_DEV).div(100); forFarmer = amount.mul(100 - burnPercent - PERCENT_FOR_DEV).div(100); } } // View function to see pending TIGERs on frontend. function pendingReward(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accTIGERPerShare = pool.accTIGERPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply > 0) { uint256 tigerForFarmer; (, , tigerForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); accTIGERPerShare = accTIGERPerShare.add(tigerForFarmer.mul(1e12).div(lpSupply)); } return user.amount.mul(accTIGERPerShare).div(1e12).sub(user.rewardDebt); } function claimReward(uint256 _pid) public { updatePool(_pid); _harvest(_pid); } // lock 75% of reward if it come from bounus time function _harvest(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accTIGERPerShare).div(1e12).sub(user.rewardDebt); uint256 masterBal = tiger.balanceOf(address(this)); if (pending > masterBal) { pending = masterBal; } if(pending > 0) { tiger.transfer(msg.sender, pending.mul(100 - PERCENT_LOCK_BONUS_REWARD).div(100)); uint256 lockAmount = 0; if (user.rewardDebtAtBlock <= FINISH_BONUS_AT_BLOCK) { lockAmount = pending.mul(PERCENT_LOCK_BONUS_REWARD).div(100); farmLock(msg.sender, lockAmount); } user.rewardDebtAtBlock = block.number; emit SendTIGERReward(msg.sender, _pid, pending, lockAmount); } user.rewardDebt = user.amount.mul(pool.accTIGERPerShare).div(1e12); } } // Deposit LP tokens to TIGERMasterFarmer for TIGER allocation. function deposit(uint256 _pid, uint256 _amount) public { require(_amount > 0, "TIGERMasterFarmer::deposit: amount must be greater than 0"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); _harvest(_pid); pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); if (user.amount == 0) { user.rewardDebtAtBlock = block.number; } user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accTIGERPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from TIGERMasterFarmer. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "TIGERMasterFarmer::withdraw: not good"); updatePool(_pid); _harvest(_pid); if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.accTIGERPerShare).div(1e12); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe tiger transfer function, just in case if rounding error causes pool to not have enough TIGERs. function safeTIGERTransfer(address _to, uint256 _amount) internal { uint256 tigerBal = tiger.balanceOf(address(this)); if (_amount > tigerBal) { tiger.transfer(_to, tigerBal); } else { tiger.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; } function getNewRewardPerBlock(uint256 pid1) public view returns (uint256) { uint256 multiplier = getMultiplier(block.number -1, block.number); if (pid1 == 0) { return multiplier.mul(REWARD_PER_BLOCK); } else { return multiplier .mul(REWARD_PER_BLOCK) .mul(poolInfo[pid1 - 1].allocPoint) .div(totalAllocPoint); } } function setBurnPercent(uint256 _burnPercent) public onlyOwner { require(_burnPercent > burnPercent, "error: set burn percent"); burnPercent = _burnPercent; } function totalLock() public view returns (uint256) { return _totalLock; } function lockOf(address _holder) public view returns (uint256) { return _locks[_holder]; } function lastUnlockBlock(address _holder) public view returns (uint256) { return _lastUnlockBlock[_holder]; } function farmLock(address _holder, uint256 _amount) internal { require(_holder != address(0), "ERC20: lock to the zero address"); require(_amount <= tiger.balanceOf(address(this)), "ERC20: lock amount over blance"); _locks[_holder] = _locks[_holder].add(_amount); _totalLock = _totalLock.add(_amount); if (_lastUnlockBlock[_holder] < lockFromBlock) { _lastUnlockBlock[_holder] = lockFromBlock; } emit Lock(_holder, _amount); } function canUnlockAmount(address _holder) public view returns (uint256) { if (block.number < lockFromBlock) { return 0; } else if (block.number >= lockToBlock) { return _locks[_holder]; } else { uint256 releaseBlock = block.number.sub(_lastUnlockBlock[_holder]); uint256 numberLockBlock = lockToBlock.sub(_lastUnlockBlock[_holder]); return _locks[_holder].mul(releaseBlock).div(numberLockBlock); } } function unlock() public { require(_locks[msg.sender] > 0, "ERC20: cannot unlock"); uint256 amount = canUnlockAmount(msg.sender); // just for sure if (amount > tiger.balanceOf(address(this))) { amount = tiger.balanceOf(address(this)); } tiger.transfer(msg.sender, amount); _locks[msg.sender] = _locks[msg.sender].sub(amount); _lastUnlockBlock[msg.sender] = block.number; _totalLock = _totalLock.sub(amount); } function setTransferBurnRate(uint256 _tranferBurnRate) public onlyOwner { tiger.setTransferBurnRate(_tranferBurnRate); } // In some circumstance, we should not burn TIGER on transfer, eg: Transfer from owner to distribute bounty, from depositing to swap for liquidity function addTransferBurnExceptAddress(address _transferBurnExceptAddress) public onlyOwner { tiger.addTransferBurnExceptAddress(_transferBurnExceptAddress); } function removeTransferBurnExceptAddress(address _transferBurnExceptAddress) public onlyOwner { tiger.removeTransferBurnExceptAddress(_transferBurnExceptAddress); } }
17,552
21
// Decrease the amount of tokens that an owner allowed to a spender.approve should be called when allowed_[_spender] == 0. To decrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol spender The address which will spend the funds. subtractedValue The amount of tokens to decrease the allowance by. /
function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool)
function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool)
3,238
10
// adds a new checkpoint Requirements: - the caller must have the ROLE_SEEDER role /
function _addCheckpoint(address target, uint256 timestamp) private { require(data[target] <= timestamp, "ERR_WRONG_ORDER"); data[target] = timestamp; emit CheckpointUpdated(target, timestamp); }
function _addCheckpoint(address target, uint256 timestamp) private { require(data[target] <= timestamp, "ERR_WRONG_ORDER"); data[target] = timestamp; emit CheckpointUpdated(target, timestamp); }
21,129
27
// Returns the the implementation contract of the proxy contract by its identifier. It returns ZERO if there is no registered address with the given id It reverts if the registered address with the given id is not `InitializableImmutableAdminUpgradeabilityProxy` id The idreturn The address of the implementation contract /
function _getProxyImplementation(bytes32 id) internal returns (address) { address proxyAddress = _addresses[id]; if (proxyAddress == address(0)) { return address(0); } else { address payable payableProxyAddress = payable(proxyAddress); return InitializableImmutableAdminUpgradeabilityProxy(payableProxyAddress).implementation(); } }
function _getProxyImplementation(bytes32 id) internal returns (address) { address proxyAddress = _addresses[id]; if (proxyAddress == address(0)) { return address(0); } else { address payable payableProxyAddress = payable(proxyAddress); return InitializableImmutableAdminUpgradeabilityProxy(payableProxyAddress).implementation(); } }
36,035
506
// The DFG TOKEN!
INBUNIERC20 public dfg;
INBUNIERC20 public dfg;
40,336
5
// Estimate the reward amount./_gasPrice The gas price for which we want to retrieve the estimation./ return The reward to be included when either posting a new request, or upgrading the reward of a previously posted one.
function _witnetEstimateReward(uint256 _gasPrice) internal view virtual returns (uint256)
function _witnetEstimateReward(uint256 _gasPrice) internal view virtual returns (uint256)
13,935
60
// Transfer tokens from one address to another _from address The address which you want to send tokens from _to address The address which you want to transfer to _value uint the amount of tokens to be transferred /
function transferFrom(address _from, address _to, uint _value) public returns (bool) { bytes memory empty; return transferFrom(_from, _to, _value, empty); }
function transferFrom(address _from, address _to, uint _value) public returns (bool) { bytes memory empty; return transferFrom(_from, _to, _value, empty); }
14,777
1
// Calculates due protocol fees originating from accumulated swap fees and yield of non-exempt tokens, paysthem by minting BPT, and returns the actual supply and current balances. We also return the current invariant computed using the amplification factor at the last join or exit, which canbe useful to skip computations in scenarios where the amplification factor is not changing. /
function _payProtocolFeesBeforeJoinExit(
function _payProtocolFeesBeforeJoinExit(
10,062
112
// Gets attributes of NFT
function _getAttributesOfToken(uint256 _tokenId) internal returns(NFT) { NFT storage lsnftObj = allNFTs[_tokenId]; return lsnftObj; }
function _getAttributesOfToken(uint256 _tokenId) internal returns(NFT) { NFT storage lsnftObj = allNFTs[_tokenId]; return lsnftObj; }
25,183
26
// PERMIT WITHDRAW TODO Need to handle case in where withdraw action replaced argument.
if (store.actionArgsHash == ZERO_BYTES32) { store.actionArgsHash = _getActionArgsHash(actions, args, beforeSlipped); }
if (store.actionArgsHash == ZERO_BYTES32) { store.actionArgsHash = _getActionArgsHash(actions, args, beforeSlipped); }
14,339
194
// player address mapped to query id does not exist // keep oraclize honest by retrieving the serialNumber from random.org result // map random result to player // produce integer bounded to 1-100 inclusivevia sha3 result from random.org and proof (IPFS address of TLSNotary proof) /
playerDieResult[myid] = uint(sha3(playerRandomResult[myid], proof)) % 100 + 1;
playerDieResult[myid] = uint(sha3(playerRandomResult[myid], proof)) % 100 + 1;
40,187
8
// === Find the length of an unsigned integer
function lengthOfUint(uint256 _num) private pure returns (uint256 length) { while (_num != 0) { length++; _num /= 10; } }
function lengthOfUint(uint256 _num) private pure returns (uint256 length) { while (_num != 0) { length++; _num /= 10; } }
30,661
12
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping(address => uint256)) allowed;
mapping(address => mapping(address => uint256)) allowed;
52,039
1,098
// If holder number decreases, probability decreases.
uint32 finish_probabilityIncreaseStep_transaction; uint32 finish_probabilityIncreaseStep_holder;
uint32 finish_probabilityIncreaseStep_transaction; uint32 finish_probabilityIncreaseStep_holder;
4,797
192
// get the rate between the pool token and the reserve token
Fraction memory poolRate = poolTokenRate(_poolToken, _reserveToken);
Fraction memory poolRate = poolTokenRate(_poolToken, _reserveToken);
14,086
22
// Allows the user to deposit funds, where the sender address and max allowed value have to be signed together with the cyclenumber by the casino. The method verifies the signature and makes sure, the deposit was made in time, before updatingthe storage variables. value the number of tokens to deposit allowedMax the maximum deposit allowed this cycle v, r, s the signature of an authorized casino wallet/
function deposit(uint value, uint allowedMax, uint8 v, bytes32 r, bytes32 s) public depositPhase { require(verifySignature(msg.sender, allowedMax, v, r, s)); if (addDeposit(msg.sender, value, numHolders, allowedMax)) numHolders = safeAdd(numHolders, 1); totalStakes = safeSub(safeAdd(totalStakes, value), depositGasCost); }
function deposit(uint value, uint allowedMax, uint8 v, bytes32 r, bytes32 s) public depositPhase { require(verifySignature(msg.sender, allowedMax, v, r, s)); if (addDeposit(msg.sender, value, numHolders, allowedMax)) numHolders = safeAdd(numHolders, 1); totalStakes = safeSub(safeAdd(totalStakes, value), depositGasCost); }
40,573
71
// We don't want to support a payable function as we are not doing ICO and instead doing private/
returns(bool) { require(_totalWeiAmount > 0 && publicSaleSupply >= _totalWeiAmount); publicSaleSupply = publicSaleSupply.sub(_totalWeiAmount); require(transferFrom(owner,_to, _totalWeiAmount)); TokensBought(_to, _totalWeiAmount, _currency, _txHash); return true; }
returns(bool) { require(_totalWeiAmount > 0 && publicSaleSupply >= _totalWeiAmount); publicSaleSupply = publicSaleSupply.sub(_totalWeiAmount); require(transferFrom(owner,_to, _totalWeiAmount)); TokensBought(_to, _totalWeiAmount, _currency, _txHash); return true; }
37,266
19
// Set endpoint specific parameters for a given endpoint
function setEndpointParams(bytes32 endpoint, bytes32[] memory endpointParams) public { // Provider must be initiated require(isProviderInitiated(msg.sender), "Error: Provider is not yet initialized"); // Can't set endpoint params on an unset provider require(!getCurveUnset(msg.sender, endpoint), "Error: Curve is not yet set"); db.setBytesArray(keccak256(abi.encodePacked('oracles', msg.sender, 'endpointParams', endpoint)), endpointParams); }
function setEndpointParams(bytes32 endpoint, bytes32[] memory endpointParams) public { // Provider must be initiated require(isProviderInitiated(msg.sender), "Error: Provider is not yet initialized"); // Can't set endpoint params on an unset provider require(!getCurveUnset(msg.sender, endpoint), "Error: Curve is not yet set"); db.setBytesArray(keccak256(abi.encodePacked('oracles', msg.sender, 'endpointParams', endpoint)), endpointParams); }
17,878
173
// skip if stage is below "currentStage" (as they have no available tokens)
if(stageId < currentStage) {
if(stageId < currentStage) {
8,759
50
// uint256 currentBalance = balanceOf(_beneficiary);
uint256 totalBalance = value.torelease; if (block.timestamp < value.cliff) { return 0; } else if (block.timestamp >= value.start.add(value.duration)) {
uint256 totalBalance = value.torelease; if (block.timestamp < value.cliff) { return 0; } else if (block.timestamp >= value.start.add(value.duration)) {
58,329
18
// Decrease the allowance by a given amount spender Spender's address subtractedValue Amount of decrease in allowancereturn True if successful /
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool)
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool)
22,275
277
// Converts to a Message _message The messagereturn The newly typed message /
function tryAsMessage(bytes29 _message) internal pure returns (bytes29) { if (isValidMessageLength(_message)) { return _message.castTo(uint40(Types.Message)); } return TypedMemView.nullView(); }
function tryAsMessage(bytes29 _message) internal pure returns (bytes29) { if (isValidMessageLength(_message)) { return _message.castTo(uint40(Types.Message)); } return TypedMemView.nullView(); }
13,992
10
// https:etherscan.io/address/0xC011A72400E58ecD99Ee497CF89E3775d4bd732F
Proxy public constant proxysynthetix_i = Proxy(0xC011A72400E58ecD99Ee497CF89E3775d4bd732F);
Proxy public constant proxysynthetix_i = Proxy(0xC011A72400E58ecD99Ee497CF89E3775d4bd732F);
50,691
22
// when toToken == eth, call this function to get eth/to The account address to receive ETH/minAmount The minimum amount to withdraw
function withdrawWETH(address to, uint256 minAmount) external payable { uint256 withdrawAmount = IWETH(_WETH_).balanceOf(address(this)); require(withdrawAmount >= minAmount, "D3PROXY_WETH_NOT_ENOUGH"); _withdrawWETH(to, withdrawAmount); }
function withdrawWETH(address to, uint256 minAmount) external payable { uint256 withdrawAmount = IWETH(_WETH_).balanceOf(address(this)); require(withdrawAmount >= minAmount, "D3PROXY_WETH_NOT_ENOUGH"); _withdrawWETH(to, withdrawAmount); }
17,083
131
// 2% Fund + 10% Dividends
f2mContract.pushDividends.value(toF2mAmount)();
f2mContract.pushDividends.value(toF2mAmount)();
19,040
31
// _burn(_owner, _tokenId);
_burn(_tokenId); emit TokenBurned(_tokenId);
_burn(_tokenId); emit TokenBurned(_tokenId);
1,662
35
// The Compound redeem executions data._key is the execution Id._value is the execution data. /
mapping(uint256 => Execution) public executions;
mapping(uint256 => Execution) public executions;
18,188
363
// Array of Bassets currently active
Basset[] bassets;
Basset[] bassets;
19,285
55
// Mint amount of token to specified account by an operator address /
function mint(address account, uint256 amount) external returns (bool);
function mint(address account, uint256 amount) external returns (bool);
18,670
160
// check if tokenId has a specified image link
if (bytes(staticIpfsImageLink[_tokenId]).length > 0) { return Strings.strConcat(projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI, staticIpfsImageLink[_tokenId]); }
if (bytes(staticIpfsImageLink[_tokenId]).length > 0) { return Strings.strConcat(projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI, staticIpfsImageLink[_tokenId]); }
19,317
66
// Copied from 0x LibMath///Calculates partial value given a numerator and denominator rounded down./Reverts if rounding error is >= 0.1%/numerator Numerator./denominator Denominator./target Value to calculate partial of./ return Partial value of target rounded down.
function safeGetPartialAmountFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { require(
function safeGetPartialAmountFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { require(
30,475
193
// Only the savings managaer (pulled from Nexus) can execute this /
modifier onlySavingsManager() { require(msg.sender == _savingsManager(), "Only savings manager can execute"); _; }
modifier onlySavingsManager() { require(msg.sender == _savingsManager(), "Only savings manager can execute"); _; }
49,671
77
// Gets the cost of appealing a specified dispute._disputeID The ID of the dispute. return cost The appeal cost. /
function appealCost(uint256 _disputeID) public view returns (uint256 cost) { Dispute storage dispute = disputes[_disputeID]; if (dispute.nbVotes >= courts[dispute.subcourtID].jurorsForCourtJump) { // Jump to parent subcourt. if (dispute.subcourtID == 0) // Already in the forking court. cost = NON_PAYABLE_AMOUNT; // Get the cost of the parent subcourt. else cost = courts[courts[dispute.subcourtID].parent].feeForJuror * ((dispute.nbVotes * 2) + 1); } // Stay in current subcourt. else cost = courts[dispute.subcourtID].feeForJuror * ((dispute.nbVotes * 2) + 1); }
function appealCost(uint256 _disputeID) public view returns (uint256 cost) { Dispute storage dispute = disputes[_disputeID]; if (dispute.nbVotes >= courts[dispute.subcourtID].jurorsForCourtJump) { // Jump to parent subcourt. if (dispute.subcourtID == 0) // Already in the forking court. cost = NON_PAYABLE_AMOUNT; // Get the cost of the parent subcourt. else cost = courts[courts[dispute.subcourtID].parent].feeForJuror * ((dispute.nbVotes * 2) + 1); } // Stay in current subcourt. else cost = courts[dispute.subcourtID].feeForJuror * ((dispute.nbVotes * 2) + 1); }
696
5
// Used to validate if a user has been borrowing from any reserve self The configuration objectreturn True if the user has been borrowing any reserve, false otherwise /
function isBorrowingAny(DataTypes.UserConfigurationMap memory self) internal pure returns (bool) { return self.data & BORROWING_MASK != 0; }
function isBorrowingAny(DataTypes.UserConfigurationMap memory self) internal pure returns (bool) { return self.data & BORROWING_MASK != 0; }
6,933
1
// Chainlink rinkeby devrel node.
oracle = 0xc57B33452b4F7BB189bB5AfaE9cc4aBa1f7a4FD8; jobId = "6b88e0402e5d415eb946e528b8e0c7ba"; fee = 0.1 * 10**18; // (Varies by network and job) .1 Link
oracle = 0xc57B33452b4F7BB189bB5AfaE9cc4aBa1f7a4FD8; jobId = "6b88e0402e5d415eb946e528b8e0c7ba"; fee = 0.1 * 10**18; // (Varies by network and job) .1 Link
49,891
22
// For Debugging
event Debug(string notes,uint opt1,uint opt2); using SafeMath for uint; address public governor; uint public priceInWei; uint8 public decimal; uint public closeTime; uint public startTime; uint public minBuy;
event Debug(string notes,uint opt1,uint opt2); using SafeMath for uint; address public governor; uint public priceInWei; uint8 public decimal; uint public closeTime; uint public startTime; uint public minBuy;
52,918
126
// Update reward per block Only callable by owner. _rewardPerBlock: the reward per block /
function updateRewardPerBlock(uint256 _rewardPerBlock) external onlyOwner { require(block.number < startBlock, "Pool has started"); rewardPerBlock = _rewardPerBlock; emit NewRewardPerBlock(_rewardPerBlock); }
function updateRewardPerBlock(uint256 _rewardPerBlock) external onlyOwner { require(block.number < startBlock, "Pool has started"); rewardPerBlock = _rewardPerBlock; emit NewRewardPerBlock(_rewardPerBlock); }
7,242
124
// Populates the return values with information about the loaded safe deposit box.
end_time = _deposit.end_time; principal = _deposit.principal; reward = _deposit.reward; premature_withdrawal_enabled = _deposit.premature_withdrawal_enabled;
end_time = _deposit.end_time; principal = _deposit.principal; reward = _deposit.reward; premature_withdrawal_enabled = _deposit.premature_withdrawal_enabled;
44,899
353
// Calculates final amounts in, accounting for the exit fee
(uint exitFee, uint amountIn) = SmartPoolManager.exitswapExternAmountOut( IConfigurableRightsPool(address(this)), bPool, tokenOut, tokenAmountOut, maxPoolAmountIn ); poolAmountIn = amountIn;
(uint exitFee, uint amountIn) = SmartPoolManager.exitswapExternAmountOut( IConfigurableRightsPool(address(this)), bPool, tokenOut, tokenAmountOut, maxPoolAmountIn ); poolAmountIn = amountIn;
26,821
10
// Length getters and modifiers
function getMyAgreementsCount() public view returns(uint myAgreementsCount) { return userToAgreements[msg.sender].length; }
function getMyAgreementsCount() public view returns(uint myAgreementsCount) { return userToAgreements[msg.sender].length; }
51,819
35
// Helper function to convert bool to string
function boolToString(bool _value) internal pure returns (string memory) { return _value ? "true" : "false"; }
function boolToString(bool _value) internal pure returns (string memory) { return _value ? "true" : "false"; }
15,480
13
// Enable depositing
function enableDepositing() external onlyOwner { require(!isShutdown, "StablzLPIntegration: Enabling deposits is not allowed due to the integration being shutdown"); isDepositingEnabled = true; emit DepositingEnabled(); }
function enableDepositing() external onlyOwner { require(!isShutdown, "StablzLPIntegration: Enabling deposits is not allowed due to the integration being shutdown"); isDepositingEnabled = true; emit DepositingEnabled(); }
18,039
52
// Returns the downcasted int192 from int256, reverting onoverflow (when the input is less than smallest int192 orgreater than largest int192). Counterpart to Solidity's `int192` operator. Requirements: - input must fit into 192 bits /
function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } }
function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } }
5,947
67
// Throws if called by any account that does not have operator role. /
modifier onlyOperator() { require(isOperator(msg.sender), "not operator"); _; }
modifier onlyOperator() { require(isOperator(msg.sender), "not operator"); _; }
20,344
37
// Gets blocknumber for mined timestamp _requestId to look up _timestamp is the timestamp to look up blocknumberreturn uint of the blocknumber which the dispute was mined /
function getMinedBlockNum(uint256 _requestId, uint256 _timestamp)
function getMinedBlockNum(uint256 _requestId, uint256 _timestamp)
18,351
26
// default Vesting parameter values
uint256 private _cliff = 2592000; // 30 days period uint256 private _duration = 93312000; // for 3 years bool private _revoked = false; IERC20 public LCXToken; event TokenReleased(address indexed account, uint256 amount); event VestingRevoked(address indexed account);
uint256 private _cliff = 2592000; // 30 days period uint256 private _duration = 93312000; // for 3 years bool private _revoked = false; IERC20 public LCXToken; event TokenReleased(address indexed account, uint256 amount); event VestingRevoked(address indexed account);
20,993
142
// mint Fucntion is to mint the NFTS for public/
function mint(uint256 _count) public payable { uint256 Supply = totalSupply(); require(!isBlacklisted[msg.sender], "caller is backlisted"); require(hasSaleStarted == true, "Sale hasn't started"); require(Supply <= MAX_SUPPLY, "Sold out"); require(Supply + _count <= MAX_SUPPLY, "Not enough tokens left"); require(_count <= 20, "Mint 20 or fewer, please."); require(msg.value == _count*(floorPrice), "The value submitted with this transaction is too low."); payable(owner()).transfer(_count*(floorPrice)); _safeMint(msg.sender,_count ); }
function mint(uint256 _count) public payable { uint256 Supply = totalSupply(); require(!isBlacklisted[msg.sender], "caller is backlisted"); require(hasSaleStarted == true, "Sale hasn't started"); require(Supply <= MAX_SUPPLY, "Sold out"); require(Supply + _count <= MAX_SUPPLY, "Not enough tokens left"); require(_count <= 20, "Mint 20 or fewer, please."); require(msg.value == _count*(floorPrice), "The value submitted with this transaction is too low."); payable(owner()).transfer(_count*(floorPrice)); _safeMint(msg.sender,_count ); }
14,094
104
// deposits the entire balance to yv2 vault
IYVaultV2(yVault).deposit(underlyingBalance);
IYVaultV2(yVault).deposit(underlyingBalance);
49,907
85
// it is player2's turn
require(stacks[_counterStack].owner==msg.sender);
require(stacks[_counterStack].owner==msg.sender);
65,318
177
// Define owner address
address ownerAddress = 0xa27999aEE6d546004fA37CfDf372a922aB1C7Eff;
address ownerAddress = 0xa27999aEE6d546004fA37CfDf372a922aB1C7Eff;
49,412
4
// metadata root uri
string private _rootURI;
string private _rootURI;
25,652
129
// function exists(uint256 tokenId) external view returns (bool exists);
function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool approved) external; function isApprovedForAll(address owner, address operator) external
function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool approved) external; function isApprovedForAll(address owner, address operator) external
14,715
101
// require(pair != uniswapV2Pair, "The pair cannot be removed from _automateMMs");
uniswapV2Pair = pair; _automateMMs[address(uniswapV2Pair)] = true; _isExcludedMaxTransactionAmount[address(uniswapV2Pair)] = true; _isExcludedmaxAmount[address(uniswapV2Pair)] = true;
uniswapV2Pair = pair; _automateMMs[address(uniswapV2Pair)] = true; _isExcludedMaxTransactionAmount[address(uniswapV2Pair)] = true; _isExcludedmaxAmount[address(uniswapV2Pair)] = true;
6,782
212
// Mapping from token ID to ownership details An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) private _ownerships;
mapping(uint256 => TokenOwnership) private _ownerships;
20,841
39
// Shuffle array
shuffleLotteryTickets(1); address winner = lotteryEntries[0];
shuffleLotteryTickets(1); address winner = lotteryEntries[0];
52,314
12
// Status of the work order contract. /
enum Status { Pending, InProgress, Completed, Paid } /** Provide (PRVD) token. */ ProvideToken public token; /** Provide platform robot. */ address public prvd; /** Provide platform wallet where fees owed to Provide are remitted. */ address public prvdWallet; /** Provide platform wallet where payment amounts owed to providers are escrowed. */ address public paymentEscrow; /** Peer requesting and purchasing service. */ address public peer; /** Peer providing service; compensated in PRVD tokens. */ address public provider; /** Provide platform work order identifier (UUIDv4). */ uint128 public identifier; /** Current status of the work order contract. **/ Status public status; /** Total amount of Provide (PRVD) tokens payable to provider, expressed in wei. */ uint256 public amount; /** Encoded transaction details. */ string public details; /** Emitted when the work order has been started. */ event WorkOrderStarted(uint128 _identifier); /** Emitted when the work order has been completed. */ event WorkOrderCompleted(uint128 _identifier, uint256 _amount, string _details); /** Emitted when the transaction has been completed. */ event TransactionCompleted(uint128 _identifier, uint256 _paymentAmount, uint256 feeAmount, string _details); /** * @param _prvd Provide platform robot contract address * @param _paymentEscrow Provide platform wallet where payment amounts owed to providers are escrowed * @param _peer Address of party purchasing services * @param _identifier Provide platform work order identifier (UUIDv4) */ function ProvideWorkOrder( address _token, address _prvd, address _prvdWallet, address _paymentEscrow, address _peer, uint128 _identifier ) { if (_token == 0x0) revert(); if (_prvd == 0x0) revert(); if (_prvdWallet == 0x0) revert(); if (_paymentEscrow == 0x0) revert(); if (_peer == 0x0) revert(); token = ProvideToken(_token); prvd = _prvd; prvdWallet = _prvdWallet; paymentEscrow = _paymentEscrow; peer = _peer; identifier = _identifier; status = Status.Pending; }
enum Status { Pending, InProgress, Completed, Paid } /** Provide (PRVD) token. */ ProvideToken public token; /** Provide platform robot. */ address public prvd; /** Provide platform wallet where fees owed to Provide are remitted. */ address public prvdWallet; /** Provide platform wallet where payment amounts owed to providers are escrowed. */ address public paymentEscrow; /** Peer requesting and purchasing service. */ address public peer; /** Peer providing service; compensated in PRVD tokens. */ address public provider; /** Provide platform work order identifier (UUIDv4). */ uint128 public identifier; /** Current status of the work order contract. **/ Status public status; /** Total amount of Provide (PRVD) tokens payable to provider, expressed in wei. */ uint256 public amount; /** Encoded transaction details. */ string public details; /** Emitted when the work order has been started. */ event WorkOrderStarted(uint128 _identifier); /** Emitted when the work order has been completed. */ event WorkOrderCompleted(uint128 _identifier, uint256 _amount, string _details); /** Emitted when the transaction has been completed. */ event TransactionCompleted(uint128 _identifier, uint256 _paymentAmount, uint256 feeAmount, string _details); /** * @param _prvd Provide platform robot contract address * @param _paymentEscrow Provide platform wallet where payment amounts owed to providers are escrowed * @param _peer Address of party purchasing services * @param _identifier Provide platform work order identifier (UUIDv4) */ function ProvideWorkOrder( address _token, address _prvd, address _prvdWallet, address _paymentEscrow, address _peer, uint128 _identifier ) { if (_token == 0x0) revert(); if (_prvd == 0x0) revert(); if (_prvdWallet == 0x0) revert(); if (_paymentEscrow == 0x0) revert(); if (_peer == 0x0) revert(); token = ProvideToken(_token); prvd = _prvd; prvdWallet = _prvdWallet; paymentEscrow = _paymentEscrow; peer = _peer; identifier = _identifier; status = Status.Pending; }
2,545
54
// make a refund
investor.transfer(refundValue + msg.value);
investor.transfer(refundValue + msg.value);
28,203
3
// Prevents new contracts from being added or changes to disbursement if permanently locked
bool public isLocked = false; mapping(bytes32 => uint256) public lastClaim; event RewardPaid(address indexed user, uint256 reward);
bool public isLocked = false; mapping(bytes32 => uint256) public lastClaim; event RewardPaid(address indexed user, uint256 reward);
7,575
8
// datacoord = userId_assurId
function addLovers(bytes32 love_hash, string lovemsg, string loveurl) payable { require(bytes(lovemsg).length < 250); require(bytes(loveurl).length < 100); require(msg.value >= price); mapLoveItems[love_hash] = LoveItem(msg.sender, block.number, block.timestamp, lovemsg, loveurl); numLoveItems++; owner.transfer(price); EvLoveItemAdded(love_hash, msg.sender, block.number, block.timestamp, lovemsg, loveurl); }
function addLovers(bytes32 love_hash, string lovemsg, string loveurl) payable { require(bytes(lovemsg).length < 250); require(bytes(loveurl).length < 100); require(msg.value >= price); mapLoveItems[love_hash] = LoveItem(msg.sender, block.number, block.timestamp, lovemsg, loveurl); numLoveItems++; owner.transfer(price); EvLoveItemAdded(love_hash, msg.sender, block.number, block.timestamp, lovemsg, loveurl); }
10,090
166
// Withdraw all funds to get max funds
masterchef.emergencyWithdraw(pid); uint256 newWantBal = want.balanceOf(address(this)); if (newWantBal > amountToFree) {
masterchef.emergencyWithdraw(pid); uint256 newWantBal = want.balanceOf(address(this)); if (newWantBal > amountToFree) {
74,239
31
// list of valid claim
mapping (address => uint) public countClaimsToken; uint256 public priceToken = 950000; uint256 public priceClaim = 0.0005 ether; uint256 public numberClaimToken = 200 * (10**uint256(decimals)); uint256 public startTimeDay = 50400; uint256 public endTimeDay = 51300; event OwnerChanged(address indexed previousOwner, address indexed newOwner); event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
mapping (address => uint) public countClaimsToken; uint256 public priceToken = 950000; uint256 public priceClaim = 0.0005 ether; uint256 public numberClaimToken = 200 * (10**uint256(decimals)); uint256 public startTimeDay = 50400; uint256 public endTimeDay = 51300; event OwnerChanged(address indexed previousOwner, address indexed newOwner); event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
54,402
45
// Getter for allowance: amount spender will be allowed to spend on behalf of owner owner - owner of the tokens spender - entity allowed to spend the tokensreturn uint - remaining amount spender is allowed to transfer /
function allowance(address owner, address spender) external view override returns (uint) { return _allowance[owner][spender]; }
function allowance(address owner, address spender) external view override returns (uint) { return _allowance[owner][spender]; }
6,592
49
// Check that taker pays properly
require(tables[_tableIndex].deposit == msg.value * maxCase); Table storage table = tables[_tableIndex]; table.taker = msg.sender; table.payment = msg.value; table.guessedNum = _guessedNum; table.takingTime = now; emit TableChanged(_tableIndex);
require(tables[_tableIndex].deposit == msg.value * maxCase); Table storage table = tables[_tableIndex]; table.taker = msg.sender; table.payment = msg.value; table.guessedNum = _guessedNum; table.takingTime = now; emit TableChanged(_tableIndex);
25,009
31
// Process sequencer transactions first.
numSequencerTransactions += uint32(curContext.numSequencedTransactions);
numSequencerTransactions += uint32(curContext.numSequencedTransactions);
23,254
13
// 3. Withdraw all the rewards.
masterChef.leaveStaking(0); uint256 reward = farmingToken.myBalance(); if (reward == 0) return;
masterChef.leaveStaking(0); uint256 reward = farmingToken.myBalance(); if (reward == 0) return;
9,196
0
// CHECK maybe implement account verification instead of data structure?address of user => is allowed to mint
mapping(address => bool) private _allowlist;
mapping(address => bool) private _allowlist;
24,617
125
// Transfers collateral from the debtor to the current contract, as custodian.agreementId bytes32 The debt agreement's ID collateralizer address The owner of the asset being collateralized /
function collateralize( bytes32 agreementId, address collateralizer ) public onlyAuthorizedToCollateralize whenNotPaused returns (bool _success)
function collateralize( bytes32 agreementId, address collateralizer ) public onlyAuthorizedToCollateralize whenNotPaused returns (bool _success)
21,326
52
// Modifier that prevents a date change once a drop has started. /
modifier dropNotStarted(uint8 index, uint date) { // the drop we're updating can't be starting within the hour. require(drops[index].date == 0 || drops[index].date > block.timestamp + 3600, "Drop starting too soon"); // the _date value must be two hours out from now require(date > block.timestamp + 7200, "New start date too close"); _; }
modifier dropNotStarted(uint8 index, uint date) { // the drop we're updating can't be starting within the hour. require(drops[index].date == 0 || drops[index].date > block.timestamp + 3600, "Drop starting too soon"); // the _date value must be two hours out from now require(date > block.timestamp + 7200, "New start date too close"); _; }
64,553
129
// Initialize new implementation within proxy-context storage:
(bool _wasInitialized,) = _newImplementation.delegatecall( abi.encodeWithSignature( "initialize(bytes)", _initData ) ); require(_wasInitialized, "WitnetProxy: unable to initialize");
(bool _wasInitialized,) = _newImplementation.delegatecall( abi.encodeWithSignature( "initialize(bytes)", _initData ) ); require(_wasInitialized, "WitnetProxy: unable to initialize");
19,844
47
// Turn off tax for this block
token.disableReflectionForCurrentBlock();
token.disableReflectionForCurrentBlock();
34,416
7
// (pID => name => bool) list of names a player owns.(used so you can change your display name amoungst any name you own)
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_;
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_;
3,944
40
// Get available tokens/
function getMyBalance() public view returns(uint) { return balanceOf(msg.sender); }
function getMyBalance() public view returns(uint) { return balanceOf(msg.sender); }
28,278
192
// wipe
inSync = false; yTokenValueCache = 0; loansValueCache = 0;
inSync = false; yTokenValueCache = 0; loansValueCache = 0;
19,491
11
// validate order
Order untrustedOrder = Order(_order);
Order untrustedOrder = Order(_order);
15,198
20
// get last byte (31st) from block hash as result
result = result_hash[31]; address[] storage winners = bettings[result]; winners_count = winners.length; if (winners_count > 0) { uint256 credit = this.balance / winners_count; for (uint256 i = 0; i < winners_count; i++) { credits[winners[i]] = credit; }
result = result_hash[31]; address[] storage winners = bettings[result]; winners_count = winners.length; if (winners_count > 0) { uint256 credit = this.balance / winners_count; for (uint256 i = 0; i < winners_count; i++) { credits[winners[i]] = credit; }
36,829
33
// Iterate through the list and withdraw all
for (uint256 i = 0; i < depositIds.length; i++) { if (depositIds[i] != 0) { withdrawPosition(depositIds[i], type(uint256).max); }
for (uint256 i = 0; i < depositIds.length; i++) { if (depositIds[i] != 0) { withdrawPosition(depositIds[i], type(uint256).max); }
12,288
116
// Sets the user_contract address _userContract is the new userContract address/
function setUserContract(address _userContract) public onlyOwner() { user_contract = _userContract; }
function setUserContract(address _userContract) public onlyOwner() { user_contract = _userContract; }
72,677
123
// Helper to verify a full merkle proof starting from some seedHash (usually commit). "offset" is the location of the proof beginning in the calldata.
function verifyMerkleProof(uint seedHash, uint offset) pure private returns (bytes32 blockHash, bytes32 uncleHash) { // (Safe) assumption - nobody will write into RAM during this method invocation. uint scratchBuf1; assembly { scratchBuf1 := mload(0x40) } uint uncleHeaderLength; uint blobLength; uint shift; uint hashSlot; // Verify merkle proofs up to uncle block header. Calldata layout is: // - 2 byte big-endian slice length // - 2 byte big-endian offset to the beginning of previous slice hash within the current slice (should be zeroed) // - followed by the current slice verbatim for (;; offset += blobLength) { assembly { blobLength := and(calldataload(sub(offset, 30)), 0xffff) } if (blobLength == 0) { // Zero slice length marks the end of uncle proof. break; } assembly { shift := and(calldataload(sub(offset, 28)), 0xffff) } require (shift + 32 <= blobLength, "Shift bounds check."); offset += 4; assembly { hashSlot := calldataload(add(offset, shift)) } require (hashSlot == 0, "Non-empty hash slot."); assembly { calldatacopy(scratchBuf1, offset, blobLength) mstore(add(scratchBuf1, shift), seedHash) seedHash := sha3(scratchBuf1, blobLength) uncleHeaderLength := blobLength } } // At this moment the uncle hash is known. uncleHash = bytes32(seedHash); // Construct the uncle list of a canonical block. uint scratchBuf2 = scratchBuf1 + uncleHeaderLength; uint unclesLength; assembly { unclesLength := and(calldataload(sub(offset, 28)), 0xffff) } uint unclesShift; assembly { unclesShift := and(calldataload(sub(offset, 26)), 0xffff) } require (unclesShift + uncleHeaderLength <= unclesLength, "Shift bounds check."); offset += 6; assembly { calldatacopy(scratchBuf2, offset, unclesLength) } memcpy(scratchBuf2 + unclesShift, scratchBuf1, uncleHeaderLength); assembly { seedHash := sha3(scratchBuf2, unclesLength) } offset += unclesLength; // Verify the canonical block header using the computed sha3Uncles. assembly { blobLength := and(calldataload(sub(offset, 30)), 0xffff) shift := and(calldataload(sub(offset, 28)), 0xffff) } require (shift + 32 <= blobLength, "Shift bounds check."); offset += 4; assembly { hashSlot := calldataload(add(offset, shift)) } require (hashSlot == 0, "Non-empty hash slot."); assembly { calldatacopy(scratchBuf1, offset, blobLength) mstore(add(scratchBuf1, shift), seedHash) // At this moment the canonical block hash is known. blockHash := sha3(scratchBuf1, blobLength) } }
function verifyMerkleProof(uint seedHash, uint offset) pure private returns (bytes32 blockHash, bytes32 uncleHash) { // (Safe) assumption - nobody will write into RAM during this method invocation. uint scratchBuf1; assembly { scratchBuf1 := mload(0x40) } uint uncleHeaderLength; uint blobLength; uint shift; uint hashSlot; // Verify merkle proofs up to uncle block header. Calldata layout is: // - 2 byte big-endian slice length // - 2 byte big-endian offset to the beginning of previous slice hash within the current slice (should be zeroed) // - followed by the current slice verbatim for (;; offset += blobLength) { assembly { blobLength := and(calldataload(sub(offset, 30)), 0xffff) } if (blobLength == 0) { // Zero slice length marks the end of uncle proof. break; } assembly { shift := and(calldataload(sub(offset, 28)), 0xffff) } require (shift + 32 <= blobLength, "Shift bounds check."); offset += 4; assembly { hashSlot := calldataload(add(offset, shift)) } require (hashSlot == 0, "Non-empty hash slot."); assembly { calldatacopy(scratchBuf1, offset, blobLength) mstore(add(scratchBuf1, shift), seedHash) seedHash := sha3(scratchBuf1, blobLength) uncleHeaderLength := blobLength } } // At this moment the uncle hash is known. uncleHash = bytes32(seedHash); // Construct the uncle list of a canonical block. uint scratchBuf2 = scratchBuf1 + uncleHeaderLength; uint unclesLength; assembly { unclesLength := and(calldataload(sub(offset, 28)), 0xffff) } uint unclesShift; assembly { unclesShift := and(calldataload(sub(offset, 26)), 0xffff) } require (unclesShift + uncleHeaderLength <= unclesLength, "Shift bounds check."); offset += 6; assembly { calldatacopy(scratchBuf2, offset, unclesLength) } memcpy(scratchBuf2 + unclesShift, scratchBuf1, uncleHeaderLength); assembly { seedHash := sha3(scratchBuf2, unclesLength) } offset += unclesLength; // Verify the canonical block header using the computed sha3Uncles. assembly { blobLength := and(calldataload(sub(offset, 30)), 0xffff) shift := and(calldataload(sub(offset, 28)), 0xffff) } require (shift + 32 <= blobLength, "Shift bounds check."); offset += 4; assembly { hashSlot := calldataload(add(offset, shift)) } require (hashSlot == 0, "Non-empty hash slot."); assembly { calldatacopy(scratchBuf1, offset, blobLength) mstore(add(scratchBuf1, shift), seedHash) // At this moment the canonical block hash is known. blockHash := sha3(scratchBuf1, blobLength) } }
28,915
81
// Removes the stakes of the operator with pubkeyHash `pubkeyHash` /
function _removeOperatorStake(bytes32 pubkeyHash) internal returns(uint32) { // gas saving by caching length here uint256 pubkeyHashToStakeHistoryLengthMinusOne = pubkeyHashToStakeHistory[pubkeyHash].length - 1; // determine current stakes OperatorStake memory currentStakes = pubkeyHashToStakeHistory[pubkeyHash][pubkeyHashToStakeHistoryLengthMinusOne]; //set nextUpdateBlockNumber in current stakes pubkeyHashToStakeHistory[pubkeyHash][pubkeyHashToStakeHistoryLengthMinusOne].nextUpdateBlockNumber = uint32(block.number); /** * @notice recording the information pertaining to change in stake for this operator in the history. operator stakes are set to 0 here. */ pubkeyHashToStakeHistory[pubkeyHash].push( OperatorStake({ // recording the current block number where the operator stake got updated updateBlockNumber: uint32(block.number), // mark as 0 since the next update has not yet occurred nextUpdateBlockNumber: 0, // setting the operator's stakes to 0 firstQuorumStake: 0, secondQuorumStake: 0 }) ); // subtract the amounts staked by the operator that is getting deregistered from the total stake // copy latest totalStakes to memory OperatorStake memory _totalStake = totalStakeHistory[totalStakeHistory.length - 1]; _totalStake.firstQuorumStake -= currentStakes.firstQuorumStake; _totalStake.secondQuorumStake -= currentStakes.secondQuorumStake; // update storage of total stake _recordTotalStakeUpdate(_totalStake); emit StakeUpdate( msg.sender, // new stakes are zero 0, 0, uint32(block.number), currentStakes.updateBlockNumber ); return currentStakes.updateBlockNumber; }
function _removeOperatorStake(bytes32 pubkeyHash) internal returns(uint32) { // gas saving by caching length here uint256 pubkeyHashToStakeHistoryLengthMinusOne = pubkeyHashToStakeHistory[pubkeyHash].length - 1; // determine current stakes OperatorStake memory currentStakes = pubkeyHashToStakeHistory[pubkeyHash][pubkeyHashToStakeHistoryLengthMinusOne]; //set nextUpdateBlockNumber in current stakes pubkeyHashToStakeHistory[pubkeyHash][pubkeyHashToStakeHistoryLengthMinusOne].nextUpdateBlockNumber = uint32(block.number); /** * @notice recording the information pertaining to change in stake for this operator in the history. operator stakes are set to 0 here. */ pubkeyHashToStakeHistory[pubkeyHash].push( OperatorStake({ // recording the current block number where the operator stake got updated updateBlockNumber: uint32(block.number), // mark as 0 since the next update has not yet occurred nextUpdateBlockNumber: 0, // setting the operator's stakes to 0 firstQuorumStake: 0, secondQuorumStake: 0 }) ); // subtract the amounts staked by the operator that is getting deregistered from the total stake // copy latest totalStakes to memory OperatorStake memory _totalStake = totalStakeHistory[totalStakeHistory.length - 1]; _totalStake.firstQuorumStake -= currentStakes.firstQuorumStake; _totalStake.secondQuorumStake -= currentStakes.secondQuorumStake; // update storage of total stake _recordTotalStakeUpdate(_totalStake); emit StakeUpdate( msg.sender, // new stakes are zero 0, 0, uint32(block.number), currentStakes.updateBlockNumber ); return currentStakes.updateBlockNumber; }
34,102
21
// Returns the Artist of the collection/
function getArtist() public view returns (address payable) { return artist; }
function getArtist() public view returns (address payable) { return artist; }
43,120
188
// Fees are deducted at resolution, so remove them if we're still bidding or trading.
return resolved ? _deposited : _deposited.multiplyDecimalRound(_feeMultiplier);
return resolved ? _deposited : _deposited.multiplyDecimalRound(_feeMultiplier);
2,763
13
// set new strategist address to receive strat fees
function setStrategist(address _strategist) external { require(msg.sender == strategist, "!strategist"); strategist = _strategist; emit SetStrategist(_strategist); }
function setStrategist(address _strategist) external { require(msg.sender == strategist, "!strategist"); strategist = _strategist; emit SetStrategist(_strategist); }
11,453
40
// Mapping of modules to fee types to fee percentage. A module can have multiple feeTypes Fee is denominated in precise unit percentages (100% = 1e18, 1% = 1e16)
mapping(address => mapping(uint256 => uint256)) public fees;
mapping(address => mapping(uint256 => uint256)) public fees;
20,003
275
// Claim the remaining unclaimed rewards for a user, and send them to that user.Reverts if the provided Merkle proof is invalid. userAddress of the user.cumulativeAmountThe total all-time rewards this user has earned.merkleProof The Merkle proof for the user and cumulative amount. return The number of rewards tokens claimed. /
function _claimRewards( address user, uint256 cumulativeAmount, bytes32[] calldata merkleProof ) internal returns (uint256)
function _claimRewards( address user, uint256 cumulativeAmount, bytes32[] calldata merkleProof ) internal returns (uint256)
77,499
31
// revert("Chain not valid");
swapRouter = IRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
swapRouter = IRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
19,234
34
// Trigger the event for a new purchase
PurchaseMade(msg.sender, paymentCode, msg.value);
PurchaseMade(msg.sender, paymentCode, msg.value);
38,354
69
// Do not pay into PriceOracle. /
function() external payable { revert(); }
function() external payable { revert(); }
10,416
21
// Function that connext will call on destination chain. Call arbitray contract depending on callData. Transfer tokens to rescuer, if call fails/transferId Connext transferId
/// @param amount Amount of {asset} that was transfered on this contract before call /// @param asset Address of token that was transfered /// @param originSender Address of caller on source chain /// @param origin Id(not chain id) of source chain /// @param callData If called as a result of MultiTB._multiRun, equal to abi.encode(CallDataParam) function xReceive( bytes32 transferId, uint256 amount, address asset, address originSender, uint32 origin, bytes memory callData ) external returns (bytes memory result) { try iMultiTB(address(this)).decodeAndRun( transferId, amount, asset, originSender, origin, callData ) {} catch { // This happen if callData can't be decoded // This case should never happen, as long as xcall called from this contract // In such scenario we don't know user address // So we send it to address, ontrolled by us, to later send back user funds IERC20(asset).transfer(rescuer, amount); emit TotalFail(transferId, originSender, origin); }
/// @param amount Amount of {asset} that was transfered on this contract before call /// @param asset Address of token that was transfered /// @param originSender Address of caller on source chain /// @param origin Id(not chain id) of source chain /// @param callData If called as a result of MultiTB._multiRun, equal to abi.encode(CallDataParam) function xReceive( bytes32 transferId, uint256 amount, address asset, address originSender, uint32 origin, bytes memory callData ) external returns (bytes memory result) { try iMultiTB(address(this)).decodeAndRun( transferId, amount, asset, originSender, origin, callData ) {} catch { // This happen if callData can't be decoded // This case should never happen, as long as xcall called from this contract // In such scenario we don't know user address // So we send it to address, ontrolled by us, to later send back user funds IERC20(asset).transfer(rescuer, amount); emit TotalFail(transferId, originSender, origin); }
16,984
223
// Get chain idreturn The the chain id /
function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; }
function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; }
9,619
128
// The address has not chosen explicitly, so use the default for its type.
if (Address.isContract(_account)) {
if (Address.isContract(_account)) {
33,939
6
// Allows the proxy owner to upgrade the current version of the proxy.implementation representing the address of the new implementation to be set./
function upgradeTo(address implementation) public onlyProxyOwner { require(block.timestamp < expiration(), "after expiration date"); super.upgradeTo(implementation); }
function upgradeTo(address implementation) public onlyProxyOwner { require(block.timestamp < expiration(), "after expiration date"); super.upgradeTo(implementation); }
19,532
116
// We always update the nonce of the creating account, even if the creation fails.
_setAccountNonce(ovmADDRESS(), _getAccountNonce(ovmADDRESS()) + 1);
_setAccountNonce(ovmADDRESS(), _getAccountNonce(ovmADDRESS()) + 1);
79,354
186
// Remove a future platform from the registry _futurePlatformName the name of the future platform to remove from the registry /
function removeFuturePlatform(string memory _futurePlatformName) external;
function removeFuturePlatform(string memory _futurePlatformName) external;
49,011
32
// LIBRARY UPGRADE step 3: stop receiving messages from the old version
function setDefaultReceiveVersion(uint16 _newDefaultReceiveVersion) external onlyOwner validVersion(_newDefaultReceiveVersion) { require(_newDefaultReceiveVersion != DEFAULT_VERSION, "LayerZero: default receive version must > 0"); defaultReceiveVersion = _newDefaultReceiveVersion; defaultReceiveLibraryAddress = address(libraryLookup[defaultReceiveVersion]); emit DefaultReceiveVersionSet(_newDefaultReceiveVersion); }
function setDefaultReceiveVersion(uint16 _newDefaultReceiveVersion) external onlyOwner validVersion(_newDefaultReceiveVersion) { require(_newDefaultReceiveVersion != DEFAULT_VERSION, "LayerZero: default receive version must > 0"); defaultReceiveVersion = _newDefaultReceiveVersion; defaultReceiveLibraryAddress = address(libraryLookup[defaultReceiveVersion]); emit DefaultReceiveVersionSet(_newDefaultReceiveVersion); }
1,715
33
// Give the tokens to the withdrawer
stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount);
stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount);
32,028
90
// 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; }
6,856
128
// Remove the ask on a piece of media /
function removeAsk(uint256 tokenId) external;
function removeAsk(uint256 tokenId) external;
25,813
73
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0; if (time >= vesting) return tokens;
if (time < cliff) return 0; if (time >= vesting) return tokens;
21,181
15
// Initiate transfer of the admin rolenewAdmin The address of the new admin
function transferAdministration(address newAdmin) external onlyAdmin { if (newAdmin == address(0)) revert InvalidAccount(); if (newAdmin == admin) revert InvalidAccount(); pendingAdmin = newAdmin; emit AdministrationTransferStarted(admin, newAdmin); }
function transferAdministration(address newAdmin) external onlyAdmin { if (newAdmin == address(0)) revert InvalidAccount(); if (newAdmin == admin) revert InvalidAccount(); pendingAdmin = newAdmin; emit AdministrationTransferStarted(admin, newAdmin); }
24,124
9
// Burnable introduces a burner role, which could be used to destroy/tokens. The burner address could be changed by himself.
contract Burnable is Controlled { address public burner; /// @notice The function with this modifier could be called by a controller /// as well as by a burner. But burner could use the onlt his/her address as /// a target. modifier onlyControllerOrBurner(address target) { assert(msg.sender == controller || (msg.sender == burner && msg.sender == target)); _; } modifier onlyBurner { assert(msg.sender == burner); _; } /// Contract creator become a burner by default function Burnable() public { burner = msg.sender;} /// @notice Change a burner address /// @param _newBurner The new burner address function changeBurner(address _newBurner) public onlyBurner { burner = _newBurner; } }
contract Burnable is Controlled { address public burner; /// @notice The function with this modifier could be called by a controller /// as well as by a burner. But burner could use the onlt his/her address as /// a target. modifier onlyControllerOrBurner(address target) { assert(msg.sender == controller || (msg.sender == burner && msg.sender == target)); _; } modifier onlyBurner { assert(msg.sender == burner); _; } /// Contract creator become a burner by default function Burnable() public { burner = msg.sender;} /// @notice Change a burner address /// @param _newBurner The new burner address function changeBurner(address _newBurner) public onlyBurner { burner = _newBurner; } }
11,842