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
|
|---|---|---|---|---|
345
|
// return our iron bank deposit:state changing
|
uint256 ibBorrows = SCErc20I(ironBankToken).borrowBalanceCurrent(address(this));
SCErc20I(ironBankToken).repayBorrow(Math.min(ibBorrows, want.balanceOf(address(this))));
want.safeTransfer(_newStrategy, want.balanceOf(address(this)));
IERC20 _comp = IERC20(comp);
uint _compB = _comp.balanceOf(address(this));
if(_compB > 0){
_comp.safeTransfer(_newStrategy, _compB);
}
|
uint256 ibBorrows = SCErc20I(ironBankToken).borrowBalanceCurrent(address(this));
SCErc20I(ironBankToken).repayBorrow(Math.min(ibBorrows, want.balanceOf(address(this))));
want.safeTransfer(_newStrategy, want.balanceOf(address(this)));
IERC20 _comp = IERC20(comp);
uint _compB = _comp.balanceOf(address(this));
if(_compB > 0){
_comp.safeTransfer(_newStrategy, _compB);
}
| 51,965
|
0
|
// flag and index for Ethereum address
|
mapping(address => Data) private isEthereumAddressAdded;
|
mapping(address => Data) private isEthereumAddressAdded;
| 45,508
|
2
|
// setAddress updates signer address
|
function setAddress(address _newSigner) public payable onlySigner {
signer = _newSigner;
uint256 _value = msg.value;
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = _newSigner.call{value: _value, gas: 21000}("");
require(success, "SignerStorage: transfer value failed");
emit SignerUpdated(_newSigner);
}
|
function setAddress(address _newSigner) public payable onlySigner {
signer = _newSigner;
uint256 _value = msg.value;
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = _newSigner.call{value: _value, gas: 21000}("");
require(success, "SignerStorage: transfer value failed");
emit SignerUpdated(_newSigner);
}
| 10,307
|
18
|
// Cap voting power to remaining unminted voting power supply.
|
uint96 votingPower_ = votingPower.safeCastUint256ToUint96();
if (totalVotingPower - mintedVotingPower_ < votingPower_) {
votingPower_ = totalVotingPower - mintedVotingPower_;
}
|
uint96 votingPower_ = votingPower.safeCastUint256ToUint96();
if (totalVotingPower - mintedVotingPower_ < votingPower_) {
votingPower_ = totalVotingPower - mintedVotingPower_;
}
| 31,582
|
27
|
// The standard EIP-20 transfer event
|
event Transfer(address indexed from, address indexed to, uint256 amount);
|
event Transfer(address indexed from, address indexed to, uint256 amount);
| 920
|
7
|
// address constant WETH = 0xd0A1E359811322d97991E03f863a0C30C2cF029C;kovan
|
address constant uniSwapRouterAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // mainnet & ropsten & goerli
|
address constant uniSwapRouterAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // mainnet & ropsten & goerli
| 7,792
|
189
|
// Returns whether the state is locked at the given block number. self The Blocklock state blockNumber The current block number. /
|
function isLocked(State storage self, uint256 blockNumber) public view returns (bool) {
uint256 endAt = lockEndAt(self);
return (
self.lockedAt != 0 &&
blockNumber >= self.lockedAt &&
blockNumber < endAt
);
}
|
function isLocked(State storage self, uint256 blockNumber) public view returns (bool) {
uint256 endAt = lockEndAt(self);
return (
self.lockedAt != 0 &&
blockNumber >= self.lockedAt &&
blockNumber < endAt
);
}
| 55,173
|
6
|
// return total supply of tokens /
|
function totalSupply() external view returns (uint256 supply);
|
function totalSupply() external view returns (uint256 supply);
| 4,628
|
14
|
// Total Fee for Swap
|
uint8 private _SwapFeeTotal = 6;
|
uint8 private _SwapFeeTotal = 6;
| 12,429
|
2
|
// Assert that the function returns the correct greeting
|
Assert.equal(greeting, "Hello World", "It should greet me with Hello World.");
|
Assert.equal(greeting, "Hello World", "It should greet me with Hello World.");
| 19,736
|
306
|
// BToken initialize does the bulk of the work
|
super.initialize(bController_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);
|
super.initialize(bController_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);
| 76,873
|
6
|
// Hammer setter _hammer New hammer address /
|
function setHammer(address _hammer) onlyHammer
|
function setHammer(address _hammer) onlyHammer
| 20,197
|
53
|
// unpacks r, s, v from signature bytes
|
function getRsv(bytes memory sig) public pure returns (bytes32, bytes32, uint8) {
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := and(mload(add(sig, 65)), 255)
}
if (v < 27) v += 27;
return (r, s, v);
}
|
function getRsv(bytes memory sig) public pure returns (bytes32, bytes32, uint8) {
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := and(mload(add(sig, 65)), 255)
}
if (v < 27) v += 27;
return (r, s, v);
}
| 13,849
|
40
|
// RetrieverCoin Contract to create the Retriever Coin /
|
contract RetrieverCoin is CrowdsaleToken {
string public constant name = "Retriever Coin";
string public constant symbol = "RETR";
uint32 public constant decimals = 1;
}
|
contract RetrieverCoin is CrowdsaleToken {
string public constant name = "Retriever Coin";
string public constant symbol = "RETR";
uint32 public constant decimals = 1;
}
| 35,620
|
28
|
// If this is the first level, prev level is 0 / 0
|
amountPrevLevel = 0;
discountPrevLevel = 0;
|
amountPrevLevel = 0;
discountPrevLevel = 0;
| 27,996
|
5
|
// Testing Functions //Tests the `batchFillOrders` function's payment of protocol fees./testProtocolFees The TestProtocolFees that should be tested against./protocolFeeMultiplier The protocol fee multiplier that should be registered/in the test suite before executing `batchFillOrders`./numberOfOrders The number of orders that should be created and executed for this test./shouldSetProtocolFeeCollector A boolean value indicating whether or not this contract/should be registered as the `protocolFeeCollector`.
|
function testBatchFillOrdersProtocolFees(
TestProtocolFees testProtocolFees,
uint256 protocolFeeMultiplier,
uint256 numberOfOrders,
bool shouldSetProtocolFeeCollector
)
external
payable
handleState(testProtocolFees, protocolFeeMultiplier, shouldSetProtocolFeeCollector)
|
function testBatchFillOrdersProtocolFees(
TestProtocolFees testProtocolFees,
uint256 protocolFeeMultiplier,
uint256 numberOfOrders,
bool shouldSetProtocolFeeCollector
)
external
payable
handleState(testProtocolFees, protocolFeeMultiplier, shouldSetProtocolFeeCollector)
| 21,609
|
21
|
// subtract 1 from activeOffers tracker.
|
activeOffers--;
emit MarketTransaction("Remove offer", msg.sender, _tokenId);
|
activeOffers--;
emit MarketTransaction("Remove offer", msg.sender, _tokenId);
| 18,127
|
27
|
// Internal Mint Function Only
|
function _mint(address account, uint256 amount) internal {
require(amount != 0);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
|
function _mint(address account, uint256 amount) internal {
require(amount != 0);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| 24,183
|
100
|
// Errors library Defines the error messages emitted by the different contracts Error messages prefix glossary: - VL = ValidationLogic - MATH = Math libraries - CT = Common errors between tokens (DepositToken, VariableDebtToken and StableDebtToken) - AT = DepositToken - SDT = StableDebtToken - VDT = VariableDebtToken - LP = LendingPool - LPAPR = AddressesProviderRegistry - LPC = LendingPoolConfiguration - RL = ReserveLogic - LPCM = LendingPoolExtension - ST = Stake /
|
library Errors {
//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_UNKNOWN_RESERVE = '4'; // Action requires an active reserve
string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5'; // User cannot withdraw more than the available balance (above min limit)
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 exceeds max size of a stable loan
string public constant VL_NO_DEBT_OF_SELECTED_TYPE = '15'; // to repay a debt, user needs to specify a correct debt type (variable or stable)
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 collateral 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 VL_RESERVE_MUST_BE_COLLATERAL = '21'; // This reserve must be enabled as collateral
string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22'; // Interest rate rebalance conditions were not met
string public constant AT_OVERDRAFT_DISABLED = '23'; // User doesn't accept allocation of overdraft
string public constant VL_INVALID_SUB_BALANCE_ARGS = '24';
string public constant AT_INVALID_SLASH_DESTINATION = '25';
string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // The caller of the function is not the lending pool configurator
string public constant LENDING_POOL_REQUIRED = '28'; // The caller of this function must be a lending pool
string public constant CALLER_NOT_LENDING_POOL = '29'; // The caller of this function must be a lending pool
string public constant AT_SUB_BALANCE_RESTIRCTED_FUNCTION = '30'; // The caller of this function must be a lending pool or a sub-balance operator
string public constant RL_RESERVE_ALREADY_INITIALIZED = '32'; // Reserve has already been initialized
string public constant CALLER_NOT_POOL_ADMIN = '33'; // The caller must be the pool admin
string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = '34'; // The liquidity of the reserve needs to be 0
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 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 CALLER_NOT_STAKE_ADMIN = '57';
string public constant CT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn
string public constant BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small
string public constant CALLER_NOT_LIQUIDITY_CONTROLLER = '60';
string public constant CALLER_NOT_REF_ADMIN = '61';
string public constant VL_INSUFFICIENT_REWARD_AVAILABLE = '62';
string public constant LP_CALLER_MUST_BE_DEPOSIT_TOKEN = '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 VL_TREASURY_REQUIRED = '74';
string public constant LPC_INVALID_CONFIGURATION = '75'; // Invalid risk parameters for the reserve
string public constant CALLER_NOT_EMERGENCY_ADMIN = '76'; // The caller must be the emergency admin
string public constant UL_INVALID_INDEX = '77';
string public constant VL_CONTRACT_REQUIRED = '78';
string public constant SDT_STABLE_DEBT_OVERFLOW = '79';
string public constant SDT_BURN_EXCEEDS_BALANCE = '80';
string public constant CALLER_NOT_REWARD_CONFIG_ADMIN = '81'; // The caller of this function must be a reward admin
string public constant LP_INVALID_PERCENTAGE = '82'; // Percentage can't be more than 100%
string public constant LP_IS_NOT_TRUSTED_FLASHLOAN = '83';
string public constant CALLER_NOT_SWEEP_ADMIN = '84';
string public constant LP_TOO_MANY_NESTED_CALLS = '85';
string public constant LP_RESTRICTED_FEATURE = '86';
string public constant LP_TOO_MANY_FLASHLOAN_CALLS = '87';
string public constant RW_BASELINE_EXCEEDED = '88';
string public constant CALLER_NOT_REWARD_RATE_ADMIN = '89';
string public constant CALLER_NOT_REWARD_CONTROLLER = '90';
string public constant RW_REWARD_PAUSED = '91';
string public constant CALLER_NOT_TEAM_MANAGER = '92';
string public constant STK_REDEEM_PAUSED = '93';
string public constant STK_INSUFFICIENT_COOLDOWN = '94';
string public constant STK_UNSTAKE_WINDOW_FINISHED = '95';
string public constant STK_INVALID_BALANCE_ON_COOLDOWN = '96';
string public constant STK_EXCESSIVE_SLASH_PCT = '97';
string public constant STK_WRONG_COOLDOWN_OR_UNSTAKE = '98';
string public constant STK_PAUSED = '99';
string public constant TXT_OWNABLE_CALLER_NOT_OWNER = 'Ownable: caller is not the owner';
string public constant TXT_CALLER_NOT_PROXY_OWNER = 'ProxyOwner: caller is not the owner';
string public constant TXT_ACCESS_RESTRICTED = 'RESTRICTED';
}
|
library Errors {
//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_UNKNOWN_RESERVE = '4'; // Action requires an active reserve
string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5'; // User cannot withdraw more than the available balance (above min limit)
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 exceeds max size of a stable loan
string public constant VL_NO_DEBT_OF_SELECTED_TYPE = '15'; // to repay a debt, user needs to specify a correct debt type (variable or stable)
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 collateral 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 VL_RESERVE_MUST_BE_COLLATERAL = '21'; // This reserve must be enabled as collateral
string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22'; // Interest rate rebalance conditions were not met
string public constant AT_OVERDRAFT_DISABLED = '23'; // User doesn't accept allocation of overdraft
string public constant VL_INVALID_SUB_BALANCE_ARGS = '24';
string public constant AT_INVALID_SLASH_DESTINATION = '25';
string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // The caller of the function is not the lending pool configurator
string public constant LENDING_POOL_REQUIRED = '28'; // The caller of this function must be a lending pool
string public constant CALLER_NOT_LENDING_POOL = '29'; // The caller of this function must be a lending pool
string public constant AT_SUB_BALANCE_RESTIRCTED_FUNCTION = '30'; // The caller of this function must be a lending pool or a sub-balance operator
string public constant RL_RESERVE_ALREADY_INITIALIZED = '32'; // Reserve has already been initialized
string public constant CALLER_NOT_POOL_ADMIN = '33'; // The caller must be the pool admin
string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = '34'; // The liquidity of the reserve needs to be 0
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 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 CALLER_NOT_STAKE_ADMIN = '57';
string public constant CT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn
string public constant BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small
string public constant CALLER_NOT_LIQUIDITY_CONTROLLER = '60';
string public constant CALLER_NOT_REF_ADMIN = '61';
string public constant VL_INSUFFICIENT_REWARD_AVAILABLE = '62';
string public constant LP_CALLER_MUST_BE_DEPOSIT_TOKEN = '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 VL_TREASURY_REQUIRED = '74';
string public constant LPC_INVALID_CONFIGURATION = '75'; // Invalid risk parameters for the reserve
string public constant CALLER_NOT_EMERGENCY_ADMIN = '76'; // The caller must be the emergency admin
string public constant UL_INVALID_INDEX = '77';
string public constant VL_CONTRACT_REQUIRED = '78';
string public constant SDT_STABLE_DEBT_OVERFLOW = '79';
string public constant SDT_BURN_EXCEEDS_BALANCE = '80';
string public constant CALLER_NOT_REWARD_CONFIG_ADMIN = '81'; // The caller of this function must be a reward admin
string public constant LP_INVALID_PERCENTAGE = '82'; // Percentage can't be more than 100%
string public constant LP_IS_NOT_TRUSTED_FLASHLOAN = '83';
string public constant CALLER_NOT_SWEEP_ADMIN = '84';
string public constant LP_TOO_MANY_NESTED_CALLS = '85';
string public constant LP_RESTRICTED_FEATURE = '86';
string public constant LP_TOO_MANY_FLASHLOAN_CALLS = '87';
string public constant RW_BASELINE_EXCEEDED = '88';
string public constant CALLER_NOT_REWARD_RATE_ADMIN = '89';
string public constant CALLER_NOT_REWARD_CONTROLLER = '90';
string public constant RW_REWARD_PAUSED = '91';
string public constant CALLER_NOT_TEAM_MANAGER = '92';
string public constant STK_REDEEM_PAUSED = '93';
string public constant STK_INSUFFICIENT_COOLDOWN = '94';
string public constant STK_UNSTAKE_WINDOW_FINISHED = '95';
string public constant STK_INVALID_BALANCE_ON_COOLDOWN = '96';
string public constant STK_EXCESSIVE_SLASH_PCT = '97';
string public constant STK_WRONG_COOLDOWN_OR_UNSTAKE = '98';
string public constant STK_PAUSED = '99';
string public constant TXT_OWNABLE_CALLER_NOT_OWNER = 'Ownable: caller is not the owner';
string public constant TXT_CALLER_NOT_PROXY_OWNER = 'ProxyOwner: caller is not the owner';
string public constant TXT_ACCESS_RESTRICTED = 'RESTRICTED';
}
| 26,545
|
94
|
// Allows merchant or Monetha to initiate exchange of tokens by withdrawing all tokens to deposit address of the exchange /
|
function withdrawAllTokensToExchange(address _tokenAddress, address _depositAccount, uint _minAmount) external onlyMerchantOrMonetha whenNotPaused {
require(_tokenAddress != address(0));
uint balance = GenericERC20(_tokenAddress).balanceOf(address(this));
require(balance >= _minAmount);
GenericERC20(_tokenAddress).transfer(_depositAccount, balance);
}
|
function withdrawAllTokensToExchange(address _tokenAddress, address _depositAccount, uint _minAmount) external onlyMerchantOrMonetha whenNotPaused {
require(_tokenAddress != address(0));
uint balance = GenericERC20(_tokenAddress).balanceOf(address(this));
require(balance >= _minAmount);
GenericERC20(_tokenAddress).transfer(_depositAccount, balance);
}
| 16,847
|
45
|
// stakeOnBehalfOfAnotherUser is called for airdropping Aurora users/account the account address/amount in AURORA tokens/ WARNING: rewards are not claimed during stake. Airdrop script must claim or/ only distribute to accounts without stake
|
function stakeOnBehalfOfAnotherUser(address account, uint256 amount)
external
pausable(1)
onlyRole(AIRDROP_ROLE)
|
function stakeOnBehalfOfAnotherUser(address account, uint256 amount)
external
pausable(1)
onlyRole(AIRDROP_ROLE)
| 2,352
|
76
|
// ark, round 38
|
st0 := addmod(st0, 0x1166d9e554616dba9e753eea427c17b7fecd58c076dfe42708b08f5b783aa9af, q)
st1 := addmod(st1, 0x2de52989431a859593413026354413db177fbf4cd2ac0b56f855a888357ee466, q)
st2 := addmod(st2, 0x3006eb4ffc7a85819a6da492f3a8ac1df51aee5b17b8e89d74bf01cf5f71e9ad, q)
|
st0 := addmod(st0, 0x1166d9e554616dba9e753eea427c17b7fecd58c076dfe42708b08f5b783aa9af, q)
st1 := addmod(st1, 0x2de52989431a859593413026354413db177fbf4cd2ac0b56f855a888357ee466, q)
st2 := addmod(st2, 0x3006eb4ffc7a85819a6da492f3a8ac1df51aee5b17b8e89d74bf01cf5f71e9ad, q)
| 8,298
|
146
|
// Ensure that a user signing key is set on this smart wallet.
|
require(userSigningKey != address(0), "No user signing key provided.");
_userSigningKey = userSigningKey;
emit NewUserSigningKey(userSigningKey);
|
require(userSigningKey != address(0), "No user signing key provided.");
_userSigningKey = userSigningKey;
emit NewUserSigningKey(userSigningKey);
| 26,723
|
163
|
// ``` The following map types are supported: - `uint256 -> address` (`UintToAddressMap`) since v3.0.0- `address -> uint256` (`AddressToUintMap`) since v4.6.0 /
|
library EnumerableMap {
using EnumerableSet for EnumerableSet.Bytes32Set;
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Map type with
// bytes32 keys and values.
// The Map implementation uses private functions, and user-facing
// implementations (such as Uint256ToAddressMap) are just wrappers around
// the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit
// in bytes32.
struct Map {
// Storage of keys
EnumerableSet.Bytes32Set _keys;
mapping(bytes32 => bytes32) _values;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function _set(
Map storage map,
bytes32 key,
bytes32 value
) private returns (bool) {
map._values[key] = value;
return map._keys.add(key);
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function _remove(Map storage map, bytes32 key) private returns (bool) {
delete map._values[key];
return map._keys.remove(key);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function _contains(Map storage map, bytes32 key) private view returns (bool) {
return map._keys.contains(key);
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function _length(Map storage map) private view returns (uint256) {
return map._keys.length();
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
bytes32 key = map._keys.at(index);
return (key, map._values[key]);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
bytes32 value = map._values[key];
if (value == bytes32(0)) {
return (_contains(map, key), bytes32(0));
} else {
return (true, value);
}
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function _get(Map storage map, bytes32 key) private view returns (bytes32) {
bytes32 value = map._values[key];
require(value != 0 || _contains(map, key), "EnumerableMap: nonexistent key");
return value;
}
/**
* @dev Same as {_get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {_tryGet}.
*/
function _get(
Map storage map,
bytes32 key,
string memory errorMessage
) private view returns (bytes32) {
bytes32 value = map._values[key];
require(value != 0 || _contains(map, key), errorMessage);
return value;
}
// UintToAddressMap
struct UintToAddressMap {
Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(
UintToAddressMap storage map,
uint256 key,
address value
) internal returns (bool) {
return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return _remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return _contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the set. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (uint256(key), address(uint160(uint256(value))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*
* _Available since v3.4._
*/
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(value))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key)))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(
UintToAddressMap storage map,
uint256 key,
string memory errorMessage
) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
}
// AddressToUintMap
struct AddressToUintMap {
Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(
AddressToUintMap storage map,
address key,
uint256 value
) internal returns (bool) {
return _set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(AddressToUintMap storage map, address key) internal returns (bool) {
return _remove(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(AddressToUintMap storage map, address key) internal view returns (bool) {
return _contains(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(AddressToUintMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the set. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (address(uint160(uint256(key))), uint256(value));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*
* _Available since v3.4._
*/
function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(uint256(uint160(key))));
return (success, uint256(value));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
return uint256(_get(map._inner, bytes32(uint256(uint160(key)))));
}
}
|
library EnumerableMap {
using EnumerableSet for EnumerableSet.Bytes32Set;
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Map type with
// bytes32 keys and values.
// The Map implementation uses private functions, and user-facing
// implementations (such as Uint256ToAddressMap) are just wrappers around
// the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit
// in bytes32.
struct Map {
// Storage of keys
EnumerableSet.Bytes32Set _keys;
mapping(bytes32 => bytes32) _values;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function _set(
Map storage map,
bytes32 key,
bytes32 value
) private returns (bool) {
map._values[key] = value;
return map._keys.add(key);
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function _remove(Map storage map, bytes32 key) private returns (bool) {
delete map._values[key];
return map._keys.remove(key);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function _contains(Map storage map, bytes32 key) private view returns (bool) {
return map._keys.contains(key);
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function _length(Map storage map) private view returns (uint256) {
return map._keys.length();
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
bytes32 key = map._keys.at(index);
return (key, map._values[key]);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
bytes32 value = map._values[key];
if (value == bytes32(0)) {
return (_contains(map, key), bytes32(0));
} else {
return (true, value);
}
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function _get(Map storage map, bytes32 key) private view returns (bytes32) {
bytes32 value = map._values[key];
require(value != 0 || _contains(map, key), "EnumerableMap: nonexistent key");
return value;
}
/**
* @dev Same as {_get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {_tryGet}.
*/
function _get(
Map storage map,
bytes32 key,
string memory errorMessage
) private view returns (bytes32) {
bytes32 value = map._values[key];
require(value != 0 || _contains(map, key), errorMessage);
return value;
}
// UintToAddressMap
struct UintToAddressMap {
Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(
UintToAddressMap storage map,
uint256 key,
address value
) internal returns (bool) {
return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return _remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return _contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the set. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (uint256(key), address(uint160(uint256(value))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*
* _Available since v3.4._
*/
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(value))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key)))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(
UintToAddressMap storage map,
uint256 key,
string memory errorMessage
) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
}
// AddressToUintMap
struct AddressToUintMap {
Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(
AddressToUintMap storage map,
address key,
uint256 value
) internal returns (bool) {
return _set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(AddressToUintMap storage map, address key) internal returns (bool) {
return _remove(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(AddressToUintMap storage map, address key) internal view returns (bool) {
return _contains(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(AddressToUintMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the set. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (address(uint160(uint256(key))), uint256(value));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*
* _Available since v3.4._
*/
function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(uint256(uint160(key))));
return (success, uint256(value));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
return uint256(_get(map._inner, bytes32(uint256(uint160(key)))));
}
}
| 20,095
|
3
|
// Prevent resetting the settings logic for standalone test deployments.
|
if (address(settings()) != address(0x0))
return require(settingsAddress.isContract(), "SETTINGS_MUST_BE_A_CONTRACT");
bytes32 slot = SETTINGS_SLOT;
assembly {
sstore(slot, settingsAddress)
}
|
if (address(settings()) != address(0x0))
return require(settingsAddress.isContract(), "SETTINGS_MUST_BE_A_CONTRACT");
bytes32 slot = SETTINGS_SLOT;
assembly {
sstore(slot, settingsAddress)
}
| 43,541
|
60
|
// when selling eth its possible that some eth isn't sold and it is returned back
|
(success, tokens[0], tokens[1]) = takeOrder(orderAddresses, _callData, address(this).balance, _data[0]);
|
(success, tokens[0], tokens[1]) = takeOrder(orderAddresses, _callData, address(this).balance, _data[0]);
| 84,886
|
15
|
// Function to recover the funds on the contract /
|
function killAndRefund() onlyOwner public {
for (uint256 i = 0; i < indexTracker; i++) {
depositIndex[i].transfer(balanceOf[depositIndex[i]] * price / 10 ** decimals);
}
selfdestruct(owner);
}
|
function killAndRefund() onlyOwner public {
for (uint256 i = 0; i < indexTracker; i++) {
depositIndex[i].transfer(balanceOf[depositIndex[i]] * price / 10 ** decimals);
}
selfdestruct(owner);
}
| 26,830
|
54
|
// New max size must be greater than old max size
|
require(_size > self.maxSize);
self.maxSize = _size;
|
require(_size > self.maxSize);
self.maxSize = _size;
| 4,731
|
3
|
// - See SecuredLine.constructor(). Deploys a new SecuredLine contract with params provided by factory. - Deploy from lib not factory so we can have multiple factories (aka marketplaces) built on same Line contractsreturn line - address of newly deployed line /
|
function deploySecuredLine(
address oracle,
address arbiter,
address borrower,
address payable swapTarget,
address s,
address e,
uint256 ttl,
uint8 revenueSplit
|
function deploySecuredLine(
address oracle,
address arbiter,
address borrower,
address payable swapTarget,
address s,
address e,
uint256 ttl,
uint8 revenueSplit
| 45,194
|
56
|
// Masterchef Contract
|
Masterchef public masterchef = Masterchef(Constants.MASTERCHEF);
uint256 public univ2SushiEthPoolId = 12;
|
Masterchef public masterchef = Masterchef(Constants.MASTERCHEF);
uint256 public univ2SushiEthPoolId = 12;
| 29,743
|
39
|
// Convert signed 64.64 fixed point number into signed 64-bit integer numberrounding down.x signed 64.64-bit fixed point numberreturn signed 64-bit integer number /
|
function toInt (int128 x) internal pure returns (int64) {
unchecked {
return int64 (x >> 64);
}
}
|
function toInt (int128 x) internal pure returns (int64) {
unchecked {
return int64 (x >> 64);
}
}
| 32,712
|
4
|
// assert(a == bc + a % b);There is no case in which this doesn't hold
|
return c;
|
return c;
| 5,586
|
129
|
// ERC677 transfer callback function. _from address of tokens sender. _value amount of transferred tokens. _data additional transfer data, can be used for passing alternative receiver address. /
|
function onTokenTransfer(
address _from,
uint256 _value,
bytes calldata _data
|
function onTokenTransfer(
address _from,
uint256 _value,
bytes calldata _data
| 8,954
|
122
|
// Gets the integration for the module with the passed in name. Validates that the address is not empty /
|
function getAndValidateAdapter(string memory _integrationName) internal view returns(address) {
bytes32 integrationHash = getNameHash(_integrationName);
return getAndValidateAdapterWithHash(integrationHash);
}
|
function getAndValidateAdapter(string memory _integrationName) internal view returns(address) {
bytes32 integrationHash = getNameHash(_integrationName);
return getAndValidateAdapterWithHash(integrationHash);
}
| 27,810
|
24
|
// This function allows governance to take unsupported tokens out of the contract. This is in an effort to make someone whole, should they seriously mess up. There is no guarantee governance will vote to return these. It also allows for removal of airdropped tokens.
|
function governanceRecoverUnsupported(IERC20 _token, uint256 amount, address to) external onlyOwner {
_token.safeTransfer(to, amount);
}
|
function governanceRecoverUnsupported(IERC20 _token, uint256 amount, address to) external onlyOwner {
_token.safeTransfer(to, amount);
}
| 19,874
|
85
|
// Determine the prior number of votes for an account as of a block number Block number must be a finalized block or else this function will revert to prevent misinformation. account The address of the account to check blockNumber The block number to get the vote balance atreturn The number of votes the account had as of the given block /
|
function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) {
require(blockNumber < block.number, "UFARM::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
|
function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) {
require(blockNumber < block.number, "UFARM::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
| 30,714
|
38
|
// Safely transfers the ownership of a given token ID to another addressIf the target address is a contract, it must implement `onERC721Received`,which is called upon a safe transfer, and return the magic value`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,the transfer is reverted.Requires the msg sender to be the owner, approved, or operator _from current owner of the token _to address to receive the ownership of the given token ID _tokenId uint256 ID of the token to be transferred _data bytes data to send along with a safe transfer check /
|
function safeTransferFrom(
ERC721Data storage self,
address _from,
address _to,
uint256 _tokenId,
bytes _data
|
function safeTransferFrom(
ERC721Data storage self,
address _from,
address _to,
uint256 _tokenId,
bytes _data
| 37,292
|
24
|
// Appeal a ruling. Note that it has to be called before the arbitrator contract calls rule. _disputeID ID of the dispute to be appealed. _extraData Can be used to give extra info on the appeal./
|
function appeal(uint _disputeID, bytes memory _extraData) public requireAppealFee(_disputeID,_extraData) payable {
emit AppealDecision(_disputeID, Arbitrable(msg.sender));
|
function appeal(uint _disputeID, bytes memory _extraData) public requireAppealFee(_disputeID,_extraData) payable {
emit AppealDecision(_disputeID, Arbitrable(msg.sender));
| 15,558
|
12
|
// Submit level to the core Ethernaut contract
|
levelSuccessfullyPassed = ethernaut.submitLevelInstance(payable(levelAddress));
|
levelSuccessfullyPassed = ethernaut.submitLevelInstance(payable(levelAddress));
| 5,724
|
6
|
// 0x780e9d63 ===bytes4(keccak256(&39;totalSupply()&39;)) ^bytes4(keccak256(&39;tokenOfOwnerByIndex(address,uint256)&39;)) ^bytes4(keccak256(&39;tokenByIndex(uint256)&39;)) /
|
bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f;
|
bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f;
| 39,948
|
128
|
// forgefmt: disable-next-item
|
result := and(
shr(mul(22, x), 0x375f0016260009d80004ec0002d00001e0000180000180000200000400001),
0x3fffff
)
break
|
result := and(
shr(mul(22, x), 0x375f0016260009d80004ec0002d00001e0000180000180000200000400001),
0x3fffff
)
break
| 19,907
|
62
|
// IERC777TokensSender ERC777TokensSender interface /
|
interface IERC777TokensSender {
function canTransfer(
bytes32 partition,
address from,
address to,
uint value,
bytes calldata data,
bytes calldata operatorData
) external view returns(bool);
function tokensToTransfer(
bytes32 partition,
address operator,
address from,
address to,
uint value,
bytes calldata data,
bytes calldata operatorData
) external;
}
|
interface IERC777TokensSender {
function canTransfer(
bytes32 partition,
address from,
address to,
uint value,
bytes calldata data,
bytes calldata operatorData
) external view returns(bool);
function tokensToTransfer(
bytes32 partition,
address operator,
address from,
address to,
uint value,
bytes calldata data,
bytes calldata operatorData
) external;
}
| 23,761
|
125
|
// Maximum IVs for stats. 0: ATK1: DEF 2: AGL3: LUK 4: HP.
|
uint32[5] maxIVForStats;
|
uint32[5] maxIVForStats;
| 17,287
|
0
|
// Contract inspired from https:www.youtube.com/watch?v=19SSvs32m8I&ab_channel=ArturChmaro
|
mapping (uint256 => string) private _tokenURIs; //We create the mapping for TokenID -> URI
using Counters for Counters.Counter;
Counters.Counter private _tokenIds; //Counter to keep track of the number of NFT we minted and make sure we dont try to mint the same twice
|
mapping (uint256 => string) private _tokenURIs; //We create the mapping for TokenID -> URI
using Counters for Counters.Counter;
Counters.Counter private _tokenIds; //Counter to keep track of the number of NFT we minted and make sure we dont try to mint the same twice
| 10,644
|
102
|
// Check whether the token exists id The id of tokenreturn bool True if the token exists, otherwise false /
|
function _isExist(uint id) private view returns (bool)
|
function _isExist(uint id) private view returns (bool)
| 41,212
|
206
|
// Returns the substraction of two unsigned integers, with an overflow flag. _Available since v3.4._ /
|
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
|
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
| 29,236
|
52
|
// return Rate of one Tempus Principal Share expressed in Asset Tokens
|
function pricePerPrincipalShare() external returns (uint256);
|
function pricePerPrincipalShare() external returns (uint256);
| 57,765
|
372
|
// newTributary
|
edition.fundingRecipient
);
ITributaryRegistry(tributaryRegistry).setTributary(
clone,
edition.fundingRecipient
);
|
edition.fundingRecipient
);
ITributaryRegistry(tributaryRegistry).setTributary(
clone,
edition.fundingRecipient
);
| 20,851
|
8
|
// === Upgradeability === solhint-disable-next-line no-empty-blocks
|
function _authorizeUpgrade(address newImplementation) internal override onlyRole(OWNER) {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
|
function _authorizeUpgrade(address newImplementation) internal override onlyRole(OWNER) {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
| 38,591
|
9
|
// the keccak encoded spaceId of the snapshot space
|
bytes32 public spaceId;
|
bytes32 public spaceId;
| 77,893
|
1
|
// --- ERC721
|
string baseURI;
uint256 totalSupply;
mapping (uint256 => ERC721Token) items;
|
string baseURI;
uint256 totalSupply;
mapping (uint256 => ERC721Token) items;
| 14,150
|
1
|
// Requests randomness from a user-provided seed /
|
function getRandomNumber(uint256 userProvidedSeed)
public
returns (bytes32 requestId)
|
function getRandomNumber(uint256 userProvidedSeed)
public
returns (bytes32 requestId)
| 60,063
|
40
|
// returns the origination fee percentage/
|
function getLoanOriginationFeePercentage() external view returns (uint256) {
return originationFeePercentage;
}
|
function getLoanOriginationFeePercentage() external view returns (uint256) {
return originationFeePercentage;
}
| 15,404
|
4
|
// Non-owner actions are always processed via the Authorizer, as "owner only" ones are when delegated.
|
return _getAuthorizer().canPerform(actionId, account, address(this));
|
return _getAuthorizer().canPerform(actionId, account, address(this));
| 22,073
|
302
|
// Checks if redeem is valid_setToken Instance of the SetToken _reserveAsset Address of the reserve asset _setTokenQuantity Quantity of SetTokens to redeem returnboolReturns true if redeem is valid /
|
function isRedeemValid(
ISetToken _setToken,
address _reserveAsset,
uint256 _setTokenQuantity
)
external
view
returns (bool)
|
function isRedeemValid(
ISetToken _setToken,
address _reserveAsset,
uint256 _setTokenQuantity
)
external
view
returns (bool)
| 27,635
|
194
|
// transfer tokens to contract
|
xmon.safeTransferFrom(msg.sender, address(this), amount);
|
xmon.safeTransferFrom(msg.sender, address(this), amount);
| 60,983
|
39
|
// Test to see if the term has already ended
|
require(block.timestamp < releaseEpoch, "Term has already ended");
|
require(block.timestamp < releaseEpoch, "Term has already ended");
| 25,674
|
171
|
// Info of each pool
|
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract
uint256 allocPoint; // How many allocation points assigned to this pool. HOLYs to distribute per block
uint256 lastRewardCalcBlock; // Last block number for which HOLYs distribution is already calculated for the pool
uint256 accHolyPerShare; // Accumulated HOLYs per share, times 1e12. See below
bool stakeable; // we should call deposit method on the LP tokens provided (used for e.g. vault staking)
address stakeableContract; // location where to deposit LP tokens if pool is stakeable
IERC20 stakedHoldableToken;
}
|
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract
uint256 allocPoint; // How many allocation points assigned to this pool. HOLYs to distribute per block
uint256 lastRewardCalcBlock; // Last block number for which HOLYs distribution is already calculated for the pool
uint256 accHolyPerShare; // Accumulated HOLYs per share, times 1e12. See below
bool stakeable; // we should call deposit method on the LP tokens provided (used for e.g. vault staking)
address stakeableContract; // location where to deposit LP tokens if pool is stakeable
IERC20 stakedHoldableToken;
}
| 14,479
|
1,088
|
// INTERNAL VARIABLES AND STORAGE// EVENTS // ADMIN STATE MODIFYING FUNCTIONS// Adds the provided identifier as a supported identifier. Price requests using this identifier will succeed after this call. identifier unique UTF-8 representation for the feed being added. Eg: BTC/USD. /
|
function addSupportedIdentifier(bytes32 identifier) external override onlyOwner {
if (!supportedIdentifiers[identifier]) {
supportedIdentifiers[identifier] = true;
emit SupportedIdentifierAdded(identifier);
}
}
|
function addSupportedIdentifier(bytes32 identifier) external override onlyOwner {
if (!supportedIdentifiers[identifier]) {
supportedIdentifiers[identifier] = true;
emit SupportedIdentifierAdded(identifier);
}
}
| 12,429
|
12
|
// Allows the proxy owner to upgrade the current version of the proxy. implementation representing the address of the new implementation to be set. /
|
function upgradeTo(address implementation) public virtual onlyProxyOwner {
address currentImplementation;
bytes32 position = implementationPosition;
assembly {
currentImplementation := sload(position)
}
require(currentImplementation != implementation);
assembly {
sstore(position, implementation)
}
emit Upgraded(implementation);
}
|
function upgradeTo(address implementation) public virtual onlyProxyOwner {
address currentImplementation;
bytes32 position = implementationPosition;
assembly {
currentImplementation := sload(position)
}
require(currentImplementation != implementation);
assembly {
sstore(position, implementation)
}
emit Upgraded(implementation);
}
| 17,617
|
15
|
// Process Allowance reduction
|
_allowances[from][msg.sender] = _allowances[from][msg.sender].sub(value);
emit Approval(msg.sender, to, value);
return true;
|
_allowances[from][msg.sender] = _allowances[from][msg.sender].sub(value);
emit Approval(msg.sender, to, value);
return true;
| 13,449
|
100
|
// create event for each approval? _tokenId guaranteed to hold correct value?
|
Approval(msg.sender, _to, _tokenId);
|
Approval(msg.sender, _to, _tokenId);
| 9,505
|
24
|
// Refund it
|
currentHighestBidder.transfer(currentHighestBiddersAmount);
|
currentHighestBidder.transfer(currentHighestBiddersAmount);
| 30,587
|
70
|
// Get smart contract balance in Parsecs
|
uint256 parsecBalance = parsecToken.balanceOf(this);
|
uint256 parsecBalance = parsecToken.balanceOf(this);
| 9,580
|
19
|
// Airdrop minting
|
function mintMany(address[] calldata _to, uint256[] calldata _tokenIds) public onlyOwner {
require(_to.length == _tokenIds.length, "Mismatched lengths.");
uint256 newSupplyAmount = totalSupply() + _tokenIds.length;
require(newSupplyAmount <= _maxSupply, "Reached minting limit.");
for (uint256 i; i < _to.length; ) {
_mint(_to[i], _tokenIds[i]);
unchecked {
i++;
}
}
}
|
function mintMany(address[] calldata _to, uint256[] calldata _tokenIds) public onlyOwner {
require(_to.length == _tokenIds.length, "Mismatched lengths.");
uint256 newSupplyAmount = totalSupply() + _tokenIds.length;
require(newSupplyAmount <= _maxSupply, "Reached minting limit.");
for (uint256 i; i < _to.length; ) {
_mint(_to[i], _tokenIds[i]);
unchecked {
i++;
}
}
}
| 32,637
|
206
|
// Internal function that handles transfering payments from buyers to sellers with special WETH handling/this function assumes that if the recipient address is a contract, it cannot handle ETH - so we always deliver WETH/special care needs to be taken when using contract addresses to sell deals - to ensure it can handle WETH properly when received
|
function transferPayment(
address weth,
address token,
address from,
address payable to,
uint256 amount
|
function transferPayment(
address weth,
address token,
address from,
address payable to,
uint256 amount
| 35,671
|
115
|
// This function handles token purchases for round 1. /
|
function _buyTokenR1() private {
if (token.balanceOf(address(this)) > 0) {
require(!_hasEnded[0],
"The first round must be active");
bool isRoundEnded = _buyToken(0, rateR1, totalSupplyR1);
if (isRoundEnded == true) {
_startTimeR2 = block.timestamp.add(timeDelayR1);
}
} else {
revert("The stake offering must be active");
}
}
|
function _buyTokenR1() private {
if (token.balanceOf(address(this)) > 0) {
require(!_hasEnded[0],
"The first round must be active");
bool isRoundEnded = _buyToken(0, rateR1, totalSupplyR1);
if (isRoundEnded == true) {
_startTimeR2 = block.timestamp.add(timeDelayR1);
}
} else {
revert("The stake offering must be active");
}
}
| 5,209
|
0
|
// chainlink aggregator for price feeds
|
interface AggregatorV3Interface {
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
|
interface AggregatorV3Interface {
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
| 32,610
|
245
|
// get generated URI for given tokenreturn token URI /
|
function uri(uint256 tokenId) external view returns (string memory);
|
function uri(uint256 tokenId) external view returns (string memory);
| 55,837
|
17
|
// Send 50% of ETH to marketing wallet
|
(bool successMarketing,) = address(marketingWallet).call{value: halfEth}("");
|
(bool successMarketing,) = address(marketingWallet).call{value: halfEth}("");
| 29,000
|
37
|
// Increase the total supply of tokens
|
totalSupply += tokens;
|
totalSupply += tokens;
| 13,612
|
25
|
// overwrite supportsInterface due to the removal of the ERC721Enumerable functionality
|
function supportsInterface(bytes4 interfaceId) public pure override(ERC721EnumerableUpgradeable, ERC721Upgradeable) returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId ||
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721MetadataUpgradeable).interfaceId;
}
|
function supportsInterface(bytes4 interfaceId) public pure override(ERC721EnumerableUpgradeable, ERC721Upgradeable) returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId ||
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721MetadataUpgradeable).interfaceId;
}
| 48,234
|
5
|
// set the last 64 bits of tokenId which is the exercise window to the new value
|
unchecked {
goldenToken = ((goldenToken >> 64) << 64) + _exerciseWindow;
}
|
unchecked {
goldenToken = ((goldenToken >> 64) << 64) + _exerciseWindow;
}
| 15,390
|
121
|
// Friday, 3 January 2020 г., 23:59:00
|
require(now >= endICODate + 47260800);
token.transfer(walletE, paymentSizeE);
completedE[order] = true;
|
require(now >= endICODate + 47260800);
token.transfer(walletE, paymentSizeE);
completedE[order] = true;
| 63,728
|
22
|
// 用应收账款赊买
|
function buyUsingReceivable(address seller, uint receivableId, string sku, uint amount) public {
Company storage fromCompany = companies[msg.sender];
Company storage toCompany = companies[seller];
Inventory storage inventory = companies[seller].inventories[sku];
Receivable storage receivable = fromCompany.receivables[receivableId];
if (!inventory.onsale || inventory.amount < amount) return;
if (receivable.amount < amount * inventory.price) return;
uint toReceivableId = toCompany.receivables.length;
toCompany.receivables.push(
Receivable(toReceivableId, amount * inventory.price, receivable.payableId, receivable.payer, 0)
);
receivable.amount -= amount * inventory.price;
companies[seller].inventories[sku].amount -= amount;
emit ReceivableTransferred(msg.sender, seller, amount, receivableId, toReceivableId, false);
emit Sold(msg.sender, seller, sku, amount,
msg.sender, seller,
receivable.payableId, toReceivableId);
}
|
function buyUsingReceivable(address seller, uint receivableId, string sku, uint amount) public {
Company storage fromCompany = companies[msg.sender];
Company storage toCompany = companies[seller];
Inventory storage inventory = companies[seller].inventories[sku];
Receivable storage receivable = fromCompany.receivables[receivableId];
if (!inventory.onsale || inventory.amount < amount) return;
if (receivable.amount < amount * inventory.price) return;
uint toReceivableId = toCompany.receivables.length;
toCompany.receivables.push(
Receivable(toReceivableId, amount * inventory.price, receivable.payableId, receivable.payer, 0)
);
receivable.amount -= amount * inventory.price;
companies[seller].inventories[sku].amount -= amount;
emit ReceivableTransferred(msg.sender, seller, amount, receivableId, toReceivableId, false);
emit Sold(msg.sender, seller, sku, amount,
msg.sender, seller,
receivable.payableId, toReceivableId);
}
| 9,157
|
13
|
// Modifier verify the price sent/
|
modifier requirePaidEnough(uint _value)
|
modifier requirePaidEnough(uint _value)
| 47,192
|
18
|
// iz fri??
|
if ( msg.value == 0){
require ( ((totalSupply()-teemHfMentid) <= HOWMENEE_FREE_MINNZ), "nO mO freeee MiNNzzz!");
require(addressToMintedFree[_msgSender()]+count<=FREE_GARB_PRO_WALLY,"tO muCHy forr Frrre dON beuRGH grrreeeDii!");
addressToMintedFree[_msgSender()]+=count;
}
|
if ( msg.value == 0){
require ( ((totalSupply()-teemHfMentid) <= HOWMENEE_FREE_MINNZ), "nO mO freeee MiNNzzz!");
require(addressToMintedFree[_msgSender()]+count<=FREE_GARB_PRO_WALLY,"tO muCHy forr Frrre dON beuRGH grrreeeDii!");
addressToMintedFree[_msgSender()]+=count;
}
| 18,573
|
631
|
// SDVD-ETH pair address
|
uint256 pairSDVDBalance = IERC20(sdvd).balanceOf(stakedToken);
if (pairSDVDBalance == 0) {
require(msg.value <= LGE_INITIAL_DEPOSIT_CAP, 'Initial deposit cap reached');
}
|
uint256 pairSDVDBalance = IERC20(sdvd).balanceOf(stakedToken);
if (pairSDVDBalance == 0) {
require(msg.value <= LGE_INITIAL_DEPOSIT_CAP, 'Initial deposit cap reached');
}
| 45,035
|
370
|
// Disallows the standard ERC20 approve() function
|
function approve(address, uint256) public override returns (bool) {
revert("Unimplemented");
}
|
function approve(address, uint256) public override returns (bool) {
revert("Unimplemented");
}
| 63,346
|
28
|
// Determine whether or not a user is authorized for public operation. _sender The address of the user.return Authorization status. /
|
function isAuthorizedForPublicOperation(address _sender) external view returns (bool);
|
function isAuthorizedForPublicOperation(address _sender) external view returns (bool);
| 54,288
|
74
|
// Define the token name, symbol, and decimals
|
string private _name = "DIONE ISLAND CLUB";
string private _symbol = "DICLUB";
uint8 private _decimals = 18;
|
string private _name = "DIONE ISLAND CLUB";
string private _symbol = "DICLUB";
uint8 private _decimals = 18;
| 51,012
|
246
|
// Sets the whitelist statuses for the given owners. Must only be called by the governor.
|
function setOwnerWhitelists(address[] calldata _owners, bool ok) external onlyGov {
for (uint idx = 0; idx < _owners.length; idx++) {
ownerWhitelists[_owners[idx]] = ok;
emit SetOwnerWhitelist(_owners[idx], ok);
}
}
|
function setOwnerWhitelists(address[] calldata _owners, bool ok) external onlyGov {
for (uint idx = 0; idx < _owners.length; idx++) {
ownerWhitelists[_owners[idx]] = ok;
emit SetOwnerWhitelist(_owners[idx], ok);
}
}
| 34,882
|
426
|
// Log when an ERC20 allocation is registered //Log when an ERC20 allocation is removed // Add a new ERC20 token to the asset allocation Should not allow duplicate tokens token The new token /
|
function registerErc20Token(IDetailedERC20 token) external;
|
function registerErc20Token(IDetailedERC20 token) external;
| 12,877
|
75
|
// Update the given pool's ESW allocation point. Can only be called by the owner. Good practice to update pools without messing up the contract
|
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
|
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
| 20,549
|
117
|
// Constructor/
|
constructor () {
//contract creator gets 90% of the token to create LP-Pair
uint256 deployerBalance=_circulatingSupply*9/10;
_balances[msg.sender] = deployerBalance;
emit Transfer(address(0), msg.sender, deployerBalance);
//contract gets 10% of the token to generate LP token and Marketing Budget fase
//contract will sell token over the first 200 sells to generate maximum LP and BNB
uint256 injectBalance=_circulatingSupply-deployerBalance;
_balances[address(this)]=injectBalance;
emit Transfer(address(0), address(this),injectBalance);
// Pancake Router
_pancakeRouter = IPancakeRouter02(PancakeRouter);
//Creates a Pancake Pair
_pancakePairAddress = IPancakeFactory(_pancakeRouter.factory()).createPair(address(this), _pancakeRouter.WETH());
//Sets Buy/Sell limits
balanceLimit=InitialSupply/BalanceLimitDivider;
sellLimit=InitialSupply/SellLimitDivider;
buyLimit=InitialSupply/BuyLimitDivider;
//Sets sellLockTime to be 2 seconds by default
sellLockTime=2 seconds;
//Set Starting Tax to very high percentage(36%) to achieve maximum burn in the beginning
//as in the beginning there is the highest token volume
//any change in tax rate needs to be below maxTax(20%)
_buyTax=11;
_sellTax=11;//Sell Tax is lower, as otherwise slippage would be too high to sell
_transferTax=11;
//a small percentage gets added to the Contract token as 10% of token are already injected to
//be converted to LP and MarketingBNB
_liquidityTax=20;
_marketingTax=80;
//Team wallet and deployer are excluded from Taxes
_excluded.add(TeamWallet);
_excluded.add(SecondTeamWallet);
_excluded.add(msg.sender);
//excludes Pancake Router, pair, contract and burn address from staking
_excludedFromRaffle.add(address(_pancakeRouter));
_excludedFromRaffle.add(_pancakePairAddress);
_excludedFromRaffle.add(address(this));
_excludedFromRaffle.add(0x000000000000000000000000000000000000dEaD);
_excludedFromSellLock.add(address(_pancakeRouter));
_excludedFromSellLock.add(_pancakePairAddress);
_excludedFromSellLock.add(address(this));
}
|
constructor () {
//contract creator gets 90% of the token to create LP-Pair
uint256 deployerBalance=_circulatingSupply*9/10;
_balances[msg.sender] = deployerBalance;
emit Transfer(address(0), msg.sender, deployerBalance);
//contract gets 10% of the token to generate LP token and Marketing Budget fase
//contract will sell token over the first 200 sells to generate maximum LP and BNB
uint256 injectBalance=_circulatingSupply-deployerBalance;
_balances[address(this)]=injectBalance;
emit Transfer(address(0), address(this),injectBalance);
// Pancake Router
_pancakeRouter = IPancakeRouter02(PancakeRouter);
//Creates a Pancake Pair
_pancakePairAddress = IPancakeFactory(_pancakeRouter.factory()).createPair(address(this), _pancakeRouter.WETH());
//Sets Buy/Sell limits
balanceLimit=InitialSupply/BalanceLimitDivider;
sellLimit=InitialSupply/SellLimitDivider;
buyLimit=InitialSupply/BuyLimitDivider;
//Sets sellLockTime to be 2 seconds by default
sellLockTime=2 seconds;
//Set Starting Tax to very high percentage(36%) to achieve maximum burn in the beginning
//as in the beginning there is the highest token volume
//any change in tax rate needs to be below maxTax(20%)
_buyTax=11;
_sellTax=11;//Sell Tax is lower, as otherwise slippage would be too high to sell
_transferTax=11;
//a small percentage gets added to the Contract token as 10% of token are already injected to
//be converted to LP and MarketingBNB
_liquidityTax=20;
_marketingTax=80;
//Team wallet and deployer are excluded from Taxes
_excluded.add(TeamWallet);
_excluded.add(SecondTeamWallet);
_excluded.add(msg.sender);
//excludes Pancake Router, pair, contract and burn address from staking
_excludedFromRaffle.add(address(_pancakeRouter));
_excludedFromRaffle.add(_pancakePairAddress);
_excludedFromRaffle.add(address(this));
_excludedFromRaffle.add(0x000000000000000000000000000000000000dEaD);
_excludedFromSellLock.add(address(_pancakeRouter));
_excludedFromSellLock.add(_pancakePairAddress);
_excludedFromSellLock.add(address(this));
}
| 11,476
|
162
|
// Larger modulos games specify the right edge of half-open interval of winning bet outcomes.
|
require(betMask > 0 && betMask <= modulo, "betMask larger than modulo");
rollUnder = betMask;
|
require(betMask > 0 && betMask <= modulo, "betMask larger than modulo");
rollUnder = betMask;
| 18,076
|
1
|
// The swap fee is internally stored using 64 bits, which is enough to represent _MAX_SWAP_FEE_PERCENTAGE.
|
bytes32 internal _miscData;
uint256 private _lastInvariant;
IVault private immutable _vault;
bytes32 private immutable _poolId;
IERC20 internal immutable _token0;
IERC20 internal immutable _token1;
|
bytes32 internal _miscData;
uint256 private _lastInvariant;
IVault private immutable _vault;
bytes32 private immutable _poolId;
IERC20 internal immutable _token0;
IERC20 internal immutable _token1;
| 35,499
|
18
|
// Emitted when the prop submitter is changed
|
event SubmitterChanged(address oldSubmitter, address newSubmitter);
|
event SubmitterChanged(address oldSubmitter, address newSubmitter);
| 9,242
|
131
|
// Transfers `tokenId` from `from` to `to`.
|
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
|
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
| 34,338
|
275
|
// Now calculate each one per the above formulas. Note: since tokens have 18 decimals of precision we multiply the result by 1e18.
|
if (ethTowardsICOPriceTokens != 0) {
icoPriceTokens = ethTowardsICOPriceTokens.mul(1e18).div(tokenPriceInitial_);
}
|
if (ethTowardsICOPriceTokens != 0) {
icoPriceTokens = ethTowardsICOPriceTokens.mul(1e18).div(tokenPriceInitial_);
}
| 24,415
|
277
|
// function ecRecoverTest( uint256 proposalId, VoteSig[] memory votesFor, VoteSig[] memory votesAgainst
|
// ) public {
// bytes32 domainSeparator =
// keccak256(
// abi.encode(
// DOMAIN_TYPEHASH,
// keccak256(bytes(name)),
// getChainId(),
// address(this)
// )
// );
// bytes32 structHashFor =
// keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, true));
// bytes32 structHashAgainst =
// keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, false));
// bytes32 digestFor =
// keccak256(
// abi.encodePacked("\x19\x01", domainSeparator, structHashFor)
// );
// bytes32 digestAgainst =
// keccak256(
// abi.encodePacked("\x19\x01", domainSeparator, structHashAgainst)
// );
// Proposal storage proposal = proposals[proposalId];
// uint256 total;
// for (uint32 i = 0; i < votesFor.length; i++) {
// bytes32 digest = digestFor;
// address signatory =
// ecrecover(digest, votesFor[i].v, votesFor[i].r, votesFor[i].s);
// require(
// signatory != address(0),
// "CompoundVotingMachine::castVoteBySig: invalid signature"
// );
// require(
// votesFor[i].support == true,
// "CompoundVotingMachine::castVoteBySig: invalid support value in for batch"
// );
// total += rep.getVotesAt(signatory, true, proposal.startBlock);
// Receipt storage receipt = proposal.receipts[signatory];
// receipt.hasVoted = true;
// receipt.support = true;
// }
// if (votesFor.length > 0) {
// address voteAddressHash =
// address(uint160(uint256(keccak256(abi.encode(votesFor)))));
// _castVote(voteAddressHash, proposalId, true, total);
// }
// total = 0;
// for (uint32 i = 0; i < votesAgainst.length; i++) {
// bytes32 digest = digestAgainst;
// address signatory =
// ecrecover(
// digest,
// votesAgainst[i].v,
// votesAgainst[i].r,
// votesAgainst[i].s
// );
// require(
// signatory != address(0),
// "CompoundVotingMachine::castVoteBySig: invalid signature"
// );
// require(
// votesAgainst[i].support == false,
// "CompoundVotingMachine::castVoteBySig: invalid support value in against batch"
// );
// total += rep.getVotesAt(signatory, true, proposal.startBlock);
// Receipt storage receipt = proposal.receipts[signatory];
// receipt.hasVoted = true;
// receipt.support = true;
// }
// if (votesAgainst.length > 0) {
// address voteAddressHash =
// address(uint160(uint256(keccak256(abi.encode(votesAgainst)))));
// _castVote(voteAddressHash, proposalId, false, total);
// }
// }
|
// ) public {
// bytes32 domainSeparator =
// keccak256(
// abi.encode(
// DOMAIN_TYPEHASH,
// keccak256(bytes(name)),
// getChainId(),
// address(this)
// )
// );
// bytes32 structHashFor =
// keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, true));
// bytes32 structHashAgainst =
// keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, false));
// bytes32 digestFor =
// keccak256(
// abi.encodePacked("\x19\x01", domainSeparator, structHashFor)
// );
// bytes32 digestAgainst =
// keccak256(
// abi.encodePacked("\x19\x01", domainSeparator, structHashAgainst)
// );
// Proposal storage proposal = proposals[proposalId];
// uint256 total;
// for (uint32 i = 0; i < votesFor.length; i++) {
// bytes32 digest = digestFor;
// address signatory =
// ecrecover(digest, votesFor[i].v, votesFor[i].r, votesFor[i].s);
// require(
// signatory != address(0),
// "CompoundVotingMachine::castVoteBySig: invalid signature"
// );
// require(
// votesFor[i].support == true,
// "CompoundVotingMachine::castVoteBySig: invalid support value in for batch"
// );
// total += rep.getVotesAt(signatory, true, proposal.startBlock);
// Receipt storage receipt = proposal.receipts[signatory];
// receipt.hasVoted = true;
// receipt.support = true;
// }
// if (votesFor.length > 0) {
// address voteAddressHash =
// address(uint160(uint256(keccak256(abi.encode(votesFor)))));
// _castVote(voteAddressHash, proposalId, true, total);
// }
// total = 0;
// for (uint32 i = 0; i < votesAgainst.length; i++) {
// bytes32 digest = digestAgainst;
// address signatory =
// ecrecover(
// digest,
// votesAgainst[i].v,
// votesAgainst[i].r,
// votesAgainst[i].s
// );
// require(
// signatory != address(0),
// "CompoundVotingMachine::castVoteBySig: invalid signature"
// );
// require(
// votesAgainst[i].support == false,
// "CompoundVotingMachine::castVoteBySig: invalid support value in against batch"
// );
// total += rep.getVotesAt(signatory, true, proposal.startBlock);
// Receipt storage receipt = proposal.receipts[signatory];
// receipt.hasVoted = true;
// receipt.support = true;
// }
// if (votesAgainst.length > 0) {
// address voteAddressHash =
// address(uint160(uint256(keccak256(abi.encode(votesAgainst)))));
// _castVote(voteAddressHash, proposalId, false, total);
// }
// }
| 22,764
|
43
|
// Track the extension that minted the token
|
_tokensExtension[_tokenCount] = extension;
|
_tokensExtension[_tokenCount] = extension;
| 12,743
|
178
|
// rare words
|
[
string("bad dude"),
string("not nice!"),
string("say sorry"),
string("you made me cry"),
string("i want to puke"),
string("thot we were frnieds :("),
string("please say sike")
],
|
[
string("bad dude"),
string("not nice!"),
string("say sorry"),
string("you made me cry"),
string("i want to puke"),
string("thot we were frnieds :("),
string("please say sike")
],
| 17,903
|
43
|
// Functions used for generating the URI
|
function amountOfZeros(uint256 num, uint256 base) public pure returns(uint256){
uint256 result = 0;
num /= base;
while (num > 0){
num /= base;
result += 1;
}
return result;
}
|
function amountOfZeros(uint256 num, uint256 base) public pure returns(uint256){
uint256 result = 0;
num /= base;
while (num > 0){
num /= base;
result += 1;
}
return result;
}
| 42,865
|
46
|
// Returns a list of owners addresses /
|
function owners() public view virtual returns (address [] memory) {
return _ownersList;
}
|
function owners() public view virtual returns (address [] memory) {
return _ownersList;
}
| 71,464
|
143
|
// Withdraw LP tokens from PioneerOre.
|
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accTokenPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
safeTokenTransfer(msg.sender, pending);
}
if (_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accTokenPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
|
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accTokenPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
safeTokenTransfer(msg.sender, pending);
}
if (_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accTokenPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
| 5,645
|
2
|
// Delegates the current call to nftImplementation This function does not return to its internal call site - it will return directly to the external caller. /
|
fallback() external payable {
IAddressRelay addressRelay = IAddressRelay(
StorageSlot.getAddressSlot(_ADDRESS_RELAY_SLOT).value
);
address implContract = addressRelay.getImplAddress(msg.sig);
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(
gas(),
implContract,
0,
calldatasize(),
0,
0
)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
|
fallback() external payable {
IAddressRelay addressRelay = IAddressRelay(
StorageSlot.getAddressSlot(_ADDRESS_RELAY_SLOT).value
);
address implContract = addressRelay.getImplAddress(msg.sig);
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(
gas(),
implContract,
0,
calldatasize(),
0,
0
)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
| 773
|
130
|
// calculate fees
|
uint256 feesAmount0 = provider0.amount.mul(feesController.feesPpm()) / 1000;
uint256 feesAmount1 = provider1.amount.mul(feesController.feesPpm()) / 1000;
|
uint256 feesAmount0 = provider0.amount.mul(feesController.feesPpm()) / 1000;
uint256 feesAmount1 = provider1.amount.mul(feesController.feesPpm()) / 1000;
| 73,933
|
274
|
// INTERFACE: Create a tree and return the root, given bytes32 elements in memory
|
function create_from_many_m(bytes32[] memory elements) internal pure returns (bytes32 new_element_root) {
return hash_node(bytes32(elements.length), get_root_from_many_m(elements));
}
|
function create_from_many_m(bytes32[] memory elements) internal pure returns (bytes32 new_element_root) {
return hash_node(bytes32(elements.length), get_root_from_many_m(elements));
}
| 14,296
|
108
|
// Verify that the asset being used in the purchase is valid.
|
bytes32 itemKey = keccak256(abi.encode(pools[_id].currentPoolVersion,
_groupId));
require(_assetIndex < pools[_id].itemPricesLength[itemKey],
"MintShop1155: specified asset index is not valid");
|
bytes32 itemKey = keccak256(abi.encode(pools[_id].currentPoolVersion,
_groupId));
require(_assetIndex < pools[_id].itemPricesLength[itemKey],
"MintShop1155: specified asset index is not valid");
| 46,439
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.