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
259
// Indicates that the contract is in the process of being initialized. /
bool private _initializing;
bool private _initializing;
1,940
41
// transfer ownership
transferOwnership(_owner);
transferOwnership(_owner);
5,276
86
// the user guessed right, he wins the roll formula minus house edge
to_pay = to_pay.add(_computeRollWin(bet).sub(edge));
to_pay = to_pay.add(_computeRollWin(bet).sub(edge));
19,052
67
// participiant put amount
uint256 amnt;
uint256 amnt;
279
8
// Modifier to check if the caller is the borrower
modifier onlyBorrower() { if (msg.sender != borrower) revert NotBorrower(msg.sender); _; }
modifier onlyBorrower() { if (msg.sender != borrower) revert NotBorrower(msg.sender); _; }
17,552
14
// Index unsubscribed eventtoken Super token addresspublisher Index publisherindexId The specified indexIdsubscriber The unsubscribed subscriberuserData The user provided data/
event IndexUnsubscribed(
event IndexUnsubscribed(
21,940
21
// Swap two tokens using this pool and the base pool. tokenIndexFrom the token the user wants to swap from tokenIndexTo the token the user wants to swap to dx the amount of tokens the user wants to swap from minDy the min amount the user would like to receive, or revert. deadline latest timestamp to accept this transaction /
function swapUnderlying( uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx, uint256 minDy, uint256 deadline ) external virtual nonReentrant
function swapUnderlying( uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx, uint256 minDy, uint256 deadline ) external virtual nonReentrant
31,931
63
// The bit position of `numberMinted` in packed address data.
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
1,511
1
// Returns the amount of tokens owned by `account`./
function balanceOf(address account) external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
29,447
7
// Allows funders to withdraw their funds if the proposal was unsuccessful/
function withdrawMoney() external{ Tellor _tellor = Tellor(tellorUserContract.tellorStorageAddress()); uint _amt = availableForWithdraw[msg.sender]; availableForWithdraw[msg.sender] =0; _tellor.transfer(msg.sender,_amt); }
function withdrawMoney() external{ Tellor _tellor = Tellor(tellorUserContract.tellorStorageAddress()); uint _amt = availableForWithdraw[msg.sender]; availableForWithdraw[msg.sender] =0; _tellor.transfer(msg.sender,_amt); }
31,760
24
// percent fee
if (!ZERO_FEE_WHITELIST.contains(userLock.tokenAddress)) { uint256 remainingShares = userLock.sharesDeposited - userLock.sharesWithdrawn; uint256 feeInShares = FullMath.mulDiv( remainingShares, FEES.tokenFee, 10000 ); uint256 balance = IERC20(userLock.tokenAddress).balanceOf(address(this));
if (!ZERO_FEE_WHITELIST.contains(userLock.tokenAddress)) { uint256 remainingShares = userLock.sharesDeposited - userLock.sharesWithdrawn; uint256 feeInShares = FullMath.mulDiv( remainingShares, FEES.tokenFee, 10000 ); uint256 balance = IERC20(userLock.tokenAddress).balanceOf(address(this));
18,950
99
// All reasons being used means the request can't be challenged again, so we can update its status.
submission.status = Status.None; submission.registered = true; submission.submissionTime = uint64(now); request.resolved = true;
submission.status = Status.None; submission.registered = true; submission.submissionTime = uint64(now); request.resolved = true;
29,817
81
// reject transfer/transferFrom requestnonce request recorded at this particular noncereason reason for rejection/
function rejectTransfer(uint256 nonce, uint256 reason) external onlyValidator checkIsAddressValid(pendingTransactions[nonce].from)
function rejectTransfer(uint256 nonce, uint256 reason) external onlyValidator checkIsAddressValid(pendingTransactions[nonce].from)
42,920
74
// Get units arrays for both sets
uint256[] memory currentSetUnits = currentSetInterface.getUnits(); uint256[] memory rebalancingSetUnits = rebalancingSetInterface.getUnits(); for (uint256 i=0; i < combinedTokenArray.length; i++) {
uint256[] memory currentSetUnits = currentSetInterface.getUnits(); uint256[] memory rebalancingSetUnits = rebalancingSetInterface.getUnits(); for (uint256 i=0; i < combinedTokenArray.length; i++) {
17,198
142
// after a day, admin finalizes mint request by providing the index of the request (visible in the MintOperationEvent accompanying the original request)
function finalizeMint(uint index) public onlyAdminOrOwner { MintOperation memory op = mintOperations[index]; require(op.admin == admin); //checks that the requester&#39;s adminship has not been revoked require(op.deferBlock <= block.number); //checks that enough time has elapsed address to = op.to; uint256 amount = op.amount; delete mintOperations[index]; trueVND.mint(to, amount); }
function finalizeMint(uint index) public onlyAdminOrOwner { MintOperation memory op = mintOperations[index]; require(op.admin == admin); //checks that the requester&#39;s adminship has not been revoked require(op.deferBlock <= block.number); //checks that enough time has elapsed address to = op.to; uint256 amount = op.amount; delete mintOperations[index]; trueVND.mint(to, amount); }
52,355
16
// If this contract has ETH, either passed in during deployment or pre-existing, credit it to the `initialContributor`.
_contribute(opts.initialContributor, opts.initialDelegate, initialContribution, "");
_contribute(opts.initialContributor, opts.initialDelegate, initialContribution, "");
40,716
210
// returns the conversion fee for a given target amount_targetAmounttarget amount return conversion fee/
function calculateFee(uint256 _targetAmount) internal view returns (uint256) { return _targetAmount.mul(conversionFee).div(PPM_RESOLUTION); }
function calculateFee(uint256 _targetAmount) internal view returns (uint256) { return _targetAmount.mul(conversionFee).div(PPM_RESOLUTION); }
10,068
88
// burn boost tokens
uint256 boostBalance = balanceOf(boostToken); uint256 burnAmount = boostBalance.mul(burnPercentage).div(DENOM); burnableBoostToken.burn(burnAmount); boostBalance = boostBalance.sub(burnAmount);
uint256 boostBalance = balanceOf(boostToken); uint256 burnAmount = boostBalance.mul(burnPercentage).div(DENOM); burnableBoostToken.burn(burnAmount); boostBalance = boostBalance.sub(burnAmount);
48,692
7
// The de facto standard address to denote the native token /
address private constant NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address private constant NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
21,697
235
// -- Mint and Burn --
function burn(uint256 amount) external; function mint(address _to, uint256 _amount) external;
function burn(uint256 amount) external; function mint(address _to, uint256 _amount) external;
84,319
48
// call provider to convert ETH to tokenTo
totalAmountReceived += swapEth(s, tokenTo);
totalAmountReceived += swapEth(s, tokenTo);
6,767
225
// alignment preserving cast
function addressToBytes32(address _addr) internal pure returns (bytes32) { return bytes32(uint256(uint160(_addr))); }
function addressToBytes32(address _addr) internal pure returns (bytes32) { return bytes32(uint256(uint160(_addr))); }
585
27
// update winner values
lottery.winnerSum += tokenCountToBuyFromSystem * price; lottery.winner = _getWinner();
lottery.winnerSum += tokenCountToBuyFromSystem * price; lottery.winner = _getWinner();
24,543
4
// EIP-20 token decimals for this token solhint-disable-next-line const-name-snakecase
uint8 public constant decimals = 18;
uint8 public constant decimals = 18;
10,591
85
// silently return on non-existing accounts
if (accountInMem.balance == 0) { return; }
if (accountInMem.balance == 0) { return; }
20,627
138
// If Vesper becomes large liquidity provider in Aave(This happened in past in vUSDC 1.0) In this case we might have more aToken compare to available liquidity in Aave and any withdraw asking more than available liquidity will fail. To do safe withdraw, check _amount against available liquidity.
(uint256 _availableLiquidity, , , , , , , , , ) = aaveProtocolDataProvider.getReserveData(_asset);
(uint256 _availableLiquidity, , , , , , , , , ) = aaveProtocolDataProvider.getReserveData(_asset);
58,631
182
// Binary search to estimate timestamp for block number/_block Block to find/max_epoch Don't go beyond this epoch/ return Approximate timestamp for block
function _find_block_epoch(uint _block, uint max_epoch) internal view returns (uint) { // Binary search uint _min = 0; uint _max = max_epoch; for (uint i = 0; i < 128; ++i) { // Will be always enough for 128-bit numbers if (_min >= _max) { break; } uint _mid = (_min + _max + 1) / 2; if (point_history[_mid].blk <= _block) { _min = _mid; } else { _max = _mid - 1; } } return _min; }
function _find_block_epoch(uint _block, uint max_epoch) internal view returns (uint) { // Binary search uint _min = 0; uint _max = max_epoch; for (uint i = 0; i < 128; ++i) { // Will be always enough for 128-bit numbers if (_min >= _max) { break; } uint _mid = (_min + _max + 1) / 2; if (point_history[_mid].blk <= _block) { _min = _mid; } else { _max = _mid - 1; } } return _min; }
30,970
184
// Methods to add minters to whitelist Requirements: - the caller must have admin role. /
function grantMinters(address[] memory _minters) public onlyRole(DEFAULT_ADMIN_ROLE)
function grantMinters(address[] memory _minters) public onlyRole(DEFAULT_ADMIN_ROLE)
29,324
19
// withdraw native currency from factory only by owner
* Emits a {WithdrawNativeFromFactory} event. */ function withdrawNativeFromFactory() external onlyOwner { payable(msg.sender).transfer(address(this).balance); emit WithdrawNativeFromFactory(msg.sender, address(this).balance); }
* Emits a {WithdrawNativeFromFactory} event. */ function withdrawNativeFromFactory() external onlyOwner { payable(msg.sender).transfer(address(this).balance); emit WithdrawNativeFromFactory(msg.sender, address(this).balance); }
29,201
84
// Logged when the TTL of a node changes
event NewTTL(bytes32 indexed node, uint64 ttl); function setSubnodeOwner( bytes32 node, bytes32 label, address owner ) external; function setResolver(bytes32 node, address resolver) external;
event NewTTL(bytes32 indexed node, uint64 ttl); function setSubnodeOwner( bytes32 node, bytes32 label, address owner ) external; function setResolver(bytes32 node, address resolver) external;
9,579
1
// Divides 2 numbers, solidity automatically throws if _y is 0.
function div(uint256 _x, uint256 _y) internal pure returns (uint256 result){ result = _x / _y; return result; }
function div(uint256 _x, uint256 _y) internal pure returns (uint256 result){ result = _x / _y; return result; }
48,721
106
// calculate current mining state
function getMiningState(uint _blockNum) public view returns(uint, uint){ require(_blockNum >= miningStateBlock, "_blockNum must be >= miningStateBlock"); uint blockNumber = _blockNum; if(_blockNum>endMiningBlockNum){ //if current block.number is bigger than the end of program, only update the state to endMiningBlockNum blockNumber = endMiningBlockNum; } uint deltaBlocks = blockNumber.sub(miningStateBlock); uint _miningStateBlock = miningStateBlock; uint _miningStateIndex = miningStateIndex; if (deltaBlocks > 0 && totalStaked > 0) { uint MVTAccrued = deltaBlocks.mul(MVTPerBlock); uint ratio = MVTAccrued.mul(1e18).div(totalStakedPower); //multiple ratio to 1e18 to prevent rounding error _miningStateIndex = miningStateIndex.add(ratio); //index is 1e18 precision _miningStateBlock = blockNumber; } return (_miningStateIndex, _miningStateBlock); }
function getMiningState(uint _blockNum) public view returns(uint, uint){ require(_blockNum >= miningStateBlock, "_blockNum must be >= miningStateBlock"); uint blockNumber = _blockNum; if(_blockNum>endMiningBlockNum){ //if current block.number is bigger than the end of program, only update the state to endMiningBlockNum blockNumber = endMiningBlockNum; } uint deltaBlocks = blockNumber.sub(miningStateBlock); uint _miningStateBlock = miningStateBlock; uint _miningStateIndex = miningStateIndex; if (deltaBlocks > 0 && totalStaked > 0) { uint MVTAccrued = deltaBlocks.mul(MVTPerBlock); uint ratio = MVTAccrued.mul(1e18).div(totalStakedPower); //multiple ratio to 1e18 to prevent rounding error _miningStateIndex = miningStateIndex.add(ratio); //index is 1e18 precision _miningStateBlock = blockNumber; } return (_miningStateIndex, _miningStateBlock); }
33,673
84
// Update storage if the new rate differs from the old rate.
if (_cache.interestRate != newInterestRate) { emit InterestRateUpdate(newInterestRate); debtTokenData.interestRate = _cache.interestRate = newInterestRate; }
if (_cache.interestRate != newInterestRate) { emit InterestRateUpdate(newInterestRate); debtTokenData.interestRate = _cache.interestRate = newInterestRate; }
40,855
4
// Params
uint256 public MinDepositPeriod; // Minimum deposit period, in seconds uint256 public MaxDepositPeriod; // Maximum deposit period, in seconds uint256 public MinDepositAmount; // Minimum deposit amount for each deposit, in stablecoins uint256 public MaxDepositAmount; // Maximum deposit amount for each deposit, in stablecoins
uint256 public MinDepositPeriod; // Minimum deposit period, in seconds uint256 public MaxDepositPeriod; // Maximum deposit period, in seconds uint256 public MinDepositAmount; // Minimum deposit amount for each deposit, in stablecoins uint256 public MaxDepositAmount; // Maximum deposit amount for each deposit, in stablecoins
28,013
0
// Library for errors related with expected function parameters. /
library ParameterError { /** * @dev Thrown when an invalid parameter is used in a function. * @param parameter The name of the parameter. * @param reason The reason why the received parameter is invalid. */ error InvalidParameter(string parameter, string reason); }
library ParameterError { /** * @dev Thrown when an invalid parameter is used in a function. * @param parameter The name of the parameter. * @param reason The reason why the received parameter is invalid. */ error InvalidParameter(string parameter, string reason); }
26,245
173
// prepare the lookup table
let tablePtr := add(table, 1)
let tablePtr := add(table, 1)
34,458
5
// Function that returns the verifier contract addressreturn The verifier contract address /
function verifier() external view returns (address);
function verifier() external view returns (address);
33,042
4
// override
initializer
initializer
32,887
103
// The main SuSquare struct. The owner may set these properties, subject/subject to certain rules. The actual 10x10 image is rendered on our/website using this data.
struct SuSquare { /// @dev This increments on each update uint256 version; /// @dev A 10x10 pixel image, stored 8-bit RGB values from left-to-right /// and top-to-bottom order (normal English reading order). So it is /// exactly 300 bytes. Or it is an empty array. /// So the first byte is the red channel for the top-left pixel, then /// the blue, then the green, and then next is the red channel for the /// pixel to the right of the first pixel. bytes rgbData; /// @dev The title of this square, at most 64 bytes, string title; /// @dev The URL of this square, at most 100 bytes, or empty string string href; }
struct SuSquare { /// @dev This increments on each update uint256 version; /// @dev A 10x10 pixel image, stored 8-bit RGB values from left-to-right /// and top-to-bottom order (normal English reading order). So it is /// exactly 300 bytes. Or it is an empty array. /// So the first byte is the red channel for the top-left pixel, then /// the blue, then the green, and then next is the red channel for the /// pixel to the right of the first pixel. bytes rgbData; /// @dev The title of this square, at most 64 bytes, string title; /// @dev The URL of this square, at most 100 bytes, or empty string string href; }
47,344
44
// This is internal function is equivalent to {transfer}, and can be used toe.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements: / /- `sender` cannot be the zero address.- `recipient` cannot be the zero address.- `sender` must have a balance of at least `amount`. /
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); }
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); }
46,931
19
// An internal function that holds all of the logic for metering a resource./_amount Amount of the resource requested./_initialGas The amount of gas before any modifier execution.
function _metered(uint64 _amount, uint256 _initialGas) internal { // Update block number and base fee if necessary. uint256 blockDiff = block.number - params.prevBlockNum; ResourceConfig memory config = _resourceConfig(); int256 targetResourceLimit = int256(uint256(config.maxResourceLimit)) / int256(uint256(config.elasticityMultiplier)); if (blockDiff > 0) { // Handle updating EIP-1559 style gas parameters. We use EIP-1559 to restrict the rate // at which deposits can be created and therefore limit the potential for deposits to // spam the L2 system. Fee scheme is very similar to EIP-1559 with minor changes. int256 gasUsedDelta = int256(uint256(params.prevBoughtGas)) - targetResourceLimit; int256 baseFeeDelta = (int256(uint256(params.prevBaseFee)) * gasUsedDelta) / (targetResourceLimit * int256(uint256(config.baseFeeMaxChangeDenominator))); // Update base fee by adding the base fee delta and clamp the resulting value between // min and max. int256 newBaseFee = Arithmetic.clamp({ _value: int256(uint256(params.prevBaseFee)) + baseFeeDelta, _min: int256(uint256(config.minimumBaseFee)), _max: int256(uint256(config.maximumBaseFee)) }); // If we skipped more than one block, we also need to account for every empty block. // Empty block means there was no demand for deposits in that block, so we should // reflect this lack of demand in the fee. if (blockDiff > 1) { // Update the base fee by repeatedly applying the exponent 1-(1/change_denominator) // blockDiff - 1 times. Simulates multiple empty blocks. Clamp the resulting value // between min and max. newBaseFee = Arithmetic.clamp({ _value: Arithmetic.cdexp({ _coefficient: newBaseFee, _denominator: int256(uint256(config.baseFeeMaxChangeDenominator)), _exponent: int256(blockDiff - 1) }), _min: int256(uint256(config.minimumBaseFee)), _max: int256(uint256(config.maximumBaseFee)) }); } // Update new base fee, reset bought gas, and update block number. params.prevBaseFee = uint128(uint256(newBaseFee)); params.prevBoughtGas = 0; params.prevBlockNum = uint64(block.number); } // Make sure we can actually buy the resource amount requested by the user. params.prevBoughtGas += _amount; require( int256(uint256(params.prevBoughtGas)) <= int256(uint256(config.maxResourceLimit)), "ResourceMetering: cannot buy more gas than available gas limit" ); // Determine the amount of ETH to be paid. uint256 resourceCost = uint256(_amount) * uint256(params.prevBaseFee); // We currently charge for this ETH amount as an L1 gas burn, so we convert the ETH amount // into gas by dividing by the L1 base fee. We assume a minimum base fee of 1 gwei to avoid // division by zero for L1s that don't support 1559 or to avoid excessive gas burns during // periods of extremely low L1 demand. One-day average gas fee hasn't dipped below 1 gwei // during any 1 day period in the last 5 years, so should be fine. uint256 gasCost = resourceCost / Math.max(block.basefee, 1 gwei); // Give the user a refund based on the amount of gas they used to do all of the work up to // this point. Since we're at the end of the modifier, this should be pretty accurate. Acts // effectively like a dynamic stipend (with a minimum value). uint256 usedGas = _initialGas - gasleft(); if (gasCost > usedGas) { Burn.gas(gasCost - usedGas); } }
function _metered(uint64 _amount, uint256 _initialGas) internal { // Update block number and base fee if necessary. uint256 blockDiff = block.number - params.prevBlockNum; ResourceConfig memory config = _resourceConfig(); int256 targetResourceLimit = int256(uint256(config.maxResourceLimit)) / int256(uint256(config.elasticityMultiplier)); if (blockDiff > 0) { // Handle updating EIP-1559 style gas parameters. We use EIP-1559 to restrict the rate // at which deposits can be created and therefore limit the potential for deposits to // spam the L2 system. Fee scheme is very similar to EIP-1559 with minor changes. int256 gasUsedDelta = int256(uint256(params.prevBoughtGas)) - targetResourceLimit; int256 baseFeeDelta = (int256(uint256(params.prevBaseFee)) * gasUsedDelta) / (targetResourceLimit * int256(uint256(config.baseFeeMaxChangeDenominator))); // Update base fee by adding the base fee delta and clamp the resulting value between // min and max. int256 newBaseFee = Arithmetic.clamp({ _value: int256(uint256(params.prevBaseFee)) + baseFeeDelta, _min: int256(uint256(config.minimumBaseFee)), _max: int256(uint256(config.maximumBaseFee)) }); // If we skipped more than one block, we also need to account for every empty block. // Empty block means there was no demand for deposits in that block, so we should // reflect this lack of demand in the fee. if (blockDiff > 1) { // Update the base fee by repeatedly applying the exponent 1-(1/change_denominator) // blockDiff - 1 times. Simulates multiple empty blocks. Clamp the resulting value // between min and max. newBaseFee = Arithmetic.clamp({ _value: Arithmetic.cdexp({ _coefficient: newBaseFee, _denominator: int256(uint256(config.baseFeeMaxChangeDenominator)), _exponent: int256(blockDiff - 1) }), _min: int256(uint256(config.minimumBaseFee)), _max: int256(uint256(config.maximumBaseFee)) }); } // Update new base fee, reset bought gas, and update block number. params.prevBaseFee = uint128(uint256(newBaseFee)); params.prevBoughtGas = 0; params.prevBlockNum = uint64(block.number); } // Make sure we can actually buy the resource amount requested by the user. params.prevBoughtGas += _amount; require( int256(uint256(params.prevBoughtGas)) <= int256(uint256(config.maxResourceLimit)), "ResourceMetering: cannot buy more gas than available gas limit" ); // Determine the amount of ETH to be paid. uint256 resourceCost = uint256(_amount) * uint256(params.prevBaseFee); // We currently charge for this ETH amount as an L1 gas burn, so we convert the ETH amount // into gas by dividing by the L1 base fee. We assume a minimum base fee of 1 gwei to avoid // division by zero for L1s that don't support 1559 or to avoid excessive gas burns during // periods of extremely low L1 demand. One-day average gas fee hasn't dipped below 1 gwei // during any 1 day period in the last 5 years, so should be fine. uint256 gasCost = resourceCost / Math.max(block.basefee, 1 gwei); // Give the user a refund based on the amount of gas they used to do all of the work up to // this point. Since we're at the end of the modifier, this should be pretty accurate. Acts // effectively like a dynamic stipend (with a minimum value). uint256 usedGas = _initialGas - gasleft(); if (gasCost > usedGas) { Burn.gas(gasCost - usedGas); } }
27,620
300
// Record vesting entry for claiming address and amount PERI already minted to rewardEscrow balance
rewardEscrow().appendVestingEntry(account, periAmount);
rewardEscrow().appendVestingEntry(account, periAmount);
13,658
89
// Returns the EIP-2612 domains separator.
function DOMAIN_SEPARATOR() public view virtual returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { result := mload(0x40) // Grab the free memory pointer. } // We simply calculate it on-the-fly to allow for cases where the `name` may change. bytes32 nameHash = keccak256(bytes(name())); /// @solidity memory-safe-assembly assembly { let m := result // `keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`. // forgefmt: disable-next-item mstore(m, 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f) mstore(add(m, 0x20), nameHash) // `keccak256("1")`. // forgefmt: disable-next-item mstore(add(m, 0x40), 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) result := keccak256(m, 0xa0) } }
function DOMAIN_SEPARATOR() public view virtual returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { result := mload(0x40) // Grab the free memory pointer. } // We simply calculate it on-the-fly to allow for cases where the `name` may change. bytes32 nameHash = keccak256(bytes(name())); /// @solidity memory-safe-assembly assembly { let m := result // `keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`. // forgefmt: disable-next-item mstore(m, 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f) mstore(add(m, 0x20), nameHash) // `keccak256("1")`. // forgefmt: disable-next-item mstore(add(m, 0x40), 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) result := keccak256(m, 0xa0) } }
27,448
103
// Called to `msg.sender` after minting liquidity to a position from IUniswapV3Poolmint./In the implementation you must pay the pool tokens owed for the minted liquidity./ The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory./amount0Owed The amount of token0 due to the pool for the minted liquidity/amount1Owed The amount of token1 due to the pool for the minted liquidity/data Any data passed through by the caller via the IUniswapV3PoolActionsmint call
function uniswapV3MintCallback( uint256 amount0Owed, uint256 amount1Owed, bytes calldata data ) external;
function uniswapV3MintCallback( uint256 amount0Owed, uint256 amount1Owed, bytes calldata data ) external;
3,644
15
// Emitted when Keep3rJobFundableLiquidityapproveLiquidity function is called/_liquidity The address of the liquidity pair being approved
event LiquidityApproval(address _liquidity);
event LiquidityApproval(address _liquidity);
431
220
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
mapping(uint256 => mapping(address => uint256)) private _balances;
1,065
114
// Returns the current admin. /
function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; }
function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; }
4,314
48
// Gets the balance of the specified address_owner address to query the balance of return uint256 representing the amount owned by the passed address/
function balanceOf(address _owner) public view returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; }
function balanceOf(address _owner) public view returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; }
28,580
11
// Automatically finish the game after coin flip
finishGame(gameId);
finishGame(gameId);
16,604
22
// Update withdrawn amount.
grants[_id].withdrawn = grants[_id].withdrawn.add(amount);
grants[_id].withdrawn = grants[_id].withdrawn.add(amount);
25,189
53
// Check whether the `_operator` address is allowed to manage the tokens held by `_tokenHolder` address./_operator address to check if it has the right to manage the tokens/_tokenHolder address which holds the tokens to be managed/ return `true` if `_operator` is authorized for `_tokenHolder`
function isOperatorFor(address _operator, address _tokenHolder) public constant returns (bool) { return (_operator == _tokenHolder || mAuthorized[_operator][_tokenHolder] || (mIsDefaultOperator[_operator] && !mRevokedDefaultOperator[_operator][_tokenHolder])); }
function isOperatorFor(address _operator, address _tokenHolder) public constant returns (bool) { return (_operator == _tokenHolder || mAuthorized[_operator][_tokenHolder] || (mIsDefaultOperator[_operator] && !mRevokedDefaultOperator[_operator][_tokenHolder])); }
5,788
35
// sell
if (diffTimestamp <= 60) {
if (diffTimestamp <= 60) {
5,918
75
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
uint64 numberBurned;
12,648
106
// Notifications for templates
event LogTemplateCreated(address indexed _creator, address indexed _template, string _offeringType); event LogNewTemplateProposal(address indexed _securityToken, address indexed _template, address indexed _delegate, uint _templateProposalIndex); event LogCancelTemplateProposal(address indexed _securityToken, address indexed _template, uint _templateProposalIndex);
event LogTemplateCreated(address indexed _creator, address indexed _template, string _offeringType); event LogNewTemplateProposal(address indexed _securityToken, address indexed _template, address indexed _delegate, uint _templateProposalIndex); event LogCancelTemplateProposal(address indexed _securityToken, address indexed _template, uint _templateProposalIndex);
31,694
41
// first deduct any previous claim
mapEraPool_Claims[currentEra][pool] = mapEraPool_Claims[currentEra][pool] .sub(mapMemberEraPool_Claim[member][currentEra][pool]); uint256 amount = mapMemberPool_Balance[member][pool]; // then get latest balance mapMemberEraPool_Claim[member][currentEra][pool] = amount; // then update the claim mapEraPool_Claims[currentEra][pool] = mapEraPool_Claims[currentEra][pool] .add(amount); // then add to total emit MemberRegisters(member, pool, amount, currentEra);
mapEraPool_Claims[currentEra][pool] = mapEraPool_Claims[currentEra][pool] .sub(mapMemberEraPool_Claim[member][currentEra][pool]); uint256 amount = mapMemberPool_Balance[member][pool]; // then get latest balance mapMemberEraPool_Claim[member][currentEra][pool] = amount; // then update the claim mapEraPool_Claims[currentEra][pool] = mapEraPool_Claims[currentEra][pool] .add(amount); // then add to total emit MemberRegisters(member, pool, amount, currentEra);
2,723
118
// _name Name of the token, also will be used for erc20 'symbol' property (see billsOfExchange.initToken )_totalSupply Number (amount) of bills of exchange to create__currency A currency in which bill payments have to be made, for example: "EUR", "USD"_sumToBePaidForEveryToken A sum of each bill of exchange_drawerName The name of the person (legal or physical) who issues the bill (drawer)_drawee The name of the person (legal or physical) who is to pay (drawee)__draweeSignerAddress Ethereum address of the person who has to accept bills of exchange in the name of the drawee. Drawer has to agree this address with the drawee (acceptor) in
function createBillsOfExchange(
function createBillsOfExchange(
26,884
110
// PermissionedTokenProxyA proxy contract that serves the latest implementation of PermissionedToken./
contract PermissionedTokenProxy is UpgradeabilityProxy, Ownable { PermissionedTokenStorage public tokenStorage; Regulator public regulator; // Events event ChangedRegulator(address indexed oldRegulator, address indexed newRegulator ); /** * @dev create a new PermissionedToken as a proxy contract * with a brand new data storage **/ constructor(address _implementation, address _regulator) UpgradeabilityProxy(_implementation) public { regulator = Regulator(_regulator); tokenStorage = new PermissionedTokenStorage(); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) public onlyOwner { _upgradeTo(newImplementation); } /** * @return The address of the implementation. */ function implementation() public view returns (address) { return _implementation(); } }
contract PermissionedTokenProxy is UpgradeabilityProxy, Ownable { PermissionedTokenStorage public tokenStorage; Regulator public regulator; // Events event ChangedRegulator(address indexed oldRegulator, address indexed newRegulator ); /** * @dev create a new PermissionedToken as a proxy contract * with a brand new data storage **/ constructor(address _implementation, address _regulator) UpgradeabilityProxy(_implementation) public { regulator = Regulator(_regulator); tokenStorage = new PermissionedTokenStorage(); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) public onlyOwner { _upgradeTo(newImplementation); } /** * @return The address of the implementation. */ function implementation() public view returns (address) { return _implementation(); } }
51,812
23
// functions
35,082
119
// Make sure ALL TEAMS PASED IN BELONG TO THE CONTEST BEING SCORED
uint32 contestIdForTeamBeingScored = teamIdToContestId[teamId]; require(contestIdForTeamBeingScored == _contestId);
uint32 contestIdForTeamBeingScored = teamIdToContestId[teamId]; require(contestIdForTeamBeingScored == _contestId);
48,507
235
// referral program
address referralProgram;
address referralProgram;
33,978
25
// Connector Details/
function connectorID() public pure returns(uint _type, uint _id) { (_type, _id) = (1, 42); }
function connectorID() public pure returns(uint _type, uint _id) { (_type, _id) = (1, 42); }
6,595
3
// 721 Interfaces
bytes4 public constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
bytes4 public constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
27,660
294
// Return all asset addresses in order /
function getAllAssets() external view returns (address[] memory) { return allAssets; }
function getAllAssets() external view returns (address[] memory) { return allAssets; }
78,548
79
// Used for calculating the actual token amount received
uint256 prevBalance = t.balanceOf(address(this));
uint256 prevBalance = t.balanceOf(address(this));
14,887
4
// Only permits calls by maintainers. /
modifier onlyMaintainer() { if (maintainers[msg.sender] == false) revert OnlyMaintainer(); _; }
modifier onlyMaintainer() { if (maintainers[msg.sender] == false) revert OnlyMaintainer(); _; }
7,614
509
// Returns averge fees in this epoch
function averageFeesPerBlockEpoch() external view returns (uint256 averagePerBlock) { averagePerBlock = rewardsInThisEpoch.div(block.number.sub(epochCalculationStartBlock)); }
function averageFeesPerBlockEpoch() external view returns (uint256 averagePerBlock) { averagePerBlock = rewardsInThisEpoch.div(block.number.sub(epochCalculationStartBlock)); }
44,692
262
// Throw event:
emit Randomized( msg.sender, _prevBlock, _queryId, witnetRandomnessRequest.hash() );
emit Randomized( msg.sender, _prevBlock, _queryId, witnetRandomnessRequest.hash() );
36,650
168
// import { ScaleStruct } from "contracts/common/Scale.struct.sol";
using Input for Input.Data; using Bytes for bytes;
using Input for Input.Data; using Bytes for bytes;
6,658
0
// Create MGC contract. Setup predicate address as the predicate role. /
constructor(address predicate) ERC777("Manager Contracts Token", "MGC", new address[](0))
constructor(address predicate) ERC777("Manager Contracts Token", "MGC", new address[](0))
78,390
14
// Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens`from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws iftransfers are impossible. from - account to make the transfer from to1 - account to transfer `value1` tokens to value1 - tokens to transfer to account `to1` to2 - account to transfer `value2` tokens to value2 - tokens to transfer to account `to2` /
function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } }
function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } }
18,024
17
// Epic rings ids are stored as a tightly packed array of uint16 Epic rings max supply is stored as a tightly packed array of uint8
bytes[5] private epicIds; bytes[5] private epicMax;
bytes[5] private epicIds; bytes[5] private epicMax;
14,935
0
// Hyperparameters
address bikeAdmin; uint256 requiredDeposit; uint256 fee;
address bikeAdmin; uint256 requiredDeposit; uint256 fee;
46,762
32
// We dont add lock here because we want to be able to change beekeeper in case of community take over long into the future.When contract is locked beekeeper has very limited access.
beekeeper = _admin;
beekeeper = _admin;
28,369
36
// According to the app basic law, we should never revert in a termination callback
return bytes("");
return bytes("");
35,993
75
// Check for expiry.
if (order.expiry <= block.timestamp) { return LibNFTOrder.OrderStatus.EXPIRED; }
if (order.expiry <= block.timestamp) { return LibNFTOrder.OrderStatus.EXPIRED; }
29,395
3
// 当前最高出价
uint public highestBid;
uint public highestBid;
37,387
240
// Internal function for setting a new user signing key. Called by theinitializer, by the `setUserSigningKey` function, and by the `recover`function. A `NewUserSigningKey` event will also be emitted. userSigningKey address The new user signing key to set on this smartwallet. /
function _setUserSigningKey(address userSigningKey) internal { // Ensure that a user signing key is set on this smart wallet. if (userSigningKey == address(0)) { revert(_revertReason(14)); } _userSigningKey = userSigningKey; emit NewUserSigningKey(userSigningKey); }
function _setUserSigningKey(address userSigningKey) internal { // Ensure that a user signing key is set on this smart wallet. if (userSigningKey == address(0)) { revert(_revertReason(14)); } _userSigningKey = userSigningKey; emit NewUserSigningKey(userSigningKey); }
7,940
2
// Constants
uint8 public MAX_MINT_PRIVATE_ROUND = 3; uint8 public MAX_MINT_PER_TX = 10; uint256 public MAX_SUPPLY = 3999; uint256 public RESERVED_NFT_COUNT = 90; uint256 public TEAM_NFT_COUNT = 49;
uint8 public MAX_MINT_PRIVATE_ROUND = 3; uint8 public MAX_MINT_PER_TX = 10; uint256 public MAX_SUPPLY = 3999; uint256 public RESERVED_NFT_COUNT = 90; uint256 public TEAM_NFT_COUNT = 49;
11,372
3
// while loop
uint i; while (i < 10) { i++; }
uint i; while (i < 10) { i++; }
39,298
180
// This function is what other USE pools will call to mint new SHARES (similar to the USE mint)
function pool_mint(address m_address, uint256 m_amount) external onlyPools { if(trackingVotes){ uint32 srcRepNum = numCheckpoints[address(this)]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[address(this)][srcRepNum - 1].votes : 0; uint96 srcRepNew = add96(srcRepOld, uint96(m_amount), "pool_mint new votes overflows"); _writeCheckpoint(address(this), srcRepNum, srcRepOld, srcRepNew); // mint new votes trackVotes(address(this), m_address, uint96(m_amount)); } require(totalSupply() <= supply_cap,"!cap"); super._mint(m_address, m_amount); emit SharesMinted(address(this), m_address, m_amount); }
function pool_mint(address m_address, uint256 m_amount) external onlyPools { if(trackingVotes){ uint32 srcRepNum = numCheckpoints[address(this)]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[address(this)][srcRepNum - 1].votes : 0; uint96 srcRepNew = add96(srcRepOld, uint96(m_amount), "pool_mint new votes overflows"); _writeCheckpoint(address(this), srcRepNum, srcRepOld, srcRepNew); // mint new votes trackVotes(address(this), m_address, uint96(m_amount)); } require(totalSupply() <= supply_cap,"!cap"); super._mint(m_address, m_amount); emit SharesMinted(address(this), m_address, m_amount); }
4,591
0
// Network: PolygonJobsId(Get -> Uint256) - 5592aa6da3d64580933fce0401d373f0Node - 0xb33D8A4e62236eA91F3a8fD7ab15A95B9B7eEc7DChainlinkToken - 0x326C977E6efc84E512bB9C30f76E30c160eD06FBFee: 0.1 LINK /
constructor() public { setChainlinkToken(0x326C977E6efc84E512bB9C30f76E30c160eD06FB); oracle = 0xb33D8A4e62236eA91F3a8fD7ab15A95B9B7eEc7D; jobId = "5592aa6da3d64580933fce0401d373f0"; fee = 0.1 * 10 ** 18; // 0.1 LINK }
constructor() public { setChainlinkToken(0x326C977E6efc84E512bB9C30f76E30c160eD06FB); oracle = 0xb33D8A4e62236eA91F3a8fD7ab15A95B9B7eEc7D; jobId = "5592aa6da3d64580933fce0401d373f0"; fee = 0.1 * 10 ** 18; // 0.1 LINK }
51,674
29
// Emit log event
emit LogModuleAdded(moduleType, moduleName, _moduleFactory, module, moduleCost, _budget, now);
emit LogModuleAdded(moduleType, moduleName, _moduleFactory, module, moduleCost, _budget, now);
3,086
24
// Buy Fee
uint256 private _redisFeeOnBuy = 0;// uint256 private _taxFeeOnBuy = 10;//
uint256 private _redisFeeOnBuy = 0;// uint256 private _taxFeeOnBuy = 10;//
2,918
34
// Add sell price minus fees to previous cup owner
balances[cup.owner] += msg.value.sub(fee);
balances[cup.owner] += msg.value.sub(fee);
53,647
141
// converts bond price to DAI value return price_ uint /
function bondPriceInUSD() public view returns ( uint price_ ) { if( isLiquidityBond ) { price_ = bondPrice().mul( IBondCalculator( bondCalculator ).markdown( principle ) ).div( 100 ); } else { price_ = bondPrice().mul( 10 ** IERC20( principle ).decimals() ).div( 100 ); } }
function bondPriceInUSD() public view returns ( uint price_ ) { if( isLiquidityBond ) { price_ = bondPrice().mul( IBondCalculator( bondCalculator ).markdown( principle ) ).div( 100 ); } else { price_ = bondPrice().mul( 10 ** IERC20( principle ).decimals() ).div( 100 ); } }
2,987
32
// Typically there wouldn't be any amount here however, it is possible because of the emergencyExit
uint256 entireBalance = IERC20(underlying()).balanceOf(address(this)); if(amount > entireBalance){
uint256 entireBalance = IERC20(underlying()).balanceOf(address(this)); if(amount > entireBalance){
37,890
17
// Interaction
msg.sender.call.value(amount)();
msg.sender.call.value(amount)();
22,703
2
// selector for transferFrom(address,address,uint256)
mstore(ptr, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(ptr, 0x04), and(owner, ADDRESS_MASK)) mstore(add(ptr, 0x24), and(to, ADDRESS_MASK)) mstore(add(ptr, 0x44), tokenId) let success := call( gas(), and(token, ADDRESS_MASK), 0, ptr,
mstore(ptr, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(ptr, 0x04), and(owner, ADDRESS_MASK)) mstore(add(ptr, 0x24), and(to, ADDRESS_MASK)) mstore(add(ptr, 0x44), tokenId) let success := call( gas(), and(token, ADDRESS_MASK), 0, ptr,
19,582
22
// Returns decimals of token/
function decimals() public pure returns(uint256){ return _decimals; }
function decimals() public pure returns(uint256){ return _decimals; }
47,873
40
// /
function getAssetPrice(address _asset) external view returns (uint256);
function getAssetPrice(address _asset) external view returns (uint256);
17,552
455
// Selector of `log(uint256,address,uint256,string)`.
mstore(0x00, 0xddb06521) mstore(0x20, p0) mstore(0x40, p1) mstore(0x60, p2) mstore(0x80, 0x80) writeString(0xa0, p3)
mstore(0x00, 0xddb06521) mstore(0x20, p0) mstore(0x40, p1) mstore(0x60, p2) mstore(0x80, 0x80) writeString(0xa0, p3)
30,660
36
// EXTERNAL FUNCTIONS (ERC1400 INTERFACE) // Document Management // Access a document associated with the token. name Short name (represented as a bytes32) associated to the document.return Requested document + document hash. /
function getDocument(bytes32 name) external override view returns (string memory, bytes32) { require(bytes(_documents[name].docURI).length != 0); // Action Blocked - Empty document return ( _documents[name].docURI, _documents[name].docHash ); }
function getDocument(bytes32 name) external override view returns (string memory, bytes32) { require(bytes(_documents[name].docURI).length != 0); // Action Blocked - Empty document return ( _documents[name].docURI, _documents[name].docHash ); }
12,212
17
// Upper bound for the per-second redemption rate
uint256 public redemptionRateUpperBound; // [ray]
uint256 public redemptionRateUpperBound; // [ray]
54,096
98
// This function will return the address and amount of the token with the lowest price
uint256 length = tokenList.length; uint256 targetID = 0; uint256 targetPrice = 0; for(uint256 i = 0; i < length; i++){ if(tokenList[i].aToken.balanceOf(address(this)) > 0){ uint256 _price = tokenList[i].price; if(targetPrice == 0 || _price <= targetPrice){ targetPrice = _price; targetID = i; }
uint256 length = tokenList.length; uint256 targetID = 0; uint256 targetPrice = 0; for(uint256 i = 0; i < length; i++){ if(tokenList[i].aToken.balanceOf(address(this)) > 0){ uint256 _price = tokenList[i].price; if(targetPrice == 0 || _price <= targetPrice){ targetPrice = _price; targetID = i; }
3,904
31
// Get specIdList on the market/_marketId marketId/ return specIdList
function specIdsOf(uint256 _marketId) public view returns (uint256[]) { require(market.ownerOf(_marketId) != address(0)); return specIdList.valuesOf(_marketId); }
function specIdsOf(uint256 _marketId) public view returns (uint256[]) { require(market.ownerOf(_marketId) != address(0)); return specIdList.valuesOf(_marketId); }
23,692
20
// Minimum price the AMM will sell back an option at for liquidations (as a % of current spot)
uint liquidateSpotMin;
uint liquidateSpotMin;
15,762
54
// Mapping from owner address to mapping of operator addresses. /
mapping (address => mapping (address => bool)) internal ownerToOperators;
mapping (address => mapping (address => bool)) internal ownerToOperators;
44,038
45
// write an oracle entry
(slot0.observationIndex, slot0.observationCardinality) = observations.write( _slot0.observationIndex, _blockTimestamp(), _slot0.tick, liquidityBefore, _slot0.observationCardinality, _slot0.observationCardinalityNext ); amount0 = SqrtPriceMath.getAmount0Delta(
(slot0.observationIndex, slot0.observationCardinality) = observations.write( _slot0.observationIndex, _blockTimestamp(), _slot0.tick, liquidityBefore, _slot0.observationCardinality, _slot0.observationCardinalityNext ); amount0 = SqrtPriceMath.getAmount0Delta(
4,235
148
// Get the token balance of a wallet with address _owner /
function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; }
function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; }
10,444
23
// gas optimization to allow a higher maximum token limit deliberately not using safemath here to keep overflows from preventing the function execution (which would break ragekicks) if a token overflows, it is because the supply was artificially inflated to oblivion, so we probably don"t care about it anyways
bank.internalTransfer( GUILD, memberAddr, currentToken, amountToRagequit );
bank.internalTransfer( GUILD, memberAddr, currentToken, amountToRagequit );
72,109