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
9
// mint to specific wallet
function devMint(uint256 numberOfTokens) public onlyOwner { require(totalSupply() + numberOfTokens <= maxSupply, "Purchase would exceed max supply."); for (uint i = 0; i < numberOfTokens; i++) { _safeMint(0xB52093Eb79BBAa599C0De56FD58ceF84656ec987, totalSupply() + 1); } }
function devMint(uint256 numberOfTokens) public onlyOwner { require(totalSupply() + numberOfTokens <= maxSupply, "Purchase would exceed max supply."); for (uint i = 0; i < numberOfTokens; i++) { _safeMint(0xB52093Eb79BBAa599C0De56FD58ceF84656ec987, totalSupply() + 1); } }
29,626
371
// No risk of wrapping around on casting to uint256 since deposit end always > deposit start and types are 64 bits
uint256 shareAmount = userDeposit.amount * getMultiplier(uint256(userDeposit.end - userDeposit.start)) / 1e18;
uint256 shareAmount = userDeposit.amount * getMultiplier(uint256(userDeposit.end - userDeposit.start)) / 1e18;
27,512
75
// To keep the math correct, the user's combined weight must be recomputed
( uint256 old_combined_weight, uint256 new_combined_weight ) = calcCurCombinedWeight(account);
( uint256 old_combined_weight, uint256 new_combined_weight ) = calcCurCombinedWeight(account);
5,151
14
// Get user's total Referral Reward (withdrawed & available to withdraw)
function getUserReferralBonus(address userAddress) public view returns(uint256) { uint256 userWithdrawedReferralBonus = getUserTotalWithdrawn(userAddress).sub(getUserTotalWithdrawnDividends(userAddress)); return users[userAddress].bonus.add(userWithdrawedReferralBonus); }
function getUserReferralBonus(address userAddress) public view returns(uint256) { uint256 userWithdrawedReferralBonus = getUserTotalWithdrawn(userAddress).sub(getUserTotalWithdrawnDividends(userAddress)); return users[userAddress].bonus.add(userWithdrawedReferralBonus); }
3,687
218
// ==============================================================================_|_ __ | _. | (_)(_)|_\.==============================================================================/ gets existing or registers new pID.use this when a player may be newreturn pID/
function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns)
function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns)
24,212
221
// calculate amount to liquidate to fix ratio including accrued interest
uint256 liquidationAmount = calculateAmountToLiquidate( pynthLoan.loanAmount.add(pynthLoan.accruedInterest).add(interestAmount), collateralValue );
uint256 liquidationAmount = calculateAmountToLiquidate( pynthLoan.loanAmount.add(pynthLoan.accruedInterest).add(interestAmount), collateralValue );
14,164
131
// use by default 300,000 gas to process auto-claiming dividends
uint256 public gasForProcessing = 300000; mapping (address => bool) private _isExcludedFromFees;
uint256 public gasForProcessing = 300000; mapping (address => bool) private _isExcludedFromFees;
4,799
54
// Add the balance to the sender
balances[msg.sender] += msg.value;
balances[msg.sender] += msg.value;
29,445
12
// pull
IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
25,111
190
// Remove an address from a supplied enumeration.toRemoveThe address to remove. enumeration The enumerated addresses to parse. /
function _removeFromEnumeration( address toRemove, address[] storage enumeration
function _removeFromEnumeration( address toRemove, address[] storage enumeration
38,038
95
// Deposits specified asset cash external precision amount into an nToken and mints the corresponding amount of nTokens into the account
DepositAssetAndMintNToken,
DepositAssetAndMintNToken,
76,933
154
// Add NFT
_addTokenTo(_to, _tokenId);
_addTokenTo(_to, _tokenId);
72,144
76
// Wrapper for safeTransfer
function _safeTransfer(address token, address to, uint256 amount) internal { IERC20(token).safeTransfer(to, amount); }
function _safeTransfer(address token, address to, uint256 amount) internal { IERC20(token).safeTransfer(to, amount); }
29,687
32
// Errors library Aave Defines the error messages emitted by the different contracts of the Aave protocol Error messages prefix glossary: - VL = ValidationLogic - MATH = Math libraries - CT = Common errors between tokens (AToken, VariableDebtToken and StableDebtToken) - AT = AToken - SDT = StableDebtToken - VDT = VariableDebtToken - LP = LendingPool - LPAPR = LendingPoolAddressesProviderRegistry - LPC = LendingPoolConfiguration - RL = ReserveLogic - LPCM = LendingPoolCollateralManager - P = Pausable /
library Errors { //common errors string public constant CALLER_NOT_POOL_ADMIN = '33'; // 'The caller must be the pool admin' string public constant BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small //contract specific errors string public constant VL_INVALID_AMOUNT = '1'; // 'Amount must be greater than 0' string public constant VL_NO_ACTIVE_RESERVE = '2'; // 'Action requires an active reserve' string public constant VL_RESERVE_FROZEN = '3'; // 'Action cannot be performed because the reserve is frozen' string public constant VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4'; // 'The current liquidity is not enough' string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5'; // 'User cannot withdraw more than the available balance' string public constant VL_TRANSFER_NOT_ALLOWED = '6'; // 'Transfer cannot be allowed.' string public constant VL_BORROWING_NOT_ENABLED = '7'; // 'Borrowing is not enabled' string public constant VL_INVALID_INTEREST_RATE_MODE_SELECTED = '8'; // 'Invalid interest rate mode selected' string public constant VL_COLLATERAL_BALANCE_IS_0 = '9'; // 'The collateral balance is 0' string public constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10'; // 'Health factor is lesser than the liquidation threshold' string public constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = '11'; // 'There is not enough collateral to cover a new borrow' string public constant VL_STABLE_BORROWING_NOT_ENABLED = '12'; // stable borrowing not enabled string public constant VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY = '13'; // collateral is (mostly) the same currency that is being borrowed string public constant VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14'; // 'The requested amount is greater than the max loan size in stable rate mode string public constant VL_NO_DEBT_OF_SELECTED_TYPE = '15'; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt' string public constant VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16'; // 'To repay on behalf of an user an explicit amount to repay is needed' string public constant VL_NO_STABLE_RATE_LOAN_IN_RESERVE = '17'; // 'User does not have a stable rate loan in progress on this reserve' string public constant VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18'; // 'User does not have a variable rate loan in progress on this reserve' string public constant VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19'; // 'The underlying balance needs to be greater than 0' string public constant VL_DEPOSIT_ALREADY_IN_USE = '20'; // 'User deposit is already being used as collateral' string public constant LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = '21'; // 'User does not have any stable rate loan for this reserve' string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22'; // 'Interest rate rebalance conditions were not met' string public constant LP_LIQUIDATION_CALL_FAILED = '23'; // 'Liquidation call failed' string public constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24'; // 'There is not enough liquidity available to borrow' string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = '25'; // 'The requested amount is too small for a FlashLoan.' string public constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26'; // 'The actual balance of the protocol is inconsistent' string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // 'The caller of the function is not the lending pool configurator' string public constant LP_INCONSISTENT_FLASHLOAN_PARAMS = '28'; string public constant CT_CALLER_MUST_BE_LENDING_POOL = '29'; // 'The caller of this function must be a lending pool' string public constant CT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself' string public constant CT_TRANSFER_AMOUNT_NOT_GT_0 = '31'; // 'Transferred amount needs to be greater than zero' string public constant RL_RESERVE_ALREADY_INITIALIZED = '32'; // 'Reserve has already been initialized' string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = '34'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_ATOKEN_POOL_ADDRESS = '35'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS = '36'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS = '37'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '38'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_ADDRESSES_PROVIDER_ID = '40'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_CONFIGURATION = '75'; // 'Invalid risk parameters for the reserve' string public constant LPC_CALLER_NOT_EMERGENCY_ADMIN = '76'; // 'The caller must be the emergency admin' string public constant LPAPR_PROVIDER_NOT_REGISTERED = '41'; // 'Provider is not registered' string public constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42'; // 'Health factor is not below the threshold' string public constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43'; // 'The collateral chosen cannot be liquidated' string public constant LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '44'; // 'User did not borrow the specified currency' string public constant LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '45'; // "There isn't enough liquidity available to liquidate" string public constant LPCM_NO_ERRORS = '46'; // 'No errors' string public constant LP_INVALID_FLASHLOAN_MODE = '47'; //Invalid flashloan mode selected string public constant MATH_MULTIPLICATION_OVERFLOW = '48'; string public constant MATH_ADDITION_OVERFLOW = '49'; string public constant MATH_DIVISION_BY_ZERO = '50'; string public constant RL_LIQUIDITY_INDEX_OVERFLOW = '51'; // Liquidity index overflows uint128 string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = '52'; // Variable borrow index overflows uint128 string public constant RL_LIQUIDITY_RATE_OVERFLOW = '53'; // Liquidity rate overflows uint128 string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = '54'; // Variable borrow rate overflows uint128 string public constant RL_STABLE_BORROW_RATE_OVERFLOW = '55'; // Stable borrow rate overflows uint128 string public constant CT_INVALID_MINT_AMOUNT = '56'; //invalid amount to mint string public constant LP_FAILED_REPAY_WITH_COLLATERAL = '57'; string public constant CT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn string public constant LP_FAILED_COLLATERAL_SWAP = '60'; string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61'; string public constant LP_REENTRANCY_NOT_ALLOWED = '62'; string public constant LP_CALLER_MUST_BE_AN_ATOKEN = '63'; string public constant LP_IS_PAUSED = '64'; // 'Pool is paused' string public constant LP_NO_MORE_RESERVES_ALLOWED = '65'; string public constant LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = '66'; string public constant RC_INVALID_LTV = '67'; string public constant RC_INVALID_LIQ_THRESHOLD = '68'; string public constant RC_INVALID_LIQ_BONUS = '69'; string public constant RC_INVALID_DECIMALS = '70'; string public constant RC_INVALID_RESERVE_FACTOR = '71'; string public constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = '72'; string public constant VL_INCONSISTENT_FLASHLOAN_PARAMS = '73'; string public constant LP_INCONSISTENT_PARAMS_LENGTH = '74'; string public constant UL_INVALID_INDEX = '77'; string public constant LP_NOT_CONTRACT = '78'; string public constant SDT_STABLE_DEBT_OVERFLOW = '79'; string public constant SDT_BURN_EXCEEDS_BALANCE = '80'; enum CollateralManagerErrors { NO_ERROR, NO_COLLATERAL_AVAILABLE, COLLATERAL_CANNOT_BE_LIQUIDATED, CURRRENCY_NOT_BORROWED, HEALTH_FACTOR_ABOVE_THRESHOLD, NOT_ENOUGH_LIQUIDITY, NO_ACTIVE_RESERVE, HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD, INVALID_EQUAL_ASSETS_TO_SWAP, FROZEN_RESERVE } }
library Errors { //common errors string public constant CALLER_NOT_POOL_ADMIN = '33'; // 'The caller must be the pool admin' string public constant BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small //contract specific errors string public constant VL_INVALID_AMOUNT = '1'; // 'Amount must be greater than 0' string public constant VL_NO_ACTIVE_RESERVE = '2'; // 'Action requires an active reserve' string public constant VL_RESERVE_FROZEN = '3'; // 'Action cannot be performed because the reserve is frozen' string public constant VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4'; // 'The current liquidity is not enough' string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5'; // 'User cannot withdraw more than the available balance' string public constant VL_TRANSFER_NOT_ALLOWED = '6'; // 'Transfer cannot be allowed.' string public constant VL_BORROWING_NOT_ENABLED = '7'; // 'Borrowing is not enabled' string public constant VL_INVALID_INTEREST_RATE_MODE_SELECTED = '8'; // 'Invalid interest rate mode selected' string public constant VL_COLLATERAL_BALANCE_IS_0 = '9'; // 'The collateral balance is 0' string public constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10'; // 'Health factor is lesser than the liquidation threshold' string public constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = '11'; // 'There is not enough collateral to cover a new borrow' string public constant VL_STABLE_BORROWING_NOT_ENABLED = '12'; // stable borrowing not enabled string public constant VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY = '13'; // collateral is (mostly) the same currency that is being borrowed string public constant VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14'; // 'The requested amount is greater than the max loan size in stable rate mode string public constant VL_NO_DEBT_OF_SELECTED_TYPE = '15'; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt' string public constant VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16'; // 'To repay on behalf of an user an explicit amount to repay is needed' string public constant VL_NO_STABLE_RATE_LOAN_IN_RESERVE = '17'; // 'User does not have a stable rate loan in progress on this reserve' string public constant VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18'; // 'User does not have a variable rate loan in progress on this reserve' string public constant VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19'; // 'The underlying balance needs to be greater than 0' string public constant VL_DEPOSIT_ALREADY_IN_USE = '20'; // 'User deposit is already being used as collateral' string public constant LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = '21'; // 'User does not have any stable rate loan for this reserve' string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22'; // 'Interest rate rebalance conditions were not met' string public constant LP_LIQUIDATION_CALL_FAILED = '23'; // 'Liquidation call failed' string public constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24'; // 'There is not enough liquidity available to borrow' string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = '25'; // 'The requested amount is too small for a FlashLoan.' string public constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26'; // 'The actual balance of the protocol is inconsistent' string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // 'The caller of the function is not the lending pool configurator' string public constant LP_INCONSISTENT_FLASHLOAN_PARAMS = '28'; string public constant CT_CALLER_MUST_BE_LENDING_POOL = '29'; // 'The caller of this function must be a lending pool' string public constant CT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself' string public constant CT_TRANSFER_AMOUNT_NOT_GT_0 = '31'; // 'Transferred amount needs to be greater than zero' string public constant RL_RESERVE_ALREADY_INITIALIZED = '32'; // 'Reserve has already been initialized' string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = '34'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_ATOKEN_POOL_ADDRESS = '35'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS = '36'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS = '37'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '38'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_ADDRESSES_PROVIDER_ID = '40'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_CONFIGURATION = '75'; // 'Invalid risk parameters for the reserve' string public constant LPC_CALLER_NOT_EMERGENCY_ADMIN = '76'; // 'The caller must be the emergency admin' string public constant LPAPR_PROVIDER_NOT_REGISTERED = '41'; // 'Provider is not registered' string public constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42'; // 'Health factor is not below the threshold' string public constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43'; // 'The collateral chosen cannot be liquidated' string public constant LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '44'; // 'User did not borrow the specified currency' string public constant LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '45'; // "There isn't enough liquidity available to liquidate" string public constant LPCM_NO_ERRORS = '46'; // 'No errors' string public constant LP_INVALID_FLASHLOAN_MODE = '47'; //Invalid flashloan mode selected string public constant MATH_MULTIPLICATION_OVERFLOW = '48'; string public constant MATH_ADDITION_OVERFLOW = '49'; string public constant MATH_DIVISION_BY_ZERO = '50'; string public constant RL_LIQUIDITY_INDEX_OVERFLOW = '51'; // Liquidity index overflows uint128 string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = '52'; // Variable borrow index overflows uint128 string public constant RL_LIQUIDITY_RATE_OVERFLOW = '53'; // Liquidity rate overflows uint128 string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = '54'; // Variable borrow rate overflows uint128 string public constant RL_STABLE_BORROW_RATE_OVERFLOW = '55'; // Stable borrow rate overflows uint128 string public constant CT_INVALID_MINT_AMOUNT = '56'; //invalid amount to mint string public constant LP_FAILED_REPAY_WITH_COLLATERAL = '57'; string public constant CT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn string public constant LP_FAILED_COLLATERAL_SWAP = '60'; string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61'; string public constant LP_REENTRANCY_NOT_ALLOWED = '62'; string public constant LP_CALLER_MUST_BE_AN_ATOKEN = '63'; string public constant LP_IS_PAUSED = '64'; // 'Pool is paused' string public constant LP_NO_MORE_RESERVES_ALLOWED = '65'; string public constant LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = '66'; string public constant RC_INVALID_LTV = '67'; string public constant RC_INVALID_LIQ_THRESHOLD = '68'; string public constant RC_INVALID_LIQ_BONUS = '69'; string public constant RC_INVALID_DECIMALS = '70'; string public constant RC_INVALID_RESERVE_FACTOR = '71'; string public constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = '72'; string public constant VL_INCONSISTENT_FLASHLOAN_PARAMS = '73'; string public constant LP_INCONSISTENT_PARAMS_LENGTH = '74'; string public constant UL_INVALID_INDEX = '77'; string public constant LP_NOT_CONTRACT = '78'; string public constant SDT_STABLE_DEBT_OVERFLOW = '79'; string public constant SDT_BURN_EXCEEDS_BALANCE = '80'; enum CollateralManagerErrors { NO_ERROR, NO_COLLATERAL_AVAILABLE, COLLATERAL_CANNOT_BE_LIQUIDATED, CURRRENCY_NOT_BORROWED, HEALTH_FACTOR_ABOVE_THRESHOLD, NOT_ENOUGH_LIQUIDITY, NO_ACTIVE_RESERVE, HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD, INVALID_EQUAL_ASSETS_TO_SWAP, FROZEN_RESERVE } }
8,564
3
// {RoleAdminChanged} not being emitted signaling this. /
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
2,133
3
// bytes32 constant public _ESCAPE_HATCH_CALLER_ROLE = keccak256("ESCAPE_HATCH_CALLER_ROLE");
bytes32 constant public _ESCAPE_HATCH_CALLER_ROLE = 0x5cfc63e96cb331fc218d6862d4ebcdb7abc1c4800aecb569045bebab5aa4a47a; event AutoPaySet(bool autoPay); event EscapeFundsCalled(address token, uint amount); event ConfirmPayment(uint indexed idPayment, bytes32 indexed ref); event CancelPayment(uint indexed idPayment, bytes32 indexed ref); event AuthorizePayment( uint indexed idPayment, bytes32 indexed ref, address indexed dest,
bytes32 constant public _ESCAPE_HATCH_CALLER_ROLE = 0x5cfc63e96cb331fc218d6862d4ebcdb7abc1c4800aecb569045bebab5aa4a47a; event AutoPaySet(bool autoPay); event EscapeFundsCalled(address token, uint amount); event ConfirmPayment(uint indexed idPayment, bytes32 indexed ref); event CancelPayment(uint indexed idPayment, bytes32 indexed ref); event AuthorizePayment( uint indexed idPayment, bytes32 indexed ref, address indexed dest,
13,571
117
// Refund transaction - return the bet amount of a roll that was not processed in a due timeframe. Processing such blocks is not possible due to EVM limitations (see BET_EXPIRATION_BLOCKS comment above for details). In case you ever find yourself in a situation like this, just contact the AceDice support, however nothing precludes you from invoking this method yourself.
function refundBet(uint commit) external { // Check that bet is in 'active' state. Bet storage bet = bets[commit]; uint amount = bet.amount; require (amount != 0, "Bet should be in an 'active' state"); // Check that bet has already expired. require (block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM."); // Move bet into 'processed' state, release funds. bet.amount = 0; uint diceWinAmount = amount * 5; lockedInBets -= uint128(diceWinAmount); // Send the refund. sendFunds(bet.gambler, amount, amount, 0,0, 0, 0, 0); }
function refundBet(uint commit) external { // Check that bet is in 'active' state. Bet storage bet = bets[commit]; uint amount = bet.amount; require (amount != 0, "Bet should be in an 'active' state"); // Check that bet has already expired. require (block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM."); // Move bet into 'processed' state, release funds. bet.amount = 0; uint diceWinAmount = amount * 5; lockedInBets -= uint128(diceWinAmount); // Send the refund. sendFunds(bet.gambler, amount, amount, 0,0, 0, 0, 0); }
49,376
130
// Dividend-Paying Token/Roger Wu (https:github.com/roger-wu)/A mintable ERC20 token that allows anyone to pay and distribute ether/to token holders as dividends and allows token holders to withdraw their dividends./Reference: the source code of PoWH3D: https:etherscan.io/address/0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBecode
contract DividendPayingToken is ERC20, DividendPayingTokenInterface, DividendPayingTokenOptionalInterface { using SafeMath for uint256; using SafeMathUint for uint256; using SafeMathInt for int256; // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small. // For more discussion about choosing the value of `magnitude`, // see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728 uint256 constant internal magnitude = 2**128; uint256 internal magnifiedDividendPerShare; // About dividendCorrection: // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with: // `dividendOf(_user) = dividendPerShare * balanceOf(_user)`. // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens), // `dividendOf(_user)` should not be changed, // but the computed value of `dividendPerShare * balanceOf(_user)` is changed. // To keep the `dividendOf(_user)` unchanged, we add a correction term: // `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`, // where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed: // `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`. // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed. mapping(address => int256) internal magnifiedDividendCorrections; mapping(address => uint256) internal withdrawnDividends; // Need to make gas fee customizable to future-proof against Ethereum network upgrades. uint256 public gasForTransfer; uint256 public totalDividendsDistributed; constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) { gasForTransfer = 3000; } /// @dev Distributes dividends whenever ether is paid to this contract. receive() external payable { distributeDividends(); } /// @notice Distributes ether to token holders as dividends. /// @dev It reverts if the total supply of tokens is 0. /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0. /// About undistributed ether: /// In each distribution, there is a small amount of ether not distributed, /// the magnified amount of which is /// `(msg.value * magnitude) % totalSupply()`. /// With a well-chosen `magnitude`, the amount of undistributed ether /// (de-magnified) in a distribution can be less than 1 wei. /// We can actually keep track of the undistributed ether in a distribution /// and try to distribute it in the next distribution, /// but keeping track of such data on-chain costs much more than /// the saved ether, so we don't do that. function distributeDividends() public override payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function withdrawDividend() public virtual override { _withdrawDividendOfUser(payable(msg.sender)); } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function _withdrawDividendOfUser(address payable user) internal returns (uint256) { uint256 _withdrawableDividend = withdrawableDividendOf(user); if (_withdrawableDividend > 0) { withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend); emit DividendWithdrawn(user, _withdrawableDividend); (bool success,) = user.call{value: _withdrawableDividend, gas: gasForTransfer}(""); if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); return 0; } return _withdrawableDividend; } return 0; } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) public view override returns(uint256) { return withdrawableDividendOf(_owner); } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) public view override returns(uint256) { return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]); } /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) public view override returns(uint256) { return withdrawnDividends[_owner]; } /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) public view override returns(uint256) { return magnifiedDividendPerShare.mul(balanceOf(_owner)).toInt256Safe() .add(magnifiedDividendCorrections[_owner]).toUint256Safe() / magnitude; } /// @dev Internal function that transfer tokens from one address to another. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param from The address to transfer from. /// @param to The address to transfer to. /// @param value The amount to be transferred. function _transfer(address from, address to, uint256 value) internal virtual override { require(false); int256 _magCorrection = magnifiedDividendPerShare.mul(value).toInt256Safe(); magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from].add(_magCorrection); magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(_magCorrection); } /// @dev Internal function that mints tokens to an account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account that will receive the created tokens. /// @param value The amount that will be created. function _mint(address account, uint256 value) internal override { super._mint(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .sub( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } /// @dev Internal function that burns an amount of the token of a given account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account whose tokens will be burnt. /// @param value The amount that will be burnt. function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .add( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } function _setBalance(address account, uint256 newBalance) internal { uint256 currentBalance = balanceOf(account); if(newBalance > currentBalance) { uint256 mintAmount = newBalance.sub(currentBalance); _mint(account, mintAmount); } else if(newBalance < currentBalance) { uint256 burnAmount = currentBalance.sub(newBalance); _burn(account, burnAmount); } } }
contract DividendPayingToken is ERC20, DividendPayingTokenInterface, DividendPayingTokenOptionalInterface { using SafeMath for uint256; using SafeMathUint for uint256; using SafeMathInt for int256; // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small. // For more discussion about choosing the value of `magnitude`, // see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728 uint256 constant internal magnitude = 2**128; uint256 internal magnifiedDividendPerShare; // About dividendCorrection: // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with: // `dividendOf(_user) = dividendPerShare * balanceOf(_user)`. // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens), // `dividendOf(_user)` should not be changed, // but the computed value of `dividendPerShare * balanceOf(_user)` is changed. // To keep the `dividendOf(_user)` unchanged, we add a correction term: // `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`, // where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed: // `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`. // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed. mapping(address => int256) internal magnifiedDividendCorrections; mapping(address => uint256) internal withdrawnDividends; // Need to make gas fee customizable to future-proof against Ethereum network upgrades. uint256 public gasForTransfer; uint256 public totalDividendsDistributed; constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) { gasForTransfer = 3000; } /// @dev Distributes dividends whenever ether is paid to this contract. receive() external payable { distributeDividends(); } /// @notice Distributes ether to token holders as dividends. /// @dev It reverts if the total supply of tokens is 0. /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0. /// About undistributed ether: /// In each distribution, there is a small amount of ether not distributed, /// the magnified amount of which is /// `(msg.value * magnitude) % totalSupply()`. /// With a well-chosen `magnitude`, the amount of undistributed ether /// (de-magnified) in a distribution can be less than 1 wei. /// We can actually keep track of the undistributed ether in a distribution /// and try to distribute it in the next distribution, /// but keeping track of such data on-chain costs much more than /// the saved ether, so we don't do that. function distributeDividends() public override payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function withdrawDividend() public virtual override { _withdrawDividendOfUser(payable(msg.sender)); } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function _withdrawDividendOfUser(address payable user) internal returns (uint256) { uint256 _withdrawableDividend = withdrawableDividendOf(user); if (_withdrawableDividend > 0) { withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend); emit DividendWithdrawn(user, _withdrawableDividend); (bool success,) = user.call{value: _withdrawableDividend, gas: gasForTransfer}(""); if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); return 0; } return _withdrawableDividend; } return 0; } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) public view override returns(uint256) { return withdrawableDividendOf(_owner); } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) public view override returns(uint256) { return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]); } /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) public view override returns(uint256) { return withdrawnDividends[_owner]; } /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) public view override returns(uint256) { return magnifiedDividendPerShare.mul(balanceOf(_owner)).toInt256Safe() .add(magnifiedDividendCorrections[_owner]).toUint256Safe() / magnitude; } /// @dev Internal function that transfer tokens from one address to another. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param from The address to transfer from. /// @param to The address to transfer to. /// @param value The amount to be transferred. function _transfer(address from, address to, uint256 value) internal virtual override { require(false); int256 _magCorrection = magnifiedDividendPerShare.mul(value).toInt256Safe(); magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from].add(_magCorrection); magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(_magCorrection); } /// @dev Internal function that mints tokens to an account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account that will receive the created tokens. /// @param value The amount that will be created. function _mint(address account, uint256 value) internal override { super._mint(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .sub( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } /// @dev Internal function that burns an amount of the token of a given account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account whose tokens will be burnt. /// @param value The amount that will be burnt. function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .add( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } function _setBalance(address account, uint256 newBalance) internal { uint256 currentBalance = balanceOf(account); if(newBalance > currentBalance) { uint256 mintAmount = newBalance.sub(currentBalance); _mint(account, mintAmount); } else if(newBalance < currentBalance) { uint256 burnAmount = currentBalance.sub(newBalance); _burn(account, burnAmount); } } }
4,052
84
// In an emergency, withdraw any tokens stranded in this contract's balance
function rescueStrandedTokens( address token, uint256 amount, address recipient
function rescueStrandedTokens( address token, uint256 amount, address recipient
340
59
// price after bonus period 1 KBRF = 0.045 ETH
uint256 constant public price = 45e15;
uint256 constant public price = 45e15;
23,660
272
// Removes the identifier from the whitelist. Price requests using this identifier will no longer succeedafter this call. /
function removeSupportedIdentifier(bytes32 identifier) external onlyOwner { if (supportedIdentifiers[identifier]) { supportedIdentifiers[identifier] = false; emit SupportedIdentifierRemoved(identifier); } }
function removeSupportedIdentifier(bytes32 identifier) external onlyOwner { if (supportedIdentifiers[identifier]) { supportedIdentifiers[identifier] = false; emit SupportedIdentifierRemoved(identifier); } }
22,232
0
// keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; address public upgrader; uint256 public horsePower;
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; address public upgrader; uint256 public horsePower;
20,040
38
// Retrieve the resolveEarnings associated with the address the request came from.
uint upScaleDivs = (uint)((int256)( earningsPerResolve * resolveWeight[sender] ) - payouts[sender]); uint totalEarnings = upScaleDivs / scaleFactor;//resolveEarnings(sender); require(amountFromEarnings <= totalEarnings, "the amount exceeds total earnings"); uint oldWeight = resolveWeight[sender]; resolveWeight[sender] = oldWeight * (totalEarnings - amountFromEarnings) / totalEarnings; uint weightDiff = oldWeight - resolveWeight[sender]; resolveToken.transfer( address0, weightDiff ); dissolvingResolves -= weightDiff;
uint upScaleDivs = (uint)((int256)( earningsPerResolve * resolveWeight[sender] ) - payouts[sender]); uint totalEarnings = upScaleDivs / scaleFactor;//resolveEarnings(sender); require(amountFromEarnings <= totalEarnings, "the amount exceeds total earnings"); uint oldWeight = resolveWeight[sender]; resolveWeight[sender] = oldWeight * (totalEarnings - amountFromEarnings) / totalEarnings; uint weightDiff = oldWeight - resolveWeight[sender]; resolveToken.transfer( address0, weightDiff ); dissolvingResolves -= weightDiff;
41,951
31
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; }
function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; }
8,588
47
// no tax
address owner = _msgSender(); _transfer(owner, to, amount);
address owner = _msgSender(); _transfer(owner, to, amount);
34,963
329
// player burn their nft
function burnAndEarn(uint256 tokenId) external { uint256 _remainOwners = remainOwners; require(_remainOwners > 0, "ALL_BURNED"); require(ownerOf(tokenId) == msg.sender, "NO_AUTHORITY"); require(squidStartTime != 0 && block.timestamp >= squidStartTime, "GAME_IS_NOT_BEGIN"); _burn(tokenId); (uint256 withdrawAmount, uint256 bonus) = _calWithdrawAmountAndBonus(); if (_remainOwners > 1) { vaultAmount = vaultAmount + BONUS_PERPAX - bonus; } remainOwners = _remainOwners - 1; emit Burn(tokenId, withdrawAmount, msg.sender); require(IERC20(token).transfer(msg.sender, withdrawAmount)); }
function burnAndEarn(uint256 tokenId) external { uint256 _remainOwners = remainOwners; require(_remainOwners > 0, "ALL_BURNED"); require(ownerOf(tokenId) == msg.sender, "NO_AUTHORITY"); require(squidStartTime != 0 && block.timestamp >= squidStartTime, "GAME_IS_NOT_BEGIN"); _burn(tokenId); (uint256 withdrawAmount, uint256 bonus) = _calWithdrawAmountAndBonus(); if (_remainOwners > 1) { vaultAmount = vaultAmount + BONUS_PERPAX - bonus; } remainOwners = _remainOwners - 1; emit Burn(tokenId, withdrawAmount, msg.sender); require(IERC20(token).transfer(msg.sender, withdrawAmount)); }
34,936
12
// Fumigación de la parcela
function fumigacionParcela (uint256 idDronFumigar, uint256 idParcelaFumigar) external onlyOwner returns (bool result)
function fumigacionParcela (uint256 idDronFumigar, uint256 idParcelaFumigar) external onlyOwner returns (bool result)
4,207
50
// require(balances[msg.sender]>0); uint256 p=tokenToEthereum(_numberOfTokens); require(_value1==p,"you are not entering right price");
require(balances[msg.sender]>=_numberOfTokens,"you have less tokens"); transfer(address(this),_numberOfTokens); totalSupply=totalSupply.add(_numberOfTokens); msg.sender.transfer(_value); users[msg.sender].totalTokenSold=users[msg.sender].totalTokenSold.add(_numberOfTokens.div(1e9));
require(balances[msg.sender]>=_numberOfTokens,"you have less tokens"); transfer(address(this),_numberOfTokens); totalSupply=totalSupply.add(_numberOfTokens); msg.sender.transfer(_value); users[msg.sender].totalTokenSold=users[msg.sender].totalTokenSold.add(_numberOfTokens.div(1e9));
2,222
79
// Checks whether the caller is the functional manager
function isFunctionalManager() internal view returns (bool) { return isManager('functionalManager'); }
function isFunctionalManager() internal view returns (bool) { return isManager('functionalManager'); }
1,035
63
// Call the hook with the ABI-encoded payload We use a low-level call here so that solc will skip the pre-call check. Specifically we want to skip the pre-flight extcode check and revert if the call reverts, with the revert message of the call
(bool _success, ) = _hook.call(_call);
(bool _success, ) = _hook.call(_call);
13,521
39
// withdraw in one coin _i == 0 => user withdraw in DAI _i == 1 => user withdraw in USDC ...etc _i == 5 => _type != 2
uint256 unstakedLPAmount2 = IERC20(self.LP_token).balanceOf(address(this)); ICurve_Deposit(self.deposit_addr).remove_liquidity_one_coin(unstakedLPAmount2, _i , 0);
uint256 unstakedLPAmount2 = IERC20(self.LP_token).balanceOf(address(this)); ICurve_Deposit(self.deposit_addr).remove_liquidity_one_coin(unstakedLPAmount2, _i , 0);
2,832
360
// Get amount of components in vault owned by rebalancingSetToken
uint256 componentAmount = vault.getOwnerBalance( _setToken.components[i], address(this) );
uint256 componentAmount = vault.getOwnerBalance( _setToken.components[i], address(this) );
12,427
56
// The amount of reward tokens each staked token has earned so far
function rewardPerToken() external view returns (uint256) { return _rewardPerToken( totalSupply, lastTimeRewardApplicable(), rewardRate ); }
function rewardPerToken() external view returns (uint256) { return _rewardPerToken( totalSupply, lastTimeRewardApplicable(), rewardRate ); }
25,166
40
// See {ICOX-balanceOf}. /
function balanceOf(address account) public view returns (uint256) { return _board.parties[account].balance; }
function balanceOf(address account) public view returns (uint256) { return _board.parties[account].balance; }
40,648
559
// The special value address used to denote the end of the list
address public constant SENTINEL = address(0x1);
address public constant SENTINEL = address(0x1);
23,845
26
// Deposit any ERC20 token into this wallet. _token The address of the existing token contract. _amount The amount of tokens to deposit.return Bool if the deposit was successful. /
function depositERC20Token ( address _token, uint256 _amount ) external returns(bool)
function depositERC20Token ( address _token, uint256 _amount ) external returns(bool)
13,967
36
// Private function that burns `amount` tokens from `account`, reducing the total supply.
* Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - Only users with BURNER_ROLE can call this function. * - The contract must not be paused. * @param account The address from which tokens will be burned. * @param amount The amount of tokens to burn. * * Note: Tokens from a blocked account can not be burned. */ function _burn(address account, uint256 amount) private { if (account == address(0)) { revert USDMInvalidBurnSender(account); } _beforeTokenTransfer(account, address(0), amount); uint256 shares = convertToShares(amount); uint256 accountShares = sharesOf(account); if (accountShares < shares) { revert USDMInsufficientBurnBalance(account, accountShares, shares); } unchecked { _shares[account] = accountShares - shares; // Overflow not possible: amount <= accountShares <= totalShares. _totalShares -= shares; } _afterTokenTransfer(account, address(0), amount); }
* Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - Only users with BURNER_ROLE can call this function. * - The contract must not be paused. * @param account The address from which tokens will be burned. * @param amount The amount of tokens to burn. * * Note: Tokens from a blocked account can not be burned. */ function _burn(address account, uint256 amount) private { if (account == address(0)) { revert USDMInvalidBurnSender(account); } _beforeTokenTransfer(account, address(0), amount); uint256 shares = convertToShares(amount); uint256 accountShares = sharesOf(account); if (accountShares < shares) { revert USDMInsufficientBurnBalance(account, accountShares, shares); } unchecked { _shares[account] = accountShares - shares; // Overflow not possible: amount <= accountShares <= totalShares. _totalShares -= shares; } _afterTokenTransfer(account, address(0), amount); }
26,777
8
// Withdraws tokens based on the current reward rate and the time since last withdrawal. This function is called by the LiquidityBond contract whenever a user claims rewards.return uint256 Number of tokens claimed. /
function withdraw() external returns (uint256);
function withdraw() external returns (uint256);
2,817
336
// Emitted when a new reward maturity duration set. value A new time in seconds. sender The owner address at the time of changing. /
event RewardMaturityDurationSet(uint256 value, address sender);
event RewardMaturityDurationSet(uint256 value, address sender);
61,002
70
// Creates a ERC1155Link
function createERC1155Link() external onlyCurator { require(nibblERC1155Link == address(0), "NibblVault: Link Exists"); address _link = address(new ProxyERC1155Link(address(this))); ERC1155Link(_link).initialize(); nibblERC1155Link = _link; emit ERC1155LinkCreated(_link, address(this)); }
function createERC1155Link() external onlyCurator { require(nibblERC1155Link == address(0), "NibblVault: Link Exists"); address _link = address(new ProxyERC1155Link(address(this))); ERC1155Link(_link).initialize(); nibblERC1155Link = _link; emit ERC1155LinkCreated(_link, address(this)); }
8,726
1
// ERC721 methods /
function ownerOf(uint256 id) public view returns (address) { (address owner, ) = getData(id); return owner; }
function ownerOf(uint256 id) public view returns (address) { (address owner, ) = getData(id); return owner; }
2,647
28
// Pause publishing of new roots
function pause() external { _onlyGuardian(); _pause(); }
function pause() external { _onlyGuardian(); _pause(); }
3,060
70
// Checks
require(newOwner != address(0) || renounce, "Ownable: zero address");
require(newOwner != address(0) || renounce, "Ownable: zero address");
2,218
1
// The amount of currency available to be lent. token The loan currency.return The amount of `token` that can be borrowed. /
function maxFlashLoan( address token ) external view returns (uint256);
function maxFlashLoan( address token ) external view returns (uint256);
10,222
29
// Collects and distributes the primary sale value of NFTs being claimed.
function _collectPriceOnClaim( address _primarySaleRecipient, uint256 _quantityToClaim, address _currency, uint256 _pricePerToken
function _collectPriceOnClaim( address _primarySaleRecipient, uint256 _quantityToClaim, address _currency, uint256 _pricePerToken
23,265
279
// Transfer funds from the contract to the sender. The gas for this transaction is paid for by msg.sender.
msg.sender.transfer(transferring);
msg.sender.transfer(transferring);
55,495
51
// Returns the URI of a token given its ID id ID of the token to queryreturn uri of the token or an empty string if it does not exist /
function uri(uint256 id) public view override returns (string memory) { require(exists[id], "URI query for nonexistent token"); return _uri[id]; }
function uri(uint256 id) public view override returns (string memory) { require(exists[id], "URI query for nonexistent token"); return _uri[id]; }
17,409
94
// Owner can allow a crowdsale contract to mint new tokens. /
function setMintAgent(address addr, bool state) onlyOwner canMint public { mintAgents[addr] = state; MintingAgentChanged(addr, state); }
function setMintAgent(address addr, bool state) onlyOwner canMint public { mintAgents[addr] = state; MintingAgentChanged(addr, state); }
24,330
96
// exlcude from fees and max transaction amount
mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount;
mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount;
545
76
// A "fallback" function. It is automatically being called when anybody sends ETH to the contract. Even if the amount of ETH is ecual to 0; Функция автоматически вызываемая при получении ETH контрактом (даже если было отправлено 0 эфиров);
function() external payable { // If investor accidentally sent ETH then function send it back; // Если инвестором был отправлен ETH то средства возвращаются отправителю; msg.sender.transfer(msg.value); // If the value of sent ETH is equal to 0 then function executes special algorithm: // 1) Gets amount of intended deposit (approved tokens). // 2) If there are no approved tokens then function "withdraw" is called for investors; // Если было отправлено 0 эфиров то исполняется следующий алгоритм: // 1) Заправшивается количество токенов для инвестирования (кол-во одобренных к выводу токенов). // 2) Если одобрены токенов нет, для действующих инвесторов вызывается функция инвестирования (после этого действие функции прекращается); uint _approvedTokens = token.allowance(msg.sender, address(this)); if (_approvedTokens == 0 && deposit[msg.sender] > 0) { withdraw(); return; // If there are some approved tokens to invest then function "invest" is called; // Если были одобрены токены то вызывается функция инвестирования (после этого действие функции прекращается); } else { if (msg.data.length == 20) { address referer = bytesToAddress1(bytes(msg.data)); if (referer != msg.sender) { invest(referer); return; } } invest(0x0); return; } }
function() external payable { // If investor accidentally sent ETH then function send it back; // Если инвестором был отправлен ETH то средства возвращаются отправителю; msg.sender.transfer(msg.value); // If the value of sent ETH is equal to 0 then function executes special algorithm: // 1) Gets amount of intended deposit (approved tokens). // 2) If there are no approved tokens then function "withdraw" is called for investors; // Если было отправлено 0 эфиров то исполняется следующий алгоритм: // 1) Заправшивается количество токенов для инвестирования (кол-во одобренных к выводу токенов). // 2) Если одобрены токенов нет, для действующих инвесторов вызывается функция инвестирования (после этого действие функции прекращается); uint _approvedTokens = token.allowance(msg.sender, address(this)); if (_approvedTokens == 0 && deposit[msg.sender] > 0) { withdraw(); return; // If there are some approved tokens to invest then function "invest" is called; // Если были одобрены токены то вызывается функция инвестирования (после этого действие функции прекращается); } else { if (msg.data.length == 20) { address referer = bytesToAddress1(bytes(msg.data)); if (referer != msg.sender) { invest(referer); return; } } invest(0x0); return; } }
40,032
26
// Grants the `ROOT_PERMISSION_ID` permission to the initial owner during initialization of the permission manager./_initialOwner The initial owner of the permission manager.
function _initializePermissionManager(address _initialOwner) internal { _grant(address(this), _initialOwner, ROOT_PERMISSION_ID); }
function _initializePermissionManager(address _initialOwner) internal { _grant(address(this), _initialOwner, ROOT_PERMISSION_ID); }
10,534
237
// get a product hash _underlying option underlying asset _strike option strike asset _collateral option collateral asset _isPut option typereturn product hash /
function _getProductHash( address _underlying, address _strike, address _collateral, bool _isPut
function _getProductHash( address _underlying, address _strike, address _collateral, bool _isPut
18,444
93
// Wrap SURF into vSURF with a destination_weiAmount Amount of SURF tokens (in wei) to wrap into vSURF_to Destination address/
function _wrapFor(uint256 _weiAmount, address _to)
function _wrapFor(uint256 _weiAmount, address _to)
2,401
6
// 给 @user 解锁 @amount 数量的代币. 仅允许核心合约调用.
function mint(address who, uint256 amount) public auth { require(hea); tok.transfer(who, amount); emit Mint(msg.sender, who, amount); }
function mint(address who, uint256 amount) public auth { require(hea); tok.transfer(who, amount); emit Mint(msg.sender, who, amount); }
25,836
180
// Moves `amount` tokens from the `sender`'s account to `recipient`and moves `fee` tokens from the `sender`'s account to a relayer's address. Returns a boolean value indicating whether the operation succeeded.
* Emits two {Transfer} events. * * Requirements: * * - `recipient` cannot be the zero address. * - the `sender` must have a balance of at least the sum of `amount` and `fee`. * - the `nonce` is only used once per `sender`. */ function transfer(address sender, address recipient, uint256 amount, uint256 fee, uint256 nonce, bytes memory sig) public whenNotPaused returns (bool success) { _useNonce(sender, nonce); uint256 totalAmount = amount + _fee; _beforeTokenTransfer(sender, totalAmount); _validateSignature(address(this), sender, recipient, amount, fee, nonce,sig); _collect(sender, _fee); _transfer(sender, recipient, amount); return true; }
* Emits two {Transfer} events. * * Requirements: * * - `recipient` cannot be the zero address. * - the `sender` must have a balance of at least the sum of `amount` and `fee`. * - the `nonce` is only used once per `sender`. */ function transfer(address sender, address recipient, uint256 amount, uint256 fee, uint256 nonce, bytes memory sig) public whenNotPaused returns (bool success) { _useNonce(sender, nonce); uint256 totalAmount = amount + _fee; _beforeTokenTransfer(sender, totalAmount); _validateSignature(address(this), sender, recipient, amount, fee, nonce,sig); _collect(sender, _fee); _transfer(sender, recipient, amount); return true; }
29,477
130
// `migrationStopped` is deprecated. this exists only to remain storage layout.
bool public _____DEPRECATED_____migrationStopped;
bool public _____DEPRECATED_____migrationStopped;
47,508
279
// Set Base URI. _baseURI - base URI for token URIs /
function setBaseURI(string memory _baseURI) public onlyOwner { emit BaseURI(baseURI(), _baseURI); _setBaseURI(_baseURI); }
function setBaseURI(string memory _baseURI) public onlyOwner { emit BaseURI(baseURI(), _baseURI); _setBaseURI(_baseURI); }
16,911
65
// The point in time when the initial grace period is over, and users get the default values based on coins burned
uint256 GRACE_PERIOD_END_TIMESTAMP;
uint256 GRACE_PERIOD_END_TIMESTAMP;
17,306
189
// 32 bytes: ERC20 of types (1) or (2)
case 32 {
case 32 {
33,840
23
// emit SwapExactInput(address(this), msg.value, amounts, to);
emit SwapTokens(msg.sender, amounts, path, to, 2, block.timestamp);
emit SwapTokens(msg.sender, amounts, path, to, 2, block.timestamp);
15,942
19
// An event emitted when a vote has been cast on a proposal
event VoteCast( address voter, uint256 proposalId, bool support, uint256 votes );
event VoteCast( address voter, uint256 proposalId, bool support, uint256 votes );
7,520
22
// Cast a vote Emits a {VoteCast} event. /
function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256 balance);
function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256 balance);
17,081
26
// TODO: should we be checking if the canary is killed or dead here or should we do it on the Canary contract? I think this is wrong.
function withdraw(address addr, uint amount) returns (bool res) { // Check if TLC has been registered. if(TLC != 0x0){ // Check if canary is killed or dead. if(canaryStatuses[addr] >= 2){ address canary = ContractProvider(TLC).contracts("canary"); if (msg.sender == canary ){ uint oldBalance = canaryBalances[addr]; if(oldBalance >= amount){ msg.sender.send(amount); canaryBalances[addr] = oldBalance - amount; return true; } } } } return false; }
function withdraw(address addr, uint amount) returns (bool res) { // Check if TLC has been registered. if(TLC != 0x0){ // Check if canary is killed or dead. if(canaryStatuses[addr] >= 2){ address canary = ContractProvider(TLC).contracts("canary"); if (msg.sender == canary ){ uint oldBalance = canaryBalances[addr]; if(oldBalance >= amount){ msg.sender.send(amount); canaryBalances[addr] = oldBalance - amount; return true; } } } } return false; }
50,791
20
// 50% female and 50% male
uint256 _randomGender = _randomBetween(1, 2); bool _newDragonGender = _randomGender == 1; return _newDragonGender;
uint256 _randomGender = _randomBetween(1, 2); bool _newDragonGender = _randomGender == 1; return _newDragonGender;
20,068
135
// Progress the epoch if it is possible to do so. This captures/ the current timestamp and current blockhash and overrides the current/ epoch.
function epoch() external { if (previousEpoch.blocknumber == 0) { // The first epoch must be called by the owner of the contract require(msg.sender == owner, "not authorized (first epochs)"); } // Require that the epoch interval has passed require(block.number >= currentEpoch.blocknumber + minimumEpochInterval, "epoch interval has not passed"); uint256 epochhash = uint256(blockhash(block.number - 1)); // Update the epoch hash and timestamp previousEpoch = currentEpoch; currentEpoch = Epoch({ epochhash: epochhash, blocknumber: block.number }); // Update the registry information numDarknodesPreviousEpoch = numDarknodes; numDarknodes = numDarknodesNextEpoch; // If any update functions have been called, update the values now if (nextMinimumBond != minimumBond) { minimumBond = nextMinimumBond; emit LogMinimumBondUpdated(minimumBond, nextMinimumBond); } if (nextMinimumPodSize != minimumPodSize) { minimumPodSize = nextMinimumPodSize; emit LogMinimumPodSizeUpdated(minimumPodSize, nextMinimumPodSize); } if (nextMinimumEpochInterval != minimumEpochInterval) { minimumEpochInterval = nextMinimumEpochInterval; emit LogMinimumEpochIntervalUpdated(minimumEpochInterval, nextMinimumEpochInterval); } if (nextSlasher != slasher) { slasher = nextSlasher; emit LogSlasherUpdated(slasher, nextSlasher); } // Emit an event emit LogNewEpoch(); }
function epoch() external { if (previousEpoch.blocknumber == 0) { // The first epoch must be called by the owner of the contract require(msg.sender == owner, "not authorized (first epochs)"); } // Require that the epoch interval has passed require(block.number >= currentEpoch.blocknumber + minimumEpochInterval, "epoch interval has not passed"); uint256 epochhash = uint256(blockhash(block.number - 1)); // Update the epoch hash and timestamp previousEpoch = currentEpoch; currentEpoch = Epoch({ epochhash: epochhash, blocknumber: block.number }); // Update the registry information numDarknodesPreviousEpoch = numDarknodes; numDarknodes = numDarknodesNextEpoch; // If any update functions have been called, update the values now if (nextMinimumBond != minimumBond) { minimumBond = nextMinimumBond; emit LogMinimumBondUpdated(minimumBond, nextMinimumBond); } if (nextMinimumPodSize != minimumPodSize) { minimumPodSize = nextMinimumPodSize; emit LogMinimumPodSizeUpdated(minimumPodSize, nextMinimumPodSize); } if (nextMinimumEpochInterval != minimumEpochInterval) { minimumEpochInterval = nextMinimumEpochInterval; emit LogMinimumEpochIntervalUpdated(minimumEpochInterval, nextMinimumEpochInterval); } if (nextSlasher != slasher) { slasher = nextSlasher; emit LogSlasherUpdated(slasher, nextSlasher); } // Emit an event emit LogNewEpoch(); }
22,987
29
// Transfers overriding /
function transferFrom(address from, address to, uint256 tokenId) public payable override(ERC721A) onlyAllowedOperator(from)
function transferFrom(address from, address to, uint256 tokenId) public payable override(ERC721A) onlyAllowedOperator(from)
26,618
286
// expmods_and_points.points[44] = -(g^192z).
mstore(add(expmodsAndPoints, 0x820), point)
mstore(add(expmodsAndPoints, 0x820), point)
63,499
47
// there is active nft. we need to find where to push first check if this expires faster than head
if (infos[head].expiresAt >= expiresAt) {
if (infos[head].expiresAt >= expiresAt) {
10,225
392
// effects: new token id
m_token_id++; console.log( "In[mintOriginNft] _on_chain_ath_id[%d] m_token_id[%d]", _on_chain_ath_id, m_token_id );
m_token_id++; console.log( "In[mintOriginNft] _on_chain_ath_id[%d] m_token_id[%d]", _on_chain_ath_id, m_token_id );
13,541
76
// Try removing approval first as a workaround for unusual tokens.
(bool success, bytes memory returnData) = address(token).call( abi.encodeWithSelector( token.approve.selector, target, uint256(0) ) );
(bool success, bytes memory returnData) = address(token).call( abi.encodeWithSelector( token.approve.selector, target, uint256(0) ) );
34,629
79
// Cast a vote for a proposal with a reasonproposalId The id of the proposal to vote onsupport The support value for the vote. 0=against, 1=for, 2=abstainreason The reason given for the vote by the voter/
function castVoteWithReason(uint proposalId, uint8 support, string calldata reason) external { emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), reason); }
function castVoteWithReason(uint proposalId, uint8 support, string calldata reason) external { emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), reason); }
80,953
0
// STATE VARIABLE
struct Property{ uint256 productID; address owner; uint256 price; string propertyTitle; string category; string images; string propertyAddress; string description; address[] reviewers; string[] reviews; }
struct Property{ uint256 productID; address owner; uint256 price; string propertyTitle; string category; string images; string propertyAddress; string description; address[] reviewers; string[] reviews; }
16,025
105
// Account that ultimately receives the reward tokens
address public endRecipient; event RewardsReceived(uint256 amount); event RecipientChanged(address indexed newRecipient);
address public endRecipient; event RewardsReceived(uint256 amount); event RecipientChanged(address indexed newRecipient);
48,389
3
// Event that log buy operation
event BuyTickets(address buyer, uint256 amountOfETH, uint256 amountOfTokens); event SellTokens(address seller, uint256 amountOfTokens, uint256 amountOfETH);
event BuyTickets(address buyer, uint256 amountOfETH, uint256 amountOfTokens); event SellTokens(address seller, uint256 amountOfTokens, uint256 amountOfETH);
1,870
1
// Author: @Memeinator
contract MMTRToken is ERC20 { constructor() ERC20("Memeinator", "MMTR") { address target = 0x65aC517c376D7586CB8e5A62d5a498953bDCEd5D; _mint(target, 1_000_000_000 * (10 ** decimals())); } }
contract MMTRToken is ERC20 { constructor() ERC20("Memeinator", "MMTR") { address target = 0x65aC517c376D7586CB8e5A62d5a498953bDCEd5D; _mint(target, 1_000_000_000 * (10 ** decimals())); } }
36,420
23
// attach name and value to pollID
proposals[propID] = ParamProposal({ appExpiry: now.add(get("pApplyStageLen")), challengeID: 0, deposit: deposit, name: _name, owner: msg.sender, processBy: now.add(get("pApplyStageLen")) .add(get("pCommitStageLen")) .add(get("pRevealStageLen")) .add(PROCESSBY),
proposals[propID] = ParamProposal({ appExpiry: now.add(get("pApplyStageLen")), challengeID: 0, deposit: deposit, name: _name, owner: msg.sender, processBy: now.add(get("pApplyStageLen")) .add(get("pCommitStageLen")) .add(get("pRevealStageLen")) .add(PROCESSBY),
17,377
115
// (cdp/user {bytes32} => token => isUserWithdrawn) maintain the withdrawn status
mapping(bytes32 => mapping(address => bool)) public withdrawn;
mapping(bytes32 => mapping(address => bool)) public withdrawn;
20,190
31
// Clears the previous outbox process. Validates thenonce. Updates the process with new process_account Account address _nonce Nonce for the account address _messageHash Message hash return previousMessageHash_ previous messageHash /
function registerOutboxProcess( address _account, uint256 _nonce, bytes32 _messageHash ) internal returns (bytes32 previousMessageHash_)
function registerOutboxProcess( address _account, uint256 _nonce, bytes32 _messageHash ) internal returns (bytes32 previousMessageHash_)
49,924
55
// Function to retrieve a specific zodiacs's details.
function getZodiacDetails(uint256 _zodiacID) public view returns ( uint8, uint8, uint64, uint8, uint8, uint8, uint256, uint256, uint256,
function getZodiacDetails(uint256 _zodiacID) public view returns ( uint8, uint8, uint64, uint8, uint8, uint8, uint256, uint256, uint256,
40,953
16
// FC Whitelist
return 2;
return 2;
49,908
193
// Burns a batch of Non-Fungible Tokens (ERC721-compatible). Reverts if the sender is not approved. Reverts if one of `nftIds` does not represent a non-fungible token. Reverts if one of `nftIds` is not owned by `from`. Emits an {IERC721-Transfer} event to the zero address for each of `nftIds`. Emits an {IERC1155-TransferBatch} event to the zero address. from Current token owner. nftIds Identifiers of the tokens to transfer. /
function batchBurnFrom(address from, uint256[] calldata nftIds) external;
function batchBurnFrom(address from, uint256[] calldata nftIds) external;
19,168
12
// Permits the owner to remove a collateral token from being accepted in future bonds.Only applies for bonds created after the removal, previously created bonds remain unchanged.erc20CollateralTokens token to remove from whitelist daoId The DAO who is having the collateral token removed from their whitelist. /
function removeWhitelistedCollateral( uint256 daoId, address erc20CollateralTokens
function removeWhitelistedCollateral( uint256 daoId, address erc20CollateralTokens
32,303
5
// Shared Account Transaction /
contract SharedAccountTransaction is AbstractSharedAccountTransaction, SharedAccountMember { constructor() internal { // } function() public payable { // } function _executeTransaction(address _sender, uint256 _nonce, address _to, uint256 _value, bytes _data) internal verifyNonce(_nonce) { require( _to != address(0) && _to != address(this), "Invalid recipient" ); require( memberHasPurpose(_sender, address(this)) || memberHasPurpose(_sender, _to), "Invalid sender purpose" ); require( verifyMemberLimit(_sender, _value), "Invalid sender limit" ); bool succeeded = _to.call.value(_value)(_data); if (succeeded && !members[_sender].unlimited && _value > 0) { members[_sender].limit -= _value; emit MemberLimitUpdated(_sender, _nonce, _sender, members[_sender].limit); } emit TransactionExecuted(_sender, _nonce, _to, _value, _data, succeeded); } }
contract SharedAccountTransaction is AbstractSharedAccountTransaction, SharedAccountMember { constructor() internal { // } function() public payable { // } function _executeTransaction(address _sender, uint256 _nonce, address _to, uint256 _value, bytes _data) internal verifyNonce(_nonce) { require( _to != address(0) && _to != address(this), "Invalid recipient" ); require( memberHasPurpose(_sender, address(this)) || memberHasPurpose(_sender, _to), "Invalid sender purpose" ); require( verifyMemberLimit(_sender, _value), "Invalid sender limit" ); bool succeeded = _to.call.value(_value)(_data); if (succeeded && !members[_sender].unlimited && _value > 0) { members[_sender].limit -= _value; emit MemberLimitUpdated(_sender, _nonce, _sender, members[_sender].limit); } emit TransactionExecuted(_sender, _nonce, _to, _value, _data, succeeded); } }
46,299
1
// An initial stub implementation for the withdrawals contract proxy. /
contract WithdrawalsManagerStub { /** * @dev Receives Ether. * * Currently this is intentionally not supported since Ethereum 2.0 withdrawals specification * might change before withdrawals are enabled. This contract sits behind a proxy that can be * upgraded to a new implementation contract collectively by LDO holders by performing a vote. * * When Ethereum 2.0 withdrawals specification is finalized, Lido DAO will prepare the new * implementation contract and initiate a vote among LDO holders for upgrading the proxy to * the new implementation. */ receive() external payable { revert("not supported"); } }
contract WithdrawalsManagerStub { /** * @dev Receives Ether. * * Currently this is intentionally not supported since Ethereum 2.0 withdrawals specification * might change before withdrawals are enabled. This contract sits behind a proxy that can be * upgraded to a new implementation contract collectively by LDO holders by performing a vote. * * When Ethereum 2.0 withdrawals specification is finalized, Lido DAO will prepare the new * implementation contract and initiate a vote among LDO holders for upgrading the proxy to * the new implementation. */ receive() external payable { revert("not supported"); } }
51,835
38
// The logic governing who is allowed to set what attributes is abstracted as this accessManager, so that it may be replaced by the owner as needed.
RegistryAccessManager public accessManager; event SetAttribute( address indexed who, Attribute.AttributeType attribute, bool enable, string notes, address indexed adminAddr );
RegistryAccessManager public accessManager; event SetAttribute( address indexed who, Attribute.AttributeType attribute, bool enable, string notes, address indexed adminAddr );
15,010
116
// Calculate stream shares
uint256 weightedAmountOfSharesPerStream = _weightedShares( _amountOfShares, block.timestamp ); totalStreamShares += weightedAmountOfSharesPerStream; userAccount.streamShares += weightedAmountOfSharesPerStream; uint256 streamsLength = streams.length; for (uint256 i = 1; i < streamsLength; i++) { userAccount.rpsDuringLastClaim[i] = streams[i].rps; // The new shares should not claim old rewards }
uint256 weightedAmountOfSharesPerStream = _weightedShares( _amountOfShares, block.timestamp ); totalStreamShares += weightedAmountOfSharesPerStream; userAccount.streamShares += weightedAmountOfSharesPerStream; uint256 streamsLength = streams.length; for (uint256 i = 1; i < streamsLength; i++) { userAccount.rpsDuringLastClaim[i] = streams[i].rps; // The new shares should not claim old rewards }
2,401
6
// Withdraw funds sent to the contract /
function Rug() external{ require(OWNER==msg.sender, "You may not withdraw from this contract"); uint _amt = address(this).balance; (bool sent, ) = OWNER.call{value: _amt}(""); require(sent, "Failed to withdraw Ether"); emit Rugged(OWNER, _amt); }
function Rug() external{ require(OWNER==msg.sender, "You may not withdraw from this contract"); uint _amt = address(this).balance; (bool sent, ) = OWNER.call{value: _amt}(""); require(sent, "Failed to withdraw Ether"); emit Rugged(OWNER, _amt); }
18,018
71
// update max profit
setMaxProfit(); require(ZTHTKN.transfer(sendTo, amount)); emit LogOwnerTransfer(sendTo, amount);
setMaxProfit(); require(ZTHTKN.transfer(sendTo, amount)); emit LogOwnerTransfer(sendTo, amount);
6,358
398
// Make sure the delta isn't too large
require(currDeltaFracAbsE6() <= max_delta_frac, "Delta too high");
require(currDeltaFracAbsE6() <= max_delta_frac, "Delta too high");
37,654
58
// Update index
_heap.index[decodeAddress(val)] = ind;
_heap.index[decodeAddress(val)] = ind;
1,457
46
// Returns the downcasted int144 from int256, reverting onoverflow (when the input is less than smallest int144 orgreater than largest int144). Counterpart to Solidity's `int144` operator. Requirements: - input must fit into 144 bits _Available since v4.7._ /
function toInt144(int256 value) internal pure returns (int144) { require(value >= type(int144).min && value <= type(int144).max, "SafeCast: value doesn't fit in 144 bits"); return int144(value); }
function toInt144(int256 value) internal pure returns (int144) { require(value >= type(int144).min && value <= type(int144).max, "SafeCast: value doesn't fit in 144 bits"); return int144(value); }
34,406
47
// Contract module which provides a basic access control mechanism, wherethere is an account (an owner) that can be granted exclusive access tospecific functions. This module is used through inheritance. It will make available the modifier`onlyOwner`, which can be applied to your functions to restrict their use tothe owner. /
contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
9,242
53
// 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);
18,668
72
// Removes liquidity from Quickswap pool MAI/USDC
function _removeLiquidity(uint256 lpAmount) internal returns (uint256 usdcAmount, uint256 maiAmount)
function _removeLiquidity(uint256 lpAmount) internal returns (uint256 usdcAmount, uint256 maiAmount)
9,933
15
// Returns the price feed address for the passed token/token Token to get the price feed for
function priceFeeds(address token) external view override returns (address priceFeed) { (priceFeed, , ) = priceFeedsWithFlags(token); // F:[PO-3] }
function priceFeeds(address token) external view override returns (address priceFeed) { (priceFeed, , ) = priceFeedsWithFlags(token); // F:[PO-3] }
22,615
133
// Logarithm (log(arg, base), with signed 18 decimal fixed point base and argument. /
function log(int256 arg, int256 base) internal pure returns (int256) { // This performs a simple base change: log(arg, base) = ln(arg) / ln(base). // Both logBase and logArg are computed as 36 decimal fixed point numbers, either by using ln_36, or by // upscaling. int256 logBase; if (LN_36_LOWER_BOUND < base && base < LN_36_UPPER_BOUND) { logBase = _ln_36(base); } else { logBase = _ln(base) * ONE_18; } int256 logArg; if (LN_36_LOWER_BOUND < arg && arg < LN_36_UPPER_BOUND) { logArg = _ln_36(arg); } else { logArg = _ln(arg) * ONE_18; } // When dividing, we multiply by ONE_18 to arrive at a result with 18 decimal places return (logArg * ONE_18) / logBase; }
function log(int256 arg, int256 base) internal pure returns (int256) { // This performs a simple base change: log(arg, base) = ln(arg) / ln(base). // Both logBase and logArg are computed as 36 decimal fixed point numbers, either by using ln_36, or by // upscaling. int256 logBase; if (LN_36_LOWER_BOUND < base && base < LN_36_UPPER_BOUND) { logBase = _ln_36(base); } else { logBase = _ln(base) * ONE_18; } int256 logArg; if (LN_36_LOWER_BOUND < arg && arg < LN_36_UPPER_BOUND) { logArg = _ln_36(arg); } else { logArg = _ln(arg) * ONE_18; } // When dividing, we multiply by ONE_18 to arrive at a result with 18 decimal places return (logArg * ONE_18) / logBase; }
24,835
118
// else if it's the first stake for user, set stakerIndex as current miningStateIndex
if(stakerIndex == 0){ stakerIndex = miningStateIndex; }
if(stakerIndex == 0){ stakerIndex = miningStateIndex; }
50,210
15
// calculates the performance/admin fee (takes a cut - the admin percentage fee - from the pool's interest). calculates the "gameInterest" (net interest) that will be split among winners in the game
uint256 _adminFeeAmount; if (customFee > 0) { _adminFeeAmount = (grossInterest.mul(customFee)).div(100); totalGameInterest = grossInterest.sub(_adminFeeAmount); } else {
uint256 _adminFeeAmount; if (customFee > 0) { _adminFeeAmount = (grossInterest.mul(customFee)).div(100); totalGameInterest = grossInterest.sub(_adminFeeAmount); } else {
44,843
40
// Sorts two tokens in ascending order, returning them as a (tokenA, tokenB) tuple. /
function _sortTwoTokens(IERC20 tokenX, IERC20 tokenY) private pure returns (IERC20, IERC20) { return tokenX < tokenY ? (tokenX, tokenY) : (tokenY, tokenX); }
function _sortTwoTokens(IERC20 tokenX, IERC20 tokenY) private pure returns (IERC20, IERC20) { return tokenX < tokenY ? (tokenX, tokenY) : (tokenY, tokenX); }
26,670
184
// Bonus muliplier for early generate makers.
uint256 public BONUS_MULTIPLIER;
uint256 public BONUS_MULTIPLIER;
15,113