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 |
|---|---|---|---|---|
8 | // Overrides _mintWithoutURI(...) from ERC1155MultiURI, providing anadditional condition to check if a token is non-mintable. / | function _mintWithoutURI(
address to,
uint256 id,
uint256 amount,
bytes memory data
| function _mintWithoutURI(
address to,
uint256 id,
uint256 amount,
bytes memory data
| 54,889 |
62 | // _to ์ง๊ฐ์ผ๋ก _cbmWei ๋งํผ์ Cbm๋ฅผ ์ก๊ธํ๊ณ _timeLockUpEnd ์๊ฐ๋งํผ ์ง๊ฐ์ ์ ๊ทผ๋ค _to ํ ํฐ์ ๋ฐ๋ ์ง๊ฐ ์ฃผ์ _cbmWei ์ ์ก๋๋ ํ ํฐ์ ์(wei) _timeLockUpEnd ์ ๊ธ์ด ํด์ ๋๋ ์๊ฐ / | function transferAndLockUntil(address _to, uint256 _cbmWei, uint _timeLockUpEnd) onlyOwner public {
require(transfer(_to, _cbmWei));
walletLockBoth(_to, _timeLockUpEnd);
}
| function transferAndLockUntil(address _to, uint256 _cbmWei, uint _timeLockUpEnd) onlyOwner public {
require(transfer(_to, _cbmWei));
walletLockBoth(_to, _timeLockUpEnd);
}
| 13,219 |
122 | // get the extension of a given token / | function tokenExtension(uint256 tokenId) external view returns (address);
| function tokenExtension(uint256 tokenId) external view returns (address);
| 19,462 |
65 | // ----------HELPERS AND CALCULATORS----------//Method to view the current Hex stored in the contractExample: totalHexBalance() / | function totalHexBalance()
public
view
returns(uint)
| function totalHexBalance()
public
view
returns(uint)
| 27,973 |
34 | // deleting participant from list | ico.participants[ico.participantsList[ico.totalParticipants]].index = p.index;
ico.participantsList[p.index] = ico.participantsList[ico.totalParticipants];
delete ico.participantsList[ico.totalParticipants--];
delete ico.participants[msg.sender];
| ico.participants[ico.participantsList[ico.totalParticipants]].index = p.index;
ico.participantsList[p.index] = ico.participantsList[ico.totalParticipants];
delete ico.participantsList[ico.totalParticipants--];
delete ico.participants[msg.sender];
| 54,093 |
30 | // Accrue interest then return the up-to-date exchange ratereturn Calculated exchange rate scaled by 1e18 / | function exchangeRateCurrent() public returns (uint256) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature('exchangeRateCurrent()'));
return abi.decode(data, (uint256));
}
| function exchangeRateCurrent() public returns (uint256) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature('exchangeRateCurrent()'));
return abi.decode(data, (uint256));
}
| 27,352 |
82 | // update global info | totalDebtGlobal = totalDebtGlobal + _borrowWithLocked; // should not overflow.
| totalDebtGlobal = totalDebtGlobal + _borrowWithLocked; // should not overflow.
| 84,397 |
88 | // Calculate total fee to be taken | fee = expectedAmount.mul(feePercent).div(10000);
| fee = expectedAmount.mul(feePercent).div(10000);
| 3,633 |
82 | // Interface of the ERC3156 FlashBorrower, as defined in _Available since v4.1._ / | interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}
| interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}
| 9,510 |
16 | // Allow the player to attack the boss | if (bigBoss.hp < player.attackDamage) {
bigBoss.hp = 0;
} else {
| if (bigBoss.hp < player.attackDamage) {
bigBoss.hp = 0;
} else {
| 53,526 |
24 | // Split Signature Validation utility / | function _splitSignature(bytes memory sig) private pure returns (bytes32 r, bytes32 s, uint8 v) {
require(sig.length == 65, "Invalid signature length.");
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := byte(0, mload(add(sig, 96)))
}
}
| function _splitSignature(bytes memory sig) private pure returns (bytes32 r, bytes32 s, uint8 v) {
require(sig.length == 65, "Invalid signature length.");
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := byte(0, mload(add(sig, 96)))
}
}
| 76,755 |
82 | // Distributes rewards among pools at the latest block of a staking epoch./ This function is called by the `reward` function./_stakingContract The address of the StakingAuRa contract./_stakingEpoch The number of the current staking epoch./_stakingEpochEndBlock The number of the latest block of the current staking epoch./ return Returns the reward amount in native coins needed to be minted/ and accrued to the balance of this contract. | function _distributeRewards(
IStakingAuRa _stakingContract,
uint256 _stakingEpoch,
uint256 _stakingEpochEndBlock
| function _distributeRewards(
IStakingAuRa _stakingContract,
uint256 _stakingEpoch,
uint256 _stakingEpochEndBlock
| 13,257 |
32 | // Get RATIO | return div(mul(add(outs[1], removableSushi), 1e18), gSushi.totalSupply());
| return div(mul(add(outs[1], removableSushi), 1e18), gSushi.totalSupply());
| 4,351 |
204 | // Converts passed bytes to V2 path pathBytes Swap path in bytes, converted to addressesreturn path list of addresses in the swap path (skipping first and last element) / | function _getV2Path(bytes calldata pathBytes) internal pure returns(address[] memory) {
require(pathBytes.length > ACTION_SIZE, "SwapHelper::_getV2Path: No path provided");
uint256 actualpathSize = pathBytes.length - ACTION_SIZE;
require(actualpathSize % ADDR_SIZE == 0 && actualpathSize <= MAX_V2_PATH, "SwapHelper::_getV2Path: Bad V2 path");
uint256 pathLength = actualpathSize / ADDR_SIZE;
address[] memory path = new address[](pathLength + 2);
// ignore first byte
path[1] = pathBytes.toAddress(ACTION_SIZE);
for (uint256 i = 1; i < pathLength; i++) {
path[i + 1] = pathBytes.toAddress(i * ADDR_SIZE + ACTION_SIZE);
}
return path;
}
| function _getV2Path(bytes calldata pathBytes) internal pure returns(address[] memory) {
require(pathBytes.length > ACTION_SIZE, "SwapHelper::_getV2Path: No path provided");
uint256 actualpathSize = pathBytes.length - ACTION_SIZE;
require(actualpathSize % ADDR_SIZE == 0 && actualpathSize <= MAX_V2_PATH, "SwapHelper::_getV2Path: Bad V2 path");
uint256 pathLength = actualpathSize / ADDR_SIZE;
address[] memory path = new address[](pathLength + 2);
// ignore first byte
path[1] = pathBytes.toAddress(ACTION_SIZE);
for (uint256 i = 1; i < pathLength; i++) {
path[i + 1] = pathBytes.toAddress(i * ADDR_SIZE + ACTION_SIZE);
}
return path;
}
| 61,128 |
2 | // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); | bytes32 private constant _TYPE_HASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
| bytes32 private constant _TYPE_HASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
| 26,148 |
12 | // Save the hash of the message inthe state variable. | messages[hash] = expireAt;
| messages[hash] = expireAt;
| 27,359 |
25 | // The number of tokens this contract actually supports | uint public immutable numTokens;
address internal immutable cToken00;
address internal immutable cToken01;
address internal immutable cToken02;
address internal immutable cToken03;
address internal immutable cToken04;
address internal immutable cToken05;
address internal immutable cToken06;
address internal immutable cToken07;
| uint public immutable numTokens;
address internal immutable cToken00;
address internal immutable cToken01;
address internal immutable cToken02;
address internal immutable cToken03;
address internal immutable cToken04;
address internal immutable cToken05;
address internal immutable cToken06;
address internal immutable cToken07;
| 62,641 |
140 | // ------------------------------------------------------------------------ Owner can transfer out any accidentally sent ERC20 tokens ------------------------------------------------------------------------ | function withdrawAnyToken(address _tokenAddress, address _transferTo, uint _value) private returns (bool success) {
return IERC20(_tokenAddress).transfer(_transferTo, _value);
}
| function withdrawAnyToken(address _tokenAddress, address _transferTo, uint _value) private returns (bool success) {
return IERC20(_tokenAddress).transfer(_transferTo, _value);
}
| 186 |
46 | // This cannot be a delayed writing as we are writing the option now | _order.isDelayedWriting = false;
IPremiaOption optionContract = IPremiaOption(_order.optionContract);
_order.optionId = optionContract.writeOptionFrom(msg.sender, _option, _referrer);
return createOrder(_order, _option.amount);
| _order.isDelayedWriting = false;
IPremiaOption optionContract = IPremiaOption(_order.optionContract);
_order.optionId = optionContract.writeOptionFrom(msg.sender, _option, _referrer);
return createOrder(_order, _option.amount);
| 50,524 |
161 | // Performs a Solidity function call using a low level `call`. Aplain `call` is an unsafe replacement for a function call: use thisfunction instead. If `target` reverts with a revert reason, it is bubbled up by thisfunction (like regular Solidity function calls). Returns the raw returned data. Requirements: - `target` must be a contract.- calling `target` with `data` must not revert. _Available since v3.1._ / | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, 'Address: low-level call failed');
}
| function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, 'Address: low-level call failed');
}
| 45,624 |
6 | // Use the bid counter to assign the index if there is not an active bid. | bidIndex = bidCounterByToken[_tokenAddress][_tokenId];
| bidIndex = bidCounterByToken[_tokenAddress][_tokenId];
| 51,064 |
28 | // Initiate rewards program for all reward tokens in pool reward amounts must be ordered based on the initial reward token order each reward token will be initialized with exactly the reward amount set here clrPool pool to initiate rewards for totalRewardAmounts array of reward amounts for each reward token / | function _initiateRewardsProgram(
ICLR clrPool,
uint256[] memory totalRewardAmounts
| function _initiateRewardsProgram(
ICLR clrPool,
uint256[] memory totalRewardAmounts
| 63,845 |
158 | // View function to see pending PLATIN on frontend. | function pendingPlatin(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accPlatinPerShare = pool.accPlatinPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 platinReward = multiplier.mul(platinPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accPlatinPerShare = accPlatinPerShare.add(platinReward.mul(1e18).div(lpSupply));
}
return user.amount.mul(accPlatinPerShare).div(1e18).sub(user.rewardDebt);
}
| function pendingPlatin(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accPlatinPerShare = pool.accPlatinPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 platinReward = multiplier.mul(platinPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accPlatinPerShare = accPlatinPerShare.add(platinReward.mul(1e18).div(lpSupply));
}
return user.amount.mul(accPlatinPerShare).div(1e18).sub(user.rewardDebt);
}
| 21,754 |
185 | // Get the uri for a given creator/tokenId / | function tokenURI(address creator, uint256 tokenId) external view returns (string memory);
| function tokenURI(address creator, uint256 tokenId) external view returns (string memory);
| 2,097 |
2 | // Write out zeros | pos := add(pos, 2)
let length := and(calldataload(add(36, pos)), 0xFFFF)
codecopy(ptr, codesize(), length)
ptr := add(ptr, length)
| pos := add(pos, 2)
let length := and(calldataload(add(36, pos)), 0xFFFF)
codecopy(ptr, codesize(), length)
ptr := add(ptr, length)
| 48,977 |
81 | // If seed sale ends and soft cap is not reached, Contributer can claim their funds | function refund() public {
require(refundAllowed);
require(!SoftCapReached);
require(weiContributedPending[msg.sender] > 0);
uint256 currentBalance = weiContributedPending[msg.sender];
weiContributedPending[msg.sender] = 0;
msg.sender.transfer(currentBalance);
}
| function refund() public {
require(refundAllowed);
require(!SoftCapReached);
require(weiContributedPending[msg.sender] > 0);
uint256 currentBalance = weiContributedPending[msg.sender];
weiContributedPending[msg.sender] = 0;
msg.sender.transfer(currentBalance);
}
| 33,341 |
11 | // SafeMathMath operations with safety checks that throw on error/ | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than
minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
| library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than
minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
| 9,483 |
109 | // Increment the reward to transfer | rewardInDexTokenToTransfer += rewardForTicketId;
| rewardInDexTokenToTransfer += rewardForTicketId;
| 53,490 |
65 | // 18 decimals | constructor() ERC20("Small Business Coin", "SBC") {
_mint(_msgSender(), 100_000_000 * (10 ** uint256(decimals())));
}
| constructor() ERC20("Small Business Coin", "SBC") {
_mint(_msgSender(), 100_000_000 * (10 ** uint256(decimals())));
}
| 15,483 |
125 | // Sets the number of unwithdrawn rewards to 0. / | setPendingWithdrawal(_property, msg.sender, 0);
| setPendingWithdrawal(_property, msg.sender, 0);
| 34,976 |
66 | // Mints assetClass token, must be isAdmin / | function mintACToken(
address _recipientAddress,
uint256 tokenId,
string calldata _tokenURI
) external returns (uint256);
| function mintACToken(
address _recipientAddress,
uint256 tokenId,
string calldata _tokenURI
) external returns (uint256);
| 34,171 |
22 | // sub from balance of sender | _kassiahomeBalances[msg.sender] = _kassiahomeBalances[msg.sender].sub(kassiahomeValue);
| _kassiahomeBalances[msg.sender] = _kassiahomeBalances[msg.sender].sub(kassiahomeValue);
| 21,283 |
286 | // If the provided asset is not supported by the Turbo Fuse Pool, revert. | require(address(assetTurboCToken) != address(0), "UNSUPPORTED_ASSET");
| require(address(assetTurboCToken) != address(0), "UNSUPPORTED_ASSET");
| 71,847 |
49 | // Settings for eggs minted by administration | contract EggMinting is PetOwnership{
uint8 public uniquePetsCount = 100;
uint16 public globalPresaleLimit = 1500;
mapping (uint16 => uint16) public eggLimits;
mapping (uint16 => uint16) public purchesedEggs;
constructor() public {
eggLimits[55375] = 200;
eggLimits[47780] = 400;
eggLimits[38820] = 100;
eggLimits[31201] = 50;
}
function totalSupply() public view returns (uint) {
return tokensCount;
}
function setEggLimit(uint16 quality, uint16 limit) external onlyOwner {
eggLimits[quality] = limit;
}
function eggAvailable(uint16 quality) constant public returns(bool) {
// first 100 eggs - only cheap
if( quality < 47000 && tokensCount < ( 100 + uniquePetsCount ) )
return false;
return (eggLimits[quality] > purchesedEggs[quality]);
}
}
| contract EggMinting is PetOwnership{
uint8 public uniquePetsCount = 100;
uint16 public globalPresaleLimit = 1500;
mapping (uint16 => uint16) public eggLimits;
mapping (uint16 => uint16) public purchesedEggs;
constructor() public {
eggLimits[55375] = 200;
eggLimits[47780] = 400;
eggLimits[38820] = 100;
eggLimits[31201] = 50;
}
function totalSupply() public view returns (uint) {
return tokensCount;
}
function setEggLimit(uint16 quality, uint16 limit) external onlyOwner {
eggLimits[quality] = limit;
}
function eggAvailable(uint16 quality) constant public returns(bool) {
// first 100 eggs - only cheap
if( quality < 47000 && tokensCount < ( 100 + uniquePetsCount ) )
return false;
return (eggLimits[quality] > purchesedEggs[quality]);
}
}
| 36,724 |
2 | // Callback function / | function fulfillWindSpeed(bytes32 _requestId, uint256 _windSpeed) public recordChainlinkFulfillment(_requestId) {
windSpeed = _windSpeed;
}
| function fulfillWindSpeed(bytes32 _requestId, uint256 _windSpeed) public recordChainlinkFulfillment(_requestId) {
windSpeed = _windSpeed;
}
| 43,642 |
34 | // - Getter Function / | function balanceOfContract() public view returns (uint balanceOfContract_DAI, uint balanceOfContract_ETH) {
return (dai.balanceOf(address(this)), address(this).balance);
}
| function balanceOfContract() public view returns (uint balanceOfContract_DAI, uint balanceOfContract_ETH) {
return (dai.balanceOf(address(this)), address(this).balance);
}
| 49,464 |
84 | // Set the migrator contract (only the owner may call) | function setMigrator(ILpTokenMigrator _migrator) external;
| function setMigrator(ILpTokenMigrator _migrator) external;
| 32,003 |
30 | // 40% of holders approx |
uint256 public B = 5;
|
uint256 public B = 5;
| 36,572 |
175 | // if the order in book did NOT fully deal, then this new order DID fully deal, so stop here | if(orderInBook.amount != 0) {
_setOrder(!isBuy, currID, orderInBook);
break;
}
| if(orderInBook.amount != 0) {
_setOrder(!isBuy, currID, orderInBook);
break;
}
| 28,056 |
998 | // 501 | entry "clerkly" : ENG_ADVERB
| entry "clerkly" : ENG_ADVERB
| 21,337 |
414 | // keep track of token pricing when purchased | mapping(uint256 => address) internal _originalTokens;
mapping(address => uint) public referrerFees;
| mapping(uint256 => address) internal _originalTokens;
mapping(address => uint) public referrerFees;
| 37,866 |
184 | // chance of burning the donor trait is a flat 1/3 | if (rn.generate(1, 3) == 1) {
donorBurnt = true;
donor.genesis = false;
| if (rn.generate(1, 3) == 1) {
donorBurnt = true;
donor.genesis = false;
| 11,281 |
20 | // Current balances of contract -bank- available reward value -stock - available value for restore bank in emergency | uint256 public bank = 0;
uint256 public stock = 0;
| uint256 public bank = 0;
uint256 public stock = 0;
| 18,616 |
400 | // res += valcoefficients[80]. | res := addmod(res,
mulmod(val, /*coefficients[80]*/ mload(0xf40), PRIME),
PRIME)
| res := addmod(res,
mulmod(val, /*coefficients[80]*/ mload(0xf40), PRIME),
PRIME)
| 32,173 |
41 | // When a user calls `exitPool`, this is the first point of entry from the Vault. We first check whether this is a Recovery Mode exit - if so, we proceed using this special lightweight exit mechanism which avoids computing any complex values, interacting with external contracts, etc., and generally should always work, even if the Pool's mathematics or a dependency break down. | if (userData.isRecoveryModeExitKind()) {
| if (userData.isRecoveryModeExitKind()) {
| 25,936 |
19 | // Deposits made with deposit() go to this function | function deposit() external payable onlyIfCreator {
availableFunds = availableFunds + msg.value;
}
| function deposit() external payable onlyIfCreator {
availableFunds = availableFunds + msg.value;
}
| 26,571 |
70 | // Staking contract for farming LPT rewards in return for staking a whitelisted token(s)/BlockRocket.tech/Fork of MasterChef.sol from SushiSwap/Only the owner can add new pools | contract LaunchPoolStaking is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/// @dev Details about each user in a pool
struct UserInfo {
uint256 amount; // How many tokens the user has provided to a pool
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of LPTs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accLptPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws ERC20 tokens to a pool. Here's what happens:
// 1. The pool's `accLptPerShare` (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.
}
/// @dev Info of each pool.
struct PoolInfo {
IERC20 erc20Token; // Address of token contract.
uint256 allocPoint; // How many allocation points assigned to this pool; this is a weighting for rewards.
uint256 lastRewardBlock; // Last block number that LPT distribution has occurred up to endBlock.
uint256 accLptPerShare; // Per LP token staked, how much LPT earned in pool that users will get
uint256 maxStakingAmountPerUser; // Max. amount of tokens that can be staked per account/user
}
/// @notice The reward token aka $LPT
LaunchPoolToken public lpt;
/// @notice Number of LPT tokens distributed per block, across all pools.
uint256 public lptPerBlock;
/// @notice The total amount of reward token available for farming across all pools between start and end block.
uint256 public maxLPTAvailableForFarming;
/// @notice List of pools that users can stake into
PoolInfo[] public poolInfo;
/// @notice Per pool, info of each user that stakes ERC20 tokens.
/// @notice Pool ID => User Address => User Info
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
/// @notice Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint;
/// @notice The block number when LPT rewards starts across all pools.
uint256 public startBlock;
/// @notice The block number when rewards ends.
uint256 public endBlock;
/// @notice Tracks ERC20 tokens added by owner
mapping(address => bool) isErc20TokenWhitelisted;
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);
/// @param _lpt Address of the LPT reward token
/// @param _maxLPTAvailableForFarming Maximum number of LPT that will be distributed between the start and end of farming
/// @param _startBlock Block number when farming will begin for all pools
/// @param _endBlock Block number when farming will end for all pools
constructor(
LaunchPoolToken _lpt,
uint256 _maxLPTAvailableForFarming,
uint256 _startBlock,
uint256 _endBlock
) public {
require(address(_lpt) != address(0), "constructor: _lpt must not be zero address");
require(_maxLPTAvailableForFarming > 0, "constructor: _maxLPTAvailableForFarming must be greater than zero");
lpt = _lpt;
maxLPTAvailableForFarming = _maxLPTAvailableForFarming;
startBlock = _startBlock;
endBlock = _endBlock;
uint256 numberOfBlocksForFarming = endBlock.sub(startBlock);
lptPerBlock = maxLPTAvailableForFarming.div(numberOfBlocksForFarming);
}
/// @notice Returns the number of pools that have been added by the owner
/// @return Number of pools
function numberOfPools() external view returns (uint256) {
return poolInfo.length;
}
/// @notice Create a new LPT pool by whitelisting a new ERC20 token.
/// @dev Can only be called by the contract owner
/// @param _allocPoint Governs what percentage of the total LPT rewards this pool and other pools will get
/// @param _erc20Token Address of the staking token being whitelisted
/// @param _maxStakingAmountPerUser For this pool, maximum amount per user that can be staked
/// @param _withUpdate Set to true for updating all pools before adding this one
function add(uint256 _allocPoint, IERC20 _erc20Token, uint256 _maxStakingAmountPerUser, bool _withUpdate) public onlyOwner {
require(block.number < endBlock, "add: must be before end");
address erc20TokenAddress = address(_erc20Token);
require(erc20TokenAddress != address(0), "add: _erc20Token must not be zero address");
require(isErc20TokenWhitelisted[erc20TokenAddress] == false, "add: already whitelisted");
require(_maxStakingAmountPerUser > 0, "add: _maxStakingAmountPerUser must be greater than zero");
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
erc20Token : _erc20Token,
allocPoint : _allocPoint,
lastRewardBlock : lastRewardBlock,
accLptPerShare : 0,
maxStakingAmountPerUser: _maxStakingAmountPerUser
}));
isErc20TokenWhitelisted[erc20TokenAddress] = true;
}
/// @notice Update a pool's allocation point to increase or decrease its share of contract-level rewards
/// @notice Can also update the max amount that can be staked per user
/// @dev Can only be called by the owner
/// @param _pid ID of the pool being updated
/// @param _allocPoint New allocation point
/// @param _maxStakingAmountPerUser Maximum amount that a user can deposit into the far
/// @param _withUpdate Set to true if you want to update all pools before making this change - it will checkpoint those rewards
function set(uint256 _pid, uint256 _allocPoint, uint256 _maxStakingAmountPerUser, bool _withUpdate) public onlyOwner {
require(block.number < endBlock, "set: must be before end");
require(_pid < poolInfo.length, "set: invalid _pid");
require(_maxStakingAmountPerUser > 0, "set: _maxStakingAmountPerUser must be greater than zero");
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
poolInfo[_pid].maxStakingAmountPerUser = _maxStakingAmountPerUser;
}
/// @notice View function to see pending and unclaimed LPTs for a given user
/// @param _pid ID of the pool where a user has a stake
/// @param _user Account being queried
/// @return Amount of LPT tokens due to a user
function pendingLpt(uint256 _pid, address _user) external view returns (uint256) {
require(_pid < poolInfo.length, "pendingLpt: invalid _pid");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accLptPerShare = pool.accLptPerShare;
uint256 lpSupply = pool.erc20Token.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 maxEndBlock = block.number <= endBlock ? block.number : endBlock;
uint256 multiplier = getMultiplier(pool.lastRewardBlock, maxEndBlock);
uint256 lptReward = multiplier.mul(lptPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accLptPerShare = accLptPerShare.add(lptReward.mul(1e18).div(lpSupply));
}
return user.amount.mul(accLptPerShare).div(1e18).sub(user.rewardDebt);
}
/// @notice Cycles through the pools to update all of the rewards accrued
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
/// @notice Updates a specific pool to track all of the rewards accrued up to the TX block
/// @param _pid ID of the pool
function updatePool(uint256 _pid) public {
require(_pid < poolInfo.length, "updatePool: invalid _pid");
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 erc20Supply = pool.erc20Token.balanceOf(address(this));
if (erc20Supply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 maxEndBlock = block.number <= endBlock ? block.number : endBlock;
uint256 multiplier = getMultiplier(pool.lastRewardBlock, maxEndBlock);
// No point in doing any more logic as the rewards have ended
if (multiplier == 0) {
return;
}
uint256 lptReward = multiplier.mul(lptPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
pool.accLptPerShare = pool.accLptPerShare.add(lptReward.mul(1e18).div(erc20Supply));
pool.lastRewardBlock = maxEndBlock;
}
/// @notice Where any user can stake their ERC20 tokens into a pool in order to farm $LPT
/// @param _pid ID of the pool
/// @param _amount Amount of ERC20 being staked
function deposit(uint256 _pid, uint256 _amount) external {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount.add(_amount) <= pool.maxStakingAmountPerUser, "deposit: can not exceed max staking amount per user");
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accLptPerShare).div(1e18).sub(user.rewardDebt);
if (pending > 0) {
safeLptTransfer(msg.sender, pending);
}
}
if (_amount > 0) {
pool.erc20Token.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
}
user.rewardDebt = user.amount.mul(pool.accLptPerShare).div(1e18);
emit Deposit(msg.sender, _pid, _amount);
}
/// @notice Allows a user to withdraw any ERC20 tokens staked in a pool
/// @dev Partial withdrawals permitted
/// @param _pid Pool ID
/// @param _amount Being withdrawn
function withdraw(uint256 _pid, uint256 _amount) external {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: _amount not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accLptPerShare).div(1e18).sub(user.rewardDebt);
if (pending > 0) {
safeLptTransfer(msg.sender, pending);
}
if (_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.erc20Token.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accLptPerShare).div(1e18);
emit Withdraw(msg.sender, _pid, _amount);
}
/// @notice Emergency only. Should the rewards issuance mechanism fail, people can still withdraw their stake
/// @param _pid Pool ID
function emergencyWithdraw(uint256 _pid) external {
require(_pid < poolInfo.length, "updatePool: invalid _pid");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
pool.erc20Token.safeTransfer(address(msg.sender), amount);
emit EmergencyWithdraw(msg.sender, _pid, amount);
}
////////////
// Private /
////////////
/// @dev Safe LPT transfer function, just in case if rounding error causes pool to not have enough LPTs.
/// @param _to Whom to send LPT into
/// @param _amount of LPT to send
function safeLptTransfer(address _to, uint256 _amount) private {
uint256 lptBal = lpt.balanceOf(address(this));
if (_amount > lptBal) {
lpt.transfer(_to, lptBal);
} else {
lpt.transfer(_to, _amount);
}
}
/// @notice Return reward multiplier over the given _from to _to block.
/// @param _from Block number
/// @param _to Block number
/// @return Number of blocks that have passed
function getMultiplier(uint256 _from, uint256 _to) private view returns (uint256) {
return _to.sub(_from);
}
}
| contract LaunchPoolStaking is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/// @dev Details about each user in a pool
struct UserInfo {
uint256 amount; // How many tokens the user has provided to a pool
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of LPTs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accLptPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws ERC20 tokens to a pool. Here's what happens:
// 1. The pool's `accLptPerShare` (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.
}
/// @dev Info of each pool.
struct PoolInfo {
IERC20 erc20Token; // Address of token contract.
uint256 allocPoint; // How many allocation points assigned to this pool; this is a weighting for rewards.
uint256 lastRewardBlock; // Last block number that LPT distribution has occurred up to endBlock.
uint256 accLptPerShare; // Per LP token staked, how much LPT earned in pool that users will get
uint256 maxStakingAmountPerUser; // Max. amount of tokens that can be staked per account/user
}
/// @notice The reward token aka $LPT
LaunchPoolToken public lpt;
/// @notice Number of LPT tokens distributed per block, across all pools.
uint256 public lptPerBlock;
/// @notice The total amount of reward token available for farming across all pools between start and end block.
uint256 public maxLPTAvailableForFarming;
/// @notice List of pools that users can stake into
PoolInfo[] public poolInfo;
/// @notice Per pool, info of each user that stakes ERC20 tokens.
/// @notice Pool ID => User Address => User Info
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
/// @notice Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint;
/// @notice The block number when LPT rewards starts across all pools.
uint256 public startBlock;
/// @notice The block number when rewards ends.
uint256 public endBlock;
/// @notice Tracks ERC20 tokens added by owner
mapping(address => bool) isErc20TokenWhitelisted;
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);
/// @param _lpt Address of the LPT reward token
/// @param _maxLPTAvailableForFarming Maximum number of LPT that will be distributed between the start and end of farming
/// @param _startBlock Block number when farming will begin for all pools
/// @param _endBlock Block number when farming will end for all pools
constructor(
LaunchPoolToken _lpt,
uint256 _maxLPTAvailableForFarming,
uint256 _startBlock,
uint256 _endBlock
) public {
require(address(_lpt) != address(0), "constructor: _lpt must not be zero address");
require(_maxLPTAvailableForFarming > 0, "constructor: _maxLPTAvailableForFarming must be greater than zero");
lpt = _lpt;
maxLPTAvailableForFarming = _maxLPTAvailableForFarming;
startBlock = _startBlock;
endBlock = _endBlock;
uint256 numberOfBlocksForFarming = endBlock.sub(startBlock);
lptPerBlock = maxLPTAvailableForFarming.div(numberOfBlocksForFarming);
}
/// @notice Returns the number of pools that have been added by the owner
/// @return Number of pools
function numberOfPools() external view returns (uint256) {
return poolInfo.length;
}
/// @notice Create a new LPT pool by whitelisting a new ERC20 token.
/// @dev Can only be called by the contract owner
/// @param _allocPoint Governs what percentage of the total LPT rewards this pool and other pools will get
/// @param _erc20Token Address of the staking token being whitelisted
/// @param _maxStakingAmountPerUser For this pool, maximum amount per user that can be staked
/// @param _withUpdate Set to true for updating all pools before adding this one
function add(uint256 _allocPoint, IERC20 _erc20Token, uint256 _maxStakingAmountPerUser, bool _withUpdate) public onlyOwner {
require(block.number < endBlock, "add: must be before end");
address erc20TokenAddress = address(_erc20Token);
require(erc20TokenAddress != address(0), "add: _erc20Token must not be zero address");
require(isErc20TokenWhitelisted[erc20TokenAddress] == false, "add: already whitelisted");
require(_maxStakingAmountPerUser > 0, "add: _maxStakingAmountPerUser must be greater than zero");
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
erc20Token : _erc20Token,
allocPoint : _allocPoint,
lastRewardBlock : lastRewardBlock,
accLptPerShare : 0,
maxStakingAmountPerUser: _maxStakingAmountPerUser
}));
isErc20TokenWhitelisted[erc20TokenAddress] = true;
}
/// @notice Update a pool's allocation point to increase or decrease its share of contract-level rewards
/// @notice Can also update the max amount that can be staked per user
/// @dev Can only be called by the owner
/// @param _pid ID of the pool being updated
/// @param _allocPoint New allocation point
/// @param _maxStakingAmountPerUser Maximum amount that a user can deposit into the far
/// @param _withUpdate Set to true if you want to update all pools before making this change - it will checkpoint those rewards
function set(uint256 _pid, uint256 _allocPoint, uint256 _maxStakingAmountPerUser, bool _withUpdate) public onlyOwner {
require(block.number < endBlock, "set: must be before end");
require(_pid < poolInfo.length, "set: invalid _pid");
require(_maxStakingAmountPerUser > 0, "set: _maxStakingAmountPerUser must be greater than zero");
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
poolInfo[_pid].maxStakingAmountPerUser = _maxStakingAmountPerUser;
}
/// @notice View function to see pending and unclaimed LPTs for a given user
/// @param _pid ID of the pool where a user has a stake
/// @param _user Account being queried
/// @return Amount of LPT tokens due to a user
function pendingLpt(uint256 _pid, address _user) external view returns (uint256) {
require(_pid < poolInfo.length, "pendingLpt: invalid _pid");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accLptPerShare = pool.accLptPerShare;
uint256 lpSupply = pool.erc20Token.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 maxEndBlock = block.number <= endBlock ? block.number : endBlock;
uint256 multiplier = getMultiplier(pool.lastRewardBlock, maxEndBlock);
uint256 lptReward = multiplier.mul(lptPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accLptPerShare = accLptPerShare.add(lptReward.mul(1e18).div(lpSupply));
}
return user.amount.mul(accLptPerShare).div(1e18).sub(user.rewardDebt);
}
/// @notice Cycles through the pools to update all of the rewards accrued
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
/// @notice Updates a specific pool to track all of the rewards accrued up to the TX block
/// @param _pid ID of the pool
function updatePool(uint256 _pid) public {
require(_pid < poolInfo.length, "updatePool: invalid _pid");
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 erc20Supply = pool.erc20Token.balanceOf(address(this));
if (erc20Supply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 maxEndBlock = block.number <= endBlock ? block.number : endBlock;
uint256 multiplier = getMultiplier(pool.lastRewardBlock, maxEndBlock);
// No point in doing any more logic as the rewards have ended
if (multiplier == 0) {
return;
}
uint256 lptReward = multiplier.mul(lptPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
pool.accLptPerShare = pool.accLptPerShare.add(lptReward.mul(1e18).div(erc20Supply));
pool.lastRewardBlock = maxEndBlock;
}
/// @notice Where any user can stake their ERC20 tokens into a pool in order to farm $LPT
/// @param _pid ID of the pool
/// @param _amount Amount of ERC20 being staked
function deposit(uint256 _pid, uint256 _amount) external {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount.add(_amount) <= pool.maxStakingAmountPerUser, "deposit: can not exceed max staking amount per user");
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accLptPerShare).div(1e18).sub(user.rewardDebt);
if (pending > 0) {
safeLptTransfer(msg.sender, pending);
}
}
if (_amount > 0) {
pool.erc20Token.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
}
user.rewardDebt = user.amount.mul(pool.accLptPerShare).div(1e18);
emit Deposit(msg.sender, _pid, _amount);
}
/// @notice Allows a user to withdraw any ERC20 tokens staked in a pool
/// @dev Partial withdrawals permitted
/// @param _pid Pool ID
/// @param _amount Being withdrawn
function withdraw(uint256 _pid, uint256 _amount) external {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: _amount not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accLptPerShare).div(1e18).sub(user.rewardDebt);
if (pending > 0) {
safeLptTransfer(msg.sender, pending);
}
if (_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.erc20Token.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accLptPerShare).div(1e18);
emit Withdraw(msg.sender, _pid, _amount);
}
/// @notice Emergency only. Should the rewards issuance mechanism fail, people can still withdraw their stake
/// @param _pid Pool ID
function emergencyWithdraw(uint256 _pid) external {
require(_pid < poolInfo.length, "updatePool: invalid _pid");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
pool.erc20Token.safeTransfer(address(msg.sender), amount);
emit EmergencyWithdraw(msg.sender, _pid, amount);
}
////////////
// Private /
////////////
/// @dev Safe LPT transfer function, just in case if rounding error causes pool to not have enough LPTs.
/// @param _to Whom to send LPT into
/// @param _amount of LPT to send
function safeLptTransfer(address _to, uint256 _amount) private {
uint256 lptBal = lpt.balanceOf(address(this));
if (_amount > lptBal) {
lpt.transfer(_to, lptBal);
} else {
lpt.transfer(_to, _amount);
}
}
/// @notice Return reward multiplier over the given _from to _to block.
/// @param _from Block number
/// @param _to Block number
/// @return Number of blocks that have passed
function getMultiplier(uint256 _from, uint256 _to) private view returns (uint256) {
return _to.sub(_from);
}
}
| 25,354 |
33 | // Set the borrower of the contract to the tx.origin We are using tx.origin, because the contract is going to be published by the main contract and msg.sender will break our logic./ | borrower = tx.origin;
| borrower = tx.origin;
| 16,154 |
20 | // Sets `_poolFactory` as the new BFactory module. Requirements: - `_poolFactory` should not be the zero address._poolFactory The address of the new Balance BFactory module. / | function _setPoolFactory(address _poolFactory) internal {
require(_poolFactory != address(0), "Pool Factory is the zero address");
emit PoolFactorySet(_poolFactory);
poolFactory = _poolFactory;
}
| function _setPoolFactory(address _poolFactory) internal {
require(_poolFactory != address(0), "Pool Factory is the zero address");
emit PoolFactorySet(_poolFactory);
poolFactory = _poolFactory;
}
| 30,621 |
151 | // params | function getPeriod() public view returns (uint256) {
return period;
}
| function getPeriod() public view returns (uint256) {
return period;
}
| 11,916 |
101 | // See {IERC721-transferFrom}. / | function transferFrom(address from, address to, uint256 tokenId) public virtual override {
| function transferFrom(address from, address to, uint256 tokenId) public virtual override {
| 851 |
26 | // Returns the daily token yield of `_address`.- Note: This is returned in wei which is the tiniest unit so to see the daily yield in whole tokens divide by 1000000000000000000. / | function getUserDailyYield(address _address) public view returns (uint256) {
uint256 units = totalStakeableUnits;
if (units == 0) return 0;
uint256 rewards;
for (uint256 i = 1; i <= units; i++){
if (stakeableUnits[i].stakeableContract.getStakingStatus(_address)){
rewards += stakeableUnits[i].stakeableContract.balanceOf(_address) * stakeableUnits[i].dailyYield;
}
}
return rewards * getStakingMultiplier(_address) / 100;
}
| function getUserDailyYield(address _address) public view returns (uint256) {
uint256 units = totalStakeableUnits;
if (units == 0) return 0;
uint256 rewards;
for (uint256 i = 1; i <= units; i++){
if (stakeableUnits[i].stakeableContract.getStakingStatus(_address)){
rewards += stakeableUnits[i].stakeableContract.balanceOf(_address) * stakeableUnits[i].dailyYield;
}
}
return rewards * getStakingMultiplier(_address) / 100;
}
| 1,006 |
262 | // Base auction contract of the Dyverse VREX Lab Co., Ltd Contains necessary functions and variables for the auction. Inherits `ERC721Holder` contract which is the implementation of the `ERC721TokenReceiver`. This is to accept safe transfers. / | contract AuctionBase is ERC721Holder {
using SafeMath for uint256;
// Represents an auction on an NFT
struct Auction {
// Current owner of NFT
address seller;
// Price (in wei) of NFT
uint128 price;
// Time when the auction started
// NOTE: 0 if this auction has been concluded
uint64 startedAt;
}
// Reference to contract tracking NFT ownership
ERC721Basic public nonFungibleContract;
// The amount owner takes from the sale, (in basis points, which are 1/100 of a percent).
uint256 public ownerCut;
// Maps token ID to it's corresponding auction.
mapping (uint256 => Auction) tokenIdToAuction;
event AuctionCreated(uint256 tokenId, uint256 price);
event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address bidder);
event AuctionCanceled(uint256 tokenId);
/// @dev Disables sending funds to this contract.
function() external {}
/// @dev A modifier to check if the given value can fit in 64-bits.
modifier canBeStoredWith64Bits(uint256 _value) {
require(_value <= (2**64 - 1));
_;
}
/// @dev A modifier to check if the given value can fit in 128-bits.
modifier canBeStoredWith128Bits(uint256 _value) {
require(_value <= (2**128 - 1));
_;
}
/**
* @dev Returns true if the claimant owns the token.
* @param _claimant An address which to query the ownership of the token.
* @param _tokenId ID of the token to query the owner of.
*/
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return (nonFungibleContract.ownerOf(_tokenId) == _claimant);
}
/**
* @dev Escrows the NFT. Grants the ownership of the NFT to this contract safely.
* Throws if the escrow fails.
* @param _owner Current owner of the token.
* @param _tokenId ID of the token to escrow.
*/
function _escrow(address _owner, uint256 _tokenId) internal {
nonFungibleContract.safeTransferFrom(_owner, this, _tokenId);
}
/**
* @dev Transfers an NFT owned by this contract to another address safely.
* @param _receiver The receiving address of NFT.
* @param _tokenId ID of the token to transfer.
*/
function _transfer(address _receiver, uint256 _tokenId) internal {
nonFungibleContract.safeTransferFrom(this, _receiver, _tokenId);
}
/**
* @dev Adds an auction to the list of open auctions.
* @param _tokenId ID of the token to be put on auction.
* @param _auction Auction information of this token to open.
*/
function _addAuction(uint256 _tokenId, Auction _auction) internal {
tokenIdToAuction[_tokenId] = _auction;
emit AuctionCreated(
uint256(_tokenId),
uint256(_auction.price)
);
}
/// @dev Cancels the auction which the _seller wants.
function _cancelAuction(uint256 _tokenId, address _seller) internal {
_removeAuction(_tokenId);
_transfer(_seller, _tokenId);
emit AuctionCanceled(_tokenId);
}
/**
* @dev Computes the price and sends it to the seller.
* Note that this does NOT transfer the ownership of the token.
*/
function _bid(uint256 _tokenId, uint256 _bidAmount)
internal
returns (uint256)
{
// Gets a reference of the token from auction storage.
Auction storage auction = tokenIdToAuction[_tokenId];
// Checks that this auction is currently open
require(_isOnAuction(auction));
// Checks that the bid is greater than or equal to the current token price.
uint256 price = _currentPrice(auction);
require(_bidAmount >= price);
// Gets a reference of the seller before the auction gets deleted.
address seller = auction.seller;
// Removes the auction before sending the proceeds to the sender
_removeAuction(_tokenId);
// Transfers proceeds to the seller.
if (price > 0) {
uint256 auctioneerCut = _computeCut(price);
uint256 sellerProceeds = price.sub(auctioneerCut);
seller.transfer(sellerProceeds);
}
// Computes the excess funds included with the bid and transfers it back to bidder.
uint256 bidExcess = _bidAmount - price;
// Returns the exceeded funds.
msg.sender.transfer(bidExcess);
// Emits the AuctionSuccessful event.
emit AuctionSuccessful(_tokenId, price, msg.sender);
return price;
}
/**
* @dev Removes an auction from the list of open auctions.
* @param _tokenId ID of the NFT on auction to be removed.
*/
function _removeAuction(uint256 _tokenId) internal {
delete tokenIdToAuction[_tokenId];
}
/**
* @dev Returns true if the NFT is on auction.
* @param _auction An auction to check if it exists.
*/
function _isOnAuction(Auction storage _auction) internal view returns (bool) {
return (_auction.startedAt > 0);
}
/// @dev Returns the current price of an NFT on auction.
function _currentPrice(Auction storage _auction)
internal
view
returns (uint256)
{
return _auction.price;
}
/**
* @dev Computes the owner's receiving amount from the sale.
* @param _price Sale price of the NFT.
*/
function _computeCut(uint256 _price) internal view returns (uint256) {
return _price * ownerCut / 10000;
}
}
| contract AuctionBase is ERC721Holder {
using SafeMath for uint256;
// Represents an auction on an NFT
struct Auction {
// Current owner of NFT
address seller;
// Price (in wei) of NFT
uint128 price;
// Time when the auction started
// NOTE: 0 if this auction has been concluded
uint64 startedAt;
}
// Reference to contract tracking NFT ownership
ERC721Basic public nonFungibleContract;
// The amount owner takes from the sale, (in basis points, which are 1/100 of a percent).
uint256 public ownerCut;
// Maps token ID to it's corresponding auction.
mapping (uint256 => Auction) tokenIdToAuction;
event AuctionCreated(uint256 tokenId, uint256 price);
event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address bidder);
event AuctionCanceled(uint256 tokenId);
/// @dev Disables sending funds to this contract.
function() external {}
/// @dev A modifier to check if the given value can fit in 64-bits.
modifier canBeStoredWith64Bits(uint256 _value) {
require(_value <= (2**64 - 1));
_;
}
/// @dev A modifier to check if the given value can fit in 128-bits.
modifier canBeStoredWith128Bits(uint256 _value) {
require(_value <= (2**128 - 1));
_;
}
/**
* @dev Returns true if the claimant owns the token.
* @param _claimant An address which to query the ownership of the token.
* @param _tokenId ID of the token to query the owner of.
*/
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return (nonFungibleContract.ownerOf(_tokenId) == _claimant);
}
/**
* @dev Escrows the NFT. Grants the ownership of the NFT to this contract safely.
* Throws if the escrow fails.
* @param _owner Current owner of the token.
* @param _tokenId ID of the token to escrow.
*/
function _escrow(address _owner, uint256 _tokenId) internal {
nonFungibleContract.safeTransferFrom(_owner, this, _tokenId);
}
/**
* @dev Transfers an NFT owned by this contract to another address safely.
* @param _receiver The receiving address of NFT.
* @param _tokenId ID of the token to transfer.
*/
function _transfer(address _receiver, uint256 _tokenId) internal {
nonFungibleContract.safeTransferFrom(this, _receiver, _tokenId);
}
/**
* @dev Adds an auction to the list of open auctions.
* @param _tokenId ID of the token to be put on auction.
* @param _auction Auction information of this token to open.
*/
function _addAuction(uint256 _tokenId, Auction _auction) internal {
tokenIdToAuction[_tokenId] = _auction;
emit AuctionCreated(
uint256(_tokenId),
uint256(_auction.price)
);
}
/// @dev Cancels the auction which the _seller wants.
function _cancelAuction(uint256 _tokenId, address _seller) internal {
_removeAuction(_tokenId);
_transfer(_seller, _tokenId);
emit AuctionCanceled(_tokenId);
}
/**
* @dev Computes the price and sends it to the seller.
* Note that this does NOT transfer the ownership of the token.
*/
function _bid(uint256 _tokenId, uint256 _bidAmount)
internal
returns (uint256)
{
// Gets a reference of the token from auction storage.
Auction storage auction = tokenIdToAuction[_tokenId];
// Checks that this auction is currently open
require(_isOnAuction(auction));
// Checks that the bid is greater than or equal to the current token price.
uint256 price = _currentPrice(auction);
require(_bidAmount >= price);
// Gets a reference of the seller before the auction gets deleted.
address seller = auction.seller;
// Removes the auction before sending the proceeds to the sender
_removeAuction(_tokenId);
// Transfers proceeds to the seller.
if (price > 0) {
uint256 auctioneerCut = _computeCut(price);
uint256 sellerProceeds = price.sub(auctioneerCut);
seller.transfer(sellerProceeds);
}
// Computes the excess funds included with the bid and transfers it back to bidder.
uint256 bidExcess = _bidAmount - price;
// Returns the exceeded funds.
msg.sender.transfer(bidExcess);
// Emits the AuctionSuccessful event.
emit AuctionSuccessful(_tokenId, price, msg.sender);
return price;
}
/**
* @dev Removes an auction from the list of open auctions.
* @param _tokenId ID of the NFT on auction to be removed.
*/
function _removeAuction(uint256 _tokenId) internal {
delete tokenIdToAuction[_tokenId];
}
/**
* @dev Returns true if the NFT is on auction.
* @param _auction An auction to check if it exists.
*/
function _isOnAuction(Auction storage _auction) internal view returns (bool) {
return (_auction.startedAt > 0);
}
/// @dev Returns the current price of an NFT on auction.
function _currentPrice(Auction storage _auction)
internal
view
returns (uint256)
{
return _auction.price;
}
/**
* @dev Computes the owner's receiving amount from the sale.
* @param _price Sale price of the NFT.
*/
function _computeCut(uint256 _price) internal view returns (uint256) {
return _price * ownerCut / 10000;
}
}
| 17,408 |
47 | // Transfer token or ETH to a destinatary _token - Address of the token _to - Address of the recipient _val - Uint256 of the amount to transferreturn bool - Whether the transfer was success or not / | function transfer(IERC20 _token, address _to, uint256 _val) internal returns (bool) {
if (ETH_ADDRESS == address(_token)) {
(bool success, ) = _to.call{value:_val}("");
return success;
}
return SafeERC20.transfer(_token, _to, _val);
}
| function transfer(IERC20 _token, address _to, uint256 _val) internal returns (bool) {
if (ETH_ADDRESS == address(_token)) {
(bool success, ) = _to.call{value:_val}("");
return success;
}
return SafeERC20.transfer(_token, _to, _val);
}
| 22,371 |
2 | // instead of gas oracle | gasPrice = _gasPriceLimit;
| gasPrice = _gasPriceLimit;
| 18,980 |
370 | // TokenMinter Token Minter and Burner Maintains registry of local mintable tokens and corresponding tokens on remote domains.This registry can be used by caller to determine which token on local domain to mint for aburned token on a remote domain, and vice versa.It is assumed that local and remote tokens are fungible at a constant 1:1 exchange rate. / | contract TokenMinter is ITokenMinter, TokenController, Pausable, Rescuable {
// ============ Events ============
/**
* @notice Emitted when a local TokenMessenger is added
* @param localTokenMessenger address of local TokenMessenger
* @notice Emitted when a local TokenMessenger is added
*/
event LocalTokenMessengerAdded(address localTokenMessenger);
/**
* @notice Emitted when a local TokenMessenger is removed
* @param localTokenMessenger address of local TokenMessenger
* @notice Emitted when a local TokenMessenger is removed
*/
event LocalTokenMessengerRemoved(address localTokenMessenger);
// ============ State Variables ============
// Local TokenMessenger with permission to call mint and burn on this TokenMinter
address public localTokenMessenger;
// ============ Modifiers ============
/**
* @notice Only accept messages from the registered message transmitter on local domain
*/
modifier onlyLocalTokenMessenger() {
require(_isLocalTokenMessenger(), "Caller not local TokenMessenger");
_;
}
// ============ Constructor ============
/**
* @param _tokenController Token controller address
*/
constructor(address _tokenController) {
_setTokenController(_tokenController);
}
// ============ External Functions ============
/**
* @notice Mints `amount` of local tokens corresponding to the
* given (`sourceDomain`, `burnToken`) pair, to `to` address.
* @dev reverts if the (`sourceDomain`, `burnToken`) pair does not
* map to a nonzero local token address. This mapping can be queried using
* getLocalToken().
* @param sourceDomain Source domain where `burnToken` was burned.
* @param burnToken Burned token address as bytes32.
* @param to Address to receive minted tokens, corresponding to `burnToken`,
* on this domain.
* @param amount Amount of tokens to mint. Must be less than or equal
* to the minterAllowance of this TokenMinter for given `_mintToken`.
* @return mintToken token minted.
*/
function mint(
uint32 sourceDomain,
bytes32 burnToken,
address to,
uint256 amount
)
external
override
whenNotPaused
onlyLocalTokenMessenger
returns (address mintToken)
{
address _mintToken = _getLocalToken(sourceDomain, burnToken);
require(_mintToken != address(0), "Mint token not supported");
IMintBurnToken _token = IMintBurnToken(_mintToken);
require(_token.mint(to, amount), "Mint operation failed");
return _mintToken;
}
/**
* @notice Burn tokens owned by this TokenMinter.
* @param burnToken burnable token address.
* @param burnAmount amount of tokens to burn. Must be
* > 0, and <= maximum burn amount per message.
*/
function burn(address burnToken, uint256 burnAmount)
external
override
whenNotPaused
onlyLocalTokenMessenger
onlyWithinBurnLimit(burnToken, burnAmount)
{
IMintBurnToken _token = IMintBurnToken(burnToken);
_token.burn(burnAmount);
}
/**
* @notice Add TokenMessenger for the local domain. Only this TokenMessenger
* has permission to call mint() and burn() on this TokenMinter.
* @dev Reverts if a TokenMessenger is already set for the local domain.
* @param newLocalTokenMessenger The address of the new TokenMessenger on the local domain.
*/
function addLocalTokenMessenger(address newLocalTokenMessenger)
external
onlyOwner
{
require(
newLocalTokenMessenger != address(0),
"Invalid TokenMessenger address"
);
require(
localTokenMessenger == address(0),
"Local TokenMessenger already set"
);
localTokenMessenger = newLocalTokenMessenger;
emit LocalTokenMessengerAdded(localTokenMessenger);
}
/**
* @notice Remove the TokenMessenger for the local domain.
* @dev Reverts if the TokenMessenger of the local domain is not set.
*/
function removeLocalTokenMessenger() external onlyOwner {
address _localTokenMessengerBeforeRemoval = localTokenMessenger;
require(
_localTokenMessengerBeforeRemoval != address(0),
"No local TokenMessenger is set"
);
delete localTokenMessenger;
emit LocalTokenMessengerRemoved(_localTokenMessengerBeforeRemoval);
}
/**
* @notice Set tokenController to `newTokenController`, and
* emit `SetTokenController` event.
* @dev newTokenController must be nonzero.
* @param newTokenController address of new token controller
*/
function setTokenController(address newTokenController)
external
override
onlyOwner
{
_setTokenController(newTokenController);
}
/**
* @notice Get the local token address associated with the given
* remote domain and token.
* @param remoteDomain Remote domain
* @param remoteToken Remote token
* @return local token address
*/
function getLocalToken(uint32 remoteDomain, bytes32 remoteToken)
external
view
override
returns (address)
{
return _getLocalToken(remoteDomain, remoteToken);
}
// ============ Internal Utils ============
/**
* @notice Returns true if the message sender is the registered local TokenMessenger
* @return True if the message sender is the registered local TokenMessenger
*/
function _isLocalTokenMessenger() internal view returns (bool) {
return
address(localTokenMessenger) != address(0) &&
msg.sender == address(localTokenMessenger);
}
} | contract TokenMinter is ITokenMinter, TokenController, Pausable, Rescuable {
// ============ Events ============
/**
* @notice Emitted when a local TokenMessenger is added
* @param localTokenMessenger address of local TokenMessenger
* @notice Emitted when a local TokenMessenger is added
*/
event LocalTokenMessengerAdded(address localTokenMessenger);
/**
* @notice Emitted when a local TokenMessenger is removed
* @param localTokenMessenger address of local TokenMessenger
* @notice Emitted when a local TokenMessenger is removed
*/
event LocalTokenMessengerRemoved(address localTokenMessenger);
// ============ State Variables ============
// Local TokenMessenger with permission to call mint and burn on this TokenMinter
address public localTokenMessenger;
// ============ Modifiers ============
/**
* @notice Only accept messages from the registered message transmitter on local domain
*/
modifier onlyLocalTokenMessenger() {
require(_isLocalTokenMessenger(), "Caller not local TokenMessenger");
_;
}
// ============ Constructor ============
/**
* @param _tokenController Token controller address
*/
constructor(address _tokenController) {
_setTokenController(_tokenController);
}
// ============ External Functions ============
/**
* @notice Mints `amount` of local tokens corresponding to the
* given (`sourceDomain`, `burnToken`) pair, to `to` address.
* @dev reverts if the (`sourceDomain`, `burnToken`) pair does not
* map to a nonzero local token address. This mapping can be queried using
* getLocalToken().
* @param sourceDomain Source domain where `burnToken` was burned.
* @param burnToken Burned token address as bytes32.
* @param to Address to receive minted tokens, corresponding to `burnToken`,
* on this domain.
* @param amount Amount of tokens to mint. Must be less than or equal
* to the minterAllowance of this TokenMinter for given `_mintToken`.
* @return mintToken token minted.
*/
function mint(
uint32 sourceDomain,
bytes32 burnToken,
address to,
uint256 amount
)
external
override
whenNotPaused
onlyLocalTokenMessenger
returns (address mintToken)
{
address _mintToken = _getLocalToken(sourceDomain, burnToken);
require(_mintToken != address(0), "Mint token not supported");
IMintBurnToken _token = IMintBurnToken(_mintToken);
require(_token.mint(to, amount), "Mint operation failed");
return _mintToken;
}
/**
* @notice Burn tokens owned by this TokenMinter.
* @param burnToken burnable token address.
* @param burnAmount amount of tokens to burn. Must be
* > 0, and <= maximum burn amount per message.
*/
function burn(address burnToken, uint256 burnAmount)
external
override
whenNotPaused
onlyLocalTokenMessenger
onlyWithinBurnLimit(burnToken, burnAmount)
{
IMintBurnToken _token = IMintBurnToken(burnToken);
_token.burn(burnAmount);
}
/**
* @notice Add TokenMessenger for the local domain. Only this TokenMessenger
* has permission to call mint() and burn() on this TokenMinter.
* @dev Reverts if a TokenMessenger is already set for the local domain.
* @param newLocalTokenMessenger The address of the new TokenMessenger on the local domain.
*/
function addLocalTokenMessenger(address newLocalTokenMessenger)
external
onlyOwner
{
require(
newLocalTokenMessenger != address(0),
"Invalid TokenMessenger address"
);
require(
localTokenMessenger == address(0),
"Local TokenMessenger already set"
);
localTokenMessenger = newLocalTokenMessenger;
emit LocalTokenMessengerAdded(localTokenMessenger);
}
/**
* @notice Remove the TokenMessenger for the local domain.
* @dev Reverts if the TokenMessenger of the local domain is not set.
*/
function removeLocalTokenMessenger() external onlyOwner {
address _localTokenMessengerBeforeRemoval = localTokenMessenger;
require(
_localTokenMessengerBeforeRemoval != address(0),
"No local TokenMessenger is set"
);
delete localTokenMessenger;
emit LocalTokenMessengerRemoved(_localTokenMessengerBeforeRemoval);
}
/**
* @notice Set tokenController to `newTokenController`, and
* emit `SetTokenController` event.
* @dev newTokenController must be nonzero.
* @param newTokenController address of new token controller
*/
function setTokenController(address newTokenController)
external
override
onlyOwner
{
_setTokenController(newTokenController);
}
/**
* @notice Get the local token address associated with the given
* remote domain and token.
* @param remoteDomain Remote domain
* @param remoteToken Remote token
* @return local token address
*/
function getLocalToken(uint32 remoteDomain, bytes32 remoteToken)
external
view
override
returns (address)
{
return _getLocalToken(remoteDomain, remoteToken);
}
// ============ Internal Utils ============
/**
* @notice Returns true if the message sender is the registered local TokenMessenger
* @return True if the message sender is the registered local TokenMessenger
*/
function _isLocalTokenMessenger() internal view returns (bool) {
return
address(localTokenMessenger) != address(0) &&
msg.sender == address(localTokenMessenger);
}
} | 42,847 |
57 | // Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5.05` (`505 / 102`). Tokens usually opt for a value of 18, imitating the relationship between | * Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
| * Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
| 59,208 |
39 | // Amount of rewards (in wei) already paid out to a certain address | mapping (address => uint) public paidOut;
| mapping (address => uint) public paidOut;
| 47,859 |
23 | // Do the fixed-point inversion inline to save gas. The numerator is SCALESCALE. | unchecked {
result = 1e36 / exp2(-x);
}
| unchecked {
result = 1e36 / exp2(-x);
}
| 8,623 |
52 | // Checks if an address is a member of the merkle tree/root the root of the merkle tree/addr The address to check/pos The position to check, index starting at 0/proof Merkle proof required for validation of the address/ return Returns true if the address is in the set | function checkAddrInSet(
bytes32 root,
address addr,
uint256 pos,
bytes32[] calldata proof
| function checkAddrInSet(
bytes32 root,
address addr,
uint256 pos,
bytes32[] calldata proof
| 43,446 |
185 | // External interface // Flash loan receiver interface / | interface IFlashloanReceiver {
function executeOperation(
address sender,
address underlying,
uint256 amount,
uint256 fee,
bytes calldata params
) external;
}
| interface IFlashloanReceiver {
function executeOperation(
address sender,
address underlying,
uint256 amount,
uint256 fee,
bytes calldata params
) external;
}
| 18,324 |
618 | // column19_row8214/ mload(0x38a0), Numerator: point - trace_generator^(8192(trace_length / 8192 - 1)). val = numerators[9]. | val := mulmod(val, mload(0x4d80), PRIME)
| val := mulmod(val, mload(0x4d80), PRIME)
| 20,890 |
103 | // This token is worth less than the ESD | highAmount = estimate;
targetID = i;
| highAmount = estimate;
targetID = i;
| 7,995 |
290 | // removing old holder's reserve price | votingTokens -= _amount;
reserveTotal -= _amount * fromPrice;
| votingTokens -= _amount;
reserveTotal -= _amount * fromPrice;
| 9,699 |
124 | // Metadata |
string private __name;
string private __symbol;
string private __tokenUriPrefix;
constructor(string memory _name,
|
string private __name;
string private __symbol;
string private __tokenUriPrefix;
constructor(string memory _name,
| 35,051 |
20 | // Advances the epoch (if needed) and redeems the max amount of coupons possibleAlso frees CHI tokens to save on gas (requires that msg.sender has CHI tokens in theiraccount and has approved this contract to spend their CHI)._user The user whose coupons will attempt to be redeemed_epoch The epoch in which the coupons were created_targetEpoch The epoch that is about to be advanced _to_.E.g., if the current epoch is 220 and we are about to advance to to epoch 221, then _targetEpochwould be set to 221. The _targetEpoch is the epoch in which the coupon redemption will be attempted. | function advanceAndRedeemMax(address _user, uint256 _epoch, uint256 _targetEpoch) external useCHI {
// End execution early if tx is mined too early
uint256 targetEpochStartTime = getEpochStartTime(_targetEpoch);
if (block.timestamp < targetEpochStartTime) { return; }
// advance epoch if it has not already been advanced
if (ESDS.epoch() != _targetEpoch) { ESDS.advance(); }
// get max redeemable amount
uint256 totalRedeemable = ESDS.totalRedeemable();
if (totalRedeemable == 0) { return; } // no coupons to redeem
uint256 userBalance = ESDS.balanceOfCoupons(_user, _epoch);
if (userBalance == 0) { return; } // no coupons to redeem
uint256 maxRedeemableAmount = totalRedeemable < userBalance ? totalRedeemable : userBalance;
// attempt to redeem coupons
_redeem(_user, _epoch, maxRedeemableAmount);
}
| function advanceAndRedeemMax(address _user, uint256 _epoch, uint256 _targetEpoch) external useCHI {
// End execution early if tx is mined too early
uint256 targetEpochStartTime = getEpochStartTime(_targetEpoch);
if (block.timestamp < targetEpochStartTime) { return; }
// advance epoch if it has not already been advanced
if (ESDS.epoch() != _targetEpoch) { ESDS.advance(); }
// get max redeemable amount
uint256 totalRedeemable = ESDS.totalRedeemable();
if (totalRedeemable == 0) { return; } // no coupons to redeem
uint256 userBalance = ESDS.balanceOfCoupons(_user, _epoch);
if (userBalance == 0) { return; } // no coupons to redeem
uint256 maxRedeemableAmount = totalRedeemable < userBalance ? totalRedeemable : userBalance;
// attempt to redeem coupons
_redeem(_user, _epoch, maxRedeemableAmount);
}
| 31,955 |
110 | // Calculating the fee in tokens | function _getValues(uint256 tAmount) private view returns (uint256, uint256) {
uint256 tDev = tAmount*_TotalFee/100;
uint256 tTransferAmount = tAmount.sub(tDev);
return (tTransferAmount, tDev);
}
| function _getValues(uint256 tAmount) private view returns (uint256, uint256) {
uint256 tDev = tAmount*_TotalFee/100;
uint256 tTransferAmount = tAmount.sub(tDev);
return (tTransferAmount, tDev);
}
| 11,080 |
5 | // configuration | function getReserveConfiguration(address _reserve)
external
view
returns (
uint256,
uint256,
uint256,
bool
);
| function getReserveConfiguration(address _reserve)
external
view
returns (
uint256,
uint256,
uint256,
bool
);
| 16,907 |
25 | // Safe dmm transfer function, just in case if rounding error causes pool to not have enough SUSHIs. | function safeBankTransfer(address _to, uint256 _amount) internal {
uint256 poolBal = bank.balanceOf(address(this));
bank.transfer(_to, Math.min(poolBal, _amount));
}
| function safeBankTransfer(address _to, uint256 _amount) internal {
uint256 poolBal = bank.balanceOf(address(this));
bank.transfer(_to, Math.min(poolBal, _amount));
}
| 34,470 |
101 | // OwnablePausableUpgradeableBundles Access Control, Pausable and Upgradeable contracts in one./ | abstract contract OwnablePausableUpgradeable is IOwnablePausable, PausableUpgradeable, AccessControlUpgradeable {
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
/**
* @dev Modifier for checking whether the caller is an admin.
*/
modifier onlyAdmin() {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "OwnablePausable: access denied");
_;
}
/**
* @dev Modifier for checking whether the caller is a pauser.
*/
modifier onlyPauser() {
require(hasRole(PAUSER_ROLE, msg.sender), "OwnablePausable: access denied");
_;
}
// solhint-disable-next-line func-name-mixedcase
function __OwnablePausableUpgradeable_init(address _admin) internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__Pausable_init_unchained();
__OwnablePausableUpgradeable_init_unchained(_admin);
}
/**
* @dev Grants `DEFAULT_ADMIN_ROLE`, `PAUSER_ROLE` to the admin account.
*/
// solhint-disable-next-line func-name-mixedcase
function __OwnablePausableUpgradeable_init_unchained(address _admin) internal initializer {
_setupRole(DEFAULT_ADMIN_ROLE, _admin);
_setupRole(PAUSER_ROLE, _admin);
}
/**
* @dev See {IOwnablePausable-isAdmin}.
*/
function isAdmin(address _account) external override view returns (bool) {
return hasRole(DEFAULT_ADMIN_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-addAdmin}.
*/
function addAdmin(address _account) external override {
grantRole(DEFAULT_ADMIN_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-removeAdmin}.
*/
function removeAdmin(address _account) external override {
revokeRole(DEFAULT_ADMIN_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-isPauser}.
*/
function isPauser(address _account) external override view returns (bool) {
return hasRole(PAUSER_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-addPauser}.
*/
function addPauser(address _account) external override {
grantRole(PAUSER_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-removePauser}.
*/
function removePauser(address _account) external override {
revokeRole(PAUSER_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-pause}.
*/
function pause() external override onlyPauser {
_pause();
}
/**
* @dev See {IOwnablePausable-unpause}.
*/
function unpause() external override onlyPauser {
_unpause();
}
}
| abstract contract OwnablePausableUpgradeable is IOwnablePausable, PausableUpgradeable, AccessControlUpgradeable {
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
/**
* @dev Modifier for checking whether the caller is an admin.
*/
modifier onlyAdmin() {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "OwnablePausable: access denied");
_;
}
/**
* @dev Modifier for checking whether the caller is a pauser.
*/
modifier onlyPauser() {
require(hasRole(PAUSER_ROLE, msg.sender), "OwnablePausable: access denied");
_;
}
// solhint-disable-next-line func-name-mixedcase
function __OwnablePausableUpgradeable_init(address _admin) internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__Pausable_init_unchained();
__OwnablePausableUpgradeable_init_unchained(_admin);
}
/**
* @dev Grants `DEFAULT_ADMIN_ROLE`, `PAUSER_ROLE` to the admin account.
*/
// solhint-disable-next-line func-name-mixedcase
function __OwnablePausableUpgradeable_init_unchained(address _admin) internal initializer {
_setupRole(DEFAULT_ADMIN_ROLE, _admin);
_setupRole(PAUSER_ROLE, _admin);
}
/**
* @dev See {IOwnablePausable-isAdmin}.
*/
function isAdmin(address _account) external override view returns (bool) {
return hasRole(DEFAULT_ADMIN_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-addAdmin}.
*/
function addAdmin(address _account) external override {
grantRole(DEFAULT_ADMIN_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-removeAdmin}.
*/
function removeAdmin(address _account) external override {
revokeRole(DEFAULT_ADMIN_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-isPauser}.
*/
function isPauser(address _account) external override view returns (bool) {
return hasRole(PAUSER_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-addPauser}.
*/
function addPauser(address _account) external override {
grantRole(PAUSER_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-removePauser}.
*/
function removePauser(address _account) external override {
revokeRole(PAUSER_ROLE, _account);
}
/**
* @dev See {IOwnablePausable-pause}.
*/
function pause() external override onlyPauser {
_pause();
}
/**
* @dev See {IOwnablePausable-unpause}.
*/
function unpause() external override onlyPauser {
_unpause();
}
}
| 51,034 |
81 | // Gets the Loan to Value of the NFT self The NFT configurationreturn The loan to value / | function getLtv(DataTypes.NftConfigurationMap storage self) internal view returns (uint256) {
return self.data & ~LTV_MASK;
}
| function getLtv(DataTypes.NftConfigurationMap storage self) internal view returns (uint256) {
return self.data & ~LTV_MASK;
}
| 74,783 |
7 | // ClaimableContract The ClaimableContract contract is a copy of Claimable Contract by Zeppelin./ | contract ClaimableContract is ProxyStorage {
function owner() public view returns (address) {
return owner_;
}
function pendingOwner() public view returns (address) {
return pendingOwner_;
}
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev sets the original `owner` of the contract to the sender
* at construction. Must then be reinitialized
*/
constructor() public {
owner_ = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner_, "only owner");
_;
}
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner_);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner_ = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
address _pendingOwner = pendingOwner_;
emit OwnershipTransferred(owner_, _pendingOwner);
owner_ = _pendingOwner;
pendingOwner_ = address(0);
}
}
| contract ClaimableContract is ProxyStorage {
function owner() public view returns (address) {
return owner_;
}
function pendingOwner() public view returns (address) {
return pendingOwner_;
}
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev sets the original `owner` of the contract to the sender
* at construction. Must then be reinitialized
*/
constructor() public {
owner_ = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner_, "only owner");
_;
}
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner_);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner_ = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
address _pendingOwner = pendingOwner_;
emit OwnershipTransferred(owner_, _pendingOwner);
owner_ = _pendingOwner;
pendingOwner_ = address(0);
}
}
| 37,191 |
18 | // ๆ ก้ช่ดฆๆท็ฎๅๆฒกๆๅตๅฐธ | require(ownerZombieCount[msg.sender] > 0, "You can create a zombie for free.");
| require(ownerZombieCount[msg.sender] > 0, "You can create a zombie for free.");
| 3,545 |
53 | // Version of withdraw that extracts the dividends and sends the Ether to the caller. This is only used in the case when there is no transaction data, and that should be quite rare unless interacting directly with the smart contract. | function withdrawOld(address to) public {
// Retrieve the dividends associated with the address the request came from.
var balance = dividends(msg.sender);
// Update the payouts array, incrementing the request address by `balance`.
payouts[msg.sender] += (int256) (balance * scaleFactor);
// Increase the total amount that's been paid out to maintain invariance.
totalPayouts += (int256) (balance * scaleFactor);
// Send the dividends to the address that requested the withdraw.
contractBalance = sub(contractBalance, balance);
to.transfer(balance);
}
| function withdrawOld(address to) public {
// Retrieve the dividends associated with the address the request came from.
var balance = dividends(msg.sender);
// Update the payouts array, incrementing the request address by `balance`.
payouts[msg.sender] += (int256) (balance * scaleFactor);
// Increase the total amount that's been paid out to maintain invariance.
totalPayouts += (int256) (balance * scaleFactor);
// Send the dividends to the address that requested the withdraw.
contractBalance = sub(contractBalance, balance);
to.transfer(balance);
}
| 10,151 |
11 | // Get the total supply of LP tokens | uint256 totalLPSupply = lpPool.totalSupply();
| uint256 totalLPSupply = lpPool.totalSupply();
| 29,097 |
42 | // ===================================================================/ Auto-generated getter functions from public state variables |
function beneficiary() external view returns (address );
function expirationDuration() external view returns (uint256 );
function freeTrialLength() external view returns (uint256 );
function isAlive() external view returns (bool );
function keyPrice() external view returns (uint256 );
|
function beneficiary() external view returns (address );
function expirationDuration() external view returns (uint256 );
function freeTrialLength() external view returns (uint256 );
function isAlive() external view returns (bool );
function keyPrice() external view returns (uint256 );
| 76,450 |
55 | // this is redundant with granularity and windowSize, but stored for gas savings & informational purposes. | uint public constant periodSize = 1800;
address[] internal _pairs;
mapping(address => bool) internal _known;
| uint public constant periodSize = 1800;
address[] internal _pairs;
mapping(address => bool) internal _known;
| 11,308 |
14 | // Grouping token owner | uint256 public MYFILockedCommunityOne;
uint256 public MYFILockedCommunityTwo;
address public owner;
ERC20 public MYFIToken;
| uint256 public MYFILockedCommunityOne;
uint256 public MYFILockedCommunityTwo;
address public owner;
ERC20 public MYFIToken;
| 34,561 |
14 | // Add 2 modifiers to check if the item is shipped already, and that the person calling this function | verifyCaller(items[sku].buyer){
items[sku].state = (uint) (State.Received);
emit LogReceived(sku);
}
| verifyCaller(items[sku].buyer){
items[sku].state = (uint) (State.Received);
emit LogReceived(sku);
}
| 29,679 |
33 | // Activates rebasingOne way function, cannot be undone, callable by anyone | function activateRebasing() public {
require(timeOfTwapInit > 0, 'activateRebasing: twap wasnt intitiated, call init_twap()');
// cannot enable prior to end of rebaseDelay
require(getNow() >= timeOfTwapInit + rebaseDelay, 'activateRebasing: !end_delay');
rebasingActive = true;
}
| function activateRebasing() public {
require(timeOfTwapInit > 0, 'activateRebasing: twap wasnt intitiated, call init_twap()');
// cannot enable prior to end of rebaseDelay
require(getNow() >= timeOfTwapInit + rebaseDelay, 'activateRebasing: !end_delay');
rebasingActive = true;
}
| 17,805 |
0 | // Create a new add two-side optimal strategy instance./_router The Uniswap router smart contract. | constructor(IUniswapV2Router02 _router, address _goblin, address _fToken) public {
factory = IUniswapV2Factory(_router.factory());
router = _router;
weth = _router.WETH();
goblin = _goblin;
fToken_ = _fToken;
}
| constructor(IUniswapV2Router02 _router, address _goblin, address _fToken) public {
factory = IUniswapV2Factory(_router.factory());
router = _router;
weth = _router.WETH();
goblin = _goblin;
fToken_ = _fToken;
}
| 2,560 |
57 | // num: num of 4, odds: num of 4 | matched = 0;
for (k = 0; k < 3; k++) {
if (nums[k] == 4) {
matched += 1;
}
| matched = 0;
for (k = 0; k < 3; k++) {
if (nums[k] == 4) {
matched += 1;
}
| 12,721 |
27 | // Mint real one | _mint(msg.sender,mobTokenId+MOB_OFFSET);
bool mintNewMob = true;
if(mobTokenIds[3] < TOTAL_MOB_COUNT){
mobTokenIds[_mobIndex] = ++mobTokenIds[3];
}else{
| _mint(msg.sender,mobTokenId+MOB_OFFSET);
bool mintNewMob = true;
if(mobTokenIds[3] < TOTAL_MOB_COUNT){
mobTokenIds[_mobIndex] = ++mobTokenIds[3];
}else{
| 59,519 |
9 | // sibblingOffset := COMMITMENT_SIZE_IN_BYTESlsb(siblingIndex). | let sibblingOffset := mulmod(
siblingIndex,
COMMITMENT_SIZE_IN_BYTES,
TWO_COMMITMENTS_SIZE_IN_BYTES
)
| let sibblingOffset := mulmod(
siblingIndex,
COMMITMENT_SIZE_IN_BYTES,
TWO_COMMITMENTS_SIZE_IN_BYTES
)
| 27,294 |
120 | // caller gives owner approval to operate token/ | if (isAllowListRequiredMapping[id]) {
require(
isOnAllowlist(id, _msgSender()),
"You are not allowed to mint this token"
);
if (tokenIdtoTokenMaxSupply[id] > 0) {
require(
totalSupply(id) + amount <= tokenIdtoTokenMaxSupply[id],
"max NFT limit exceeded"
);
| if (isAllowListRequiredMapping[id]) {
require(
isOnAllowlist(id, _msgSender()),
"You are not allowed to mint this token"
);
if (tokenIdtoTokenMaxSupply[id] > 0) {
require(
totalSupply(id) + amount <= tokenIdtoTokenMaxSupply[id],
"max NFT limit exceeded"
);
| 32,154 |
353 | // Extension of the ERC20 token contract to support token wrapping. Users can deposit and withdraw "underlying tokens" and receive a matching number of "wrapped tokens". This is useful | * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the
* wrapping of an existing "basic" ERC20 into a governance token.
*
* _Available since v4.2._
*/
abstract contract ERC20Wrapper is ERC20 {
IERC20 public immutable underlying;
constructor(IERC20 underlyingToken) {
underlying = underlyingToken;
}
/**
* @dev See {ERC20-decimals}.
*/
function decimals() public view virtual override returns (uint8) {
try IERC20Metadata(address(underlying)).decimals() returns (uint8 value) {
return value;
} catch {
return super.decimals();
}
}
/**
* @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.
*/
function depositFor(address account, uint256 amount) public virtual returns (bool) {
SafeERC20.safeTransferFrom(underlying, _msgSender(), address(this), amount);
_mint(account, amount);
return true;
}
/**
* @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.
*/
function withdrawTo(address account, uint256 amount) public virtual returns (bool) {
_burn(_msgSender(), amount);
SafeERC20.safeTransfer(underlying, account, amount);
return true;
}
/**
* @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
* function that can be exposed with access control if desired.
*/
function _recover(address account) internal virtual returns (uint256) {
uint256 value = underlying.balanceOf(address(this)) - totalSupply();
_mint(account, value);
return value;
}
}
| * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the
* wrapping of an existing "basic" ERC20 into a governance token.
*
* _Available since v4.2._
*/
abstract contract ERC20Wrapper is ERC20 {
IERC20 public immutable underlying;
constructor(IERC20 underlyingToken) {
underlying = underlyingToken;
}
/**
* @dev See {ERC20-decimals}.
*/
function decimals() public view virtual override returns (uint8) {
try IERC20Metadata(address(underlying)).decimals() returns (uint8 value) {
return value;
} catch {
return super.decimals();
}
}
/**
* @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.
*/
function depositFor(address account, uint256 amount) public virtual returns (bool) {
SafeERC20.safeTransferFrom(underlying, _msgSender(), address(this), amount);
_mint(account, amount);
return true;
}
/**
* @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.
*/
function withdrawTo(address account, uint256 amount) public virtual returns (bool) {
_burn(_msgSender(), amount);
SafeERC20.safeTransfer(underlying, account, amount);
return true;
}
/**
* @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
* function that can be exposed with access control if desired.
*/
function _recover(address account) internal virtual returns (uint256) {
uint256 value = underlying.balanceOf(address(this)) - totalSupply();
_mint(account, value);
return value;
}
}
| 35,906 |
77 | // Allows spinwin to update uint setting when there is a token exchange transaction exchangeAmount The converted exchange amount / | function spinwinUpdateExchangeMetric(uint256 exchangeAmount) public onlySpinwin {
_uintSettings['contractBalance'] = _uintSettings['contractBalance'].sub(exchangeAmount);
_setMaxProfit(false);
}
| function spinwinUpdateExchangeMetric(uint256 exchangeAmount) public onlySpinwin {
_uintSettings['contractBalance'] = _uintSettings['contractBalance'].sub(exchangeAmount);
_setMaxProfit(false);
}
| 3,997 |
1 | // Mapping from layer to item ID to index of the owner items list | mapping(uint256 => mapping(uint256 => uint256)) private _ownedItemsIndex;
| mapping(uint256 => mapping(uint256 => uint256)) private _ownedItemsIndex;
| 20,156 |
87 | // Release the tokens from the Voting Escrow contract when the lock expires./_recipient Address to send the tokens to | function release(address _recipient) external onlyGovernance {
IVotingEscrowMav(veToken).unstake(0);
uint256 _balance = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransfer(_recipient, _balance);
emit Released(msg.sender, IERC20(token).balanceOf(address(this)));
}
| function release(address _recipient) external onlyGovernance {
IVotingEscrowMav(veToken).unstake(0);
uint256 _balance = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransfer(_recipient, _balance);
emit Released(msg.sender, IERC20(token).balanceOf(address(this)));
}
| 27,330 |
22 | // staking function which receives AXN and creates the stake - takes as param the amount of AXN and the number of days to be stakedstaking days need to be >0 and lower than max days which is 5555 | // @param amount {uint256} - AXN amount to be staked
// @param stakingDays {uint256} - number of days to be staked
function stake(uint256 amount, uint256 stakingDays) external pausable {
require(stakingDays != 0, 'Staking: Staking days < 1');
require(stakingDays <= 5555, 'Staking: Staking days > 5555');
//call stake internal method
stakeInternal(amount, stakingDays, msg.sender);
//on stake axion gets burned
IToken(addresses.mainToken).burn(msg.sender, amount);
}
| // @param amount {uint256} - AXN amount to be staked
// @param stakingDays {uint256} - number of days to be staked
function stake(uint256 amount, uint256 stakingDays) external pausable {
require(stakingDays != 0, 'Staking: Staking days < 1');
require(stakingDays <= 5555, 'Staking: Staking days > 5555');
//call stake internal method
stakeInternal(amount, stakingDays, msg.sender);
//on stake axion gets burned
IToken(addresses.mainToken).burn(msg.sender, amount);
}
| 37,807 |
52 | // hacker get its reward via vesting contract | tokenLock = tokenLockFactory.createTokenLock(
address(HAT),
0x000000000000000000000000000000000000dEaD, //this address as owner, so it can do nothing.
_beneficiary,
hackerReward,
| tokenLock = tokenLockFactory.createTokenLock(
address(HAT),
0x000000000000000000000000000000000000dEaD, //this address as owner, so it can do nothing.
_beneficiary,
hackerReward,
| 29,131 |
115 | // HOOTS | string[4] memory parts = [
string(abi.encodePacked
(
'<pattern id="e" viewBox="13,-1,10,15" width="15%" height="95%"><polygon points="-99,-99 -99,99 99,99 99,-99" fill ="', colors[rug.background],'"/> <g stroke="black" stroke-width="0.75"><polygon points="5,5 18,10 23,5 18,0" fill ="', colors[rug.colorTwo],'"/><polygon points="21,0 26,5 21,10 33,5" fill ="', colors[rug.colorThree],'"/> </g><animate attributeName="x" from="0" to="0.3" dur="2.5s" repeatCount="indefinite"/> </pattern>'
)),
string(abi.encodePacked
(
'<pattern id="h" viewBox="10,0,20,25" width="15%" height="107%"><polygon points="-99,-99 -99,99 99,99 99,-99" fill ="', colors[rug.background],'"/><polygon points="9,4 14,9 14,18 9,23 26,23 31,18 31,9 26,4" fill ="', colors[rug.colorOne],'" stroke="black" stroke-width="1"/><g fill ="', colors[rug.background],'" stroke="black" stroke-width="0.5"><circle cx="20" cy="10" r="2.5"/><circle cx="20" cy="17" r="2.5"/><polygon points="24,11 24,16 29,13.5"/></g><circle cx="20" cy="10" r="1.75" fill="black"/><circle cx="20" cy="17" r="1.75" fill="black"/>'
)),
string(abi.encodePacked
| string[4] memory parts = [
string(abi.encodePacked
(
'<pattern id="e" viewBox="13,-1,10,15" width="15%" height="95%"><polygon points="-99,-99 -99,99 99,99 99,-99" fill ="', colors[rug.background],'"/> <g stroke="black" stroke-width="0.75"><polygon points="5,5 18,10 23,5 18,0" fill ="', colors[rug.colorTwo],'"/><polygon points="21,0 26,5 21,10 33,5" fill ="', colors[rug.colorThree],'"/> </g><animate attributeName="x" from="0" to="0.3" dur="2.5s" repeatCount="indefinite"/> </pattern>'
)),
string(abi.encodePacked
(
'<pattern id="h" viewBox="10,0,20,25" width="15%" height="107%"><polygon points="-99,-99 -99,99 99,99 99,-99" fill ="', colors[rug.background],'"/><polygon points="9,4 14,9 14,18 9,23 26,23 31,18 31,9 26,4" fill ="', colors[rug.colorOne],'" stroke="black" stroke-width="1"/><g fill ="', colors[rug.background],'" stroke="black" stroke-width="0.5"><circle cx="20" cy="10" r="2.5"/><circle cx="20" cy="17" r="2.5"/><polygon points="24,11 24,16 29,13.5"/></g><circle cx="20" cy="10" r="1.75" fill="black"/><circle cx="20" cy="17" r="1.75" fill="black"/>'
)),
string(abi.encodePacked
| 51,766 |
9 | // each GTAP1 holder can mint 2 | mapping(address => uint256) public gtapHolderMintCount;
| mapping(address => uint256) public gtapHolderMintCount;
| 825 |
28 | // Splitting | error SplittingUnapprovedPosition(address thrower, address caller, uint positionId);
error InvalidSplitAmount(address thrower, uint originalPositionAmount, uint splitAmount);
error ResultingOriginalPositionLiquidatable(address thrower, OptionPosition position, uint spotPrice);
error ResultingNewPositionLiquidatable(address thrower, OptionPosition position, uint spotPrice);
| error SplittingUnapprovedPosition(address thrower, address caller, uint positionId);
error InvalidSplitAmount(address thrower, uint originalPositionAmount, uint splitAmount);
error ResultingOriginalPositionLiquidatable(address thrower, OptionPosition position, uint spotPrice);
error ResultingNewPositionLiquidatable(address thrower, OptionPosition position, uint spotPrice);
| 15,733 |
71 | // Perform an ERC20 token transfer. Designed to be called by transfer functions possessingthe onlyProxy or optionalProxy modifiers. / | function _transfer_byProxy(address from, address to, uint value) internal returns (bool) {
return _internalTransfer(from, to, value);
}
| function _transfer_byProxy(address from, address to, uint value) internal returns (bool) {
return _internalTransfer(from, to, value);
}
| 26,564 |
3 | // a += e is equivalent to a = a + e.The operators -=, =, /=, %=, a |=, &= and ^= are defined accordingly. | a += 5; // a = 11+5 = 16
| a += 5; // a = 11+5 = 16
| 36,696 |
11 | // Sets `amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the riskthat someone may use both the old and the new allowance by unfortunatetransaction ordering. One possible solution to mitigate this racecondition is to first reduce the spender's allowance to 0 and set thedesired value afterwards: Emits an {Approval} event. / | function approve(address spender, uint256 amount) external returns (bool);
| function approve(address spender, uint256 amount) external returns (bool);
| 32,491 |
7 | // Ohm (3, 3) makes your code more efficient WGMI | revert(3, 3)
| revert(3, 3)
| 82,382 |
42 | // Adding to existing lock, or if a lock is expired - creating a new one |
require(_canConvertInt128(_value), "!convertInt128");
_locked.amount += int128(uint128(_value));
if (unlockTime != 0) {
_locked.end = unlockTime;
}
|
require(_canConvertInt128(_value), "!convertInt128");
_locked.amount += int128(uint128(_value));
if (unlockTime != 0) {
_locked.end = unlockTime;
}
| 16,291 |
91 | // helper functions | function wrap1 (address _token_addr, bytes32 _hash, uint256 _start, uint256 _end) internal pure
| function wrap1 (address _token_addr, bytes32 _hash, uint256 _start, uint256 _end) internal pure
| 18,588 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.