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
658
// returns the address of the new owner candidate /
function newOwner() external view returns (address) { return _newOwner; }
function newOwner() external view returns (address) { return _newOwner; }
3,681
69
// A token holder contract that will allow a beneficiary to extract thetokens after a given release time. Useful for simple vesting schedules like "advisors get all of their tokensafter 1 year". /
contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private _token; // beneficiary of tokens after they are released address private _beneficiary; // timestamp when token release is enabled uint256 private _releaseTime; constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) public { // solhint-disable-next-line not-rely-on-time require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { // solhint-disable-next-line not-rely-on-time require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time"); uint256 amount = _token.balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); _token.safeTransfer(_beneficiary, amount); } }
contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private _token; // beneficiary of tokens after they are released address private _beneficiary; // timestamp when token release is enabled uint256 private _releaseTime; constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) public { // solhint-disable-next-line not-rely-on-time require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { // solhint-disable-next-line not-rely-on-time require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time"); uint256 amount = _token.balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); _token.safeTransfer(_beneficiary, amount); } }
6,931
1
// owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
mapping(address => mapping(address => bool)) internal _operatorApprovals;
40,321
4
// Get the time at which a given schedule entry will vest./
function getVestingTime(address account, uint index) external view returns (uint);
function getVestingTime(address account, uint index) external view returns (uint);
21,559
159
// TODO: Add execution times param type?
bytes32 constant public EMPTY_PARAM_HASH = keccak256(uint256(0)); address constant ANY_ENTITY = address(-1);
bytes32 constant public EMPTY_PARAM_HASH = keccak256(uint256(0)); address constant ANY_ENTITY = address(-1);
76,619
8
// check user isExist
for(uint _i = 1; _i <= starterCount; _i++){ if(starterUsers[_i].userAddress == msg.sender){ revert("User already registered as Starter"); }
for(uint _i = 1; _i <= starterCount; _i++){ if(starterUsers[_i].userAddress == msg.sender){ revert("User already registered as Starter"); }
20,855
25
// Allows the current owner to transfer control of the contract to a newOwner.newOwner The address to transfer ownership to./
function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; }
function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; }
50,286
48
// Safety method in case user sends in ETH
function ownerWithdrawAllETH() public onlyOwner
function ownerWithdrawAllETH() public onlyOwner
28,993
21
// Function to queue a proposal to the timelock. /
function queue( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash
function queue( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash
18,610
232
// only owner
function reveal() public onlyOwner { revealed = true; }
function reveal() public onlyOwner { revealed = true; }
335
61
// dictionary which shows if ether account is owner
mapping (address => bool) internal isOwner;
mapping (address => bool) internal isOwner;
34,136
5
// Equivalent to x to the power of y because xy = (eln(x))y = e(ln(x)y)
return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.
return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.
22,105
0
// Derives initial state of the asset terms and stores together withterms, schedule, ownership, engine, admin of the asset in the contract types specific AssetRegistry. terms asset specific terms schedule schedule of the asset ownership ownership of the asset engine address of the ACTUS engine used for the spec. ContractType admin address of the admin of the asset (optional) extension address of the extension (optional) /
function initialize( STKTerms calldata terms, bytes32[] calldata schedule, AssetOwnership calldata ownership, address engine, address admin, address extension ) external {
function initialize( STKTerms calldata terms, bytes32[] calldata schedule, AssetOwnership calldata ownership, address engine, address admin, address extension ) external {
46,814
51
// return the price as number of tokens released for each ether
function price() public view returns(uint);
function price() public view returns(uint);
22,646
60
// Calculate the pending non-cliff installments to pay based on current time
uint256 installments = ((currInterval * tokenGenInterval) - cliff) / vestingPeriod; uint256 installmentsToPay = installments + 1 - paidInstallments;
uint256 installments = ((currInterval * tokenGenInterval) - cliff) / vestingPeriod; uint256 installmentsToPay = installments + 1 - paidInstallments;
11,143
2
// the address oftorn relayer registry contract
address immutable public TORN_RELAYER_REGISTRY;
address immutable public TORN_RELAYER_REGISTRY;
36,144
389
// Call the implementation. out and outsize are 0 because we don't know the size yet.
let result := delegatecall( gas, implementation, 0, calldatasize, 0, 0 )
let result := delegatecall( gas, implementation, 0, calldatasize, 0, 0 )
9,717
37
// Mapping from owner to number of owned token
mapping (address => Counters.Counter) private _ownedTokensCount;
mapping (address => Counters.Counter) private _ownedTokensCount;
45,956
27
// (abondDebt()debtShare) / EXP_SCALE
uint256 forfeits = abondDebt().mul(debtShare).div(EXP_SCALE);
uint256 forfeits = abondDebt().mul(debtShare).div(EXP_SCALE);
63,201
74
// Internal function to delegate votes from `delegator` to `delegatee` delegator The address that delegates its votes delegatee The address to delegate votes to /
function _delegate(address delegator, address delegatee) internal { address currentDelegate = delegates[delegator]; delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, balanceOf(delegator)); }
function _delegate(address delegator, address delegatee) internal { address currentDelegate = delegates[delegator]; delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, balanceOf(delegator)); }
39,609
49
// ChainLink's USD Price oracles return results in 8 decimal places
uint256 private constant ORACLE_PRICE_MULTIPLIER = 10**8; event DeltaSet(uint256 oldDelta, uint256 newDelta, address indexed owner); event StepSet(uint256 oldStep, uint256 newStep, address indexed owner); constructor( address _optionsPremiumPricer, uint256 _delta, uint256 _step
uint256 private constant ORACLE_PRICE_MULTIPLIER = 10**8; event DeltaSet(uint256 oldDelta, uint256 newDelta, address indexed owner); event StepSet(uint256 oldStep, uint256 newStep, address indexed owner); constructor( address _optionsPremiumPricer, uint256 _delta, uint256 _step
49,909
13
// Presale toggle
bool public isPresaleActive = false;
bool public isPresaleActive = false;
6,836
218
// Transfers the funds out of the contract to the owners wallet.
function withdraw() public onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); emit WithdrawBalance(msg.sender, balance); }
function withdraw() public onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); emit WithdrawBalance(msg.sender, balance); }
70,155
22
// used by a new owner to accept an ownership transfer /
function acceptOwnership() public override { require(msg.sender == newOwner, "ERR_ACCESS_DENIED"); emit OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = address(0); }
function acceptOwnership() public override { require(msg.sender == newOwner, "ERR_ACCESS_DENIED"); emit OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = address(0); }
23,048
119
// differentiate between buy/sell/transfer to apply different taxes/restrictions
bool isBuy=sender==_uniswapV2PairAddress|| sender == uniswapV2Router; bool isSell=recipient==_uniswapV2PairAddress|| recipient == uniswapV2Router;
bool isBuy=sender==_uniswapV2PairAddress|| sender == uniswapV2Router; bool isSell=recipient==_uniswapV2PairAddress|| recipient == uniswapV2Router;
16,505
2
// Investors&39; dividents increase goals due to a bank growth
uint bank1 = 5e20; // 500 eth uint bank2 = 15e20; // 1500 eth uint bank3 = 25e20; // 2500 eth uint bank4 = 7e21; // 7000 eth uint bank5 = 15e20; // 15000 eth
uint bank1 = 5e20; // 500 eth uint bank2 = 15e20; // 1500 eth uint bank3 = 25e20; // 2500 eth uint bank4 = 7e21; // 7000 eth uint bank5 = 15e20; // 15000 eth
43,404
12
// FEES
function updateMiningFee(uint256 numerator, uint256 denominator) public { require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin"); require(denominator != 0, "invalid value"); miningFeeNumerator = numerator; miningFeeDenominator = denominator; }
function updateMiningFee(uint256 numerator, uint256 denominator) public { require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin"); require(denominator != 0, "invalid value"); miningFeeNumerator = numerator; miningFeeDenominator = denominator; }
65,472
207
// Appends a bytes20 to the buffer. Resizes if doing so would exceedthe capacity of the buffer.buf The buffer to append to.data The data to append. return The original buffer, for chhaining./
function appendBytes20( buffer memory buf, bytes20 data ) internal pure returns ( buffer memory )
function appendBytes20( buffer memory buf, bytes20 data ) internal pure returns ( buffer memory )
14,594
7
// Unpauses contract.Requirements: - the caller must be the owner. /
function unpause() external virtual onlyOwner whenPaused { _unpause(); }
function unpause() external virtual onlyOwner whenPaused { _unpause(); }
37,604
16
// SMART CONTRACT FUNCTIONS / /Add an airline to the registration queueCan only be called from FlightSuretyApp contract/
function registerAirline(address airline) external requireIsOperational returns (bool)
function registerAirline(address airline) external requireIsOperational returns (bool)
39,719
12
// Math Assorted math operations /
library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Calculates the average of two numbers. Since these are integers, * averages of an even and odd number cannot be represented, and will be * rounded down. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Calculates the average of two numbers. Since these are integers, * averages of an even and odd number cannot be represented, and will be * rounded down. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
6,416
8
// Checking the size of `offer_gasbase` is necessary to prevent a) data loss when copied to an `OfferDetail` struct, and b) overflow when used in calculations. /+clear+
locals[outbound_tkn][inbound_tkn] = locals[outbound_tkn][inbound_tkn].offer_gasbase(offer_gasbase); emit SetGasbase(outbound_tkn, inbound_tkn, offer_gasbase);
locals[outbound_tkn][inbound_tkn] = locals[outbound_tkn][inbound_tkn].offer_gasbase(offer_gasbase); emit SetGasbase(outbound_tkn, inbound_tkn, offer_gasbase);
32,050
442
// Emit event with asset, old collateral factor, and new collateral factor
emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa); return uint(Error.NO_ERROR);
emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa); return uint(Error.NO_ERROR);
21,150
0
// data structure of a single tweet
struct Tweet { uint timestamp; string tweetString; }
struct Tweet { uint timestamp; string tweetString; }
51,982
5
// Keeps track of how much an address allows any other address to spend on its behalf
mapping (address => mapping (address => uint256)) private allowances;
mapping (address => mapping (address => uint256)) private allowances;
12,672
102
// ETH case
if ( token == address(0) || token == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) ) { return address(this).balance; }
if ( token == address(0) || token == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) ) { return address(this).balance; }
27,482
38
// Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], butwith `errorMessage` as a fallback revert reason when `target` reverts. _Available since v3.1._ /
function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data);
function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data);
144
315
// Add reward to existing epoch or crete a new one protocol Protocol for reward token Reward token epoch Epoch number - can be 0 to create new Epoch amount Amount of Reward token to deposit /
function _addReward(address protocol, address token, uint256 epoch, uint256 amount) internal { ProtocolRewards storage r = rewards[protocol]; RewardInfo storage ri = r.rewardInfo[token]; uint256 epochsLength = ri.epochs.length; require(epochsLength > 0, "RewardVesting: protocol or token not registered"); if(epoch == 0) epoch = epochsLength; // creating a new epoch if (epoch == epochsLength) { uint256 epochEnd = ri.epochs[epochsLength-1].end.add(defaultEpochLength); if(epochEnd < block.timestamp) epochEnd = block.timestamp; //This generally should not happen, but just in case - we generate only one epoch since previous end ri.epochs.push(Epoch({ end: epochEnd, amount: amount })); } else { require(epochsLength > epoch, "RewardVesting: epoch is too high"); Epoch storage ep = ri.epochs[epoch]; require(ep.end > block.timestamp, "RewardVesting: epoch already finished"); ep.amount = ep.amount.add(amount); } emit EpochRewardAdded(protocol, token, epoch, amount); IERC20(token).safeTransferFrom(_msgSender(), address(this), amount); }
function _addReward(address protocol, address token, uint256 epoch, uint256 amount) internal { ProtocolRewards storage r = rewards[protocol]; RewardInfo storage ri = r.rewardInfo[token]; uint256 epochsLength = ri.epochs.length; require(epochsLength > 0, "RewardVesting: protocol or token not registered"); if(epoch == 0) epoch = epochsLength; // creating a new epoch if (epoch == epochsLength) { uint256 epochEnd = ri.epochs[epochsLength-1].end.add(defaultEpochLength); if(epochEnd < block.timestamp) epochEnd = block.timestamp; //This generally should not happen, but just in case - we generate only one epoch since previous end ri.epochs.push(Epoch({ end: epochEnd, amount: amount })); } else { require(epochsLength > epoch, "RewardVesting: epoch is too high"); Epoch storage ep = ri.epochs[epoch]; require(ep.end > block.timestamp, "RewardVesting: epoch already finished"); ep.amount = ep.amount.add(amount); } emit EpochRewardAdded(protocol, token, epoch, amount); IERC20(token).safeTransferFrom(_msgSender(), address(this), amount); }
8,573
41
// Returns the state and configuration of the reserve asset The address of the underlying asset of the reservereturn The state and configuration data of the reserve /
function getReserveData(address asset) external view returns (DataTypes.ReserveData memory);
function getReserveData(address asset) external view returns (DataTypes.ReserveData memory);
25,484
6
// Sample buy quotes from Bancor. Unimplemented/paths The paths to check for Bancor. Only the best is used/takerToken Address of the taker token (what to sell)./makerToken Address of the maker token (what to buy)./makerTokenAmounts Maker token buy amount for each sample./ return bancorNetwork the Bancor Network address/ return path the selected conversion path from bancor/ return takerTokenAmounts Taker amounts sold at each maker token/ amount.
function sampleBuysFromBancor( address[][] memory paths, address takerToken, address makerToken, uint256[] memory makerTokenAmounts ) public view returns (address bancorNetwork, address[] memory path, uint256[] memory takerTokenAmounts)
function sampleBuysFromBancor( address[][] memory paths, address takerToken, address makerToken, uint256[] memory makerTokenAmounts ) public view returns (address bancorNetwork, address[] memory path, uint256[] memory takerTokenAmounts)
30,189
57
// Perform the payments to the given addresses and amounts, public method. _payments The array of the Payment data. Available to send ETH or ERC20. /
function performMultiPayment(Payment[] calldata _payments) external payable nonReentrant { _performMultiPayment(_payments); refundETH(); }
function performMultiPayment(Payment[] calldata _payments) external payable nonReentrant { _performMultiPayment(_payments); refundETH(); }
28,032
74
// Token to be locked (ERC-20)
IERC20 public immutable token;
IERC20 public immutable token;
67,557
26
// When migration process is finished (1 year from Goldmint blockchain launch), then transaction fee is 1% GOLD.
if (_isMigrationFinished) { return (_value / 100); }
if (_isMigrationFinished) { return (_value / 100); }
11,540
18
// reference to refined EON for if EonOnlyMints are enabled (all raw eon mined)
IEON public eon;
IEON public eon;
54,480
20
// WithdrawValidatorCommission defines an Event emitted when validator commissions are being withdrawn/validatorAddress is the address of the validator/commission is the total commission earned by the validator
event WithdrawValidatorCommission( string indexed validatorAddress, uint256 commission );
event WithdrawValidatorCommission( string indexed validatorAddress, uint256 commission );
32,020
11
// This function checks all requirements for claiming, updates batches and balances and transfers tokens /
function claim( bytes32 batchId, address owner, uint256 shares, address recipient
function claim( bytes32 batchId, address owner, uint256 shares, address recipient
18,029
49
// king should on original pos
if (move.sourceSq != 4){ return false; }
if (move.sourceSq != 4){ return false; }
97
4
// Issuers
mapping(address => address) internal _issuerTreasury; mapping(address => bool) internal _issuerStatus; mapping(bytes32 => bool) internal _issuerAttributePermission; address[] internal _issuers;
mapping(address => address) internal _issuerTreasury; mapping(address => bool) internal _issuerStatus; mapping(bytes32 => bool) internal _issuerAttributePermission; address[] internal _issuers;
40,157
210
// IMarketControllerManages configuration and consignments used by the Seen.Haus contract suite. Contributes its events and functions to the IMarketController interface The ERC-165 identifier for this interface is: 0x57f9f26d/
interface IMarketConfig { /// Events event NFTAddressChanged(address indexed nft); event EscrowTicketerAddressChanged(address indexed escrowTicketer, SeenTypes.Ticketer indexed ticketerType); event StakingAddressChanged(address indexed staking); event MultisigAddressChanged(address indexed multisig); event VipStakerAmountChanged(uint256 indexed vipStakerAmount); event PrimaryFeePercentageChanged(uint16 indexed feePercentage); event SecondaryFeePercentageChanged(uint16 indexed feePercentage); event MaxRoyaltyPercentageChanged(uint16 indexed maxRoyaltyPercentage); event OutBidPercentageChanged(uint16 indexed outBidPercentage); event DefaultTicketerTypeChanged(SeenTypes.Ticketer indexed ticketerType); /** * @notice Sets the address of the xSEEN ERC-20 staking contract. * * Emits a NFTAddressChanged event. * * @param _nft - the address of the nft contract */ function setNft(address _nft) external; /** * @notice The nft getter */ function getNft() external view returns (address); /** * @notice Sets the address of the Seen.Haus lots-based escrow ticketer contract. * * Emits a EscrowTicketerAddressChanged event. * * @param _lotsTicketer - the address of the items-based escrow ticketer contract */ function setLotsTicketer(address _lotsTicketer) external; /** * @notice The lots-based escrow ticketer getter */ function getLotsTicketer() external view returns (address); /** * @notice Sets the address of the Seen.Haus items-based escrow ticketer contract. * * Emits a EscrowTicketerAddressChanged event. * * @param _itemsTicketer - the address of the items-based escrow ticketer contract */ function setItemsTicketer(address _itemsTicketer) external; /** * @notice The items-based escrow ticketer getter */ function getItemsTicketer() external view returns (address); /** * @notice Sets the address of the xSEEN ERC-20 staking contract. * * Emits a StakingAddressChanged event. * * @param _staking - the address of the staking contract */ function setStaking(address payable _staking) external; /** * @notice The staking getter */ function getStaking() external view returns (address payable); /** * @notice Sets the address of the Seen.Haus multi-sig wallet. * * Emits a MultisigAddressChanged event. * * @param _multisig - the address of the multi-sig wallet */ function setMultisig(address payable _multisig) external; /** * @notice The multisig getter */ function getMultisig() external view returns (address payable); /** * @notice Sets the VIP staker amount. * * Emits a VipStakerAmountChanged event. * * @param _vipStakerAmount - the minimum amount of xSEEN ERC-20 a caller must hold to participate in VIP events */ function setVipStakerAmount(uint256 _vipStakerAmount) external; /** * @notice The vipStakerAmount getter */ function getVipStakerAmount() external view returns (uint256); /** * @notice Sets the marketplace fee percentage. * Emits a PrimaryFeePercentageChanged event. * * @param _primaryFeePercentage - the percentage that will be taken as a fee from the net of a Seen.Haus primary sale or auction * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setPrimaryFeePercentage(uint16 _primaryFeePercentage) external; /** * @notice Sets the marketplace fee percentage. * Emits a SecondaryFeePercentageChanged event. * * @param _secondaryFeePercentage - the percentage that will be taken as a fee from the net of a Seen.Haus secondary sale or auction (after royalties) * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setSecondaryFeePercentage(uint16 _secondaryFeePercentage) external; /** * @notice The primaryFeePercentage and secondaryFeePercentage getter */ function getFeePercentage(SeenTypes.Market _market) external view returns (uint16); /** * @notice Sets the external marketplace maximum royalty percentage. * * Emits a MaxRoyaltyPercentageChanged event. * * @param _maxRoyaltyPercentage - the maximum percentage of a Seen.Haus sale or auction that will be paid as a royalty */ function setMaxRoyaltyPercentage(uint16 _maxRoyaltyPercentage) external; /** * @notice The maxRoyaltyPercentage getter */ function getMaxRoyaltyPercentage() external view returns (uint16); /** * @notice Sets the marketplace auction outbid percentage. * * Emits a OutBidPercentageChanged event. * * @param _outBidPercentage - the minimum percentage a Seen.Haus auction bid must be above the previous bid to prevail */ function setOutBidPercentage(uint16 _outBidPercentage) external; /** * @notice The outBidPercentage getter */ function getOutBidPercentage() external view returns (uint16); /** * @notice Sets the default escrow ticketer type. * * Emits a DefaultTicketerTypeChanged event. * * Reverts if _ticketerType is Ticketer.Default * Reverts if _ticketerType is already the defaultTicketerType * * @param _ticketerType - the new default escrow ticketer type. */ function setDefaultTicketerType(SeenTypes.Ticketer _ticketerType) external; /** * @notice The defaultTicketerType getter */ function getDefaultTicketerType() external view returns (SeenTypes.Ticketer); /** * @notice Get the Escrow Ticketer to be used for a given consignment * * If a specific ticketer has not been set for the consignment, * the default escrow ticketer will be returned. * * @param _consignmentId - the id of the consignment * @return ticketer = the address of the escrow ticketer to use */ function getEscrowTicketer(uint256 _consignmentId) external view returns (address ticketer); }
interface IMarketConfig { /// Events event NFTAddressChanged(address indexed nft); event EscrowTicketerAddressChanged(address indexed escrowTicketer, SeenTypes.Ticketer indexed ticketerType); event StakingAddressChanged(address indexed staking); event MultisigAddressChanged(address indexed multisig); event VipStakerAmountChanged(uint256 indexed vipStakerAmount); event PrimaryFeePercentageChanged(uint16 indexed feePercentage); event SecondaryFeePercentageChanged(uint16 indexed feePercentage); event MaxRoyaltyPercentageChanged(uint16 indexed maxRoyaltyPercentage); event OutBidPercentageChanged(uint16 indexed outBidPercentage); event DefaultTicketerTypeChanged(SeenTypes.Ticketer indexed ticketerType); /** * @notice Sets the address of the xSEEN ERC-20 staking contract. * * Emits a NFTAddressChanged event. * * @param _nft - the address of the nft contract */ function setNft(address _nft) external; /** * @notice The nft getter */ function getNft() external view returns (address); /** * @notice Sets the address of the Seen.Haus lots-based escrow ticketer contract. * * Emits a EscrowTicketerAddressChanged event. * * @param _lotsTicketer - the address of the items-based escrow ticketer contract */ function setLotsTicketer(address _lotsTicketer) external; /** * @notice The lots-based escrow ticketer getter */ function getLotsTicketer() external view returns (address); /** * @notice Sets the address of the Seen.Haus items-based escrow ticketer contract. * * Emits a EscrowTicketerAddressChanged event. * * @param _itemsTicketer - the address of the items-based escrow ticketer contract */ function setItemsTicketer(address _itemsTicketer) external; /** * @notice The items-based escrow ticketer getter */ function getItemsTicketer() external view returns (address); /** * @notice Sets the address of the xSEEN ERC-20 staking contract. * * Emits a StakingAddressChanged event. * * @param _staking - the address of the staking contract */ function setStaking(address payable _staking) external; /** * @notice The staking getter */ function getStaking() external view returns (address payable); /** * @notice Sets the address of the Seen.Haus multi-sig wallet. * * Emits a MultisigAddressChanged event. * * @param _multisig - the address of the multi-sig wallet */ function setMultisig(address payable _multisig) external; /** * @notice The multisig getter */ function getMultisig() external view returns (address payable); /** * @notice Sets the VIP staker amount. * * Emits a VipStakerAmountChanged event. * * @param _vipStakerAmount - the minimum amount of xSEEN ERC-20 a caller must hold to participate in VIP events */ function setVipStakerAmount(uint256 _vipStakerAmount) external; /** * @notice The vipStakerAmount getter */ function getVipStakerAmount() external view returns (uint256); /** * @notice Sets the marketplace fee percentage. * Emits a PrimaryFeePercentageChanged event. * * @param _primaryFeePercentage - the percentage that will be taken as a fee from the net of a Seen.Haus primary sale or auction * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setPrimaryFeePercentage(uint16 _primaryFeePercentage) external; /** * @notice Sets the marketplace fee percentage. * Emits a SecondaryFeePercentageChanged event. * * @param _secondaryFeePercentage - the percentage that will be taken as a fee from the net of a Seen.Haus secondary sale or auction (after royalties) * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setSecondaryFeePercentage(uint16 _secondaryFeePercentage) external; /** * @notice The primaryFeePercentage and secondaryFeePercentage getter */ function getFeePercentage(SeenTypes.Market _market) external view returns (uint16); /** * @notice Sets the external marketplace maximum royalty percentage. * * Emits a MaxRoyaltyPercentageChanged event. * * @param _maxRoyaltyPercentage - the maximum percentage of a Seen.Haus sale or auction that will be paid as a royalty */ function setMaxRoyaltyPercentage(uint16 _maxRoyaltyPercentage) external; /** * @notice The maxRoyaltyPercentage getter */ function getMaxRoyaltyPercentage() external view returns (uint16); /** * @notice Sets the marketplace auction outbid percentage. * * Emits a OutBidPercentageChanged event. * * @param _outBidPercentage - the minimum percentage a Seen.Haus auction bid must be above the previous bid to prevail */ function setOutBidPercentage(uint16 _outBidPercentage) external; /** * @notice The outBidPercentage getter */ function getOutBidPercentage() external view returns (uint16); /** * @notice Sets the default escrow ticketer type. * * Emits a DefaultTicketerTypeChanged event. * * Reverts if _ticketerType is Ticketer.Default * Reverts if _ticketerType is already the defaultTicketerType * * @param _ticketerType - the new default escrow ticketer type. */ function setDefaultTicketerType(SeenTypes.Ticketer _ticketerType) external; /** * @notice The defaultTicketerType getter */ function getDefaultTicketerType() external view returns (SeenTypes.Ticketer); /** * @notice Get the Escrow Ticketer to be used for a given consignment * * If a specific ticketer has not been set for the consignment, * the default escrow ticketer will be returned. * * @param _consignmentId - the id of the consignment * @return ticketer = the address of the escrow ticketer to use */ function getEscrowTicketer(uint256 _consignmentId) external view returns (address ticketer); }
18,246
32
// Calculates the chunk rebalance size. This can be used by external contracts and keeper bots to calculate the optimal exchange to rebalance with.Note: this function does not take into account timestamps, so it may return a nonzero value even when shouldRebalance would return ShouldRebalance.NONE forall exchanges (since minimum delays have not elapsed)_exchangeNamesArray of exchange names to get rebalance sizes for return sizesArray of total notional chunk size. Measured in the asset that would be soldreturn sellAssetAsset that would be sold during a rebalancereturn buyAsset Asset that would be purchased during a rebalance /
function getChunkRebalanceNotional( string[] calldata _exchangeNames ) external view returns(uint256[] memory sizes, address sellAsset, address buyAsset)
function getChunkRebalanceNotional( string[] calldata _exchangeNames ) external view returns(uint256[] memory sizes, address sellAsset, address buyAsset)
29,164
35
// Returns the value 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 On more values are added or removed. Requirements:
* - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; }
* - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; }
290
5
// Get all redeemed ticket addresses. Useful for ethers client to get the entire array at once. /
function getAllRedeemedTickets() external view returns (address[MAX_SUPPLY] memory)
function getAllRedeemedTickets() external view returns (address[MAX_SUPPLY] memory)
3,848
96
// When token is released to be transferable, prohibit new token creation. /
function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; super.releaseTokenTransfer(); }
function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; super.releaseTokenTransfer(); }
28,327
15
// Stores the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
uint64 startTimestamp;
18,385
234
// Save Original minters
minters[_realIndex] = msg.sender;
minters[_realIndex] = msg.sender;
17,969
104
// it is a new sanity rate contract
if (sanityRateContract.length == 0) { sanityRateContract.push(_sanityRate); } else {
if (sanityRateContract.length == 0) { sanityRateContract.push(_sanityRate); } else {
641
44
// Withdraw all LP tokens from the farm and claim available UBE rewardsNeed to restake remaining LP tokens later
IStakingRewards(farmAddress).exit();
IStakingRewards(farmAddress).exit();
14,408
1
// do this shit with safe math or whateverif this is the officially best way to write this then i am disappointed
owner = msg.sender; AURGov = IAURGov(govaddy); govContract = govaddy;
owner = msg.sender; AURGov = IAURGov(govaddy); govContract = govaddy;
27,486
12
// -----
uint256 public totalSupply; uint256 public icoSalesSupply = 0; // Needed when burning tokens uint256 public icoReserveSupply = 0; uint256 public softCap = 5000000 * 10**decimals; uint256 public hardCap = 21500000 * 10**decimals;
uint256 public totalSupply; uint256 public icoSalesSupply = 0; // Needed when burning tokens uint256 public icoReserveSupply = 0; uint256 public softCap = 5000000 * 10**decimals; uint256 public hardCap = 21500000 * 10**decimals;
42,960
70
// get voting mechanism
function getVotingMechanism() constant returns (IVotingMechanism addy); event DeployedToken(address _payoutToken, address _backerToken, address _rewardToken);
function getVotingMechanism() constant returns (IVotingMechanism addy); event DeployedToken(address _payoutToken, address _backerToken, address _rewardToken);
21,503
137
// Mapping from partition to controllers for the partition. [NOT TOKEN-HOLDER-SPECIFIC]
mapping (bytes32 => address[]) internal _controllersByPartition;
mapping (bytes32 => address[]) internal _controllersByPartition;
23,812
8
// 配列の長さを短縮
StakingUser[] memory trimmedUsers = new StakingUser[](userCount); for (uint256 i = 0; i < userCount; i++) { trimmedUsers[i] = stakingUsers[i]; }
StakingUser[] memory trimmedUsers = new StakingUser[](userCount); for (uint256 i = 0; i < userCount; i++) { trimmedUsers[i] = stakingUsers[i]; }
8,535
119
// Sets the paused failsafe. Can only be called by owner _setPaused - paused state /
function setPaused(bool _setPaused) public onlyOwner { return (_setPaused) ? _pause() : _unpause(); }
function setPaused(bool _setPaused) public onlyOwner { return (_setPaused) ? _pause() : _unpause(); }
22,263
114
// delete the last selector
ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop(); delete ds.selectorToFacetAndPosition[_selector];
ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop(); delete ds.selectorToFacetAndPosition[_selector];
16,849
2
// return The Address of the implementation. /
function _implementation() virtual internal view returns (address);
function _implementation() virtual internal view returns (address);
4,950
21
// Get the current weights of the LBP/ return tokenWeight/ return collateralWeight
function getWeights() external view returns (uint tokenWeight, uint collateralWeight) { tokenWeight = pool.getNormalizedWeight(tokenAddress); collateralWeight = pool.getNormalizedWeight(collateralAddress); }
function getWeights() external view returns (uint tokenWeight, uint collateralWeight) { tokenWeight = pool.getNormalizedWeight(tokenAddress); collateralWeight = pool.getNormalizedWeight(collateralAddress); }
18,199
130
// Updates address where strategist fee earnings will go. _strategist new strategist address. /
function setStrategist(address _strategist) external { require(msg.sender == strategist, "!strategist"); strategist = _strategist; }
function setStrategist(address _strategist) external { require(msg.sender == strategist, "!strategist"); strategist = _strategist; }
37,217
0
// Pool Id
uint256 public pid;
uint256 public pid;
1,840
36
// The total amount of tokens which are in the auxiliary buffer.
uint256 public totalBuffered;
uint256 public totalBuffered;
40,995
142
// etherATM-DeFi /
contract etherATM_DeFi_v1 is ERC20, Ownable { using SafeMath for uint256; using Address for address; event Reserved(address indexed from, uint256 value); uint256 private _currentSupply = 0; uint256 private _softLimit = 99999000000000000000000; uint256 private _hardLimit = 99999000000000000000000; uint256 private _baseSlab = 0; uint256 private _basePriceWei = 16000000000000000; uint256 private _incrementWei = 666700000000; uint256 private _buyFee = 50; uint256 private _buyCommission = 4500; uint256 private _sellCommission = 5000; uint256 private _maxHolding = 1100000000000000000000; //in EATM uint256 private _maxSellBatch = 1100000000000000000000; //in EATM address payable _commissionReceiver; address payable _feeReceiver; constructor ( string memory name, string memory symbol, uint8 decimals, address payable commissionReceiver, address payable feeReceiver ) ERC20(name, symbol) payable { _setupDecimals(decimals); _commissionReceiver = commissionReceiver; _feeReceiver = feeReceiver; } function percent(uint numerator, uint denominator, uint precision) public pure returns(uint quotient) { // caution, check safe-to-multiply here uint _numerator = numerator * 10 ** (precision+1); // with rounding of last digit uint _quotient = ((_numerator / denominator) + 5) / 10; return ( _quotient); } receive() external payable{ emit Reserved(msg.sender, msg.value); } function setIncrement(uint256 increment) external onlyOwner(){ _incrementWei = increment; } function getIncrement() public view returns (uint256){ return _incrementWei; } function getHardLimit() public view returns (uint256){ return _hardLimit; } function getSoftLimit() public view returns (uint256){ return _softLimit; } function setMaxHolding(uint256 limit) external onlyOwner(){ _maxHolding = limit; } function getMaxHolding() public view returns (uint256){ return _maxHolding; } function setMaxSellBatch(uint256 limit) external onlyOwner(){ _maxSellBatch = limit; } function getMaxSellBatch() public view returns (uint256){ return _maxSellBatch; } function setCommissionReceiver(address payable rec) external onlyOwner(){ _commissionReceiver = rec; } function getCommissionReceiver() public view returns (address){ return _commissionReceiver; } function setFeeReceiver(address payable rec) external onlyOwner(){ _feeReceiver = rec; } function getFeeReceiver() public view returns (address){ return _feeReceiver; } function getCurrentSupply() public view returns (uint256){ return _currentSupply; } function setCurrentSupply(uint256 cs) external onlyOwner(){ _currentSupply = cs * 1 ether; } function getBaseSlab() public view returns (uint256){ return _baseSlab; } function setBaseSlab(uint256 bs) external onlyOwner(){ _baseSlab = bs * 1 ether; } function getBasePrice() public view returns (uint256){ return _basePriceWei; } function getBuyFee() public view returns (uint256){ return _buyFee; } function getBuyCommission() public view returns (uint256){ return _buyCommission; } function getSellCommission() public view returns (uint256){ return _sellCommission; } function setBuyCommission(uint256 bc) external onlyOwner(){ _buyCommission = bc; } function setBuyFee(uint256 bf) external onlyOwner(){ _buyFee = bf; } function setSellCommission(uint256 sc) external onlyOwner(){ _sellCommission = sc; } function setBasePrice(uint256 bp) external onlyOwner(){ _basePriceWei = bp; } function updateSlabs(uint256 bs, uint256 bp, uint256 increment) external onlyOwner(){ _basePriceWei = bp; _baseSlab = bs * 1 ether; _incrementWei = increment; } function getCurrentPrice() public view returns (uint256){ uint256 additionalTokens = _currentSupply.sub( _baseSlab, "An error has occurred"); uint256 increment = ((additionalTokens * _incrementWei) / 1 ether); uint256 price = _basePriceWei.add(increment); return price; } function transferTo(address to, uint256 value, bool convert_to_wei) internal { require(to != address(0), "etherATM: transfer to zero address"); deploy(to, value, convert_to_wei); } function transferTo(address to, uint256 value) internal { require(to != address(0), "etherATM: transfer to zero address"); deploy(to, value); } function deploy(address to, uint256 value) internal { value = value * 1 ether; require((_currentSupply + value ) < _hardLimit , "Max supply reached"); require((balanceOf(to) + value ) < _maxHolding , "You cannot hold more EATM" ); _mint(to, value); _currentSupply = _currentSupply.add(value); } function deploy(address to, uint256 value, bool convert_to_wei) internal { if(convert_to_wei) value = value * 1 ether; require((_currentSupply + value ) < _hardLimit , "Max supply reached"); require((balanceOf(to) + value ) < _maxHolding , "You cannot hold more EATM" ); _mint(to, value); _currentSupply = _currentSupply.add(value); } function assassination() external onlyOwner() { selfdestruct(owner()); } function clean(uint256 _amount) external onlyOwner(){ require(address(this).balance > _amount, "Invalid digits"); owner().transfer(_amount); } function buyTokens() external payable{ uint256 value = msg.value; uint256 price = getCurrentPrice(); uint256 tokens = uint256(value.div(price)) ; uint256 token_wei = tokens * 1 ether; //reduce tokens by BUY_FEE uint256 fee = uint256((token_wei * _buyFee ) / 10000 ); uint256 commission = uint256((token_wei * _buyCommission ) / 100000 ); token_wei = token_wei.sub((fee + commission), "Calculation error"); require(balanceOf(_msgSender()) + token_wei < _maxHolding, "etherATM: You cannot buy more tokens"); transferTo(_msgSender(), token_wei, false); transferTo(_commissionReceiver, commission , false); transferTo(_feeReceiver, fee, false); } function sellTokens(uint256 amount) external { amount = amount * 1 ether; require(balanceOf(_msgSender()) >= amount, "etherATM: recipient account doesn't have enough balance"); require(amount <= _maxSellBatch, "etherATM: invalid sell quantity" ); _currentSupply = _currentSupply.sub(amount, "Base reached"); //reduce tokens by SELL_COMMISSION uint256 commission = uint256((amount * _sellCommission ) / 100000 ); amount = amount.sub((commission), "Calculation error"); uint256 wei_value = ((getCurrentPrice() * amount) / 1 ether); require(address(this).balance >= wei_value, "etherATM: invalid digits"); _burn(_msgSender(), (amount + commission)); transferTo(_commissionReceiver, commission, false); _msgSender().transfer(wei_value); } }
contract etherATM_DeFi_v1 is ERC20, Ownable { using SafeMath for uint256; using Address for address; event Reserved(address indexed from, uint256 value); uint256 private _currentSupply = 0; uint256 private _softLimit = 99999000000000000000000; uint256 private _hardLimit = 99999000000000000000000; uint256 private _baseSlab = 0; uint256 private _basePriceWei = 16000000000000000; uint256 private _incrementWei = 666700000000; uint256 private _buyFee = 50; uint256 private _buyCommission = 4500; uint256 private _sellCommission = 5000; uint256 private _maxHolding = 1100000000000000000000; //in EATM uint256 private _maxSellBatch = 1100000000000000000000; //in EATM address payable _commissionReceiver; address payable _feeReceiver; constructor ( string memory name, string memory symbol, uint8 decimals, address payable commissionReceiver, address payable feeReceiver ) ERC20(name, symbol) payable { _setupDecimals(decimals); _commissionReceiver = commissionReceiver; _feeReceiver = feeReceiver; } function percent(uint numerator, uint denominator, uint precision) public pure returns(uint quotient) { // caution, check safe-to-multiply here uint _numerator = numerator * 10 ** (precision+1); // with rounding of last digit uint _quotient = ((_numerator / denominator) + 5) / 10; return ( _quotient); } receive() external payable{ emit Reserved(msg.sender, msg.value); } function setIncrement(uint256 increment) external onlyOwner(){ _incrementWei = increment; } function getIncrement() public view returns (uint256){ return _incrementWei; } function getHardLimit() public view returns (uint256){ return _hardLimit; } function getSoftLimit() public view returns (uint256){ return _softLimit; } function setMaxHolding(uint256 limit) external onlyOwner(){ _maxHolding = limit; } function getMaxHolding() public view returns (uint256){ return _maxHolding; } function setMaxSellBatch(uint256 limit) external onlyOwner(){ _maxSellBatch = limit; } function getMaxSellBatch() public view returns (uint256){ return _maxSellBatch; } function setCommissionReceiver(address payable rec) external onlyOwner(){ _commissionReceiver = rec; } function getCommissionReceiver() public view returns (address){ return _commissionReceiver; } function setFeeReceiver(address payable rec) external onlyOwner(){ _feeReceiver = rec; } function getFeeReceiver() public view returns (address){ return _feeReceiver; } function getCurrentSupply() public view returns (uint256){ return _currentSupply; } function setCurrentSupply(uint256 cs) external onlyOwner(){ _currentSupply = cs * 1 ether; } function getBaseSlab() public view returns (uint256){ return _baseSlab; } function setBaseSlab(uint256 bs) external onlyOwner(){ _baseSlab = bs * 1 ether; } function getBasePrice() public view returns (uint256){ return _basePriceWei; } function getBuyFee() public view returns (uint256){ return _buyFee; } function getBuyCommission() public view returns (uint256){ return _buyCommission; } function getSellCommission() public view returns (uint256){ return _sellCommission; } function setBuyCommission(uint256 bc) external onlyOwner(){ _buyCommission = bc; } function setBuyFee(uint256 bf) external onlyOwner(){ _buyFee = bf; } function setSellCommission(uint256 sc) external onlyOwner(){ _sellCommission = sc; } function setBasePrice(uint256 bp) external onlyOwner(){ _basePriceWei = bp; } function updateSlabs(uint256 bs, uint256 bp, uint256 increment) external onlyOwner(){ _basePriceWei = bp; _baseSlab = bs * 1 ether; _incrementWei = increment; } function getCurrentPrice() public view returns (uint256){ uint256 additionalTokens = _currentSupply.sub( _baseSlab, "An error has occurred"); uint256 increment = ((additionalTokens * _incrementWei) / 1 ether); uint256 price = _basePriceWei.add(increment); return price; } function transferTo(address to, uint256 value, bool convert_to_wei) internal { require(to != address(0), "etherATM: transfer to zero address"); deploy(to, value, convert_to_wei); } function transferTo(address to, uint256 value) internal { require(to != address(0), "etherATM: transfer to zero address"); deploy(to, value); } function deploy(address to, uint256 value) internal { value = value * 1 ether; require((_currentSupply + value ) < _hardLimit , "Max supply reached"); require((balanceOf(to) + value ) < _maxHolding , "You cannot hold more EATM" ); _mint(to, value); _currentSupply = _currentSupply.add(value); } function deploy(address to, uint256 value, bool convert_to_wei) internal { if(convert_to_wei) value = value * 1 ether; require((_currentSupply + value ) < _hardLimit , "Max supply reached"); require((balanceOf(to) + value ) < _maxHolding , "You cannot hold more EATM" ); _mint(to, value); _currentSupply = _currentSupply.add(value); } function assassination() external onlyOwner() { selfdestruct(owner()); } function clean(uint256 _amount) external onlyOwner(){ require(address(this).balance > _amount, "Invalid digits"); owner().transfer(_amount); } function buyTokens() external payable{ uint256 value = msg.value; uint256 price = getCurrentPrice(); uint256 tokens = uint256(value.div(price)) ; uint256 token_wei = tokens * 1 ether; //reduce tokens by BUY_FEE uint256 fee = uint256((token_wei * _buyFee ) / 10000 ); uint256 commission = uint256((token_wei * _buyCommission ) / 100000 ); token_wei = token_wei.sub((fee + commission), "Calculation error"); require(balanceOf(_msgSender()) + token_wei < _maxHolding, "etherATM: You cannot buy more tokens"); transferTo(_msgSender(), token_wei, false); transferTo(_commissionReceiver, commission , false); transferTo(_feeReceiver, fee, false); } function sellTokens(uint256 amount) external { amount = amount * 1 ether; require(balanceOf(_msgSender()) >= amount, "etherATM: recipient account doesn't have enough balance"); require(amount <= _maxSellBatch, "etherATM: invalid sell quantity" ); _currentSupply = _currentSupply.sub(amount, "Base reached"); //reduce tokens by SELL_COMMISSION uint256 commission = uint256((amount * _sellCommission ) / 100000 ); amount = amount.sub((commission), "Calculation error"); uint256 wei_value = ((getCurrentPrice() * amount) / 1 ether); require(address(this).balance >= wei_value, "etherATM: invalid digits"); _burn(_msgSender(), (amount + commission)); transferTo(_commissionReceiver, commission, false); _msgSender().transfer(wei_value); } }
59,874
7
// make execute() calls to the proxy voter
function _proxyCall(address _to, bytes memory _data) internal{ (bool success,) = IStaker(proxy).execute(_to,uint256(0),_data); require(success, "Proxy Call Fail"); }
function _proxyCall(address _to, bytes memory _data) internal{ (bool success,) = IStaker(proxy).execute(_to,uint256(0),_data); require(success, "Proxy Call Fail"); }
7,670
37
// reject the buyer from contract
require(!isContract(msg.sender)); require(Remain>0);
require(!isContract(msg.sender)); require(Remain>0);
1,605
265
// Changes the creator for the current sender, in the event weneed to be able to mint new tokens from an existing digital mediaprint production. When changing creator, the old creator willno longer be able to mint tokens. A creator may need to be changed:1. If we want to allow a creator to take control over their token minting (i.e go decentralized)2. If we want to re-issue private keys due to a compromise.For this reason, we can call this functionwhen the contract is paused. _creator the creator address _newCreator the new creator address /
function changeCreator(address _creator, address _newCreator) external { address approvedCreator = changedCreators[_creator]; require(msg.sender != address(0) && _creator != address(0), "Creator must be valid non 0x0 address."); require(msg.sender == _creator || msg.sender == approvedCreator, "Unauthorized caller."); if (approvedCreator == address(0)) { changedCreators[msg.sender] = _newCreator; } else { require(msg.sender == approvedCreator, "Unauthorized caller."); changedCreators[_creator] = _newCreator; } emit ChangedCreator(_creator, _newCreator); }
function changeCreator(address _creator, address _newCreator) external { address approvedCreator = changedCreators[_creator]; require(msg.sender != address(0) && _creator != address(0), "Creator must be valid non 0x0 address."); require(msg.sender == _creator || msg.sender == approvedCreator, "Unauthorized caller."); if (approvedCreator == address(0)) { changedCreators[msg.sender] = _newCreator; } else { require(msg.sender == approvedCreator, "Unauthorized caller."); changedCreators[_creator] = _newCreator; } emit ChangedCreator(_creator, _newCreator); }
2,149
50
// Update boost contract address and max boost factor./_newBoostContract The new address for handling all the share boosts.
function updateBoostContract(address _newBoostContract) external onlyOwner { require( _newBoostContract != address(0) && _newBoostContract != boostContract, "MasterChefV2: New boost contract address must be valid" ); boostContract = _newBoostContract; emit UpdateBoostContract(_newBoostContract); }
function updateBoostContract(address _newBoostContract) external onlyOwner { require( _newBoostContract != address(0) && _newBoostContract != boostContract, "MasterChefV2: New boost contract address must be valid" ); boostContract = _newBoostContract; emit UpdateBoostContract(_newBoostContract); }
10,815
394
// if amount is equal to uint(-1), the user wants to redeem everything
if (amount == type(uint256).max) { amountToWithdraw = userBalance; }
if (amount == type(uint256).max) { amountToWithdraw = userBalance; }
15,361
31
// jhhong/node가 체인에 연결된 상태인지를 확인한다./node 체인 연결 여부를 확인할 노드 주소/ return 연결 여부 (boolean), true: 연결됨(linked), false: 연결되지 않음(unlinked)
function isLinked(address node) public view returns (bool) { if(_slist.count == 1 && _slist.head == node && _slist.tail == node) { return true; } else { return (_slist.map[node].prev == address(0) && _slist.map[node].next == address(0))? (false) :(true); } }
function isLinked(address node) public view returns (bool) { if(_slist.count == 1 && _slist.head == node && _slist.tail == node) { return true; } else { return (_slist.map[node].prev == address(0) && _slist.map[node].next == address(0))? (false) :(true); } }
46,235
52
// Deposit an amount of `token` represented in either `amount` or `share`./token_ The ERC-20 token to deposit./from which account to pull the tokens./to which account to push the tokens./amount Token amount in native representation to deposit./share Token amount represented in shares to deposit. Takes precedence over `amount`./ return amountOut The amount deposited./ return shareOut The deposited amount repesented in shares.
function deposit( address token_, address from, address to, uint256 amount, uint256 share ) external payable returns (uint256 amountOut, uint256 shareOut);
function deposit( address token_, address from, address to, uint256 amount, uint256 share ) external payable returns (uint256 amountOut, uint256 shareOut);
1,490
335
// Synthetic token created by this contract.
ExpandedIERC20 public tokenCurrency;
ExpandedIERC20 public tokenCurrency;
17,239
135
// Adds two `Signed`s, reverting on overflow. a a FixedPoint.Signed. b a FixedPoint.Signed.return the sum of `a` and `b`. /
function add(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return Signed(a.rawValue.add(b.rawValue)); }
function add(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return Signed(a.rawValue.add(b.rawValue)); }
45,857
565
// to change max number of AB members allowed _val is the new value to be set /
function changeMaxABCount(uint _val) external onlyInternal { maxABCount = _val; }
function changeMaxABCount(uint _val) external onlyInternal { maxABCount = _val; }
28,741
288
// Batch mint._accounts Array of all addresses to mint to._amounts Array of all values to mint./
function batchMint(address[] memory _accounts, uint256[] memory _amounts) public{ require(_accounts.length == _amounts.length, "SygnumToken: values and recipients are not equal."); require(_accounts.length < BATCH_LIMIT, "SygnumToken: batch count is greater than BATCH_LIMIT."); for(uint256 i = 0; i < _accounts.length; i++) { mint(_accounts[i], _amounts[i]); } }
function batchMint(address[] memory _accounts, uint256[] memory _amounts) public{ require(_accounts.length == _amounts.length, "SygnumToken: values and recipients are not equal."); require(_accounts.length < BATCH_LIMIT, "SygnumToken: batch count is greater than BATCH_LIMIT."); for(uint256 i = 0; i < _accounts.length; i++) { mint(_accounts[i], _amounts[i]); } }
8,210
137
// Withdraws the ether distributed to the sender./It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.
function withdrawDividend() public virtual override { _withdrawDividendOfUser(payable(msg.sender)); }
function withdrawDividend() public virtual override { _withdrawDividendOfUser(payable(msg.sender)); }
16,274
6
// Withdraw asset from AlphaHomora _recipient Address to receive withdrawn asset _asset Address of asset to withdraw _amount Amount of asset to withdraw /
function withdraw( address _recipient, address _asset, uint256 _amount
function withdraw( address _recipient, address _asset, uint256 _amount
44,393
28
// Admin withdraw event
event AdminEarnings(address indexed user, uint value, uint time);
event AdminEarnings(address indexed user, uint value, uint time);
4,934
11
// Represents a constituent call of a batch sell.
struct BatchSellSubcall { // The function to call. MultiplexSubcall id; // Amount of input token to sell. If the highest bit is 1, // this value represents a proportion of the total // `sellAmount` of the batch sell. See `_normalizeSellAmount` // for details. uint256 sellAmount; // ABI-encoded parameters needed to perform the call. bytes data; }
struct BatchSellSubcall { // The function to call. MultiplexSubcall id; // Amount of input token to sell. If the highest bit is 1, // this value represents a proportion of the total // `sellAmount` of the batch sell. See `_normalizeSellAmount` // for details. uint256 sellAmount; // ABI-encoded parameters needed to perform the call. bytes data; }
49,200
31
// Verifies if claim signature is valid. _signer address of signer. _claim Signed Keccak-256 hash. _signature Signature data. /
function isValidSignature( address _signer, bytes32 _claim, SignatureData memory _signature ) public pure returns (bool)
function isValidSignature( address _signer, bytes32 _claim, SignatureData memory _signature ) public pure returns (bool)
45,898
15
// Allows RigoBlock Dao to set the parameters for a group./groupAddress Address of the pool's group./ratio Value of the ratio between assets and performance reward for a group./inflationFactor Value of the reward factor for a group./onlyRigoblockDao can set ratio.
function setGroupParams( address groupAddress, uint256 ratio, uint256 inflationFactor ) external override onlyRigoblockDao isApprovedFactory(groupAddress)
function setGroupParams( address groupAddress, uint256 ratio, uint256 inflationFactor ) external override onlyRigoblockDao isApprovedFactory(groupAddress)
35,902
36
// totalSupply New total token supply /
function rebase(uint256 totalSupply) public onlyValueHolder { _totalSupply = totalSupply; _gonsPerFragment = _totalGons.div(_totalSupply); emit LogRebase(_totalSupply); }
function rebase(uint256 totalSupply) public onlyValueHolder { _totalSupply = totalSupply; _gonsPerFragment = _totalGons.div(_totalSupply); emit LogRebase(_totalSupply); }
43,655
41
// Can be overridden to add finalization logic. The overriding function should call super.finalization() to ensure the chain of finalization is executed entirely./
function finalization() internal {} }
function finalization() internal {} }
5,597
17
// IERC20Standard.decimals() will revert if the collateral contract has not implemented the decimals() method, which is possible since the method is only an OPTIONAL method in the ERC20 standard: https:eips.ethereum.org/EIPS/eip-20methods.
function _getSyntheticDecimals(address _collateralAddress) public view returns (uint8 decimals) { try IERC20Standard(_collateralAddress).decimals() returns (uint8 _decimals) { return _decimals; } catch { return 18; } }
function _getSyntheticDecimals(address _collateralAddress) public view returns (uint8 decimals) { try IERC20Standard(_collateralAddress).decimals() returns (uint8 _decimals) { return _decimals; } catch { return 18; } }
16,154
172
// Determine the higher generation number of the two parents
uint16 parentGen = matron.generation; if (sire.generation > matron.generation) { parentGen = sire.generation; }
uint16 parentGen = matron.generation; if (sire.generation > matron.generation) { parentGen = sire.generation; }
14,635
726
// IBlockReceiver/Brecht Devos - <brecht@loopring.org>
abstract contract IBlockReceiver
abstract contract IBlockReceiver
24,664
31
// An event to make the transfer easy to find on the blockchain
emit Transfer(_from, _to, _amount); return true;
emit Transfer(_from, _to, _amount); return true;
1,155
243
// Get the earned rewards and withdraw staked tokens
function exit() external { getReward(); withdraw(balanceOf(msg.sender)); }
function exit() external { getReward(); withdraw(balanceOf(msg.sender)); }
56,953
8
// The length for testing
uint expectedLength_empty = 0; uint expectedLength_array = 4; string expected_t3 = "t3"; string expected_t1 = "t1";
uint expectedLength_empty = 0; uint expectedLength_array = 4; string expected_t3 = "t3"; string expected_t1 = "t1";
21,193
14
// pool index => swapped amount of token0
mapping(uint256 => uint256) public swappedAmount0P;
mapping(uint256 => uint256) public swappedAmount0P;
15,937
54
// Redeem PIPT
_redeem_pipt(); _refundLeftoverEth();
_redeem_pipt(); _refundLeftoverEth();
29,022
12
// Locked Staking Factory/Creates new LockedStaking Contracts
contract LockedStakingFactory is EIP712, IMYCStakingFactory { /** * @dev Emitted when withdawing MYC `reward` fees for `poolAddress` */ event WithdrawnMYCFees(address indexed poolAddress, uint256 reward); error SignatureMismatch(); error TransactionOverdue(); error DatesSort(); error IncompleteArray(); error WrongExecutor(); IMYCStakingManager internal _mycStakingManager; IWETH internal _WETH; constructor( IMYCStakingManager mycStakingManager_, IWETH weth_ ) EIP712("MyCointainer", "1") { _mycStakingManager = mycStakingManager_; _WETH = weth_; } /** * @dev Returns WETH address * */ function WETH() external view returns (address) { return address(_WETH); } /** * @dev Returns MyCointainer Staking Manager Contract Address * */ function mycStakingManager() external view returns (address) { return address(_mycStakingManager); } /** * @dev Returns signer address */ function signer() external view returns (address) { return _mycStakingManager.signer(); } /** * @dev Returns signer address */ function treasury() external view returns (address) { return _mycStakingManager.treasury(); } /** * @dev Returns main owner address */ function owner() external view returns (address) { return _mycStakingManager.owner(); } /** * @dev Creates {LockedStaking} new smart contract * */ function createPool( address poolOwner, // pool Owner address tokenAddress, // staking token address uint256[] memory durations, // for how long user cannot unstake uint256[] memory maxTokensBeStaked, // maximum amount that can be staked amoung all stakers for each duration uint256[] memory rewardsPool, // reward pool for each duration uint256[] memory mycFeesPool, //myc fees pools for each duration uint256[] memory maxStakingAmount, //max staking amount uint256[] memory dates, // 0 - dateStart, 1 - dateEnd, 2 - deadline address referralAddress, uint256 feeToReferral, bytes memory signature ) external payable{ //check pool owner if (poolOwner != msg.sender && poolOwner != address(0)) { revert WrongExecutor(); } // checking dates if (dates[0] >= dates[1]) { revert DatesSort(); } // checking arrays if ( durations.length != maxTokensBeStaked.length || maxTokensBeStaked.length != rewardsPool.length || rewardsPool.length != mycFeesPool.length || maxStakingAmount.length != mycFeesPool.length || durations.length == 0 ) { revert IncompleteArray(); } if (block.timestamp > dates[2]) revert TransactionOverdue(); bytes32 typedHash = _hashTypedDataV4( keccak256( abi.encode( keccak256( "AddStakePoolData(address tokenAddress,address owner,uint256[] durations,uint256[] maxTokensBeStaked,uint256[] rewardsPool,uint256[] mycFeesPool,uint256[] maxStakingAmount,uint256 dateStart,uint256 dateEnd,uint256 deadline,address referralAddress,uint256 feeToReferral)" ), tokenAddress, poolOwner == address(0) ? address(0) : msg.sender, keccak256(abi.encodePacked(durations)), keccak256(abi.encodePacked(maxTokensBeStaked)), keccak256(abi.encodePacked(rewardsPool)), keccak256(abi.encodePacked(mycFeesPool)), keccak256(abi.encodePacked(maxStakingAmount)), dates[0], dates[1], dates[2], referralAddress, feeToReferral ) ) ); if (ECDSA.recover(typedHash, signature) != _mycStakingManager.signer()) revert SignatureMismatch(); LockedStaking createdPool = new LockedStaking{salt: bytes32(signature)}( tokenAddress, msg.sender, durations, maxTokensBeStaked, rewardsPool, mycFeesPool, maxStakingAmount, dates[0], dates[1] ); uint256 rewardPoolSum = 0; uint256 mycFeeSum = 0; for (uint256 i = 0; i < rewardsPool.length; i++) { mycFeeSum += mycFeesPool[i]; rewardPoolSum += rewardsPool[i]; } require(feeToReferral<=10000, "Fee too high"); if(feeToReferral > 0) { require(referralAddress != address(0), "Referral address is zero"); } uint256 feeToReferralWei = feeToReferral * mycFeeSum / 10000; if(address(_WETH) == tokenAddress){ require(rewardPoolSum + mycFeeSum == msg.value, "Native currency amount mismatch"); _WETH.deposit{value: msg.value}(); _WETH.transfer(address(createdPool),rewardPoolSum); if(mycFeeSum>0){ _WETH.transfer(_mycStakingManager.treasury(),mycFeeSum-feeToReferralWei); } if(feeToReferralWei>0){ _WETH.transfer(referralAddress,feeToReferralWei); } } else{ IERC20(tokenAddress).transferFrom( msg.sender, address(createdPool), rewardPoolSum ); if(feeToReferralWei > 0){ IERC20(tokenAddress).transferFrom( msg.sender, referralAddress, feeToReferralWei ); } if (mycFeeSum > 0) { IERC20(tokenAddress).transferFrom( msg.sender, _mycStakingManager.treasury(), mycFeeSum-feeToReferralWei ); } } _mycStakingManager.addStakingPool( address(createdPool), bytes32(signature) ); } }
contract LockedStakingFactory is EIP712, IMYCStakingFactory { /** * @dev Emitted when withdawing MYC `reward` fees for `poolAddress` */ event WithdrawnMYCFees(address indexed poolAddress, uint256 reward); error SignatureMismatch(); error TransactionOverdue(); error DatesSort(); error IncompleteArray(); error WrongExecutor(); IMYCStakingManager internal _mycStakingManager; IWETH internal _WETH; constructor( IMYCStakingManager mycStakingManager_, IWETH weth_ ) EIP712("MyCointainer", "1") { _mycStakingManager = mycStakingManager_; _WETH = weth_; } /** * @dev Returns WETH address * */ function WETH() external view returns (address) { return address(_WETH); } /** * @dev Returns MyCointainer Staking Manager Contract Address * */ function mycStakingManager() external view returns (address) { return address(_mycStakingManager); } /** * @dev Returns signer address */ function signer() external view returns (address) { return _mycStakingManager.signer(); } /** * @dev Returns signer address */ function treasury() external view returns (address) { return _mycStakingManager.treasury(); } /** * @dev Returns main owner address */ function owner() external view returns (address) { return _mycStakingManager.owner(); } /** * @dev Creates {LockedStaking} new smart contract * */ function createPool( address poolOwner, // pool Owner address tokenAddress, // staking token address uint256[] memory durations, // for how long user cannot unstake uint256[] memory maxTokensBeStaked, // maximum amount that can be staked amoung all stakers for each duration uint256[] memory rewardsPool, // reward pool for each duration uint256[] memory mycFeesPool, //myc fees pools for each duration uint256[] memory maxStakingAmount, //max staking amount uint256[] memory dates, // 0 - dateStart, 1 - dateEnd, 2 - deadline address referralAddress, uint256 feeToReferral, bytes memory signature ) external payable{ //check pool owner if (poolOwner != msg.sender && poolOwner != address(0)) { revert WrongExecutor(); } // checking dates if (dates[0] >= dates[1]) { revert DatesSort(); } // checking arrays if ( durations.length != maxTokensBeStaked.length || maxTokensBeStaked.length != rewardsPool.length || rewardsPool.length != mycFeesPool.length || maxStakingAmount.length != mycFeesPool.length || durations.length == 0 ) { revert IncompleteArray(); } if (block.timestamp > dates[2]) revert TransactionOverdue(); bytes32 typedHash = _hashTypedDataV4( keccak256( abi.encode( keccak256( "AddStakePoolData(address tokenAddress,address owner,uint256[] durations,uint256[] maxTokensBeStaked,uint256[] rewardsPool,uint256[] mycFeesPool,uint256[] maxStakingAmount,uint256 dateStart,uint256 dateEnd,uint256 deadline,address referralAddress,uint256 feeToReferral)" ), tokenAddress, poolOwner == address(0) ? address(0) : msg.sender, keccak256(abi.encodePacked(durations)), keccak256(abi.encodePacked(maxTokensBeStaked)), keccak256(abi.encodePacked(rewardsPool)), keccak256(abi.encodePacked(mycFeesPool)), keccak256(abi.encodePacked(maxStakingAmount)), dates[0], dates[1], dates[2], referralAddress, feeToReferral ) ) ); if (ECDSA.recover(typedHash, signature) != _mycStakingManager.signer()) revert SignatureMismatch(); LockedStaking createdPool = new LockedStaking{salt: bytes32(signature)}( tokenAddress, msg.sender, durations, maxTokensBeStaked, rewardsPool, mycFeesPool, maxStakingAmount, dates[0], dates[1] ); uint256 rewardPoolSum = 0; uint256 mycFeeSum = 0; for (uint256 i = 0; i < rewardsPool.length; i++) { mycFeeSum += mycFeesPool[i]; rewardPoolSum += rewardsPool[i]; } require(feeToReferral<=10000, "Fee too high"); if(feeToReferral > 0) { require(referralAddress != address(0), "Referral address is zero"); } uint256 feeToReferralWei = feeToReferral * mycFeeSum / 10000; if(address(_WETH) == tokenAddress){ require(rewardPoolSum + mycFeeSum == msg.value, "Native currency amount mismatch"); _WETH.deposit{value: msg.value}(); _WETH.transfer(address(createdPool),rewardPoolSum); if(mycFeeSum>0){ _WETH.transfer(_mycStakingManager.treasury(),mycFeeSum-feeToReferralWei); } if(feeToReferralWei>0){ _WETH.transfer(referralAddress,feeToReferralWei); } } else{ IERC20(tokenAddress).transferFrom( msg.sender, address(createdPool), rewardPoolSum ); if(feeToReferralWei > 0){ IERC20(tokenAddress).transferFrom( msg.sender, referralAddress, feeToReferralWei ); } if (mycFeeSum > 0) { IERC20(tokenAddress).transferFrom( msg.sender, _mycStakingManager.treasury(), mycFeeSum-feeToReferralWei ); } } _mycStakingManager.addStakingPool( address(createdPool), bytes32(signature) ); } }
34,828
314
// Get the old combined weight
old_combined_weight = _combined_weights[account];
old_combined_weight = _combined_weights[account];
11,715
296
// our supply rate is:comp + lend - borrow
supplyRate = compRate.add(supplyRate); if(supplyRate > borrowRate){ supply = supplyRate.sub(borrowRate); }else{
supplyRate = compRate.add(supplyRate); if(supplyRate > borrowRate){ supply = supplyRate.sub(borrowRate); }else{
11,427